00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef THYRA_MULTI_VECTOR_BASE_DECL_HPP
00030 #define THYRA_MULTI_VECTOR_BASE_DECL_HPP
00031
00032 #include "Thyra_LinearOpBaseDecl.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(Index j) const
00494 { return colImpl(j); }
00495
00500 RCP<VectorBase<Scalar> > col(Index 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 Index primary_first_ele_offset,
00557 const Index primary_sub_dim,
00558 const Index primary_global_offset,
00559 const Index secondary_first_ele_offset,
00560 const Index secondary_sub_dim
00561 ) const
00562 {
00563 mvMultiReductApplyOpImpl(
00564 primary_op, multi_vecs, targ_multi_vecs, reduct_objs,
00565 primary_first_ele_offset, primary_sub_dim,
00566 primary_global_offset, secondary_first_ele_offset, secondary_sub_dim
00567 );
00568 }
00569
00574 void applyOp(
00575 const RTOpPack::RTOpT<Scalar> &primary_op,
00576 const RTOpPack::RTOpT<Scalar> &secondary_op,
00577 const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
00578 const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
00579 const Ptr<RTOpPack::ReductTarget> &reduct_obj,
00580 const Index primary_first_ele_offset,
00581 const Index primary_sub_dim,
00582 const Index primary_global_offset,
00583 const Index secondary_first_ele_offset,
00584 const Index secondary_sub_dim
00585 ) const
00586 {
00587 mvSingleReductApplyOpImpl(
00588 primary_op, secondary_op, multi_vecs, targ_multi_vecs, reduct_obj,
00589 primary_first_ele_offset, primary_sub_dim,
00590 primary_global_offset, secondary_first_ele_offset,
00591 secondary_sub_dim
00592 );
00593 }
00594
00596
00599
00604 void acquireDetachedView(
00605 const Range1D &rowRng,
00606 const Range1D &colRng,
00607 RTOpPack::ConstSubMultiVectorView<Scalar> *sub_mv
00608 ) const
00609 { acquireDetachedMultiVectorViewImpl( rowRng, colRng, sub_mv ); }
00610
00615 void releaseDetachedView(
00616 RTOpPack::ConstSubMultiVectorView<Scalar>* sub_mv
00617 ) const
00618 { releaseDetachedMultiVectorViewImpl(sub_mv); }
00619
00624 void acquireDetachedView(
00625 const Range1D &rowRng,
00626 const Range1D &colRng,
00627 RTOpPack::SubMultiVectorView<Scalar> *sub_mv
00628 )
00629 { acquireNonconstDetachedMultiVectorViewImpl(rowRng,colRng,sub_mv); }
00630
00635 void commitDetachedView(
00636 RTOpPack::SubMultiVectorView<Scalar>* sub_mv
00637 )
00638 { commitNonconstDetachedMultiVectorViewImpl(sub_mv); }
00639
00641
00644
00653 virtual RCP<MultiVectorBase<Scalar> > clone_mv() const = 0;
00654
00656
00659
00661 RCP<const LinearOpBase<Scalar> > clone() const;
00662
00664
00665 protected:
00666
00669
00691 virtual RCP<const VectorBase<Scalar> > colImpl(Index j) const;
00692
00713 virtual RCP<VectorBase<Scalar> > nonconstColImpl(Index j) = 0;
00714
00739 virtual RCP<const MultiVectorBase<Scalar> >
00740 contigSubViewImpl( const Range1D& colRng ) const = 0;
00741
00766 virtual RCP<MultiVectorBase<Scalar> >
00767 nonconstContigSubViewImpl( const Range1D& colRng ) = 0;
00768
00793 virtual RCP<const MultiVectorBase<Scalar> >
00794 nonContigSubViewImpl( const ArrayView<const int> &cols ) const = 0;
00795
00820 virtual RCP<MultiVectorBase<Scalar> >
00821 nonconstNonContigSubViewImpl( const ArrayView<const int> &cols ) = 0;
00822
00844 virtual void mvMultiReductApplyOpImpl(
00845 const RTOpPack::RTOpT<Scalar> &primary_op,
00846 const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
00847 const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
00848 const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
00849 const Index primary_first_ele_offset,
00850 const Index primary_sub_dim,
00851 const Index primary_global_offset,
00852 const Index secondary_first_ele_offset,
00853 const Index secondary_sub_dim
00854 ) const = 0;
00855
00876 virtual void mvSingleReductApplyOpImpl(
00877 const RTOpPack::RTOpT<Scalar> &primary_op,
00878 const RTOpPack::RTOpT<Scalar> &secondary_op,
00879 const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
00880 const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
00881 const Ptr<RTOpPack::ReductTarget> &reduct_obj,
00882 const Index primary_first_ele_offset,
00883 const Index primary_sub_dim,
00884 const Index primary_global_offset,
00885 const Index secondary_first_ele_offset,
00886 const Index secondary_sub_dim
00887 ) const = 0;
00888
00952 virtual void acquireDetachedMultiVectorViewImpl(
00953 const Range1D &rowRng,
00954 const Range1D &colRng,
00955 RTOpPack::ConstSubMultiVectorView<Scalar> *sub_mv
00956 ) const = 0;
00957
00983 virtual void releaseDetachedMultiVectorViewImpl(
00984 RTOpPack::ConstSubMultiVectorView<Scalar>* sub_mv
00985 ) const = 0;
00986
01059 virtual void acquireNonconstDetachedMultiVectorViewImpl(
01060 const Range1D &rowRng,
01061 const Range1D &colRng,
01062 RTOpPack::SubMultiVectorView<Scalar> *sub_mv
01063 ) = 0;
01064
01092 virtual void commitNonconstDetachedMultiVectorViewImpl(
01093 RTOpPack::SubMultiVectorView<Scalar>* sub_mv
01094 ) = 0;
01095
01097
01098 public:
01099
01102
01104 RCP<const MultiVectorBase<Scalar> >
01105 subView( const int numCols, const int cols[] ) const
01106 { return subView( Teuchos::arrayView<const int>(cols,numCols) ); }
01107
01109 RCP<MultiVectorBase<Scalar> >
01110 subView( const int numCols, const int cols[] )
01111 { return subView( Teuchos::arrayView<const int>(cols,numCols) ); }
01112
01114 void applyOp(
01115 const RTOpPack::RTOpT<Scalar> &primary_op,
01116 const int num_multi_vecs,
01117 const MultiVectorBase<Scalar>*const multi_vecs_in[],
01118 const int num_targ_multi_vecs,
01119 MultiVectorBase<Scalar>*const targ_multi_vecs_inout[],
01120 RTOpPack::ReductTarget*const reduct_objs_inout[],
01121 const Index primary_first_ele_offset,
01122 const Index primary_sub_dim,
01123 const Index primary_global_offset,
01124 const Index secondary_first_ele_offset,
01125 const Index secondary_sub_dim_in
01126 ) const;
01127
01129 void applyOp(
01130 const RTOpPack::RTOpT<Scalar> &primary_op,
01131 const RTOpPack::RTOpT<Scalar> &secondary_op,
01132 const int num_multi_vecs,
01133 const MultiVectorBase<Scalar>*const multi_vecs_in[],
01134 const int num_targ_multi_vecs,
01135 MultiVectorBase<Scalar>*const targ_multi_vecs_inout[],
01136 RTOpPack::ReductTarget* reduct_obj,
01137 const Index primary_first_ele_offset,
01138 const Index primary_sub_dim,
01139 const Index primary_global_offset,
01140 const Index secondary_first_ele_offset,
01141 const Index secondary_sub_dim
01142 ) const;
01143
01145
01146 };
01147
01148
01156 template<class Scalar>
01157 inline
01158 void applyOp(
01159 const RTOpPack::RTOpT<Scalar> &primary_op,
01160 const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
01161 const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
01162 const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
01163 const Index primary_first_ele_offset = 0,
01164 const Index primary_sub_dim = -1,
01165 const Index primary_global_offset = 0,
01166 const Index secondary_first_ele_offset = 0,
01167 const Index secondary_sub_dim = -1
01168 )
01169 {
01170 if(multi_vecs.size())
01171 multi_vecs[0]->applyOp(
01172 primary_op
01173 ,multi_vecs,targ_multi_vecs
01174 ,reduct_objs,primary_first_ele_offset,primary_sub_dim,primary_global_offset
01175 ,secondary_first_ele_offset,secondary_sub_dim
01176 );
01177 else if(targ_multi_vecs.size())
01178 targ_multi_vecs[0]->applyOp(
01179 primary_op
01180 ,multi_vecs,targ_multi_vecs
01181 ,reduct_objs,primary_first_ele_offset,primary_sub_dim,primary_global_offset
01182 ,secondary_first_ele_offset,secondary_sub_dim
01183 );
01184 }
01185
01186
01194 template<class Scalar>
01195 inline
01196 void applyOp(
01197 const RTOpPack::RTOpT<Scalar> &primary_op,
01198 const RTOpPack::RTOpT<Scalar> &secondary_op,
01199 const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
01200 const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
01201 const Ptr<RTOpPack::ReductTarget> &reduct_obj,
01202 const Index primary_first_ele_offset = 0,
01203 const Index primary_sub_dim = -1,
01204 const Index primary_global_offset = 0,
01205 const Index secondary_first_ele_offset = 0,
01206 const Index secondary_sub_dim = -1
01207 )
01208 {
01209 if(multi_vecs.size())
01210 multi_vecs[0]->applyOp(
01211 primary_op,secondary_op
01212 ,multi_vecs,targ_multi_vecs
01213 ,reduct_obj,primary_first_ele_offset,primary_sub_dim,primary_global_offset
01214 ,secondary_first_ele_offset,secondary_sub_dim
01215 );
01216 else if(targ_multi_vecs.size())
01217 targ_multi_vecs[0]->applyOp(
01218 primary_op,secondary_op
01219 ,multi_vecs,targ_multi_vecs
01220 ,reduct_obj,primary_first_ele_offset,primary_sub_dim,primary_global_offset
01221 ,secondary_first_ele_offset,secondary_sub_dim
01222 );
01223 }
01224
01225
01226
01227
01228
01229
01230
01235 template<class Scalar>
01236 inline
01237 void applyOp(
01238 const RTOpPack::RTOpT<Scalar> &primary_op,
01239 const int num_multi_vecs,
01240 const MultiVectorBase<Scalar>*const multi_vecs[],
01241 const int num_targ_multi_vecs,
01242 MultiVectorBase<Scalar>*const targ_multi_vecs[],
01243 RTOpPack::ReductTarget*const reduct_objs[],
01244 const Index primary_first_ele_offset = 0,
01245 const Index primary_sub_dim = -1,
01246 const Index primary_global_offset = 0,
01247 const Index secondary_first_ele_offset = 0,
01248 const Index secondary_sub_dim = -1
01249 )
01250 {
01251 if(num_multi_vecs)
01252 multi_vecs[0]->applyOp(
01253 primary_op
01254 ,num_multi_vecs,multi_vecs,num_targ_multi_vecs,targ_multi_vecs
01255 ,reduct_objs,primary_first_ele_offset,primary_sub_dim,primary_global_offset
01256 ,secondary_first_ele_offset,secondary_sub_dim
01257 );
01258 else if(num_targ_multi_vecs)
01259 targ_multi_vecs[0]->applyOp(
01260 primary_op
01261 ,num_multi_vecs,multi_vecs,num_targ_multi_vecs,targ_multi_vecs
01262 ,reduct_objs,primary_first_ele_offset,primary_sub_dim,primary_global_offset
01263 ,secondary_first_ele_offset,secondary_sub_dim
01264 );
01265 }
01266
01267
01274 template<class Scalar>
01275 inline
01276 void applyOp(
01277 const RTOpPack::RTOpT<Scalar> &primary_op,
01278 const RTOpPack::RTOpT<Scalar> &secondary_op,
01279 const int num_multi_vecs,
01280 const MultiVectorBase<Scalar>*const multi_vecs[],
01281 const int num_targ_multi_vecs,
01282 MultiVectorBase<Scalar>*const targ_multi_vecs[],
01283 RTOpPack::ReductTarget *reduct_obj,
01284 const Index primary_first_ele_offset = 0,
01285 const Index primary_sub_dim = -1,
01286 const Index primary_global_offset = 0,
01287 const Index secondary_first_ele_offset = 0,
01288 const Index secondary_sub_dim = -1
01289 )
01290 {
01291 if(num_multi_vecs)
01292 multi_vecs[0]->applyOp(
01293 primary_op,secondary_op
01294 ,num_multi_vecs,multi_vecs,num_targ_multi_vecs,targ_multi_vecs
01295 ,reduct_obj,primary_first_ele_offset,primary_sub_dim,primary_global_offset
01296 ,secondary_first_ele_offset,secondary_sub_dim
01297 );
01298 else if(num_targ_multi_vecs)
01299 targ_multi_vecs[0]->applyOp(
01300 primary_op,secondary_op
01301 ,num_multi_vecs,multi_vecs,num_targ_multi_vecs,targ_multi_vecs
01302 ,reduct_obj,primary_first_ele_offset,primary_sub_dim,primary_global_offset
01303 ,secondary_first_ele_offset,secondary_sub_dim
01304 );
01305 }
01306
01307
01308 }
01309
01310
01311 #endif // THYRA_MULTI_VECTOR_BASE_DECL_HPP