Thyra_LinearOpBase_decl.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 
00204 template<class Scalar>
00205 class LinearOpBase : virtual public Teuchos::Describable {
00206 public:
00207 
00210 
00227   virtual RCP< const VectorSpaceBase<Scalar> > range() const = 0;
00228 
00245   virtual RCP< const VectorSpaceBase<Scalar> > domain() const = 0;
00246 
00258   bool opSupported(EOpTransp M_trans) const
00259     {
00260       return opSupportedImpl(M_trans);
00261     }
00262 
00308   void apply(
00309     const EOpTransp M_trans,
00310     const MultiVectorBase<Scalar> &X,
00311     const Ptr<MultiVectorBase<Scalar> > &Y,
00312     const Scalar alpha,
00313     const Scalar beta
00314     ) const
00315     {
00316       applyImpl(M_trans, X, Y, alpha, beta);
00317     }
00318 
00331   virtual RCP<const LinearOpBase<Scalar> > clone() const;
00332 
00334 
00337 
00339   THYRA_DEPRECATED bool applySupports( const EConj conj ) const;
00340 
00342   THYRA_DEPRECATED void apply(
00343     const EConj conj,
00344     const MultiVectorBase<Scalar> &X,
00345     MultiVectorBase<Scalar> *Y,
00346     const Scalar alpha = static_cast<Scalar>(1.0),
00347     const Scalar beta = static_cast<Scalar>(0.0)
00348     ) const;
00349 
00351   THYRA_DEPRECATED bool applyTransposeSupports( const EConj conj ) const;
00352 
00354   THYRA_DEPRECATED void applyTranspose(
00355     const EConj conj,
00356     const MultiVectorBase<Scalar> &X,
00357     MultiVectorBase<Scalar> *Y,
00358     const Scalar alpha = static_cast<Scalar>(1.0),
00359     const Scalar beta = static_cast<Scalar>(0.0)
00360     ) const;
00361 
00363 
00364 protected:
00365 
00368 
00370   virtual bool opSupportedImpl(EOpTransp M_trans) const = 0;
00371 
00373   virtual void applyImpl(
00374     const EOpTransp M_trans,
00375     const MultiVectorBase<Scalar> &X,
00376     const Ptr<MultiVectorBase<Scalar> > &Y,
00377     const Scalar alpha,
00378     const Scalar beta
00379     ) const = 0;
00380 
00382 
00383 };
00384 
00385 
00391 template<class Scalar>
00392 bool isFullyUninitialized( const LinearOpBase<Scalar> &M );
00393 
00394 
00400 template<class Scalar>
00401 bool isPartiallyInitialized( const LinearOpBase<Scalar> &M );
00402 
00403 
00409 template<class Scalar>
00410 bool isFullyInitialized( const LinearOpBase<Scalar> &M );
00411 
00412 
00417 template<class Scalar>
00418 inline
00419 bool opSupported( const LinearOpBase<Scalar> &M, EOpTransp M_trans );
00420 
00421 
00426 template<class Scalar>
00427 void apply(
00428   const LinearOpBase<Scalar> &M,
00429   const EOpTransp M_trans,
00430   const MultiVectorBase<Scalar> &X,
00431   const Ptr<MultiVectorBase<Scalar> > &Y,
00432   const Scalar alpha = static_cast<Scalar>(1.0),
00433   const Scalar beta = static_cast<Scalar>(0.0)
00434   );
00435 
00436 
00443 inline
00444 void apply(
00445   const LinearOpBase<double> &M,
00446   const EOpTransp M_trans,
00447   const MultiVectorBase<double> &X,
00448   const Ptr<MultiVectorBase<double> > &Y,
00449   const double alpha = 1.0,
00450   const double beta = 0.0
00451   );
00452 
00453 
00454 // Deprecated
00455 
00456 
00458 template<class Scalar>
00459 inline
00460 THYRA_DEPRECATED void apply(
00461   const LinearOpBase<Scalar> &M,
00462   const EConj conj,
00463   const MultiVectorBase<Scalar> &X,
00464   MultiVectorBase<Scalar> *Y,
00465   const Scalar alpha = static_cast<Scalar>(1.0),
00466   const Scalar beta = static_cast<Scalar>(0.0)
00467   );
00468 
00469 
00471 template<class Scalar>
00472 inline
00473 THYRA_DEPRECATED void applyTranspose(
00474   const LinearOpBase<Scalar> &M,
00475   const EConj conj,
00476   const MultiVectorBase<Scalar> &X,
00477   MultiVectorBase<Scalar> *Y,
00478   const Scalar alpha = static_cast<Scalar>(1.0),
00479   const Scalar beta = static_cast<Scalar>(0.0)
00480   );
00481 
00482 
00484 template<class Scalar>
00485 THYRA_DEPRECATED void apply(
00486   const LinearOpBase<Scalar> &M,
00487   const EOpTransp M_trans,
00488   const MultiVectorBase<Scalar> &X,
00489   MultiVectorBase<Scalar> *Y,
00490   const Scalar alpha = static_cast<Scalar>(1.0),
00491   const Scalar beta = static_cast<Scalar>(0.0)
00492   );
00493 
00494 
00495 } // end namespace Thyra
00496 
00497 
00498 //
00499 // Inline and other Template Implementations
00500 //
00501 
00502 
00503 template<class Scalar>
00504 inline
00505 bool Thyra::isFullyUninitialized( const LinearOpBase<Scalar> &M )
00506 {
00507   return ( is_null(M.range()) || is_null(M.domain()) );
00508 }
00509 
00510 
00511 template<class Scalar>
00512 bool Thyra::isPartiallyInitialized( const LinearOpBase<Scalar> &M )
00513 {
00514   return
00515     (
00516       ( !is_null(M.range()) && !is_null(M.domain()) )
00517       && 
00518       (
00519         !opSupported(M,NOTRANS) && !opSupported(M,CONJ)
00520         && !opSupported(M,TRANS) && !opSupported(M,CONJTRANS)
00521         )
00522       );
00523 }
00524 
00525 
00526 template<class Scalar>
00527 bool Thyra::isFullyInitialized( const LinearOpBase<Scalar> &M )
00528 {
00529   return
00530     (
00531       ( !is_null(M.range()) && !is_null(M.domain()) )
00532       && 
00533       (
00534         opSupported(M,NOTRANS) || opSupported(M,CONJ)
00535         || opSupported(M,TRANS) || opSupported(M,CONJTRANS)
00536         )
00537       );
00538 }
00539 
00540 
00541 template<class Scalar>
00542 inline
00543 bool Thyra::opSupported( const LinearOpBase<Scalar> &M, EOpTransp M_trans )
00544 {
00545   return M.opSupported(M_trans);
00546 }
00547 
00548 
00549 inline
00550 void Thyra::apply(
00551   const LinearOpBase<double> &M,
00552   const EOpTransp M_trans,
00553   const MultiVectorBase<double> &X,
00554   const Ptr<MultiVectorBase<double> > &Y,
00555   const double alpha,
00556   const double beta
00557   )
00558 {
00559   apply<double>(M, M_trans, X, Y, alpha, beta);
00560 }
00561 
00562 
00563 // Deprecated
00564 
00565 
00566 template<class Scalar>
00567 inline
00568 void Thyra::apply(
00569   const LinearOpBase<Scalar> &M,
00570   const EConj conj,
00571   const MultiVectorBase<Scalar> &X,
00572   MultiVectorBase<Scalar> *Y,
00573   const Scalar alpha,
00574   const Scalar beta
00575   )
00576 {
00577   M.apply(conj, X, Y, alpha, beta);
00578 }
00579 
00580 
00581 template<class Scalar>
00582 inline
00583 void Thyra::applyTranspose(
00584   const LinearOpBase<Scalar> &M,
00585   const EConj conj,
00586   const MultiVectorBase<Scalar> &X,
00587   MultiVectorBase<Scalar> *Y,
00588   const Scalar alpha,
00589   const Scalar beta
00590   )
00591 {
00592   M.applyTranspose(conj, X, Y, alpha, beta);
00593 }
00594 
00595 
00596 template<class Scalar>
00597 inline
00598 void Thyra::apply(
00599   const LinearOpBase<Scalar> &M,
00600   const EOpTransp M_trans,
00601   const MultiVectorBase<Scalar> &X,
00602   MultiVectorBase<Scalar> *Y,
00603   const Scalar alpha,
00604   const Scalar beta
00605   )
00606 {
00607   apply(M, M_trans, X, Teuchos::ptr(Y), alpha, beta);
00608 }
00609 
00610 
00611 #endif  // THYRA_LINEAR_OP_DECL_HPP

Generated on Wed Feb 10 16:27:51 2010 for Fundamental Thyra ANA Operator/Vector Interfaces by  doxygen 1.4.7