Thyra Version of the Day
Thyra_MultiVectorStdOps_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_STD_OPS_DECL_HPP
00043 #define THYRA_MULTI_VECTOR_STD_OPS_DECL_HPP
00044 
00045 #include "Thyra_MultiVectorBase.hpp"
00046 #include "RTOpPack_ROpNorm1.hpp"
00047 #include "RTOpPack_ROpNorm2.hpp"
00048 #include "RTOpPack_ROpNormInf.hpp"
00049 
00050 namespace Thyra {
00051 
00052 
00063 template<class Scalar>
00064 void norms( const MultiVectorBase<Scalar>& V,
00065   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
00066 
00067 
00081 template<class Scalar, class NormOp>
00082 void reductions( const MultiVectorBase<Scalar>& V, const NormOp &op,
00083   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
00084 
00085 
00099 template<class Scalar>
00100 void norms_1( const MultiVectorBase<Scalar>& V,
00101   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
00102 
00103 
00117 template<class Scalar>
00118 void norms_2( const MultiVectorBase<Scalar>& V,
00119   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
00120 
00121 
00135 template<class Scalar>
00136 void norms_inf( const MultiVectorBase<Scalar>& V,
00137   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
00138 
00139 
00144 template<class Scalar>
00145 Array<typename ScalarTraits<Scalar>::magnitudeType>
00146 norms_inf( const MultiVectorBase<Scalar>& V );
00147 
00148 
00161 template<class Scalar>
00162 void dots( const MultiVectorBase<Scalar>& V1, const MultiVectorBase<Scalar>& V2,
00163   const ArrayView<Scalar> &dots );
00164 
00165 
00176 template<class Scalar>
00177 void sums( const MultiVectorBase<Scalar>& V, const ArrayView<Scalar> &sums );
00178 
00179 
00184 template<class Scalar>
00185 typename ScalarTraits<Scalar>::magnitudeType
00186 norm_1( const MultiVectorBase<Scalar>& V );
00187 
00188 
00196 template<class Scalar>
00197 void scale( Scalar alpha, const Ptr<MultiVectorBase<Scalar> > &V );
00198 
00199 
00204 template<class Scalar>
00205 void scaleUpdate( const VectorBase<Scalar>& a, const MultiVectorBase<Scalar>& U,
00206   const Ptr<MultiVectorBase<Scalar> > &V );
00207 
00212 template<class Scalar>
00213 void assign( const Ptr<MultiVectorBase<Scalar> > &V, Scalar alpha );
00214 
00219 template<class Scalar>
00220 void assign( const Ptr<MultiVectorBase<Scalar> > &V,
00221   const MultiVectorBase<Scalar>& U );
00222 
00223 
00228 template<class Scalar>
00229 void update( Scalar alpha, const MultiVectorBase<Scalar>& U,
00230   const Ptr<MultiVectorBase<Scalar> > &V );
00231 
00232 
00238 template<class Scalar>
00239 void update(
00240   const ArrayView<const Scalar> &alpha,
00241   Scalar beta,
00242   const MultiVectorBase<Scalar>& U,
00243   const Ptr<MultiVectorBase<Scalar> > &V
00244   );
00245 
00246 
00252 template<class Scalar>
00253 void update(
00254   const MultiVectorBase<Scalar>& U,
00255   const ArrayView<const Scalar> &alpha,
00256   Scalar beta,
00257   const Ptr<MultiVectorBase<Scalar> > &V
00258   );
00259 
00260 
00287 template<class Scalar>
00288 void linear_combination(
00289   const ArrayView<const Scalar> &alpha,
00290   const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &X,
00291   const Scalar &beta,
00292   const Ptr<MultiVectorBase<Scalar> > &Y
00293   );
00294 
00295 
00306 template<class Scalar>
00307 void randomize( Scalar l, Scalar u, const Ptr<MultiVectorBase<Scalar> > &V );
00308 
00309 
00315 template<class Scalar>
00316 void Vt_S( const Ptr<MultiVectorBase<Scalar> > &Z, const Scalar& alpha );
00317 
00318 
00324 template<class Scalar>
00325 void Vp_S( const Ptr<MultiVectorBase<Scalar> > &Z, const Scalar& alpha );
00326 
00327 
00333 template<class Scalar>
00334 void Vp_V( const Ptr<MultiVectorBase<Scalar> > &Z,
00335   const MultiVectorBase<Scalar>& X );
00336 
00337 
00343 template<class Scalar>
00344 void V_VpV( const Ptr<MultiVectorBase<Scalar> > &Z,
00345   const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y );
00346 
00347 
00353 template<class Scalar>
00354 void V_VmV( const Ptr<MultiVectorBase<Scalar> > &Z,
00355   const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y );
00356 
00357 
00363 template<class Scalar>
00364 void V_StVpV( const Ptr<MultiVectorBase<Scalar> > &Z, const Scalar &alpha,
00365   const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y );
00366 
00367 
00368 } // end namespace Thyra
00369 
00370 
00371 // /////////////////////////////////////
00372 // Inline functions
00373 
00374 
00375 template<class Scalar>
00376 inline
00377 void Thyra::norms_1( const MultiVectorBase<Scalar>& V,
00378   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
00379 {
00380   reductions<Scalar>(V, RTOpPack::ROpNorm1<Scalar>(), norms);
00381 }
00382 
00383 
00384 template<class Scalar>
00385 inline
00386 void Thyra::norms_2( const MultiVectorBase<Scalar>& V,
00387   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
00388 {
00389   reductions<Scalar>(V, RTOpPack::ROpNorm2<Scalar>(), norms);
00390 }
00391 
00392 
00393 template<class Scalar>
00394 inline
00395 void Thyra::norms_inf( const MultiVectorBase<Scalar>& V,
00396   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
00397 {
00398   reductions<Scalar>(V, RTOpPack::ROpNormInf<Scalar>(), norms);
00399 }
00400 
00401 
00402 template<class Scalar>
00403 Teuchos::Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType>
00404 Thyra::norms_inf( const MultiVectorBase<Scalar>& V )
00405 {
00406   typedef typename ScalarTraits<Scalar>::magnitudeType ScalarMag;
00407   Array<ScalarMag> norms(V.domain()->dim());
00408   Thyra::norms_inf<Scalar>(V, norms());
00409   return norms;
00410 }
00411 
00412 
00413 // /////////////////////////////////////////////
00414 // Other implementations
00415 
00416 
00417 template<class Scalar, class NormOp>
00418 void Thyra::reductions( const MultiVectorBase<Scalar>& V, const NormOp &op,
00419   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
00420 {
00421   using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00422   const int m = V.domain()->dim();
00423   Array<RCP<RTOpPack::ReductTarget> > rcp_op_targs(m);
00424   Array<Ptr<RTOpPack::ReductTarget> > op_targs(m);
00425   for( int kc = 0; kc < m; ++kc ) {
00426     rcp_op_targs[kc] = op.reduct_obj_create();
00427     op_targs[kc] = rcp_op_targs[kc].ptr();
00428   }
00429   applyOp<Scalar>(op, tuple(ptrInArg(V)),
00430     ArrayView<Ptr<MultiVectorBase<Scalar> > >(null),
00431     op_targs );
00432   for( int kc = 0; kc < m; ++kc ) {
00433     norms[kc] = op(*op_targs[kc]);
00434   }
00435 }
00436 
00437 
00438 #endif // THYRA_MULTI_VECTOR_STD_OPS_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines