Thyra_LinearOpBaseDecl.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_LINEAR_OP_DECL_HPP
00030 #define THYRA_LINEAR_OP_DECL_HPP
00031 
00032 #include "Thyra_OperatorVectorTypes.hpp"
00033 #include "Teuchos_Describable.hpp"
00034 #include "Teuchos_PromotionTraits.hpp"
00035 
00036 namespace Thyra {
00037 
00201 template<class RangeScalar, class DomainScalar>
00202 class LinearOpBase : virtual public Teuchos::Describable {
00203 public:
00204 
00207 
00224   virtual RCP< const VectorSpaceBase<RangeScalar> > range() const = 0;
00225 
00242   virtual RCP< const VectorSpaceBase<DomainScalar> > domain() const = 0;
00243 
00279   virtual void apply(
00280     const EConj conj,
00281     const MultiVectorBase<DomainScalar> &X,
00282     MultiVectorBase<RangeScalar> *Y,
00283     const RangeScalar alpha = Teuchos::ScalarTraits<RangeScalar>::one(),
00284     const RangeScalar beta = Teuchos::ScalarTraits<RangeScalar>::zero()
00285     ) const = 0;
00286 
00288 
00291 
00297   virtual bool applySupports( const EConj conj ) const;
00298 
00304   virtual bool applyTransposeSupports( const EConj conj ) const;
00305 
00347   virtual void applyTranspose(
00348     const EConj conj,
00349     const MultiVectorBase<RangeScalar> &X,
00350     MultiVectorBase<DomainScalar> *Y,
00351     const DomainScalar alpha = Teuchos::ScalarTraits<DomainScalar>::one(),
00352     const DomainScalar beta = Teuchos::ScalarTraits<DomainScalar>::zero()
00353     ) const;
00354 
00367   virtual RCP<const LinearOpBase<RangeScalar,DomainScalar> > clone() const;
00368 
00370 
00371 };  // end class LinearOpBase
00372 
00377 template<class Scalar>
00378 inline bool opSupported( const LinearOpBase<Scalar> &M, ETransp M_trans )
00379 {
00380   if(real_trans(M_trans)==NOTRANS)
00381     return M.applySupports(transToConj(M_trans));
00382   return M.applyTransposeSupports(transToConj(M_trans));
00383 }
00384 
00391 template<class RangeScalar, class DomainScalar>
00392 inline void apply(
00393   const LinearOpBase<RangeScalar,DomainScalar> &M,
00394   const EConj conj,
00395   const MultiVectorBase<DomainScalar> &X,
00396   MultiVectorBase<RangeScalar> *Y,
00397   const RangeScalar alpha = ScalarTraits<RangeScalar>::one(),
00398   const RangeScalar beta = ScalarTraits<RangeScalar>::zero()
00399   )
00400 {
00401   M.apply(conj,X,Y,alpha,beta);
00402 }
00403 
00411 template<class RangeScalar, class DomainScalar>
00412 inline void applyTranspose(
00413   const LinearOpBase<RangeScalar,DomainScalar> &M,
00414   const EConj conj,
00415   const MultiVectorBase<RangeScalar> &X,
00416   MultiVectorBase<DomainScalar> *Y,
00417   const DomainScalar alpha = ScalarTraits<DomainScalar>::one(),
00418   const DomainScalar beta = ScalarTraits<DomainScalar>::zero()
00419   )
00420 {
00421   M.applyTranspose(conj,X,Y,alpha,beta);
00422 }
00423 
00424 
00434 template<class Scalar>
00435 inline void apply(
00436   const LinearOpBase<Scalar> &M,
00437   const ETransp M_trans,
00438   const MultiVectorBase<Scalar> &X,
00439   MultiVectorBase<Scalar> *Y,
00440   const Scalar alpha = ScalarTraits<Scalar>::one(),
00441   const Scalar beta = ScalarTraits<Scalar>::zero()
00442   )
00443 {
00444   if(real_trans(M_trans)==NOTRANS) {
00445     M.apply(transToConj(M_trans),X,Y,alpha,beta);
00446   }
00447   else {
00448     M.applyTranspose(transToConj(M_trans),X,Y,alpha,beta);
00449   }
00450 }
00451 
00452 
00453 } // end namespace Thyra
00454 
00455 #endif  // THYRA_LINEAR_OP_DECL_HPP

Generated on Tue Oct 20 12:46:45 2009 for Fundamental Thyra ANA Operator/Vector Interfaces by doxygen 1.4.7