Thyra_MultiVectorBase.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_HPP
00030 #define THYRA_MULTI_VECTOR_BASE_HPP
00031 
00032 #include "Thyra_MultiVectorBaseDecl.hpp"
00033 #include "Thyra_LinearOpBase.hpp"
00034 
00035 
00036 namespace Thyra {
00037 
00038 
00039 // Provide access to the columns as VectorBase objects
00040 
00041 
00042 template<class Scalar>
00043 RCP<const VectorBase<Scalar> >
00044 MultiVectorBase<Scalar>::colImpl(Index j) const
00045 {
00046   return const_cast<MultiVectorBase*>(this)->nonconstColImpl(j);
00047 }
00048 
00049 
00050 // Overridden methods from LinearOpBase
00051 
00052 
00053 template<class Scalar>
00054 RCP<const LinearOpBase<Scalar> >
00055 MultiVectorBase<Scalar>::clone() const
00056 {
00057   return this->clone_mv();
00058 }
00059 
00060 
00061 //
00062 // Deprecated public function
00063 //
00064 
00065 
00066 template<class Scalar>
00067 void MultiVectorBase<Scalar>::applyOp(
00068   const RTOpPack::RTOpT<Scalar> &primary_op,
00069   const int num_multi_vecs,
00070   const MultiVectorBase<Scalar>*const multi_vecs_in[],
00071   const int num_targ_multi_vecs,
00072   MultiVectorBase<Scalar>*const targ_multi_vecs_inout[],
00073   RTOpPack::ReductTarget*const reduct_objs_inout[],
00074   const Index primary_first_ele_offset,
00075   const Index primary_sub_dim,
00076   const Index primary_global_offset,
00077     const Index secondary_first_ele_offset,
00078   const Index secondary_sub_dim_in
00079   ) const
00080 {
00081   Array<Ptr<const MultiVectorBase<Scalar> > > multi_vecs;
00082   for (int k = 0; k < num_multi_vecs; ++k)
00083     multi_vecs.push_back(Teuchos::ptr(multi_vecs_in[k]));
00084   Array<Ptr<MultiVectorBase<Scalar> > > targ_multi_vecs;
00085   for (int k = 0; k < num_targ_multi_vecs; ++k)
00086     targ_multi_vecs.push_back(Teuchos::ptr(targ_multi_vecs_inout[k]));
00087   Array<Ptr<RTOpPack::ReductTarget> > reduct_objs;
00088   if (reduct_objs_inout) {
00089     const int secondary_sub_dim =
00090       (
00091         secondary_sub_dim_in >= 0
00092         ? secondary_sub_dim_in
00093         : ( num_multi_vecs ? multi_vecs[0]->domain() : targ_multi_vecs[0]->domain() )->dim()
00094         );
00095     const int num_reduct_objs = ( secondary_sub_dim - secondary_first_ele_offset );
00096     for (int k = 0; k < num_reduct_objs; ++k)
00097       reduct_objs.push_back(Teuchos::ptr(reduct_objs_inout[k]));
00098   }
00099   mvMultiReductApplyOpImpl(
00100     primary_op
00101     ,multi_vecs,targ_multi_vecs
00102     ,reduct_objs,primary_first_ele_offset,primary_sub_dim,primary_global_offset
00103     ,secondary_first_ele_offset,secondary_sub_dim_in
00104     );
00105 }
00106 
00107 
00108 template<class Scalar>
00109 void MultiVectorBase<Scalar>::applyOp(
00110   const RTOpPack::RTOpT<Scalar> &primary_op,
00111   const RTOpPack::RTOpT<Scalar> &secondary_op,
00112   const int num_multi_vecs,
00113   const MultiVectorBase<Scalar>*const multi_vecs_in[],
00114   const int num_targ_multi_vecs,
00115   MultiVectorBase<Scalar>*const targ_multi_vecs_inout[],
00116   RTOpPack::ReductTarget* reduct_obj,
00117   const Index primary_first_ele_offset,
00118   const Index primary_sub_dim,
00119   const Index primary_global_offset,
00120   const Index secondary_first_ele_offset,
00121   const Index secondary_sub_dim
00122   ) const
00123 {
00124   Array<Ptr<const MultiVectorBase<Scalar> > > multi_vecs;
00125   for (int k = 0; k < num_multi_vecs; ++k)
00126     multi_vecs.push_back(Teuchos::ptr(multi_vecs_in[k]));
00127   Array<Ptr<MultiVectorBase<Scalar> > > targ_multi_vecs;
00128   for (int k = 0; k < num_targ_multi_vecs; ++k)
00129     targ_multi_vecs.push_back(Teuchos::ptr(targ_multi_vecs_inout[k]));
00130   mvSingleReductApplyOpImpl(
00131     primary_op, secondary_op
00132     ,multi_vecs,targ_multi_vecs
00133     ,Teuchos::ptr(reduct_obj)
00134     ,primary_first_ele_offset,primary_sub_dim,primary_global_offset
00135     ,secondary_first_ele_offset,secondary_sub_dim
00136     );
00137 }
00138 
00139 
00140 } // end namespace Thyra
00141 
00142 
00143 #endif // THYRA_MULTI_VECTOR_BASE_HPP

Generated on Wed May 12 21:42:09 2010 for Fundamental Thyra ANA Operator/Vector Interfaces by  doxygen 1.4.7