Thyra_DefaultAddedLinearOpDecl.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 // 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_ADDED_LINEAR_OP_DECL_HPP
00030 #define THYRA_DEFAULT_ADDED_LINEAR_OP_DECL_HPP
00031 
00032 
00033 #include "Thyra_AddedLinearOpBase.hpp"
00034 #include "Thyra_SingleScalarLinearOpBase.hpp"
00035 #include "Teuchos_ConstNonconstObjectContainer.hpp"
00036 #include "Teuchos_arrayArg.hpp"
00037 
00038 
00039 namespace Thyra {
00040 
00041 
00073 template<class Scalar>
00074 class DefaultAddedLinearOp
00075   : virtual public AddedLinearOpBase<Scalar>             // Public interface
00076   , virtual protected SingleScalarLinearOpBase<Scalar>   // Implementation detail
00077 {
00078 public:
00079 
00080 #ifdef THYRA_INJECT_USING_DECLARATIONS
00081   using SingleScalarLinearOpBase<Scalar>::apply;
00082 #endif
00083 
00086 
00093   DefaultAddedLinearOp();
00094 
00100   DefaultAddedLinearOp(
00101     const int numOps,
00102     const RCP<LinearOpBase<Scalar> > Ops[]
00103     );
00104 
00110   DefaultAddedLinearOp(
00111     const int numOps,
00112     const RCP<const LinearOpBase<Scalar> > Ops[]
00113     );
00114 
00134   void initialize(
00135     const int numOps,
00136     const RCP<LinearOpBase<Scalar> > Ops[]
00137     );
00138 
00158   void initialize(
00159     const int numOps,
00160     const RCP<const LinearOpBase<Scalar> > Ops[]
00161     );
00162 
00169   void uninitialize();
00170 
00172 
00175 
00177   int numOps() const;
00179   bool opIsConst(const int k) const;
00181   RCP<LinearOpBase<Scalar> > getNonconstOp(const int k);
00183   RCP<const LinearOpBase<Scalar> > getOp(const int k) const;
00184 
00186 
00189 
00193   RCP< const VectorSpaceBase<Scalar> > range() const;
00194 
00198   RCP< const VectorSpaceBase<Scalar> > domain() const;
00199 
00201   RCP<const LinearOpBase<Scalar> > clone() const;
00202 
00204 
00207                                                 
00211   std::string description() const;
00212 
00220   void describe(
00221     Teuchos::FancyOStream &out,
00222     const Teuchos::EVerbosityLevel verbLevel
00223     ) const;
00224 
00226 
00227 protected:
00228 
00231 
00235   bool opSupported(EOpTransp M_trans) const;
00236 
00238   void apply(
00239     const EOpTransp M_trans,
00240     const MultiVectorBase<Scalar> &X,
00241     MultiVectorBase<Scalar> *Y,
00242     const Scalar alpha,
00243     const Scalar beta
00244     ) const;
00245 
00247 
00248 private:
00249 
00250   std::vector<Teuchos::ConstNonconstObjectContainer<LinearOpBase<Scalar> > >   Ops_;
00251 
00252   void assertInitialized() const;
00253   void validateOps();
00254   void setupDefaultObjectLabel();
00255 
00256   // Not defined and not to be called
00257   DefaultAddedLinearOp(const DefaultAddedLinearOp&);
00258   DefaultAddedLinearOp& operator=(const DefaultAddedLinearOp&);
00259 
00260 };
00261 
00262 
00267 template<class Scalar>
00268 RCP<LinearOpBase<Scalar> >
00269 nonconstAdd(
00270   const RCP<LinearOpBase<Scalar> > &A,
00271   const RCP<LinearOpBase<Scalar> > &B,
00272   const std::string &label = ""
00273   );
00274 
00275 
00280 template<class Scalar>
00281 RCP<const LinearOpBase<Scalar> >
00282 add(
00283   const RCP<const LinearOpBase<Scalar> > &A,
00284   const RCP<const LinearOpBase<Scalar> > &B,
00285   const std::string &label = ""
00286   );
00287 
00288 
00293 template<class Scalar>
00294 RCP<LinearOpBase<Scalar> >
00295 nonconstSubtract(
00296   const RCP<LinearOpBase<Scalar> > &A,
00297   const RCP<LinearOpBase<Scalar> > &B,
00298   const std::string &label = ""
00299   );
00300 
00301 
00306 template<class Scalar>
00307 RCP<const LinearOpBase<Scalar> >
00308 subtract(
00309   const RCP<const LinearOpBase<Scalar> > &A,
00310   const RCP<const LinearOpBase<Scalar> > &B,
00311   const std::string &label = ""
00312   );
00313 
00314 
00315 // /////////////////////////////////
00316 // Inline members
00317 
00318 
00319 template<class Scalar>
00320 inline
00321 void DefaultAddedLinearOp<Scalar>::assertInitialized() const
00322 {
00323 #ifdef TEUCHOS_DEBUG
00324   TEST_FOR_EXCEPT( !( numOps() > 0 ) );
00325 #endif
00326 }
00327 
00328 
00329 } // end namespace Thyra
00330 
00331 
00332 #endif  // THYRA_DEFAULT_ADDED_LINEAR_OP_DECL_HPP

Generated on Wed May 12 21:26:53 2010 for Thyra Operator/Vector Support by  doxygen 1.4.7