Thyra Version of the Day
Thyra_MultiVectorBase_decl.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 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov) 
00038 // 
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 #ifndef THYRA_MULTI_VECTOR_BASE_DECL_HPP
00043 #define THYRA_MULTI_VECTOR_BASE_DECL_HPP
00044 
00045 #include "Thyra_LinearOpBase_decl.hpp"
00046 #include "RTOpPack_RTOpT.hpp"
00047 
00048 
00049 namespace Thyra {
00050 
00051 
00490 template<class Scalar>
00491 class MultiVectorBase : virtual public LinearOpBase<Scalar>
00492 {
00493 public:
00494 
00495 #ifdef THYRA_INJECT_USING_DECLARATIONS
00496   using LinearOpBase<Scalar>::apply;
00497 #endif
00498 
00501 
00506   RCP<const VectorBase<Scalar> > col(Ordinal j) const
00507     { return colImpl(j); }
00508 
00513   RCP<VectorBase<Scalar> > col(Ordinal j)
00514     { return nonconstColImpl(j); }
00515 
00517 
00520 
00525   RCP<const MultiVectorBase<Scalar> >
00526   subView( const Range1D& colRng ) const
00527     {
00528       return contigSubViewImpl(colRng);
00529     }
00530 
00535   RCP<MultiVectorBase<Scalar> >
00536   subView( const Range1D& colRng )
00537     { return nonconstContigSubViewImpl(colRng); }
00538 
00543   RCP<const MultiVectorBase<Scalar> >
00544   subView( const ArrayView<const int> &cols ) const
00545     { return nonContigSubViewImpl(cols); }
00546 
00551   RCP<MultiVectorBase<Scalar> >
00552   subView( const ArrayView<const int> &cols )
00553     { return nonconstNonContigSubViewImpl(cols); }
00554   
00556 
00559 
00564   void applyOp(
00565     const RTOpPack::RTOpT<Scalar> &primary_op,
00566     const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
00567     const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
00568     const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
00569     const Ordinal primary_global_offset
00570     ) const
00571     {
00572       mvMultiReductApplyOpImpl(primary_op, multi_vecs, targ_multi_vecs,
00573         reduct_objs, primary_global_offset);
00574     }
00575 
00580   void applyOp(
00581     const RTOpPack::RTOpT<Scalar> &primary_op,
00582     const RTOpPack::RTOpT<Scalar> &secondary_op,
00583     const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
00584     const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
00585     const Ptr<RTOpPack::ReductTarget> &reduct_obj,
00586     const Ordinal primary_global_offset
00587     ) const
00588     {
00589       mvSingleReductApplyOpImpl(primary_op, secondary_op, multi_vecs, targ_multi_vecs,
00590         reduct_obj, primary_global_offset);
00591     }
00592   
00594 
00597 
00602   void acquireDetachedView(
00603     const Range1D &rowRng,
00604     const Range1D &colRng,
00605     RTOpPack::ConstSubMultiVectorView<Scalar> *sub_mv
00606     ) const
00607     { acquireDetachedMultiVectorViewImpl( rowRng, colRng, sub_mv ); }
00608 
00613   void releaseDetachedView(
00614     RTOpPack::ConstSubMultiVectorView<Scalar>* sub_mv
00615     ) const
00616     { releaseDetachedMultiVectorViewImpl(sub_mv); }
00617 
00622   void acquireDetachedView(
00623     const Range1D &rowRng,
00624     const Range1D &colRng,
00625     RTOpPack::SubMultiVectorView<Scalar> *sub_mv
00626     )
00627     { acquireNonconstDetachedMultiVectorViewImpl(rowRng,colRng,sub_mv); }
00628 
00633   void commitDetachedView(
00634     RTOpPack::SubMultiVectorView<Scalar>* sub_mv
00635     )
00636     { commitNonconstDetachedMultiVectorViewImpl(sub_mv); }
00637 
00639 
00642 
00651   virtual RCP<MultiVectorBase<Scalar> > clone_mv() const = 0;
00652 
00654 
00657 
00659   RCP<const LinearOpBase<Scalar> > clone() const;
00660 
00662 
00663 protected:
00664 
00667 
00689   virtual RCP<const VectorBase<Scalar> > colImpl(Ordinal j) const;
00690 
00711   virtual RCP<VectorBase<Scalar> > nonconstColImpl(Ordinal j) = 0;
00712 
00737   virtual RCP<const MultiVectorBase<Scalar> >
00738   contigSubViewImpl( const Range1D& colRng ) const = 0;
00739 
00764   virtual RCP<MultiVectorBase<Scalar> >
00765   nonconstContigSubViewImpl( const Range1D& colRng ) = 0;
00766 
00791   virtual RCP<const MultiVectorBase<Scalar> >
00792   nonContigSubViewImpl( const ArrayView<const int> &cols ) const = 0;
00793 
00818   virtual RCP<MultiVectorBase<Scalar> >
00819   nonconstNonContigSubViewImpl( const ArrayView<const int> &cols ) = 0;
00820 
00842   virtual void mvMultiReductApplyOpImpl(
00843     const RTOpPack::RTOpT<Scalar> &primary_op,
00844     const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
00845     const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
00846     const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
00847     const Ordinal primary_global_offset
00848     ) const = 0;
00849 
00870   virtual void mvSingleReductApplyOpImpl(
00871     const RTOpPack::RTOpT<Scalar> &primary_op,
00872     const RTOpPack::RTOpT<Scalar> &secondary_op,
00873     const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
00874     const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
00875     const Ptr<RTOpPack::ReductTarget> &reduct_obj,
00876     const Ordinal primary_global_offset
00877     ) const = 0;
00878 
00942   virtual void acquireDetachedMultiVectorViewImpl(
00943     const Range1D &rowRng,
00944     const Range1D &colRng,
00945     RTOpPack::ConstSubMultiVectorView<Scalar> *sub_mv
00946     ) const = 0;
00947 
00973   virtual void releaseDetachedMultiVectorViewImpl(
00974     RTOpPack::ConstSubMultiVectorView<Scalar>* sub_mv
00975     ) const = 0;
00976 
01049   virtual void acquireNonconstDetachedMultiVectorViewImpl(
01050     const Range1D &rowRng,
01051     const Range1D &colRng,
01052     RTOpPack::SubMultiVectorView<Scalar> *sub_mv
01053     ) = 0;
01054 
01082   virtual void commitNonconstDetachedMultiVectorViewImpl(
01083     RTOpPack::SubMultiVectorView<Scalar>* sub_mv
01084     ) = 0;
01085 
01087 
01088 public:
01089 
01090 private:
01091   
01092   // Not defined and not to be called
01093   MultiVectorBase<Scalar>&
01094   operator=(const MultiVectorBase<Scalar>&);
01095 
01096 };
01097 
01098 
01106 template<class Scalar>
01107 inline
01108 void applyOp(
01109   const RTOpPack::RTOpT<Scalar> &primary_op,
01110   const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
01111   const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
01112   const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
01113   const Ordinal primary_global_offset = 0
01114   )
01115 {
01116   if(multi_vecs.size())
01117     multi_vecs[0]->applyOp(primary_op, multi_vecs, targ_multi_vecs,
01118       reduct_objs, primary_global_offset);
01119   else if(targ_multi_vecs.size())
01120     targ_multi_vecs[0]->applyOp(primary_op, multi_vecs, targ_multi_vecs,
01121       reduct_objs, primary_global_offset);
01122 }
01123 
01124 
01132 template<class Scalar>
01133 inline
01134 void applyOp(
01135   const RTOpPack::RTOpT<Scalar> &primary_op,
01136   const RTOpPack::RTOpT<Scalar> &secondary_op,
01137   const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
01138   const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
01139   const Ptr<RTOpPack::ReductTarget> &reduct_obj,
01140   const Ordinal primary_global_offset = 0
01141   )
01142 {
01143   if(multi_vecs.size())
01144     multi_vecs[0]->applyOp(primary_op, secondary_op, multi_vecs, targ_multi_vecs,
01145       reduct_obj, primary_global_offset);
01146   else if(targ_multi_vecs.size())
01147     targ_multi_vecs[0]->applyOp(primary_op, secondary_op, multi_vecs, targ_multi_vecs,
01148       reduct_obj, primary_global_offset);
01149 }
01150 
01151 
01152 } // namespace Thyra
01153 
01154 
01155 #endif // THYRA_MULTI_VECTOR_BASE_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines