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 
00037 namespace Thyra {
00038 
00039 
00234 template<class RangeScalar, class DomainScalar>
00235 class LinearOpBase : virtual public Teuchos::Describable {
00236 public:
00237 
00240 
00257   virtual RCP< const VectorSpaceBase<RangeScalar> > range() const = 0;
00258 
00275   virtual RCP< const VectorSpaceBase<DomainScalar> > domain() const = 0;
00276 
00315   virtual void apply(
00316     const EConj conj,
00317     const MultiVectorBase<DomainScalar> &X,
00318     MultiVectorBase<RangeScalar> *Y,
00319     const RangeScalar alpha = Teuchos::ScalarTraits<RangeScalar>::one(),
00320     const RangeScalar beta = Teuchos::ScalarTraits<RangeScalar>::zero()
00321     ) const = 0;
00322 
00324 
00327 
00337   virtual bool applySupports( const EConj conj ) const;
00338 
00348   virtual bool applyTransposeSupports( const EConj conj ) const;
00349 
00394   virtual void applyTranspose(
00395     const EConj conj,
00396     const MultiVectorBase<RangeScalar> &X,
00397     MultiVectorBase<DomainScalar> *Y,
00398     const DomainScalar alpha = Teuchos::ScalarTraits<DomainScalar>::one(),
00399     const DomainScalar beta = Teuchos::ScalarTraits<DomainScalar>::zero()
00400     ) const;
00401 
00414   virtual RCP<const LinearOpBase<RangeScalar,DomainScalar> > clone() const;
00415 
00417 
00418 };  // end class LinearOpBase
00419 
00420 
00426 template<class Scalar>
00427 bool isFullyUninitialized( const LinearOpBase<Scalar> &M );
00428 
00429 
00435 template<class Scalar>
00436 bool isPartiallyInitialized( const LinearOpBase<Scalar> &M );
00437 
00438 
00444 template<class Scalar>
00445 bool isFullyInitialized( const LinearOpBase<Scalar> &M );
00446 
00447 
00452 template<class Scalar>
00453 inline
00454 bool opSupported( const LinearOpBase<Scalar> &M, EOpTransp M_trans );
00455 
00456 
00463 template<class RangeScalar, class DomainScalar>
00464 inline
00465 void apply(
00466   const LinearOpBase<RangeScalar,DomainScalar> &M,
00467   const EConj conj,
00468   const MultiVectorBase<DomainScalar> &X,
00469   MultiVectorBase<RangeScalar> *Y,
00470   const RangeScalar alpha = ScalarTraits<RangeScalar>::one(),
00471   const RangeScalar beta = ScalarTraits<RangeScalar>::zero()
00472   );
00473 
00474 
00482 template<class RangeScalar, class DomainScalar>
00483 inline
00484 void applyTranspose(
00485   const LinearOpBase<RangeScalar,DomainScalar> &M,
00486   const EConj conj,
00487   const MultiVectorBase<RangeScalar> &X,
00488   MultiVectorBase<DomainScalar> *Y,
00489   const DomainScalar alpha = ScalarTraits<DomainScalar>::one(),
00490   const DomainScalar beta = ScalarTraits<DomainScalar>::zero()
00491   );
00492 
00493 
00503 template<class Scalar>
00504 void apply(
00505   const LinearOpBase<Scalar> &M,
00506   const EOpTransp M_trans,
00507   const MultiVectorBase<Scalar> &X,
00508   const Ptr<MultiVectorBase<Scalar> > &Y,
00509   const Scalar alpha = ScalarTraits<Scalar>::one(),
00510   const Scalar beta = ScalarTraits<Scalar>::zero()
00511   );
00512 
00513 
00515 template<class Scalar>
00516 void apply(
00517   const LinearOpBase<Scalar> &M,
00518   const EOpTransp M_trans,
00519   const MultiVectorBase<Scalar> &X,
00520   MultiVectorBase<Scalar> *Y,
00521   const Scalar alpha = ScalarTraits<Scalar>::one(),
00522   const Scalar beta = ScalarTraits<Scalar>::zero()
00523   );
00524 
00525 
00526 } // end namespace Thyra
00527 
00528 
00529 //
00530 // Implementations
00531 //
00532 
00533 
00534 template<class Scalar>
00535 bool Thyra::isFullyUninitialized( const LinearOpBase<Scalar> &M )
00536 {
00537   return ( is_null(M.range()) || is_null(M.domain()) );
00538 }
00539 
00540 
00541 template<class Scalar>
00542 bool Thyra::isPartiallyInitialized( const LinearOpBase<Scalar> &M )
00543 {
00544   return
00545     (
00546       ( !is_null(M.range()) && !is_null(M.domain()) )
00547       && 
00548       (
00549         !opSupported(M,NOTRANS) && !opSupported(M,CONJ)
00550         && !opSupported(M,TRANS) && !opSupported(M,CONJTRANS)
00551         )
00552       );
00553 }
00554 
00555 
00556 template<class Scalar>
00557 bool Thyra::isFullyInitialized( const LinearOpBase<Scalar> &M )
00558 {
00559   return
00560     (
00561       ( !is_null(M.range()) && !is_null(M.domain()) )
00562       && 
00563       (
00564         opSupported(M,NOTRANS) || opSupported(M,CONJ)
00565         || opSupported(M,TRANS) || opSupported(M,CONJTRANS)
00566         )
00567       );
00568 }
00569 
00570 
00571 template<class Scalar>
00572 inline
00573 bool Thyra::opSupported( const LinearOpBase<Scalar> &M, EOpTransp M_trans )
00574 {
00575   if(real_trans(M_trans)==NOTRANS)
00576     return M.applySupports(transToConj(M_trans));
00577   return M.applyTransposeSupports(transToConj(M_trans));
00578 }
00579 
00580 
00581 template<class RangeScalar, class DomainScalar>
00582 inline
00583 void Thyra::apply(
00584   const LinearOpBase<RangeScalar,DomainScalar> &M,
00585   const EConj conj,
00586   const MultiVectorBase<DomainScalar> &X,
00587   MultiVectorBase<RangeScalar> *Y,
00588   const RangeScalar alpha,
00589   const RangeScalar beta
00590   )
00591 {
00592   M.apply(conj,X,Y,alpha,beta);
00593 }
00594 
00595 
00596 template<class RangeScalar, class DomainScalar>
00597 inline
00598 void Thyra::applyTranspose(
00599   const LinearOpBase<RangeScalar,DomainScalar> &M,
00600   const EConj conj,
00601   const MultiVectorBase<RangeScalar> &X,
00602   MultiVectorBase<DomainScalar> *Y,
00603   const DomainScalar alpha,
00604   const DomainScalar beta
00605   )
00606 {
00607   M.applyTranspose(conj,X,Y,alpha,beta);
00608 }
00609 
00610 
00611 template<class Scalar>
00612 void Thyra::apply(
00613   const LinearOpBase<Scalar> &M,
00614   const EOpTransp M_trans,
00615   const MultiVectorBase<Scalar> &X,
00616   const Ptr<MultiVectorBase<Scalar> > &Y,
00617   const Scalar alpha,
00618   const Scalar beta
00619   )
00620 {
00621   if(real_trans(M_trans)==NOTRANS) {
00622     M.apply(transToConj(M_trans),X,&*Y,alpha,beta);
00623   }
00624   else {
00625     M.applyTranspose(transToConj(M_trans),X,&*Y,alpha,beta);
00626   }
00627 }
00628 
00629 
00630 template<class Scalar>
00631 void Thyra::apply(
00632   const LinearOpBase<Scalar> &M,
00633   const EOpTransp M_trans,
00634   const MultiVectorBase<Scalar> &X,
00635   MultiVectorBase<Scalar> *Y,
00636   const Scalar alpha,
00637   const Scalar beta
00638   )
00639 {
00640   apply(M, M_trans, X, Teuchos::ptr(Y), alpha, beta);
00641 }
00642 
00643 
00644 
00645 #endif  // THYRA_LINEAR_OP_DECL_HPP

Generated on Wed May 12 21:42:09 2010 for Fundamental Thyra ANA Operator/Vector Interfaces by  doxygen 1.4.7