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

Generated on Thu Sep 18 12:33:02 2008 for Thyra Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1