Thyra_DefaultIdentityLinearOp.hpp

Go to the documentation of this file.
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_DEFAULT_IDENTITY_LINEAR_OP_HPP
00030 #define THYRA_DEFAULT_IDENTITY_LINEAR_OP_HPP
00031 
00032 #include "Thyra_DefaultIdentityLinearOpDecl.hpp"
00033 #include "Thyra_MultiVectorStdOps.hpp"
00034 #include "Teuchos_arrayArg.hpp"
00035 
00036 namespace Thyra {
00037 
00038 // Constructors/initializers/accessors
00039 
00040 template<class Scalar>
00041 DefaultIdentityLinearOp<Scalar>::DefaultIdentityLinearOp()
00042 {}
00043 
00044 template<class Scalar>
00045 DefaultIdentityLinearOp<Scalar>::DefaultIdentityLinearOp(
00046   const Teuchos::RCP<const VectorSpaceBase<Scalar> >   &space
00047   )
00048 {
00049   initialize(space);
00050 }
00051 
00052 template<class Scalar>
00053 void DefaultIdentityLinearOp<Scalar>::initialize(
00054   const Teuchos::RCP<const VectorSpaceBase<Scalar> >   &space
00055   )
00056 {
00057   space_ = space.assert_not_null();
00058 }
00059 
00060 template<class Scalar>
00061 void DefaultIdentityLinearOp<Scalar>::uninitialize()
00062 {
00063   space_ = Teuchos::null;
00064 }
00065 
00066 // Overridden from LinearOpBase
00067   
00068 template<class Scalar>
00069 Teuchos::RCP< const VectorSpaceBase<Scalar> >
00070 DefaultIdentityLinearOp<Scalar>::range() const
00071 {
00072   return space_;
00073 }
00074 
00075 template<class Scalar>
00076 Teuchos::RCP< const VectorSpaceBase<Scalar> >
00077 DefaultIdentityLinearOp<Scalar>::domain() const
00078 {
00079   return space_;
00080 }
00081   
00082 template<class Scalar>
00083 Teuchos::RCP<const LinearOpBase<Scalar> >
00084 DefaultIdentityLinearOp<Scalar>::clone() const
00085 {
00086   typedef DefaultIdentityLinearOp<Scalar> this_t;
00087   if(space_.get())
00088     return Teuchos::rcp(new this_t(space_));
00089   return Teuchos::rcp(new this_t());
00090 }
00091   
00092 // Overridden from Teuchos::Describable
00093 
00094 template<class Scalar>
00095 std::string DefaultIdentityLinearOp<Scalar>::description() const
00096 {
00097   typedef Teuchos::ScalarTraits<Scalar>  ST;
00098   std::ostringstream oss;
00099   oss
00100     << "Thyra::DefaultIdentityLinearOp<" << ST::name() << ">{"
00101     << "space="<<(space_.get()?space_->description():"NULL")
00102     << "}";
00103   return oss.str();
00104 }
00105 
00106 // protected
00107 
00108 // Overridden from SingleScalarLinearOpBase
00109 
00110 template<class Scalar>
00111 bool DefaultIdentityLinearOp<Scalar>::opSupported(ETransp M_trans) const
00112 {
00113   return true;
00114 }
00115 
00116 template<class Scalar>
00117 void DefaultIdentityLinearOp<Scalar>::apply(
00118   const ETransp                     M_trans
00119   ,const MultiVectorBase<Scalar>    &X
00120   ,MultiVectorBase<Scalar>          *Y
00121   ,const Scalar                     alpha
00122   ,const Scalar                     beta
00123   ) const
00124 {
00125   using Teuchos::arrayArg;
00126 #ifdef TEUCHOS_DEBUG
00127   THYRA_ASSERT_LINEAR_OP_MULTIVEC_APPLY_SPACES(
00128     "DefaultIdentityLinearOp<Scalar>::apply(...)",*this,M_trans,X,Y
00129     );
00130 #endif // TEUCHOS_DEBUG  
00131   Thyra::linear_combination<Scalar>(
00132     1,arrayArg<Scalar>(alpha),arrayArg<const MultiVectorBase<Scalar>*>(&X)()
00133     ,beta,Y
00134     );
00135 }
00136 
00137 } // end namespace Thyra
00138 
00139 template<class Scalar>
00140 Teuchos::RCP<const Thyra::LinearOpBase<Scalar> >
00141 Thyra::identity(
00142   const Teuchos::RCP<const VectorSpaceBase<Scalar> >   &space
00143   )
00144 {
00145   return Teuchos::rcp(new DefaultIdentityLinearOp<Scalar>(space));
00146 }
00147 
00148 #endif  // THYRA_DEFAULT_IDENTITY_LINEAR_OP_HPP

Generated on Tue Oct 20 12:47:25 2009 for Thyra Package Browser (Single Doxygen Collection) by doxygen 1.4.7