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 "Thyra_RowStatLinearOpBase.hpp"
00047 #include "Thyra_ScaledLinearOpBase.hpp"
00048 #include "RTOpPack_RTOpT.hpp"
00049 
00050 
00051 namespace Thyra {
00052 
00053 
00492 template<class Scalar>
00493 class MultiVectorBase : virtual public LinearOpBase<Scalar>, 
00494                         virtual public RowStatLinearOpBase<Scalar>,
00495                         virtual public ScaledLinearOpBase<Scalar>
00496 {
00497 public:
00498 
00499 #ifdef THYRA_INJECT_USING_DECLARATIONS
00500   using LinearOpBase<Scalar>::apply;
00501 #endif
00502 
00505 
00510   RCP<const VectorBase<Scalar> > col(Ordinal j) const
00511     { return colImpl(j); }
00512 
00517   RCP<VectorBase<Scalar> > col(Ordinal j)
00518     { return nonconstColImpl(j); }
00519 
00521 
00524 
00529   RCP<const MultiVectorBase<Scalar> >
00530   subView( const Range1D& colRng ) const
00531     {
00532       return contigSubViewImpl(colRng);
00533     }
00534 
00539   RCP<MultiVectorBase<Scalar> >
00540   subView( const Range1D& colRng )
00541     { return nonconstContigSubViewImpl(colRng); }
00542 
00547   RCP<const MultiVectorBase<Scalar> >
00548   subView( const ArrayView<const int> &cols ) const
00549     { return nonContigSubViewImpl(cols); }
00550 
00555   RCP<MultiVectorBase<Scalar> >
00556   subView( const ArrayView<const int> &cols )
00557     { return nonconstNonContigSubViewImpl(cols); }
00558   
00560 
00563 
00568   void applyOp(
00569     const RTOpPack::RTOpT<Scalar> &primary_op,
00570     const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
00571     const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
00572     const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
00573     const Ordinal primary_global_offset
00574     ) const
00575     {
00576       mvMultiReductApplyOpImpl(primary_op, multi_vecs, targ_multi_vecs,
00577         reduct_objs, primary_global_offset);
00578     }
00579 
00584   void applyOp(
00585     const RTOpPack::RTOpT<Scalar> &primary_op,
00586     const RTOpPack::RTOpT<Scalar> &secondary_op,
00587     const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
00588     const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
00589     const Ptr<RTOpPack::ReductTarget> &reduct_obj,
00590     const Ordinal primary_global_offset
00591     ) const
00592     {
00593       mvSingleReductApplyOpImpl(primary_op, secondary_op, multi_vecs, targ_multi_vecs,
00594         reduct_obj, primary_global_offset);
00595     }
00596   
00598 
00601 
00606   void acquireDetachedView(
00607     const Range1D &rowRng,
00608     const Range1D &colRng,
00609     RTOpPack::ConstSubMultiVectorView<Scalar> *sub_mv
00610     ) const
00611     { acquireDetachedMultiVectorViewImpl( rowRng, colRng, sub_mv ); }
00612 
00617   void releaseDetachedView(
00618     RTOpPack::ConstSubMultiVectorView<Scalar>* sub_mv
00619     ) const
00620     { releaseDetachedMultiVectorViewImpl(sub_mv); }
00621 
00626   void acquireDetachedView(
00627     const Range1D &rowRng,
00628     const Range1D &colRng,
00629     RTOpPack::SubMultiVectorView<Scalar> *sub_mv
00630     )
00631     { acquireNonconstDetachedMultiVectorViewImpl(rowRng,colRng,sub_mv); }
00632 
00637   void commitDetachedView(
00638     RTOpPack::SubMultiVectorView<Scalar>* sub_mv
00639     )
00640     { commitNonconstDetachedMultiVectorViewImpl(sub_mv); }
00641 
00643 
00646 
00655   virtual RCP<MultiVectorBase<Scalar> > clone_mv() const = 0;
00656 
00658 
00661 
00663   RCP<const LinearOpBase<Scalar> > clone() const;
00664 
00666 
00667 protected:
00668 
00671 
00693   virtual RCP<const VectorBase<Scalar> > colImpl(Ordinal j) const;
00694 
00715   virtual RCP<VectorBase<Scalar> > nonconstColImpl(Ordinal j) = 0;
00716 
00741   virtual RCP<const MultiVectorBase<Scalar> >
00742   contigSubViewImpl( const Range1D& colRng ) const = 0;
00743 
00768   virtual RCP<MultiVectorBase<Scalar> >
00769   nonconstContigSubViewImpl( const Range1D& colRng ) = 0;
00770 
00795   virtual RCP<const MultiVectorBase<Scalar> >
00796   nonContigSubViewImpl( const ArrayView<const int> &cols ) const = 0;
00797 
00822   virtual RCP<MultiVectorBase<Scalar> >
00823   nonconstNonContigSubViewImpl( const ArrayView<const int> &cols ) = 0;
00824 
00846   virtual void mvMultiReductApplyOpImpl(
00847     const RTOpPack::RTOpT<Scalar> &primary_op,
00848     const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
00849     const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
00850     const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
00851     const Ordinal primary_global_offset
00852     ) const = 0;
00853 
00874   virtual void mvSingleReductApplyOpImpl(
00875     const RTOpPack::RTOpT<Scalar> &primary_op,
00876     const RTOpPack::RTOpT<Scalar> &secondary_op,
00877     const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
00878     const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
00879     const Ptr<RTOpPack::ReductTarget> &reduct_obj,
00880     const Ordinal primary_global_offset
00881     ) const = 0;
00882 
00946   virtual void acquireDetachedMultiVectorViewImpl(
00947     const Range1D &rowRng,
00948     const Range1D &colRng,
00949     RTOpPack::ConstSubMultiVectorView<Scalar> *sub_mv
00950     ) const = 0;
00951 
00977   virtual void releaseDetachedMultiVectorViewImpl(
00978     RTOpPack::ConstSubMultiVectorView<Scalar>* sub_mv
00979     ) const = 0;
00980 
01053   virtual void acquireNonconstDetachedMultiVectorViewImpl(
01054     const Range1D &rowRng,
01055     const Range1D &colRng,
01056     RTOpPack::SubMultiVectorView<Scalar> *sub_mv
01057     ) = 0;
01058 
01086   virtual void commitNonconstDetachedMultiVectorViewImpl(
01087     RTOpPack::SubMultiVectorView<Scalar>* sub_mv
01088     ) = 0;
01089 
01091   virtual bool rowStatIsSupportedImpl(
01092     const RowStatLinearOpBaseUtils::ERowStat rowStat) const;
01093 
01095   virtual void getRowStatImpl(
01096     const RowStatLinearOpBaseUtils::ERowStat rowStat,
01097     const Ptr<VectorBase<Scalar> > &rowStatVec) const;
01098 
01100   virtual bool supportsScaleLeftImpl() const;
01101   
01103   virtual bool supportsScaleRightImpl() const;
01104   
01106   virtual void scaleLeftImpl(const VectorBase< Scalar > &row_scaling);
01107   
01109   virtual void scaleRightImpl(const VectorBase< Scalar > &col_scaling);
01110 
01112 
01120   void absRowSum(const Teuchos::Ptr<Thyra::VectorBase<Scalar> > & output) const;
01121 
01127   void absColSum(const Teuchos::Ptr<Thyra::VectorBase<Scalar> > & output) const;
01128 
01129 public:
01130 
01131 private:
01132   
01133   // Not defined and not to be called
01134   MultiVectorBase<Scalar>&
01135   operator=(const MultiVectorBase<Scalar>&);
01136 
01137 };
01138 
01139 
01147 template<class Scalar>
01148 inline
01149 void applyOp(
01150   const RTOpPack::RTOpT<Scalar> &primary_op,
01151   const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
01152   const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
01153   const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
01154   const Ordinal primary_global_offset = 0
01155   )
01156 {
01157   if(multi_vecs.size())
01158     multi_vecs[0]->applyOp(primary_op, multi_vecs, targ_multi_vecs,
01159       reduct_objs, primary_global_offset);
01160   else if(targ_multi_vecs.size())
01161     targ_multi_vecs[0]->applyOp(primary_op, multi_vecs, targ_multi_vecs,
01162       reduct_objs, primary_global_offset);
01163 }
01164 
01165 
01173 template<class Scalar>
01174 inline
01175 void applyOp(
01176   const RTOpPack::RTOpT<Scalar> &primary_op,
01177   const RTOpPack::RTOpT<Scalar> &secondary_op,
01178   const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
01179   const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
01180   const Ptr<RTOpPack::ReductTarget> &reduct_obj,
01181   const Ordinal primary_global_offset = 0
01182   )
01183 {
01184   if(multi_vecs.size())
01185     multi_vecs[0]->applyOp(primary_op, secondary_op, multi_vecs, targ_multi_vecs,
01186       reduct_obj, primary_global_offset);
01187   else if(targ_multi_vecs.size())
01188     targ_multi_vecs[0]->applyOp(primary_op, secondary_op, multi_vecs, targ_multi_vecs,
01189       reduct_obj, primary_global_offset);
01190 }
01191 
01192 
01193 } // namespace Thyra
01194 
01195 
01196 #endif // THYRA_MULTI_VECTOR_BASE_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines