Thyra_MultiVectorStdOpsDecl.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_STD_OPS_DECL_HPP
00030 #define THYRA_MULTI_VECTOR_STD_OPS_DECL_HPP
00031 
00032 #include "Thyra_OperatorVectorTypes.hpp"
00033 #include "RTOpPack_ROpNorm1.hpp"
00034 #include "RTOpPack_ROpNorm2.hpp"
00035 #include "RTOpPack_ROpNormInf.hpp"
00036 
00037 namespace Thyra {
00038 
00039 
00055 
00064 template<class Scalar>
00065 void norms( const MultiVectorBase<Scalar>& V,
00066   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
00067 
00079 template<class Scalar, class NormOp>
00080 void reductions( const MultiVectorBase<Scalar>& V, const NormOp &op,
00081   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
00082 
00094 template<class Scalar>
00095 void norms_1( const MultiVectorBase<Scalar>& V,
00096   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
00097 
00109 template<class Scalar>
00110 void norms_2( const MultiVectorBase<Scalar>& V,
00111   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
00112 
00124 template<class Scalar>
00125 void norms_inf( const MultiVectorBase<Scalar>& V,
00126   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
00127 
00129 template<class Scalar>
00130 Array<typename ScalarTraits<Scalar>::magnitudeType>
00131 norms_inf( const MultiVectorBase<Scalar>& V );
00132 
00143 template<class Scalar>
00144 void dots( const MultiVectorBase<Scalar>& V1, const MultiVectorBase<Scalar>& V2,
00145   const ArrayView<Scalar> &dots );
00146 
00155 template<class Scalar>
00156 void sums( const MultiVectorBase<Scalar>& V, const ArrayView<Scalar> &sums );
00157 
00159 template<class Scalar>
00160 typename ScalarTraits<Scalar>::magnitudeType
00161 norm_1( const MultiVectorBase<Scalar>& V );
00162 
00168 template<class Scalar>
00169 void scale( Scalar alpha, const Ptr<MultiVectorBase<Scalar> > &V );
00170 
00172 template<class Scalar>
00173 void scaleUpdate( const VectorBase<Scalar>& a, const MultiVectorBase<Scalar>& U,
00174   const Ptr<MultiVectorBase<Scalar> > &V );
00175 
00177 template<class Scalar>
00178 void assign( const Ptr<MultiVectorBase<Scalar> > &V, Scalar alpha );
00179 
00182 template<class Scalar>
00183 void assign( const Ptr<MultiVectorBase<Scalar> > &V,
00184   const MultiVectorBase<Scalar>& U );
00185 
00188 template<class Scalar>
00189 void update( Scalar alpha, const MultiVectorBase<Scalar>& U,
00190   const Ptr<MultiVectorBase<Scalar> > &V );
00191 
00195 template<class Scalar>
00196 void update(
00197   const ArrayView<const Scalar> &alpha,
00198   Scalar beta,
00199   const MultiVectorBase<Scalar>& U,
00200   const Ptr<MultiVectorBase<Scalar> > &V
00201   );
00202 
00206 template<class Scalar>
00207 void update(
00208   const MultiVectorBase<Scalar>& U,
00209   const ArrayView<const Scalar> &alpha,
00210   Scalar beta,
00211   const Ptr<MultiVectorBase<Scalar> > &V
00212   );
00213 
00238 template<class Scalar>
00239 void linear_combination(
00240   const ArrayView<const Scalar> &alpha,
00241   const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &X,
00242   const Scalar &beta,
00243   const Ptr<MultiVectorBase<Scalar> > &Y
00244   );
00245 
00254 template<class Scalar>
00255 void randomize( Scalar l, Scalar u, const Ptr<MultiVectorBase<Scalar> > &V );
00256 
00258 
00271 
00275 template<class Scalar>
00276 void Vt_S( const Ptr<MultiVectorBase<Scalar> > &Z, const Scalar& alpha );
00277 
00281 template<class Scalar>
00282 void Vp_S( const Ptr<MultiVectorBase<Scalar> > &Z, const Scalar& alpha );
00283 
00287 template<class Scalar>
00288 void Vp_V( const Ptr<MultiVectorBase<Scalar> > &Z,
00289   const MultiVectorBase<Scalar>& X );
00290 
00294 template<class Scalar>
00295 void V_VpV( const Ptr<MultiVectorBase<Scalar> > &Z,
00296   const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y );
00297 
00301 template<class Scalar>
00302 void V_VmV( const Ptr<MultiVectorBase<Scalar> > &Z,
00303   const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y );
00304 
00308 template<class Scalar>
00309 void V_StVpV( const Ptr<MultiVectorBase<Scalar> > &Z, const Scalar &alpha,
00310   const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y );
00311 
00313 
00319 
00321 template<class Scalar>
00322 void norms( const MultiVectorBase<Scalar>& V,
00323   typename ScalarTraits<Scalar>::magnitudeType norms_out[] )
00324 { norms(V, Teuchos::arrayView(norms_out, V.domain()->dim())); }
00325 
00327 template<class Scalar, class NormOp>
00328 void reductions( const MultiVectorBase<Scalar>& V, const NormOp &op,
00329   typename ScalarTraits<Scalar>::magnitudeType norms_out[] )
00330 { reductions(V, op, Teuchos::arrayView(norms_out, V.domain()->dim())); }
00331 
00333 template<class Scalar>
00334 void norms_1( const MultiVectorBase<Scalar>& V,
00335   typename ScalarTraits<Scalar>::magnitudeType norms_out[] )
00336 { norms_1(V, Teuchos::arrayView(norms_out, V.domain()->dim())); }
00337 
00339 template<class Scalar>
00340 void norms_2( const MultiVectorBase<Scalar>& V,
00341   typename ScalarTraits<Scalar>::magnitudeType norms_out[] )
00342 { norms_2(V, Teuchos::arrayView(norms_out, V.domain()->dim())); }
00343 
00345 template<class Scalar>
00346 void norms_inf( const MultiVectorBase<Scalar>& V,
00347   typename ScalarTraits<Scalar>::magnitudeType norms_out[] )
00348 { norms_inf<Scalar>(V, Teuchos::arrayView(norms_out, V.domain()->dim())); }
00349 
00351 template<class Scalar>
00352 void dots( const MultiVectorBase<Scalar>& V1, const MultiVectorBase<Scalar>& V2,
00353   Scalar dots_out[] )
00354 { dots<Scalar>(V1, V2, Teuchos::arrayView(dots_out, V1.domain()->dim())); }
00355 
00357 template<class Scalar>
00358 void sums( const MultiVectorBase<Scalar>& V, Scalar sums_out[] )
00359 { sums<Scalar>(V, Teuchos::arrayView(sums_out, V.domain()->dim())); }
00360 
00362 template<class Scalar>
00363 void scale( Scalar alpha, MultiVectorBase<Scalar>* V )
00364 { scale(alpha, Teuchos::ptr(V)); }
00365 
00367 template<class Scalar>
00368 void scaleUpdate( const VectorBase<Scalar>& a, const MultiVectorBase<Scalar>& U,
00369   MultiVectorBase<Scalar>* V )
00370 { scaleUpdate(a, U, Teuchos::ptr(V)); }
00371 
00373 template<class Scalar>
00374 void assign( MultiVectorBase<Scalar>* V, Scalar alpha )
00375 { assign(Teuchos::ptr(V), alpha); }
00376 
00378 template<class Scalar>
00379 void assign( MultiVectorBase<Scalar>* V, const MultiVectorBase<Scalar>& U )
00380 { assign(Teuchos::ptr(V), U); }
00381 
00383 template<class Scalar>
00384 void update( Scalar alpha, const MultiVectorBase<Scalar>& U, MultiVectorBase<Scalar>* V )
00385 { update(alpha, U, Teuchos::ptr(V)); }
00386 
00388 template<class Scalar>
00389 void update( const Scalar alpha[], Scalar beta, const MultiVectorBase<Scalar>& U,
00390   MultiVectorBase<Scalar>* V )
00391 { update(Teuchos::arrayView(alpha, U.domain()->dim()), beta, U, Teuchos::ptr(V)); }
00392 
00394 template<class Scalar>
00395 void update( const MultiVectorBase<Scalar>& U, Scalar alpha[], Scalar beta,
00396   MultiVectorBase<Scalar>* V )
00397 { update(U, Teuchos::arrayView(alpha, U.domain()->dim()), beta, Teuchos::ptr(V)); }
00398 
00400 template<class Scalar>
00401 void linear_combination(
00402   const int m
00403   ,const Scalar alpha[]
00404   ,const MultiVectorBase<Scalar>* X_in[]
00405   ,const Scalar &beta
00406   ,MultiVectorBase<Scalar> *Y
00407   )
00408 {
00409   Array<Ptr<const MultiVectorBase<Scalar> > > X(m);
00410   for ( int k = 0; k < m; ++k )
00411     X[k] = Teuchos::ptr(X_in[k]);
00412   linear_combination<Scalar>(
00413     Teuchos::arrayView(alpha,m), X(), beta, Teuchos::ptr(Y) );
00414 }
00415 
00417 template<class Scalar>
00418 void randomize( Scalar l, Scalar u, MultiVectorBase<Scalar>* V )
00419 { randomize(l, u, Teuchos::ptr(V)); }
00420 
00422 template<class Scalar>
00423 void Vt_S( MultiVectorBase<Scalar>* Z, const Scalar& alpha )
00424 { Vt_S(Teuchos::ptr(Z), alpha); }
00425 
00427 template<class Scalar>
00428 void Vp_S( MultiVectorBase<Scalar>* Z, const Scalar& alpha )
00429 { Vp_S(Teuchos::ptr(Z), alpha); }
00430 
00432 template<class Scalar>
00433 void Vp_V( MultiVectorBase<Scalar>* Z, const MultiVectorBase<Scalar>& X )
00434 { Vp_V(Teuchos::ptr(Z), X); }
00435 
00437 template<class Scalar>
00438 void V_VpV( MultiVectorBase<Scalar>* Z, const MultiVectorBase<Scalar>& X,
00439   const MultiVectorBase<Scalar>& Y )
00440 { V_VpV(Teuchos::ptr(Z), X, Y); }
00441 
00443 template<class Scalar>
00444 void V_VmV( MultiVectorBase<Scalar>* Z, const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y )
00445 { V_VmV(Teuchos::ptr(Z), X, Y); }
00446 
00448 template<class Scalar>
00449 void V_StVpV(
00450   MultiVectorBase<Scalar>* Z, const Scalar &alpha,
00451   const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y 
00452   )
00453 { V_StVpV(Teuchos::ptr(Z), alpha, X, Y); }
00454 
00456 
00457 } // end namespace Thyra
00458 
00459 
00460 // /////////////////////////////////////
00461 // Inline functions
00462 
00463 
00464 template<class Scalar>
00465 inline
00466 void Thyra::norms_1( const MultiVectorBase<Scalar>& V,
00467   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
00468 {
00469   reductions<Scalar>(V, RTOpPack::ROpNorm1<Scalar>(), norms);
00470 }
00471 
00472 
00473 template<class Scalar>
00474 inline
00475 void Thyra::norms_2( const MultiVectorBase<Scalar>& V,
00476   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
00477 {
00478   reductions<Scalar>(V, RTOpPack::ROpNorm2<Scalar>(), norms);
00479 }
00480 
00481 
00482 template<class Scalar>
00483 inline
00484 void Thyra::norms_inf( const MultiVectorBase<Scalar>& V,
00485   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
00486 {
00487   reductions<Scalar>(V, RTOpPack::ROpNormInf<Scalar>(), norms);
00488 }
00489 
00490 
00491 template<class Scalar>
00492 Teuchos::Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType>
00493 Thyra::norms_inf( const MultiVectorBase<Scalar>& V )
00494 {
00495   typedef typename ScalarTraits<Scalar>::magnitudeType ScalarMag;
00496   Array<ScalarMag> norms(V.domain()->dim());
00497   Thyra::norms_inf<Scalar>(V, norms());
00498   return norms;
00499 }
00500 
00501 
00502 #endif // THYRA_MULTI_VECTOR_STD_OPS_DECL_HPP

Generated on Wed May 12 21:42:28 2010 for Thyra Operator/Vector Support by  doxygen 1.4.7