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 Teuchos::RefCountPtr< const VectorSpaceBase<RangeScalar> > range() const = 0;
00225 
00242   virtual Teuchos::RefCountPtr< 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 Teuchos::RefCountPtr<const LinearOpBase<RangeScalar,DomainScalar> > clone() const;
00368 
00370 
00371 };  // end class LinearOpBase
00372 
00382 
00386 template<class Scalar>
00387 inline bool opSupported( const LinearOpBase<Scalar> &M, ETransp M_trans )
00388 {
00389   if(real_trans(M_trans)==NOTRANS)
00390     return M.applySupports(transToConj(M_trans));
00391   return M.applyTransposeSupports(transToConj(M_trans));
00392 }
00393 
00399 template<class RangeScalar, class DomainScalar>
00400 inline void apply(
00401   const LinearOpBase<RangeScalar,DomainScalar>     &M
00402   ,const EConj                                     conj
00403   ,const MultiVectorBase<DomainScalar>             &X
00404   ,MultiVectorBase<RangeScalar>                    *Y
00405   ,const RangeScalar                               alpha
00406 #ifndef __sun
00407                                                          = Teuchos::ScalarTraits<RangeScalar>::one()
00408 #endif
00409   ,const RangeScalar                               beta
00410 #ifndef __sun
00411                                                          = Teuchos::ScalarTraits<RangeScalar>::zero()
00412 #endif
00413   )
00414 {
00415   M.apply(conj,X,Y,alpha,beta);
00416 }
00417 
00418 #ifdef __sun
00419 
00420 template<class RangeScalar, class DomainScalar>
00421 inline void apply(
00422   const LinearOpBase<RangeScalar,DomainScalar>     &M
00423   ,const EConj                                     conj
00424   ,const MultiVectorBase<DomainScalar>             &X
00425   ,MultiVectorBase<RangeScalar>                    *Y
00426   ,const RangeScalar                               alpha
00427   )
00428 {
00429   typedef Teuchos::ScalarTraits<RangeScalar> ST;
00430   apply(M,conj,X,Y,alpha,ST::zero());
00431 }
00432 
00433 template<class RangeScalar, class DomainScalar>
00434 inline void apply(
00435   const LinearOpBase<RangeScalar,DomainScalar>     &M
00436   ,const EConj                                     conj
00437   ,const MultiVectorBase<DomainScalar>             &X
00438   ,MultiVectorBase<RangeScalar>                    *Y
00439   )
00440 {
00441   typedef Teuchos::ScalarTraits<RangeScalar> ST;
00442   apply(M,conj,X,Y,ST::one(),ST::zero());
00443 }
00444 
00445 #endif // __sun
00446 
00452 template<class RangeScalar, class DomainScalar>
00453 inline void applyTranspose(
00454   const LinearOpBase<RangeScalar,DomainScalar>      &M
00455   ,const EConj                                      conj
00456   ,const MultiVectorBase<RangeScalar>               &X
00457   ,MultiVectorBase<DomainScalar>                    *Y
00458   ,const DomainScalar                               alpha
00459 #ifndef __sun
00460                                                           = Teuchos::ScalarTraits<DomainScalar>::one()
00461 #endif
00462   ,const DomainScalar                               beta
00463 #ifndef __sun
00464                                                           = Teuchos::ScalarTraits<DomainScalar>::zero()
00465 #endif
00466   )
00467 {
00468   M.applyTranspose(conj,X,Y,alpha,beta);
00469 }
00470 
00471 #ifdef __sun
00472 
00473 template<class RangeScalar, class DomainScalar>
00474 inline void applyTranspose(
00475   const LinearOpBase<RangeScalar,DomainScalar>      &M
00476   ,const EConj                                      conj
00477   ,const MultiVectorBase<RangeScalar>               &X
00478   ,MultiVectorBase<DomainScalar>                    *Y
00479   ,const DomainScalar                               alpha
00480   )
00481 {
00482   typedef Teuchos::ScalarTraits<DomainScalar> ST;
00483   applyTranspose(M,conj,X,Y,alpha,ST::zero());
00484 }
00485 
00486 template<class RangeScalar, class DomainScalar>
00487 inline void applyTranspose(
00488   const LinearOpBase<RangeScalar,DomainScalar>      &M
00489   ,const EConj                                      conj
00490   ,const MultiVectorBase<RangeScalar>               &X
00491   ,MultiVectorBase<DomainScalar>                    *Y
00492   )
00493 {
00494   typedef Teuchos::ScalarTraits<DomainScalar> ST;
00495   applyTranspose(M,conj,X,Y,ST::one(),ST::zero());
00496 }
00497 
00498 #endif
00499 
00508 template<class Scalar>
00509 inline void apply(
00510   const LinearOpBase<Scalar>        &M
00511   ,const ETransp                    M_trans
00512   ,const MultiVectorBase<Scalar>    &X
00513   ,MultiVectorBase<Scalar>          *Y
00514   ,const Scalar                     alpha
00515 #ifndef __sun
00516                                           = Teuchos::ScalarTraits<Scalar>::one()
00517 #endif
00518   ,const Scalar                     beta
00519 #ifndef __sun
00520                                           = Teuchos::ScalarTraits<Scalar>::zero()
00521 #endif
00522   )
00523 {
00524   if(real_trans(M_trans)==NOTRANS) {
00525     M.apply(transToConj(M_trans),X,Y,alpha,beta);
00526   }
00527   else {
00528     M.applyTranspose(transToConj(M_trans),X,Y,alpha,beta);
00529   }
00530 }
00531 
00532 #ifdef __sun
00533 
00534 template<class Scalar>
00535 inline void apply(
00536   const LinearOpBase<Scalar>        &M
00537   ,const ETransp                    M_trans
00538   ,const MultiVectorBase<Scalar>    &X
00539   ,MultiVectorBase<Scalar>          *Y
00540   ,const Scalar                     alpha
00541   )
00542 {
00543   apply(M,M_trans,X,Y,alpha,Teuchos::ScalarTraits<Scalar>::zero());
00544 }
00545 
00546 template<class Scalar>
00547 inline void apply(
00548   const LinearOpBase<Scalar>        &M
00549   ,const ETransp                    M_trans
00550   ,const MultiVectorBase<Scalar>    &X
00551   ,MultiVectorBase<Scalar>          *Y
00552   )
00553 {
00554   apply(M,M_trans,X,Y,Teuchos::ScalarTraits<Scalar>::one());
00555 }
00556 
00557 #endif
00558 
00560 
00561 } // end namespace Thyra
00562 
00563 #endif  // THYRA_LINEAR_OP_DECL_HPP

Generated on Thu Sep 18 12:32:11 2008 for Fundamental Thyra ANA Operator/Vector Interfaces by doxygen 1.3.9.1