Thyra Package Browser (Single Doxygen Collection) Version of the Day
Thyra_DefaultZeroLinearOp_def.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_ZERO_LINEAR_OP_DEF_HPP
00030 #define THYRA_DEFAULT_ZERO_LINEAR_OP_DEF_HPP
00031 
00032 #include "Thyra_DefaultZeroLinearOp_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 DefaultZeroLinearOp<Scalar>::DefaultZeroLinearOp()
00045 {}
00046 
00047 
00048 template<class Scalar>
00049 DefaultZeroLinearOp<Scalar>::DefaultZeroLinearOp(
00050   const RCP<const VectorSpaceBase<Scalar> > &range_in,
00051   const RCP<const VectorSpaceBase<Scalar> > &domain_in
00052   )
00053 {
00054   initialize(range_in,domain_in);
00055 }
00056 
00057 
00058 template<class Scalar>
00059 void DefaultZeroLinearOp<Scalar>::initialize(
00060   const RCP<const VectorSpaceBase<Scalar> > &range_in,
00061   const RCP<const VectorSpaceBase<Scalar> > &domain_in
00062   )
00063 {
00064   range_ = range_in.assert_not_null();
00065   domain_ = domain_in.assert_not_null();
00066 }
00067 
00068 
00069 template<class Scalar>
00070 void DefaultZeroLinearOp<Scalar>::uninitialize()
00071 {
00072   range_ = Teuchos::null;
00073   domain_ = Teuchos::null;
00074 }
00075 
00076 
00077 // Overridden from LinearOpBase
00078 
00079   
00080 template<class Scalar>
00081 RCP< const VectorSpaceBase<Scalar> >
00082 DefaultZeroLinearOp<Scalar>::range() const
00083 {
00084   return range_;
00085 }
00086 
00087 
00088 template<class Scalar>
00089 RCP< const VectorSpaceBase<Scalar> >
00090 DefaultZeroLinearOp<Scalar>::domain() const
00091 {
00092   return domain_;
00093 }
00094 
00095   
00096 template<class Scalar>
00097 RCP<const LinearOpBase<Scalar> >
00098 DefaultZeroLinearOp<Scalar>::clone() const
00099 {
00100   typedef DefaultZeroLinearOp<Scalar> this_t;
00101   if(range_.get())
00102     return Teuchos::rcp(new this_t(range_,domain_));
00103   return Teuchos::rcp(new this_t());
00104 }
00105 
00106   
00107 // Overridden from Teuchos::Describable
00108 
00109 
00110 template<class Scalar>
00111 std::string DefaultZeroLinearOp<Scalar>::description() const
00112 {
00113   typedef Teuchos::ScalarTraits<Scalar>  ST;
00114   std::ostringstream oss;
00115   oss
00116     << "Thyra::DefaultZeroLinearOp<" << ST::name() << ">{"
00117     << "range="<<(range_.get()?range_->description():"NULL")
00118     << ",domain="<<(domain_.get()?domain_->description():"NULL")
00119     << "}";
00120   return oss.str();
00121 }
00122 
00123 
00124 // protected
00125 
00126 
00127 // Overridden from LinearOpBase
00128 
00129 
00130 template<class Scalar>
00131 bool DefaultZeroLinearOp<Scalar>::opSupportedImpl(EOpTransp M_trans) const
00132 {
00133   return true;
00134 }
00135 
00136 
00137 template<class Scalar>
00138 void DefaultZeroLinearOp<Scalar>::applyImpl(
00139   const EOpTransp M_trans,
00140   const MultiVectorBase<Scalar> &X,
00141   const Ptr<MultiVectorBase<Scalar> > &Y,
00142   const Scalar alpha,
00143   const Scalar beta
00144   ) const
00145 {
00146 #ifdef TEUCHOS_DEBUG
00147   THYRA_ASSERT_LINEAR_OP_MULTIVEC_APPLY_SPACES(
00148     "DefaultZeroLinearOp<Scalar>::apply(...)", *this, M_trans, X, &*Y
00149     );
00150 #endif // TEUCHOS_DEBUG  
00151   scale(beta, Y);
00152 }
00153 
00154 
00155 } // end namespace Thyra
00156 
00157 
00158 template<class Scalar>
00159 Teuchos::RCP<const Thyra::LinearOpBase<Scalar> >
00160 Thyra::zero(
00161   const RCP<const VectorSpaceBase<Scalar> > &range_in,
00162   const RCP<const VectorSpaceBase<Scalar> > &domain_in
00163   )
00164 {
00165   return Teuchos::rcp(new DefaultZeroLinearOp<Scalar>(range_in, domain_in));
00166 }
00167 
00168 
00169 //
00170 // Explicit instantaition
00171 //
00172 
00173 
00174 #define THYRA_DEFAULT_ZERO_LINEAR_OP_INSTANT(SCALAR) \
00175   \
00176   template class DefaultZeroLinearOp<SCALAR >; \
00177   \
00178   template RCP<const Thyra::LinearOpBase<SCALAR > >  \
00179   zero(  \
00180     const RCP<const VectorSpaceBase<SCALAR > > &range,  \
00181     const RCP<const VectorSpaceBase<SCALAR > > &domain  \
00182     );  \
00183 
00184 
00185 #endif  // THYRA_DEFAULT_ZERO_LINEAR_OP_DEF_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines