Thyra Package Browser (Single Doxygen Collection) Version of the Day
Thyra_MultiVectorStdOps_decl.hpp
Go to the documentation of this file.
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_MultiVectorBase.hpp"
00033 #include "RTOpPack_ROpNorm1.hpp"
00034 #include "RTOpPack_ROpNorm2.hpp"
00035 #include "RTOpPack_ROpNormInf.hpp"
00036 
00037 namespace Thyra {
00038 
00039 
00050 template<class Scalar>
00051 void norms( const MultiVectorBase<Scalar>& V,
00052   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
00053 
00054 
00068 template<class Scalar, class NormOp>
00069 void reductions( const MultiVectorBase<Scalar>& V, const NormOp &op,
00070   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
00071 
00072 
00086 template<class Scalar>
00087 void norms_1( const MultiVectorBase<Scalar>& V,
00088   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
00089 
00090 
00104 template<class Scalar>
00105 void norms_2( const MultiVectorBase<Scalar>& V,
00106   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
00107 
00108 
00122 template<class Scalar>
00123 void norms_inf( const MultiVectorBase<Scalar>& V,
00124   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms );
00125 
00126 
00131 template<class Scalar>
00132 Array<typename ScalarTraits<Scalar>::magnitudeType>
00133 norms_inf( const MultiVectorBase<Scalar>& V );
00134 
00135 
00148 template<class Scalar>
00149 void dots( const MultiVectorBase<Scalar>& V1, const MultiVectorBase<Scalar>& V2,
00150   const ArrayView<Scalar> &dots );
00151 
00152 
00163 template<class Scalar>
00164 void sums( const MultiVectorBase<Scalar>& V, const ArrayView<Scalar> &sums );
00165 
00166 
00171 template<class Scalar>
00172 typename ScalarTraits<Scalar>::magnitudeType
00173 norm_1( const MultiVectorBase<Scalar>& V );
00174 
00175 
00183 template<class Scalar>
00184 void scale( Scalar alpha, const Ptr<MultiVectorBase<Scalar> > &V );
00185 
00186 
00191 template<class Scalar>
00192 void scaleUpdate( const VectorBase<Scalar>& a, const MultiVectorBase<Scalar>& U,
00193   const Ptr<MultiVectorBase<Scalar> > &V );
00194 
00199 template<class Scalar>
00200 void assign( const Ptr<MultiVectorBase<Scalar> > &V, Scalar alpha );
00201 
00206 template<class Scalar>
00207 void assign( const Ptr<MultiVectorBase<Scalar> > &V,
00208   const MultiVectorBase<Scalar>& U );
00209 
00210 
00215 template<class Scalar>
00216 void update( Scalar alpha, const MultiVectorBase<Scalar>& U,
00217   const Ptr<MultiVectorBase<Scalar> > &V );
00218 
00219 
00225 template<class Scalar>
00226 void update(
00227   const ArrayView<const Scalar> &alpha,
00228   Scalar beta,
00229   const MultiVectorBase<Scalar>& U,
00230   const Ptr<MultiVectorBase<Scalar> > &V
00231   );
00232 
00233 
00239 template<class Scalar>
00240 void update(
00241   const MultiVectorBase<Scalar>& U,
00242   const ArrayView<const Scalar> &alpha,
00243   Scalar beta,
00244   const Ptr<MultiVectorBase<Scalar> > &V
00245   );
00246 
00247 
00274 template<class Scalar>
00275 void linear_combination(
00276   const ArrayView<const Scalar> &alpha,
00277   const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &X,
00278   const Scalar &beta,
00279   const Ptr<MultiVectorBase<Scalar> > &Y
00280   );
00281 
00282 
00293 template<class Scalar>
00294 void randomize( Scalar l, Scalar u, const Ptr<MultiVectorBase<Scalar> > &V );
00295 
00296 
00302 template<class Scalar>
00303 void Vt_S( const Ptr<MultiVectorBase<Scalar> > &Z, const Scalar& alpha );
00304 
00305 
00311 template<class Scalar>
00312 void Vp_S( const Ptr<MultiVectorBase<Scalar> > &Z, const Scalar& alpha );
00313 
00314 
00320 template<class Scalar>
00321 void Vp_V( const Ptr<MultiVectorBase<Scalar> > &Z,
00322   const MultiVectorBase<Scalar>& X );
00323 
00324 
00330 template<class Scalar>
00331 void V_VpV( const Ptr<MultiVectorBase<Scalar> > &Z,
00332   const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y );
00333 
00334 
00340 template<class Scalar>
00341 void V_VmV( const Ptr<MultiVectorBase<Scalar> > &Z,
00342   const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y );
00343 
00344 
00350 template<class Scalar>
00351 void V_StVpV( const Ptr<MultiVectorBase<Scalar> > &Z, const Scalar &alpha,
00352   const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y );
00353 
00354 
00356 template<class Scalar>
00357 void norms( const MultiVectorBase<Scalar>& V,
00358   typename ScalarTraits<Scalar>::magnitudeType norms_out[] )
00359 { norms(V, Teuchos::arrayView(norms_out, V.domain()->dim())); }
00360 
00361 
00363 template<class Scalar, class NormOp>
00364 void reductions( const MultiVectorBase<Scalar>& V, const NormOp &op,
00365   typename ScalarTraits<Scalar>::magnitudeType norms_out[] )
00366 { reductions(V, op, Teuchos::arrayView(norms_out, V.domain()->dim())); }
00367 
00368 
00370 template<class Scalar>
00371 void norms_1( const MultiVectorBase<Scalar>& V,
00372   typename ScalarTraits<Scalar>::magnitudeType norms_out[] )
00373 { norms_1(V, Teuchos::arrayView(norms_out, V.domain()->dim())); }
00374 
00375 
00377 template<class Scalar>
00378 void norms_2( const MultiVectorBase<Scalar>& V,
00379   typename ScalarTraits<Scalar>::magnitudeType norms_out[] )
00380 { norms_2(V, Teuchos::arrayView(norms_out, V.domain()->dim())); }
00381 
00382 
00384 template<class Scalar>
00385 void norms_inf( const MultiVectorBase<Scalar>& V,
00386   typename ScalarTraits<Scalar>::magnitudeType norms_out[] )
00387 { norms_inf<Scalar>(V, Teuchos::arrayView(norms_out, V.domain()->dim())); }
00388 
00389 
00391 template<class Scalar>
00392 void dots( const MultiVectorBase<Scalar>& V1, const MultiVectorBase<Scalar>& V2,
00393   Scalar dots_out[] )
00394 { dots<Scalar>(V1, V2, Teuchos::arrayView(dots_out, V1.domain()->dim())); }
00395 
00396 
00398 template<class Scalar>
00399 void sums( const MultiVectorBase<Scalar>& V, Scalar sums_out[] )
00400 { sums<Scalar>(V, Teuchos::arrayView(sums_out, V.domain()->dim())); }
00401 
00402 
00404 template<class Scalar>
00405 void scale( Scalar alpha, MultiVectorBase<Scalar>* V )
00406 { scale(alpha, Teuchos::ptr(V)); }
00407 
00408 
00410 template<class Scalar>
00411 void scaleUpdate( const VectorBase<Scalar>& a, const MultiVectorBase<Scalar>& U,
00412   MultiVectorBase<Scalar>* V )
00413 { scaleUpdate(a, U, Teuchos::ptr(V)); }
00414 
00415 
00417 template<class Scalar>
00418 void assign( MultiVectorBase<Scalar>* V, Scalar alpha )
00419 { assign(Teuchos::ptr(V), alpha); }
00420 
00421 
00423 template<class Scalar>
00424 void assign( MultiVectorBase<Scalar>* V, const MultiVectorBase<Scalar>& U )
00425 { assign(Teuchos::ptr(V), U); }
00426 
00427 
00429 template<class Scalar>
00430 void update( Scalar alpha, const MultiVectorBase<Scalar>& U, MultiVectorBase<Scalar>* V )
00431 { update(alpha, U, Teuchos::ptr(V)); }
00432 
00433 
00435 template<class Scalar>
00436 void update( const Scalar alpha[], Scalar beta, const MultiVectorBase<Scalar>& U,
00437   MultiVectorBase<Scalar>* V )
00438 { update(Teuchos::arrayView(alpha, U.domain()->dim()), beta, U, Teuchos::ptr(V)); }
00439 
00440 
00442 template<class Scalar>
00443 void update( const MultiVectorBase<Scalar>& U, Scalar alpha[], Scalar beta,
00444   MultiVectorBase<Scalar>* V )
00445 { update(U, Teuchos::arrayView(alpha, U.domain()->dim()), beta, Teuchos::ptr(V)); }
00446 
00447 
00449 template<class Scalar>
00450 void linear_combination(
00451   const int m
00452   ,const Scalar alpha[]
00453   ,const MultiVectorBase<Scalar>* X_in[]
00454   ,const Scalar &beta
00455   ,MultiVectorBase<Scalar> *Y
00456   )
00457 {
00458   Array<Ptr<const MultiVectorBase<Scalar> > > X(m);
00459   for ( int k = 0; k < m; ++k )
00460     X[k] = Teuchos::ptr(X_in[k]);
00461   linear_combination<Scalar>(
00462     Teuchos::arrayView(alpha,m), X(), beta, Teuchos::ptr(Y) );
00463 }
00464 
00465 
00467 template<class Scalar>
00468 void randomize( Scalar l, Scalar u, MultiVectorBase<Scalar>* V )
00469 { randomize(l, u, Teuchos::ptr(V)); }
00470 
00471 
00473 template<class Scalar>
00474 void Vt_S( MultiVectorBase<Scalar>* Z, const Scalar& alpha )
00475 { Vt_S(Teuchos::ptr(Z), alpha); }
00476 
00477 
00479 template<class Scalar>
00480 void Vp_S( MultiVectorBase<Scalar>* Z, const Scalar& alpha )
00481 { Vp_S(Teuchos::ptr(Z), alpha); }
00482 
00483 
00485 template<class Scalar>
00486 void Vp_V( MultiVectorBase<Scalar>* Z, const MultiVectorBase<Scalar>& X )
00487 { Vp_V(Teuchos::ptr(Z), X); }
00488 
00489 
00491 template<class Scalar>
00492 void V_VpV( MultiVectorBase<Scalar>* Z, const MultiVectorBase<Scalar>& X,
00493   const MultiVectorBase<Scalar>& Y )
00494 { V_VpV(Teuchos::ptr(Z), X, Y); }
00495 
00496 
00498 template<class Scalar>
00499 void V_VmV( MultiVectorBase<Scalar>* Z, const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y )
00500 { V_VmV(Teuchos::ptr(Z), X, Y); }
00501 
00502 
00504 template<class Scalar>
00505 void V_StVpV(
00506   MultiVectorBase<Scalar>* Z, const Scalar &alpha,
00507   const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y 
00508   )
00509 { V_StVpV(Teuchos::ptr(Z), alpha, X, Y); }
00510 
00511 
00512 } // end namespace Thyra
00513 
00514 
00515 // /////////////////////////////////////
00516 // Inline functions
00517 
00518 
00519 template<class Scalar>
00520 inline
00521 void Thyra::norms_1( const MultiVectorBase<Scalar>& V,
00522   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
00523 {
00524   reductions<Scalar>(V, RTOpPack::ROpNorm1<Scalar>(), norms);
00525 }
00526 
00527 
00528 template<class Scalar>
00529 inline
00530 void Thyra::norms_2( const MultiVectorBase<Scalar>& V,
00531   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
00532 {
00533   reductions<Scalar>(V, RTOpPack::ROpNorm2<Scalar>(), norms);
00534 }
00535 
00536 
00537 template<class Scalar>
00538 inline
00539 void Thyra::norms_inf( const MultiVectorBase<Scalar>& V,
00540   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
00541 {
00542   reductions<Scalar>(V, RTOpPack::ROpNormInf<Scalar>(), norms);
00543 }
00544 
00545 
00546 template<class Scalar>
00547 Teuchos::Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType>
00548 Thyra::norms_inf( const MultiVectorBase<Scalar>& V )
00549 {
00550   typedef typename ScalarTraits<Scalar>::magnitudeType ScalarMag;
00551   Array<ScalarMag> norms(V.domain()->dim());
00552   Thyra::norms_inf<Scalar>(V, norms());
00553   return norms;
00554 }
00555 
00556 
00557 // /////////////////////////////////////////////
00558 // Other implementations
00559 
00560 
00561 template<class Scalar, class NormOp>
00562 void Thyra::reductions( const MultiVectorBase<Scalar>& V, const NormOp &op,
00563   const ArrayView<typename ScalarTraits<Scalar>::magnitudeType> &norms )
00564 {
00565   using Teuchos::tuple; using Teuchos::ptrInArg; using Teuchos::null;
00566   const int m = V.domain()->dim();
00567   Array<RCP<RTOpPack::ReductTarget> > rcp_op_targs(m);
00568   Array<Ptr<RTOpPack::ReductTarget> > op_targs(m);
00569   for( int kc = 0; kc < m; ++kc ) {
00570     rcp_op_targs[kc] = op.reduct_obj_create();
00571     op_targs[kc] = rcp_op_targs[kc].ptr();
00572   }
00573   applyOp<Scalar>(op, tuple(ptrInArg(V)),
00574     ArrayView<Ptr<MultiVectorBase<Scalar> > >(null),
00575     op_targs );
00576   for( int kc = 0; kc < m; ++kc ) {
00577     norms[kc] = op(*op_targs[kc]);
00578   }
00579 }
00580 
00581 
00582 #endif // THYRA_MULTI_VECTOR_STD_OPS_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines