MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AbstractLinAlgPack_MultiVectorMutableThyra.cpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
5 // Copyright (2003) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #include <assert.h>
43 
46 #include "Teuchos_Assert.hpp"
47 #include "Teuchos_dyn_cast.hpp"
48 
49 namespace AbstractLinAlgPack {
50 
51 // Constructors / Initializers
52 
54 {}
55 
57  const Teuchos::RCP<Thyra::MultiVectorBase<value_type> >& thyra_multi_vec
58  )
59 {
61 }
62 
64  const Teuchos::RCP<Thyra::MultiVectorBase<value_type> >& thyra_multi_vec
65  )
66 {
67  namespace mmp = MemMngPack;
69  thyra_multi_vec.get()==NULL, std::invalid_argument
70  ,"MultiVectorMutableThyra::initialize(thyra_multi_vec): Error!"
71  );
73 }
74 
77 {
79  tmp_thyra_multi_vec = cast_thyra_multi_vec();
81  return tmp_thyra_multi_vec;
82 }
83 
86 {
87  return Teuchos::rcp_dynamic_cast<const Thyra::MultiVectorBase<value_type> >(this->thyra_linear_op());
88 }
89 
90 // Overridden from MatrixOpThyra
91 
93  const Teuchos::RCP<const Thyra::LinearOpBase<value_type> >& thyra_linear_op
94  )
95 {
96  namespace mmp = MemMngPack;
97  this->initialize(
98  Teuchos::rcp_dynamic_cast<Thyra::MultiVectorBase<value_type> >(
99  Teuchos::rcp_const_cast<Thyra::LinearOpBase<value_type> >(thyra_linear_op)
100  )
101  );
102 }
103 
104 // Overridden from MatrixOp
105 
106 MatrixOp::mat_mut_ptr_t
108 {
109  return this->MatrixOpThyra::clone();
110 }
111 
113 {
114  return this->MultiVectorMutable::operator=(mwo_rhs);
115 }
116 
118  VectorMutable* v_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1
119  ,const Vector& v_rhs2, value_type beta
120  ) const
121 {
122  this->MatrixOpThyra::Vp_StMtV(v_lhs,alpha,trans_rhs1,v_rhs2,beta);
123 }
124 
126  MatrixOp* mwo_lhs, value_type alpha
127  ,BLAS_Cpp::Transp trans_rhs1
128  ,const MatrixOp& mwo_rhs2, BLAS_Cpp::Transp trans_rhs2
129  ,value_type beta
130  ) const
131 {
132  return this->MatrixOpThyra::Mp_StMtM(mwo_lhs,alpha,trans_rhs1,mwo_rhs2,trans_rhs2,beta);
133 }
134 
135 // Overridden from MultiVector
136 
139 {
140  return COL_ACCESS;
141 }
142 
144  EApplyBy apply_by, const RTOpPack::RTOp& primary_op
145  ,const size_t num_multi_vecs, const MultiVector* multi_vecs[]
146  ,const size_t num_targ_multi_vecs, MultiVectorMutable* targ_multi_vecs[]
147  ,RTOpPack::ReductTarget* reduct_objs[]
148  ,const index_type primary_first_ele, const index_type primary_sub_dim, const index_type primary_global_offset
149  ,const index_type secondary_first_ele, const index_type secondary_sub_dim
150  ) const
151 {
153  apply_by,primary_op,num_multi_vecs,multi_vecs,num_targ_multi_vecs,targ_multi_vecs
154  ,reduct_objs
155  ,primary_first_ele,primary_sub_dim,primary_global_offset
156  ,secondary_first_ele,secondary_sub_dim
157  ); // ToDo: Specialize!
158 }
159 
161  EApplyBy apply_by, const RTOpPack::RTOp& primary_op, const RTOpPack::RTOp& secondary_op
162  ,const size_t num_multi_vecs, const MultiVector* multi_vecs[]
163  ,const size_t num_targ_multi_vecs, MultiVectorMutable* targ_multi_vecs[]
164  ,RTOpPack::ReductTarget *reduct_obj
165  ,const index_type primary_first_ele, const index_type primary_sub_dim, const index_type primary_global_offset
166  ,const index_type secondary_first_ele, const index_type secondary_sub_dim
167  ) const
168 {
170  apply_by,primary_op,secondary_op,num_multi_vecs,multi_vecs,num_targ_multi_vecs,targ_multi_vecs
171  ,reduct_obj
172  ,primary_first_ele,primary_sub_dim,primary_global_offset
173  ,secondary_first_ele,secondary_sub_dim
174  ); // ToDo: Specialize!
175 }
176 
177 // Overridden from MultiVectorMutable
178 
181 {
183 }
184 
187 {
188  return Teuchos::null;
189 }
190 
193 {
194  return Teuchos::null;
195 }
196 
198 MultiVectorMutableThyra::mv_sub_view(const Range1D& row_rng_in, const Range1D& col_rng_in)
199 {
200  const index_type this_rows = this->rows();
201  const Range1D row_rng = RangePack::full_range(row_rng_in,1,this->rows());
203  !(row_rng.lbound()==1 && row_rng.ubound()==this_rows), std::invalid_argument
204  ,"MultiVectorMutableThyra::mv_sub_view(thyra_multi_vec): Error, can not handle subviews of the"
205  " elements in a row yet!"
206  );
207  return Teuchos::rcp(new MultiVectorMutableThyra(cast_thyra_multi_vec()->subView(convert(col_rng_in))));
208 }
209 
210 // private
211 
214 {
215  namespace mmp = MemMngPack;
216  return Teuchos::rcp_dynamic_cast<Thyra::MultiVectorBase<value_type> >(
217  Teuchos::rcp_const_cast<Thyra::LinearOpBase<value_type> >(this->thyra_linear_op())
218  );
219 }
220 
221 } // end namespace AbstractLinAlgPack
Abstract interface for immutable, finite dimensional, coordinate vectors {abstract}.
mat_mut_ptr_t clone()
Overridden to call MatrixOpThyra::clone()
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Index ubound() const
Return upper bound of the range.
void Vp_StMtV(VectorMutable *v_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2, value_type beta) const
multi_vec_mut_ptr_t mv_sub_view(const Range1D &row_rng, const Range1D &col_rng)
virtual void initialize(const Teuchos::RCP< const Thyra::LinearOpBase< value_type > > &thyra_linear_op, BLAS_Cpp::Transp thyra_linear_op_trans=BLAS_Cpp::no_trans)
Initalize given a smart pointer to a Thyra::LinearOpBase object.
MatrixOp & operator=(const MatrixOp &mwo_rhs)
Overridden to call MultiVectorMutable::operator=()
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
. One-based subregion index range class.
RTOpT< RTOp_value_type > RTOp
bool Mp_StMtM(MatrixOp *mwo_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1, const MatrixOp &mwo_rhs2, BLAS_Cpp::Transp trans_rhs2, value_type beta) const
Works for MultiVectorMutableThyra arguments.
void Vp_StMtV(VectorMutable *v_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2, value_type beta) const
Overridden to call MatrixOpThyra::Vp_StMtV()
void initialize(const Teuchos::RCP< Thyra::MultiVectorBase< value_type > > &thyra_multi_vec)
Initalize given a smart pointer to a Thyra::MultiVectorBase object.
VectorMutable adapter subclass for Thyra::VectorBase.
Teuchos::RCP< const Thyra::LinearOpBase< value_type > > set_uninitialized()
Set to uninitialized and return smart pointer to the internal Thyra::VectorBase object.
Base class for all matrices that support basic matrix operations.
Interface for a collection of non-mutable vectors (multi-vector, matrix).
void apply_op(EApplyBy apply_by, const RTOpPack::RTOp &primary_op, const size_t num_multi_vecs, const MultiVector *multi_vecs[], const size_t num_targ_multi_vecs, MultiVectorMutable *targ_multi_vecs[], RTOpPack::ReductTarget *reduct_objs[], const index_type primary_first_ele, const index_type primary_sub_dim, const index_type primary_global_offset, const index_type secondary_first_ele, const index_type secondary_sub_dim) const
Index lbound() const
Return lower bound of the range.
Teuchos::RCP< Thyra::MultiVectorBase< value_type > > cast_thyra_multi_vec()
Interface for a collection of mutable vectors (multi-vector, matrix).
Abstract interface for mutable coordinate vectors {abstract}.
bool Mp_StMtM(MatrixOp *mwo_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1, const MatrixOp &mwo_rhs2, BLAS_Cpp::Transp trans_rhs2, value_type beta) const
Overridden to call MatrixOpThyra::Mp_StMtM()
friend void apply_op(EApplyBy apply_by, const RTOpPack::RTOp &primary_op, const size_t num_multi_vecs, const MultiVector *multi_vecs[], const size_t num_targ_multi_vecs, MultiVectorMutable *targ_multi_vecs[], RTOpPack::ReductTarget *reduct_objs[], const index_type primary_first_ele, const index_type primary_sub_dim, const index_type primary_global_offset, const index_type secondary_first_ele, const index_type secondary_sub_dim)
Teuchos::RCP< Thyra::MultiVectorBase< value_type > > set_uninitialized()
Set to uninitialized and return smart pointer to the internal Thyra::LinearOpBase object...
virtual size_type rows() const
Return the number of rows in the matrix.
Transp
TRANS.
const Teuchos::RCP< const Thyra::LinearOpBase< value_type > > & thyra_linear_op() const
Return a (converted) smart pointer to the internal smart pointer to the Thyra::VectorBase object...
Teuchos::RCP< const Thyra::MultiVectorBase< value_type > > thyra_multi_vec() const
Return a smart pointer to the internal Thyra::LinearOpBase object.