Thyra Version of the Day
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 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov) 
00038 // 
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 #ifndef THYRA_LINEAR_OP_DECL_HPP
00043 #define THYRA_LINEAR_OP_DECL_HPP
00044 
00045 #include "Thyra_OperatorVectorTypes.hpp"
00046 #include "Teuchos_Describable.hpp"
00047 #include "Teuchos_ExpandScalarTypeMacros.hpp"
00048 #include "Teuchos_PromotionTraits.hpp"
00049 
00050 
00051 namespace Thyra {
00052 
00053 
00190 template<class Scalar>
00191 class LinearOpBase : virtual public Teuchos::Describable {
00192 public:
00193 
00196 
00212   virtual RCP< const VectorSpaceBase<Scalar> > range() const = 0;
00213 
00229   virtual RCP< const VectorSpaceBase<Scalar> > domain() const = 0;
00230 
00242   bool opSupported(EOpTransp M_trans) const
00243     {
00244       return opSupportedImpl(M_trans);
00245     }
00246 
00292   void apply(
00293     const EOpTransp M_trans,
00294     const MultiVectorBase<Scalar> &X,
00295     const Ptr<MultiVectorBase<Scalar> > &Y,
00296     const Scalar alpha,
00297     const Scalar beta
00298     ) const
00299     {
00300       applyImpl(M_trans, X, Y, alpha, beta);
00301     }
00302 
00315   virtual RCP<const LinearOpBase<Scalar> > clone() const;
00316 
00318 
00321 
00323   THYRA_DEPRECATED bool applySupports( const EConj conj ) const;
00324 
00326   THYRA_DEPRECATED void apply(
00327     const EConj conj,
00328     const MultiVectorBase<Scalar> &X,
00329     MultiVectorBase<Scalar> *Y,
00330     const Scalar alpha = static_cast<Scalar>(1.0),
00331     const Scalar beta = static_cast<Scalar>(0.0)
00332     ) const;
00333 
00335   THYRA_DEPRECATED bool applyTransposeSupports( const EConj conj ) const;
00336 
00338   THYRA_DEPRECATED void applyTranspose(
00339     const EConj conj,
00340     const MultiVectorBase<Scalar> &X,
00341     MultiVectorBase<Scalar> *Y,
00342     const Scalar alpha = static_cast<Scalar>(1.0),
00343     const Scalar beta = static_cast<Scalar>(0.0)
00344     ) const;
00345 
00347 
00348 protected:
00349 
00352 
00354   virtual bool opSupportedImpl(EOpTransp M_trans) const = 0;
00355 
00357   virtual void applyImpl(
00358     const EOpTransp M_trans,
00359     const MultiVectorBase<Scalar> &X,
00360     const Ptr<MultiVectorBase<Scalar> > &Y,
00361     const Scalar alpha,
00362     const Scalar beta
00363     ) const = 0;
00364 
00366 
00367 private:
00368   
00369   // Not defined and not to be called
00370   LinearOpBase<Scalar>&
00371   operator=(const LinearOpBase<Scalar>&);
00372 
00373 };
00374 
00375 
00381 template<class Scalar>
00382 bool isFullyUninitialized( const LinearOpBase<Scalar> &M );
00383 
00384 
00390 template<class Scalar>
00391 bool isPartiallyInitialized( const LinearOpBase<Scalar> &M );
00392 
00393 
00399 template<class Scalar>
00400 bool isFullyInitialized( const LinearOpBase<Scalar> &M );
00401 
00402 
00407 template<class Scalar>
00408 inline
00409 bool opSupported( const LinearOpBase<Scalar> &M, EOpTransp M_trans );
00410 
00411 
00416 template<class Scalar>
00417 void apply(
00418   const LinearOpBase<Scalar> &M,
00419   const EOpTransp M_trans,
00420   const MultiVectorBase<Scalar> &X,
00421   const Ptr<MultiVectorBase<Scalar> > &Y,
00422   const Scalar alpha = static_cast<Scalar>(1.0),
00423   const Scalar beta = static_cast<Scalar>(0.0)
00424   );
00425 
00426 
00433 inline
00434 void apply(
00435   const LinearOpBase<double> &M,
00436   const EOpTransp M_trans,
00437   const MultiVectorBase<double> &X,
00438   const Ptr<MultiVectorBase<double> > &Y,
00439   const double alpha = 1.0,
00440   const double beta = 0.0
00441   );
00442 
00443 
00444 // Deprecated
00445 
00446 
00448 template<class Scalar>
00449 inline
00450 THYRA_DEPRECATED void apply(
00451   const LinearOpBase<Scalar> &M,
00452   const EConj conj,
00453   const MultiVectorBase<Scalar> &X,
00454   MultiVectorBase<Scalar> *Y,
00455   const Scalar alpha = static_cast<Scalar>(1.0),
00456   const Scalar beta = static_cast<Scalar>(0.0)
00457   );
00458 
00459 
00461 template<class Scalar>
00462 inline
00463 THYRA_DEPRECATED void applyTranspose(
00464   const LinearOpBase<Scalar> &M,
00465   const EConj conj,
00466   const MultiVectorBase<Scalar> &X,
00467   MultiVectorBase<Scalar> *Y,
00468   const Scalar alpha = static_cast<Scalar>(1.0),
00469   const Scalar beta = static_cast<Scalar>(0.0)
00470   );
00471 
00472 
00474 template<class Scalar>
00475 THYRA_DEPRECATED void apply(
00476   const LinearOpBase<Scalar> &M,
00477   const EOpTransp M_trans,
00478   const MultiVectorBase<Scalar> &X,
00479   MultiVectorBase<Scalar> *Y,
00480   const Scalar alpha = static_cast<Scalar>(1.0),
00481   const Scalar beta = static_cast<Scalar>(0.0)
00482   );
00483 
00484 
00485 } // end namespace Thyra
00486 
00487 
00488 //
00489 // Inline and other Template Implementations
00490 //
00491 
00492 
00493 template<class Scalar>
00494 inline
00495 bool Thyra::isFullyUninitialized( const LinearOpBase<Scalar> &M )
00496 {
00497   return ( is_null(M.range()) || is_null(M.domain()) );
00498 }
00499 
00500 
00501 template<class Scalar>
00502 bool Thyra::isPartiallyInitialized( const LinearOpBase<Scalar> &M )
00503 {
00504   return
00505     (
00506       ( !is_null(M.range()) && !is_null(M.domain()) )
00507       && 
00508       (
00509         !opSupported(M,NOTRANS) && !opSupported(M,CONJ)
00510         && !opSupported(M,TRANS) && !opSupported(M,CONJTRANS)
00511         )
00512       );
00513 }
00514 
00515 
00516 template<class Scalar>
00517 bool Thyra::isFullyInitialized( const LinearOpBase<Scalar> &M )
00518 {
00519   return
00520     (
00521       ( !is_null(M.range()) && !is_null(M.domain()) )
00522       && 
00523       (
00524         opSupported(M,NOTRANS) || opSupported(M,CONJ)
00525         || opSupported(M,TRANS) || opSupported(M,CONJTRANS)
00526         )
00527       );
00528 }
00529 
00530 
00531 template<class Scalar>
00532 inline
00533 bool Thyra::opSupported( const LinearOpBase<Scalar> &M, EOpTransp M_trans )
00534 {
00535   return M.opSupported(M_trans);
00536 }
00537 
00538 
00539 inline
00540 void Thyra::apply(
00541   const LinearOpBase<double> &M,
00542   const EOpTransp M_trans,
00543   const MultiVectorBase<double> &X,
00544   const Ptr<MultiVectorBase<double> > &Y,
00545   const double alpha,
00546   const double beta
00547   )
00548 {
00549   apply<double>(M, M_trans, X, Y, alpha, beta);
00550 }
00551 
00552 
00553 // Deprecated
00554 
00555 
00556 template<class Scalar>
00557 inline
00558 void Thyra::apply(
00559   const LinearOpBase<Scalar> &M,
00560   const EConj conj,
00561   const MultiVectorBase<Scalar> &X,
00562   MultiVectorBase<Scalar> *Y,
00563   const Scalar alpha,
00564   const Scalar beta
00565   )
00566 {
00567   M.apply(conj, X, Y, alpha, beta);
00568 }
00569 
00570 
00571 template<class Scalar>
00572 inline
00573 void Thyra::applyTranspose(
00574   const LinearOpBase<Scalar> &M,
00575   const EConj conj,
00576   const MultiVectorBase<Scalar> &X,
00577   MultiVectorBase<Scalar> *Y,
00578   const Scalar alpha,
00579   const Scalar beta
00580   )
00581 {
00582   M.applyTranspose(conj, X, Y, alpha, beta);
00583 }
00584 
00585 
00586 template<class Scalar>
00587 inline
00588 void Thyra::apply(
00589   const LinearOpBase<Scalar> &M,
00590   const EOpTransp M_trans,
00591   const MultiVectorBase<Scalar> &X,
00592   MultiVectorBase<Scalar> *Y,
00593   const Scalar alpha,
00594   const Scalar beta
00595   )
00596 {
00597   apply(M, M_trans, X, Teuchos::ptr(Y), alpha, beta);
00598 }
00599 
00600 
00601 #endif  // THYRA_LINEAR_OP_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines