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_ExpandScalarTypeMacros.hpp"
00035 #include "Teuchos_PromotionTraits.hpp"
00036 
00037 
00038 namespace Thyra {
00039 
00040 
00235 template<class RangeScalar, class DomainScalar>
00236 class LinearOpBase : virtual public Teuchos::Describable {
00237 public:
00238 
00241 
00258   virtual RCP< const VectorSpaceBase<RangeScalar> > range() const = 0;
00259 
00276   virtual RCP< const VectorSpaceBase<DomainScalar> > domain() const = 0;
00277 
00316   virtual void apply(
00317     const EConj conj,
00318     const MultiVectorBase<DomainScalar> &X,
00319     MultiVectorBase<RangeScalar> *Y,
00320     const RangeScalar alpha = static_cast<RangeScalar>(1.0),
00321     const RangeScalar beta = static_cast<RangeScalar>(0.0)
00322     ) const = 0;
00323 
00325 
00328 
00338   virtual bool applySupports( const EConj conj ) const;
00339 
00349   virtual bool applyTransposeSupports( const EConj conj ) const;
00350 
00395   virtual void applyTranspose(
00396     const EConj conj,
00397     const MultiVectorBase<RangeScalar> &X,
00398     MultiVectorBase<DomainScalar> *Y,
00399     const DomainScalar alpha = static_cast<DomainScalar>(1.0),
00400     const DomainScalar beta = static_cast<DomainScalar>(0.0)
00401     ) const;
00402 
00415   virtual RCP<const LinearOpBase<RangeScalar,DomainScalar> > clone() const;
00416 
00418 
00419 };  // end class LinearOpBase
00420 
00421 
00427 template<class Scalar>
00428 bool isFullyUninitialized( const LinearOpBase<Scalar> &M );
00429 
00430 
00436 template<class Scalar>
00437 bool isPartiallyInitialized( const LinearOpBase<Scalar> &M );
00438 
00439 
00445 template<class Scalar>
00446 bool isFullyInitialized( const LinearOpBase<Scalar> &M );
00447 
00448 
00453 template<class Scalar>
00454 inline
00455 bool opSupported( const LinearOpBase<Scalar> &M, EOpTransp M_trans );
00456 
00457 
00464 template<class RangeScalar, class DomainScalar>
00465 inline
00466 void apply(
00467   const LinearOpBase<RangeScalar,DomainScalar> &M,
00468   const EConj conj,
00469   const MultiVectorBase<DomainScalar> &X,
00470   MultiVectorBase<RangeScalar> *Y,
00471   const RangeScalar alpha = static_cast<RangeScalar>(1.0),
00472   const RangeScalar beta = static_cast<RangeScalar>(0.0)
00473   );
00474 
00475 
00483 template<class RangeScalar, class DomainScalar>
00484 inline
00485 void applyTranspose(
00486   const LinearOpBase<RangeScalar,DomainScalar> &M,
00487   const EConj conj,
00488   const MultiVectorBase<RangeScalar> &X,
00489   MultiVectorBase<DomainScalar> *Y,
00490   const DomainScalar alpha = static_cast<DomainScalar>(1.0),
00491   const DomainScalar beta = static_cast<DomainScalar>(0.0)
00492   );
00493 
00494 
00504 template<class Scalar>
00505 void apply(
00506   const LinearOpBase<Scalar> &M,
00507   const EOpTransp M_trans,
00508   const MultiVectorBase<Scalar> &X,
00509   const Ptr<MultiVectorBase<Scalar> > &Y,
00510   const Scalar alpha = static_cast<Scalar>(1.0),
00511   const Scalar beta = static_cast<Scalar>(0.0)
00512   );
00513 
00514 
00521 void apply(
00522   const LinearOpBase<double> &M,
00523   const EOpTransp M_trans,
00524   const MultiVectorBase<double> &X,
00525   const Ptr<MultiVectorBase<double> > &Y,
00526   const double alpha = 1.0,
00527   const double beta = 0.0
00528   );
00529 
00530 
00532 template<class Scalar>
00533 void apply(
00534   const LinearOpBase<Scalar> &M,
00535   const EOpTransp M_trans,
00536   const MultiVectorBase<Scalar> &X,
00537   MultiVectorBase<Scalar> *Y,
00538   const Scalar alpha = static_cast<Scalar>(1.0),
00539   const Scalar beta = static_cast<Scalar>(0.0)
00540   );
00541 
00542 
00543 } // end namespace Thyra
00544 
00545 
00546 //
00547 // Inline and other Template Implementations
00548 //
00549 
00550 
00551 template<class Scalar>
00552 inline
00553 bool Thyra::isFullyUninitialized( const LinearOpBase<Scalar> &M )
00554 {
00555   return ( is_null(M.range()) || is_null(M.domain()) );
00556 }
00557 
00558 
00559 template<class Scalar>
00560 bool Thyra::isPartiallyInitialized( const LinearOpBase<Scalar> &M )
00561 {
00562   return
00563     (
00564       ( !is_null(M.range()) && !is_null(M.domain()) )
00565       && 
00566       (
00567         !opSupported(M,NOTRANS) && !opSupported(M,CONJ)
00568         && !opSupported(M,TRANS) && !opSupported(M,CONJTRANS)
00569         )
00570       );
00571 }
00572 
00573 
00574 template<class Scalar>
00575 bool Thyra::isFullyInitialized( const LinearOpBase<Scalar> &M )
00576 {
00577   return
00578     (
00579       ( !is_null(M.range()) && !is_null(M.domain()) )
00580       && 
00581       (
00582         opSupported(M,NOTRANS) || opSupported(M,CONJ)
00583         || opSupported(M,TRANS) || opSupported(M,CONJTRANS)
00584         )
00585       );
00586 }
00587 
00588 
00589 template<class Scalar>
00590 inline
00591 bool Thyra::opSupported( const LinearOpBase<Scalar> &M, EOpTransp M_trans )
00592 {
00593   if(real_trans(M_trans)==NOTRANS)
00594     return M.applySupports(transToConj(M_trans));
00595   return M.applyTransposeSupports(transToConj(M_trans));
00596 }
00597 
00598 
00599 template<class RangeScalar, class DomainScalar>
00600 inline
00601 void Thyra::apply(
00602   const LinearOpBase<RangeScalar,DomainScalar> &M,
00603   const EConj conj,
00604   const MultiVectorBase<DomainScalar> &X,
00605   MultiVectorBase<RangeScalar> *Y,
00606   const RangeScalar alpha,
00607   const RangeScalar beta
00608   )
00609 {
00610   M.apply(conj,X,Y,alpha,beta);
00611 }
00612 
00613 
00614 template<class RangeScalar, class DomainScalar>
00615 inline
00616 void Thyra::applyTranspose(
00617   const LinearOpBase<RangeScalar,DomainScalar> &M,
00618   const EConj conj,
00619   const MultiVectorBase<RangeScalar> &X,
00620   MultiVectorBase<DomainScalar> *Y,
00621   const DomainScalar alpha,
00622   const DomainScalar beta
00623   )
00624 {
00625   M.applyTranspose(conj,X,Y,alpha,beta);
00626 }
00627 
00628 
00629 inline
00630 void Thyra::apply(
00631   const LinearOpBase<double> &M,
00632   const EOpTransp M_trans,
00633   const MultiVectorBase<double> &X,
00634   const Ptr<MultiVectorBase<double> > &Y,
00635   const double alpha,
00636   const double beta
00637   )
00638 {
00639   apply<double>(M, M_trans, X, Y, alpha, beta);
00640 }
00641 
00642 
00643 template<class Scalar>
00644 inline
00645 void Thyra::apply(
00646   const LinearOpBase<Scalar> &M,
00647   const EOpTransp M_trans,
00648   const MultiVectorBase<Scalar> &X,
00649   MultiVectorBase<Scalar> *Y,
00650   const Scalar alpha,
00651   const Scalar beta
00652   )
00653 {
00654   apply(M, M_trans, X, Teuchos::ptr(Y), alpha, beta);
00655 }
00656 
00657 
00658 #endif  // THYRA_LINEAR_OP_DECL_HPP

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