Thyra_MultiVectorBaseDecl.hpp

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_LinearOpBaseDecl.hpp"
00033 #include "RTOpPack_RTOpT.hpp"
00034 
00035 namespace Thyra {
00036 
00475 template<class Scalar>
00476 class MultiVectorBase : virtual public LinearOpBase<Scalar>
00477 {
00478 public:
00479 
00481   using LinearOpBase<Scalar>::describe;
00482 
00485 
00507   virtual RCP<const VectorBase<Scalar> > col(Index j) const;
00508 
00529   virtual RCP<VectorBase<Scalar> > col(Index j) = 0;
00530 
00532 
00535 
00559   virtual RCP<const MultiVectorBase<Scalar> >
00560   subView( const Range1D& colRng ) const = 0;
00561   
00586   virtual RCP<MultiVectorBase<Scalar> >
00587   subView( const Range1D& colRng ) = 0;
00588 
00614   virtual RCP<const MultiVectorBase<Scalar> >
00615   subView( const int numCols, const int cols[] ) const = 0;
00616 
00642   virtual RCP<MultiVectorBase<Scalar> >
00643   subView( const int numCols, const int cols[] ) = 0;
00644   
00646 
00649 
00651   void applyOp(
00652     const RTOpPack::RTOpT<Scalar> &primary_op,
00653     const int num_multi_vecs,
00654     const MultiVectorBase<Scalar>*const multi_vecs[],
00655     const int num_targ_multi_vecs,
00656     MultiVectorBase<Scalar>*const targ_multi_vecs[],
00657     RTOpPack::ReductTarget*const reduct_objs[],
00658     const Index primary_first_ele_offset,
00659     const Index primary_sub_dim,
00660     const Index primary_global_offset,
00661     const Index secondary_first_ele_offset,
00662     const Index secondary_sub_dim
00663     ) const
00664     {
00665       mvMultiReductApplyOpImpl(
00666         primary_op, num_multi_vecs, multi_vecs, num_targ_multi_vecs,
00667         targ_multi_vecs, reduct_objs,
00668         primary_first_ele_offset, primary_sub_dim,
00669         primary_global_offset, secondary_first_ele_offset, secondary_sub_dim
00670         );
00671     }
00672 
00694   virtual void mvMultiReductApplyOpImpl(
00695     const RTOpPack::RTOpT<Scalar> &primary_op,
00696     const int num_multi_vecs,
00697     const MultiVectorBase<Scalar>*const multi_vecs[],
00698     const int num_targ_multi_vecs,
00699     MultiVectorBase<Scalar>*const targ_multi_vecs[],
00700     RTOpPack::ReductTarget*const reduct_objs[],
00701     const Index primary_first_ele_offset,
00702     const Index primary_sub_dim,
00703     const Index primary_global_offset,
00704     const Index secondary_first_ele_offset,
00705     const Index secondary_sub_dim
00706     ) const = 0;
00707 
00709   void applyOp(
00710     const RTOpPack::RTOpT<Scalar> &primary_op,
00711     const RTOpPack::RTOpT<Scalar> &secondary_op,
00712     const int num_multi_vecs,
00713     const MultiVectorBase<Scalar>*const multi_vecs[],
00714     const int num_targ_multi_vecs,
00715     MultiVectorBase<Scalar>*const targ_multi_vecs[],
00716     RTOpPack::ReductTarget *reduct_obj,
00717     const Index primary_first_ele_offset,
00718     const Index primary_sub_dim,
00719     const Index primary_global_offset,
00720     const Index secondary_first_ele_offset,
00721     const Index secondary_sub_dim
00722     ) const
00723     {
00724       mvSingleReductApplyOpImpl(
00725         primary_op, secondary_op, num_multi_vecs, multi_vecs,
00726         num_targ_multi_vecs, targ_multi_vecs, reduct_obj,
00727         primary_first_ele_offset, primary_sub_dim,
00728         primary_global_offset, secondary_first_ele_offset,
00729         secondary_sub_dim
00730         );
00731     }
00732 
00753   virtual void mvSingleReductApplyOpImpl(
00754     const RTOpPack::RTOpT<Scalar> &primary_op,
00755     const RTOpPack::RTOpT<Scalar> &secondary_op,
00756     const int num_multi_vecs,
00757     const MultiVectorBase<Scalar>*const multi_vecs[],
00758     const int num_targ_multi_vecs,
00759     MultiVectorBase<Scalar>*const targ_multi_vecs[],
00760     RTOpPack::ReductTarget *reduct_obj,
00761     const Index primary_first_ele_offset,
00762     const Index primary_sub_dim,
00763     const Index primary_global_offset,
00764     const Index secondary_first_ele_offset,
00765     const Index secondary_sub_dim
00766     ) const = 0;
00767   
00769 
00772 
00774   void acquireDetachedView(
00775     const Range1D &rowRng,
00776     const Range1D &colRng,
00777     RTOpPack::ConstSubMultiVectorView<Scalar> *sub_mv
00778     ) const
00779     {
00780       acquireDetachedMultiVectorViewImpl( rowRng, colRng, sub_mv );
00781     }
00782 
00842   virtual void acquireDetachedMultiVectorViewImpl(
00843     const Range1D &rowRng,
00844     const Range1D &colRng,
00845     RTOpPack::ConstSubMultiVectorView<Scalar> *sub_mv
00846     ) const = 0;
00847 
00849   void releaseDetachedView(
00850     RTOpPack::ConstSubMultiVectorView<Scalar>* sub_mv
00851     ) const
00852     {
00853       releaseDetachedMultiVectorViewImpl(sub_mv);
00854     }
00855 
00881   virtual void releaseDetachedMultiVectorViewImpl(
00882     RTOpPack::ConstSubMultiVectorView<Scalar>* sub_mv
00883     ) const = 0;
00884 
00886   void acquireDetachedView(
00887     const Range1D &rowRng,
00888     const Range1D &colRng,
00889     RTOpPack::SubMultiVectorView<Scalar> *sub_mv
00890     )
00891     {
00892       acquireNonconstDetachedMultiVectorViewImpl(rowRng,colRng,sub_mv);
00893     }
00894 
00964   virtual void acquireNonconstDetachedMultiVectorViewImpl(
00965     const Range1D &rowRng,
00966     const Range1D &colRng,
00967     RTOpPack::SubMultiVectorView<Scalar> *sub_mv
00968     ) = 0;
00969 
00971   void commitDetachedView(
00972     RTOpPack::SubMultiVectorView<Scalar>* sub_mv
00973     )
00974     {
00975       commitNonconstDetachedMultiVectorViewImpl(sub_mv);
00976     }
00977 
01006   virtual void commitNonconstDetachedMultiVectorViewImpl(
01007     RTOpPack::SubMultiVectorView<Scalar>* sub_mv
01008     ) = 0;
01009 
01011 
01014 
01023   virtual RCP<MultiVectorBase<Scalar> > clone_mv() const = 0;
01024 
01026 
01029 
01031   RCP<const LinearOpBase<Scalar> > clone() const;
01032 
01034 
01035 private:
01036   
01037 #ifdef DOXYGEN_COMPILE
01038   VectorBase<Scalar>  *columns; // Doxygen only
01039 #endif  
01040 
01041 }; // end class MultiVectorBase<Scalar>
01042 
01050 template<class Scalar>
01051 inline
01052 void applyOp(
01053   const RTOpPack::RTOpT<Scalar> &primary_op,
01054   const int num_multi_vecs,
01055   const MultiVectorBase<Scalar>*const multi_vecs[],
01056   const int num_targ_multi_vecs,
01057   MultiVectorBase<Scalar>*const targ_multi_vecs[],
01058   RTOpPack::ReductTarget*const reduct_objs[],
01059   const Index primary_first_ele_offset = 0,
01060   const Index primary_sub_dim = -1,
01061   const Index primary_global_offset = 0,
01062   const Index secondary_first_ele_offset = 0,
01063   const Index secondary_sub_dim = -1
01064   )
01065 {
01066   if(num_multi_vecs)
01067     multi_vecs[0]->applyOp(
01068       primary_op
01069       ,num_multi_vecs,multi_vecs,num_targ_multi_vecs,targ_multi_vecs
01070       ,reduct_objs,primary_first_ele_offset,primary_sub_dim,primary_global_offset
01071       ,secondary_first_ele_offset,secondary_sub_dim
01072       );
01073   else if(num_targ_multi_vecs)
01074     targ_multi_vecs[0]->applyOp(
01075       primary_op
01076       ,num_multi_vecs,multi_vecs,num_targ_multi_vecs,targ_multi_vecs
01077       ,reduct_objs,primary_first_ele_offset,primary_sub_dim,primary_global_offset
01078       ,secondary_first_ele_offset,secondary_sub_dim
01079       );
01080 }
01081 
01089 template<class Scalar>
01090 inline
01091 void applyOp(
01092   const RTOpPack::RTOpT<Scalar> &primary_op,
01093   const RTOpPack::RTOpT<Scalar> &secondary_op,
01094   const int num_multi_vecs,
01095   const MultiVectorBase<Scalar>*const multi_vecs[],
01096   const int num_targ_multi_vecs,
01097   MultiVectorBase<Scalar>*const targ_multi_vecs[],
01098   RTOpPack::ReductTarget *reduct_obj,
01099   const Index primary_first_ele_offset = 0,
01100   const Index primary_sub_dim = -1,
01101   const Index primary_global_offset = 0,
01102   const Index secondary_first_ele_offset = 0,
01103   const Index secondary_sub_dim = -1
01104   )
01105 {
01106   if(num_multi_vecs)
01107     multi_vecs[0]->applyOp(
01108       primary_op,secondary_op
01109       ,num_multi_vecs,multi_vecs,num_targ_multi_vecs,targ_multi_vecs
01110       ,reduct_obj,primary_first_ele_offset,primary_sub_dim,primary_global_offset
01111       ,secondary_first_ele_offset,secondary_sub_dim
01112       );
01113   else if(num_targ_multi_vecs)
01114     targ_multi_vecs[0]->applyOp(
01115       primary_op,secondary_op
01116       ,num_multi_vecs,multi_vecs,num_targ_multi_vecs,targ_multi_vecs
01117       ,reduct_obj,primary_first_ele_offset,primary_sub_dim,primary_global_offset
01118       ,secondary_first_ele_offset,secondary_sub_dim
01119       );
01120 }
01121 
01122 } // namespace Thyra
01123 
01124 #endif // THYRA_MULTI_VECTOR_BASE_DECL_HPP

Generated on Tue Oct 20 12:46:45 2009 for Fundamental Thyra ANA Operator/Vector Interfaces by doxygen 1.4.7