|
Thyra Package Browser (Single Doxygen Collection) Version of the Day
|
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_DEF_HPP 00030 #define THYRA_DEFAULT_IDENTITY_LINEAR_OP_DEF_HPP 00031 00032 #include "Thyra_DefaultIdentityLinearOp_decl.hpp" 00033 #include "Thyra_MultiVectorStdOps.hpp" 00034 #include "Thyra_AssertOp.hpp" 00035 00036 00037 namespace Thyra { 00038 00039 00040 // Constructors/initializers/accessors 00041 00042 00043 template<class Scalar> 00044 DefaultIdentityLinearOp<Scalar>::DefaultIdentityLinearOp() 00045 {} 00046 00047 00048 template<class Scalar> 00049 DefaultIdentityLinearOp<Scalar>::DefaultIdentityLinearOp( 00050 const Teuchos::RCP<const VectorSpaceBase<Scalar> > &space 00051 ) 00052 { 00053 initialize(space); 00054 } 00055 00056 00057 template<class Scalar> 00058 void DefaultIdentityLinearOp<Scalar>::initialize( 00059 const Teuchos::RCP<const VectorSpaceBase<Scalar> > &space 00060 ) 00061 { 00062 space_ = space.assert_not_null(); 00063 } 00064 00065 00066 template<class Scalar> 00067 void DefaultIdentityLinearOp<Scalar>::uninitialize() 00068 { 00069 space_ = Teuchos::null; 00070 } 00071 00072 00073 // Overridden from LinearOpBase 00074 00075 00076 template<class Scalar> 00077 Teuchos::RCP< const VectorSpaceBase<Scalar> > 00078 DefaultIdentityLinearOp<Scalar>::range() const 00079 { 00080 return space_; 00081 } 00082 00083 00084 template<class Scalar> 00085 Teuchos::RCP< const VectorSpaceBase<Scalar> > 00086 DefaultIdentityLinearOp<Scalar>::domain() const 00087 { 00088 return space_; 00089 } 00090 00091 00092 template<class Scalar> 00093 Teuchos::RCP<const LinearOpBase<Scalar> > 00094 DefaultIdentityLinearOp<Scalar>::clone() const 00095 { 00096 typedef DefaultIdentityLinearOp<Scalar> this_t; 00097 if(space_.get()) 00098 return Teuchos::rcp(new this_t(space_)); 00099 return Teuchos::rcp(new this_t()); 00100 } 00101 00102 00103 // Overridden from Teuchos::Describable 00104 00105 00106 template<class Scalar> 00107 std::string DefaultIdentityLinearOp<Scalar>::description() const 00108 { 00109 typedef Teuchos::ScalarTraits<Scalar> ST; 00110 std::ostringstream oss; 00111 oss 00112 << "Thyra::DefaultIdentityLinearOp<" << ST::name() << ">{" 00113 << "space="<<(space_.get()?space_->description():"NULL") 00114 << "}"; 00115 return oss.str(); 00116 } 00117 00118 00119 // protected 00120 00121 00122 // Overridden from LinearOpBase 00123 00124 00125 template<class Scalar> 00126 bool DefaultIdentityLinearOp<Scalar>::opSupportedImpl(EOpTransp M_trans) const 00127 { 00128 return true; 00129 } 00130 00131 00132 template<class Scalar> 00133 void DefaultIdentityLinearOp<Scalar>::applyImpl( 00134 const EOpTransp M_trans, 00135 const MultiVectorBase<Scalar> &X, 00136 const Ptr<MultiVectorBase<Scalar> > &Y, 00137 const Scalar alpha, 00138 const Scalar beta 00139 ) const 00140 { 00141 using Teuchos::tuple; 00142 using Teuchos::ptrFromRef; 00143 #ifdef TEUCHOS_DEBUG 00144 THYRA_ASSERT_LINEAR_OP_MULTIVEC_APPLY_SPACES( 00145 "DefaultIdentityLinearOp<Scalar>::apply(...)", *this, M_trans, X, &*Y 00146 ); 00147 #endif // TEUCHOS_DEBUG 00148 Thyra::linear_combination<Scalar>( 00149 tuple<Scalar>(alpha)(), 00150 tuple<Ptr<const MultiVectorBase<Scalar> > >(ptrFromRef(X))(), 00151 beta, Y 00152 ); 00153 } 00154 00155 00156 } // end namespace Thyra 00157 00158 00159 template<class Scalar> 00160 Teuchos::RCP<const Thyra::LinearOpBase<Scalar> > 00161 Thyra::identity( 00162 const Teuchos::RCP<const VectorSpaceBase<Scalar> > &space, 00163 const std::string &label 00164 ) 00165 { 00166 RCP<Thyra::LinearOpBase<Scalar> > ilo = 00167 Teuchos::rcp(new DefaultIdentityLinearOp<Scalar>(space)); 00168 if (label.length()) 00169 ilo->setObjectLabel(label); 00170 return ilo; 00171 } 00172 00173 00174 // 00175 // Explicit instantaition 00176 // 00177 00178 00179 #define THYRA_DEFAULT_IDENTITY_LINEAR_OP_INSTANT(SCALAR) \ 00180 \ 00181 template class DefaultIdentityLinearOp<SCALAR >; \ 00182 \ 00183 template RCP<const LinearOpBase<SCALAR > > \ 00184 identity( \ 00185 const RCP<const VectorSpaceBase<SCALAR > > &space, \ 00186 const std::string &label \ 00187 ); \ 00188 00189 00190 #endif // THYRA_DEFAULT_IDENTITY_LINEAR_OP_DEF_HPP
1.7.4