|
Thyra Package Browser (Single Doxygen Collection) Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Thyra: Interfaces and Support for Abstract Numerical Algorithms 00005 // Copyright (2004) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 00029 #ifndef THYRA_MULTI_VECTOR_BASE_DECL_HPP 00030 #define THYRA_MULTI_VECTOR_BASE_DECL_HPP 00031 00032 #include "Thyra_LinearOpBase_decl.hpp" 00033 #include "RTOpPack_RTOpT.hpp" 00034 00035 00036 namespace Thyra { 00037 00038 00477 template<class Scalar> 00478 class MultiVectorBase : virtual public LinearOpBase<Scalar> 00479 { 00480 public: 00481 00482 #ifdef THYRA_INJECT_USING_DECLARATIONS 00483 using LinearOpBase<Scalar>::apply; 00484 #endif 00485 00488 00493 RCP<const VectorBase<Scalar> > col(Ordinal j) const 00494 { return colImpl(j); } 00495 00500 RCP<VectorBase<Scalar> > col(Ordinal j) 00501 { return nonconstColImpl(j); } 00502 00504 00507 00512 RCP<const MultiVectorBase<Scalar> > 00513 subView( const Range1D& colRng ) const 00514 { 00515 return contigSubViewImpl(colRng); 00516 } 00517 00522 RCP<MultiVectorBase<Scalar> > 00523 subView( const Range1D& colRng ) 00524 { return nonconstContigSubViewImpl(colRng); } 00525 00530 RCP<const MultiVectorBase<Scalar> > 00531 subView( const ArrayView<const int> &cols ) const 00532 { return nonContigSubViewImpl(cols); } 00533 00538 RCP<MultiVectorBase<Scalar> > 00539 subView( const ArrayView<const int> &cols ) 00540 { return nonconstNonContigSubViewImpl(cols); } 00541 00543 00546 00551 void applyOp( 00552 const RTOpPack::RTOpT<Scalar> &primary_op, 00553 const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs, 00554 const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs, 00555 const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs, 00556 const Ordinal primary_global_offset 00557 ) const 00558 { 00559 mvMultiReductApplyOpImpl(primary_op, multi_vecs, targ_multi_vecs, 00560 reduct_objs, primary_global_offset); 00561 } 00562 00567 void applyOp( 00568 const RTOpPack::RTOpT<Scalar> &primary_op, 00569 const RTOpPack::RTOpT<Scalar> &secondary_op, 00570 const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs, 00571 const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs, 00572 const Ptr<RTOpPack::ReductTarget> &reduct_obj, 00573 const Ordinal primary_global_offset 00574 ) const 00575 { 00576 mvSingleReductApplyOpImpl(primary_op, secondary_op, multi_vecs, targ_multi_vecs, 00577 reduct_obj, primary_global_offset); 00578 } 00579 00581 00584 00589 void acquireDetachedView( 00590 const Range1D &rowRng, 00591 const Range1D &colRng, 00592 RTOpPack::ConstSubMultiVectorView<Scalar> *sub_mv 00593 ) const 00594 { acquireDetachedMultiVectorViewImpl( rowRng, colRng, sub_mv ); } 00595 00600 void releaseDetachedView( 00601 RTOpPack::ConstSubMultiVectorView<Scalar>* sub_mv 00602 ) const 00603 { releaseDetachedMultiVectorViewImpl(sub_mv); } 00604 00609 void acquireDetachedView( 00610 const Range1D &rowRng, 00611 const Range1D &colRng, 00612 RTOpPack::SubMultiVectorView<Scalar> *sub_mv 00613 ) 00614 { acquireNonconstDetachedMultiVectorViewImpl(rowRng,colRng,sub_mv); } 00615 00620 void commitDetachedView( 00621 RTOpPack::SubMultiVectorView<Scalar>* sub_mv 00622 ) 00623 { commitNonconstDetachedMultiVectorViewImpl(sub_mv); } 00624 00626 00629 00638 virtual RCP<MultiVectorBase<Scalar> > clone_mv() const = 0; 00639 00641 00644 00646 RCP<const LinearOpBase<Scalar> > clone() const; 00647 00649 00650 protected: 00651 00654 00676 virtual RCP<const VectorBase<Scalar> > colImpl(Ordinal j) const; 00677 00698 virtual RCP<VectorBase<Scalar> > nonconstColImpl(Ordinal j) = 0; 00699 00724 virtual RCP<const MultiVectorBase<Scalar> > 00725 contigSubViewImpl( const Range1D& colRng ) const = 0; 00726 00751 virtual RCP<MultiVectorBase<Scalar> > 00752 nonconstContigSubViewImpl( const Range1D& colRng ) = 0; 00753 00778 virtual RCP<const MultiVectorBase<Scalar> > 00779 nonContigSubViewImpl( const ArrayView<const int> &cols ) const = 0; 00780 00805 virtual RCP<MultiVectorBase<Scalar> > 00806 nonconstNonContigSubViewImpl( const ArrayView<const int> &cols ) = 0; 00807 00829 virtual void mvMultiReductApplyOpImpl( 00830 const RTOpPack::RTOpT<Scalar> &primary_op, 00831 const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs, 00832 const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs, 00833 const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs, 00834 const Ordinal primary_global_offset 00835 ) const = 0; 00836 00857 virtual void mvSingleReductApplyOpImpl( 00858 const RTOpPack::RTOpT<Scalar> &primary_op, 00859 const RTOpPack::RTOpT<Scalar> &secondary_op, 00860 const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs, 00861 const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs, 00862 const Ptr<RTOpPack::ReductTarget> &reduct_obj, 00863 const Ordinal primary_global_offset 00864 ) const = 0; 00865 00929 virtual void acquireDetachedMultiVectorViewImpl( 00930 const Range1D &rowRng, 00931 const Range1D &colRng, 00932 RTOpPack::ConstSubMultiVectorView<Scalar> *sub_mv 00933 ) const = 0; 00934 00960 virtual void releaseDetachedMultiVectorViewImpl( 00961 RTOpPack::ConstSubMultiVectorView<Scalar>* sub_mv 00962 ) const = 0; 00963 01036 virtual void acquireNonconstDetachedMultiVectorViewImpl( 01037 const Range1D &rowRng, 01038 const Range1D &colRng, 01039 RTOpPack::SubMultiVectorView<Scalar> *sub_mv 01040 ) = 0; 01041 01069 virtual void commitNonconstDetachedMultiVectorViewImpl( 01070 RTOpPack::SubMultiVectorView<Scalar>* sub_mv 01071 ) = 0; 01072 01074 01075 public: 01076 01079 01081 THYRA_DEPRECATED RCP<const MultiVectorBase<Scalar> > 01082 subView( const int numCols, const int cols[] ) const 01083 { return subView( Teuchos::arrayView<const int>(cols,numCols) ); } 01084 01086 THYRA_DEPRECATED RCP<MultiVectorBase<Scalar> > 01087 subView( const int numCols, const int cols[] ) 01088 { return subView( Teuchos::arrayView<const int>(cols,numCols) ); } 01089 01091 THYRA_DEPRECATED void applyOp( 01092 const RTOpPack::RTOpT<Scalar> &primary_op, 01093 const int num_multi_vecs, 01094 const MultiVectorBase<Scalar>*const multi_vecs_in[], 01095 const int num_targ_multi_vecs, 01096 MultiVectorBase<Scalar>*const targ_multi_vecs_inout[], 01097 RTOpPack::ReductTarget*const reduct_objs_inout[], 01098 const Ordinal primary_global_offset 01099 ) const; 01100 01102 THYRA_DEPRECATED void applyOp( 01103 const RTOpPack::RTOpT<Scalar> &primary_op, 01104 const RTOpPack::RTOpT<Scalar> &secondary_op, 01105 const int num_multi_vecs, 01106 const MultiVectorBase<Scalar>*const multi_vecs_in[], 01107 const int num_targ_multi_vecs, 01108 MultiVectorBase<Scalar>*const targ_multi_vecs_inout[], 01109 RTOpPack::ReductTarget* reduct_obj, 01110 const Ordinal primary_global_offset 01111 ) const; 01112 01114 01115 private: 01116 01117 // Not defined and not to be called 01118 MultiVectorBase<Scalar>& 01119 operator=(const MultiVectorBase<Scalar>&); 01120 01121 }; 01122 01123 01131 template<class Scalar> 01132 inline 01133 void applyOp( 01134 const RTOpPack::RTOpT<Scalar> &primary_op, 01135 const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs, 01136 const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs, 01137 const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs, 01138 const Ordinal primary_global_offset = 0 01139 ) 01140 { 01141 if(multi_vecs.size()) 01142 multi_vecs[0]->applyOp(primary_op, multi_vecs, targ_multi_vecs, 01143 reduct_objs, primary_global_offset); 01144 else if(targ_multi_vecs.size()) 01145 targ_multi_vecs[0]->applyOp(primary_op, multi_vecs, targ_multi_vecs, 01146 reduct_objs, primary_global_offset); 01147 } 01148 01149 01157 template<class Scalar> 01158 inline 01159 void applyOp( 01160 const RTOpPack::RTOpT<Scalar> &primary_op, 01161 const RTOpPack::RTOpT<Scalar> &secondary_op, 01162 const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs, 01163 const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs, 01164 const Ptr<RTOpPack::ReductTarget> &reduct_obj, 01165 const Ordinal primary_global_offset = 0 01166 ) 01167 { 01168 if(multi_vecs.size()) 01169 multi_vecs[0]->applyOp(primary_op, secondary_op, multi_vecs, targ_multi_vecs, 01170 reduct_obj, primary_global_offset); 01171 else if(targ_multi_vecs.size()) 01172 targ_multi_vecs[0]->applyOp(primary_op, secondary_op, multi_vecs, targ_multi_vecs, 01173 reduct_obj, primary_global_offset); 01174 } 01175 01176 01177 // 01178 // Deprecated non-members 01179 // 01180 01181 01186 template<class Scalar> 01187 THYRA_DEPRECATED inline 01188 void applyOp( 01189 const RTOpPack::RTOpT<Scalar> &primary_op, 01190 const int num_multi_vecs, 01191 const MultiVectorBase<Scalar>*const multi_vecs[], 01192 const int num_targ_multi_vecs, 01193 MultiVectorBase<Scalar>*const targ_multi_vecs[], 01194 RTOpPack::ReductTarget*const reduct_objs[], 01195 const Ordinal primary_global_offset = 0 01196 ) 01197 { 01198 if(num_multi_vecs) 01199 multi_vecs[0]->applyOp( 01200 primary_op, 01201 num_multi_vecs, multi_vecs, num_targ_multi_vecs, targ_multi_vecs, 01202 reduct_objs, primary_global_offset); 01203 else if(num_targ_multi_vecs) 01204 targ_multi_vecs[0]->applyOp( 01205 primary_op, 01206 num_multi_vecs, multi_vecs, num_targ_multi_vecs, targ_multi_vecs, 01207 reduct_objs, primary_global_offset); 01208 } 01209 01210 01217 template<class Scalar> 01218 THYRA_DEPRECATED inline 01219 void applyOp( 01220 const RTOpPack::RTOpT<Scalar> &primary_op, 01221 const RTOpPack::RTOpT<Scalar> &secondary_op, 01222 const int num_multi_vecs, 01223 const MultiVectorBase<Scalar>*const multi_vecs[], 01224 const int num_targ_multi_vecs, 01225 MultiVectorBase<Scalar>*const targ_multi_vecs[], 01226 RTOpPack::ReductTarget *reduct_obj, 01227 const Ordinal primary_global_offset = 0 01228 ) 01229 { 01230 if(num_multi_vecs) 01231 multi_vecs[0]->applyOp( 01232 primary_op, secondary_op, 01233 num_multi_vecs, multi_vecs, num_targ_multi_vecs, targ_multi_vecs, 01234 reduct_obj, primary_global_offset); 01235 else if(num_targ_multi_vecs) 01236 targ_multi_vecs[0]->applyOp( 01237 primary_op, secondary_op, 01238 num_multi_vecs, multi_vecs, num_targ_multi_vecs, targ_multi_vecs, 01239 reduct_obj, primary_global_offset); 01240 } 01241 01242 01243 } // namespace Thyra 01244 01245 01246 #endif // THYRA_MULTI_VECTOR_BASE_DECL_HPP
1.7.4