Thyra_DefaultAddedLinearOpDecl.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_ADDED_LINEAR_OP_DECL_HPP
00030 #define THYRA_DEFAULT_ADDED_LINEAR_OP_DECL_HPP
00031 
00032 #include "Thyra_AddedLinearOpBase.hpp"
00033 #include "Thyra_SingleScalarLinearOpBase.hpp"
00034 #include "Teuchos_ConstNonconstObjectContainer.hpp"
00035 #include "Teuchos_arrayArg.hpp"
00036 
00037 namespace Thyra {
00038 
00070 template<class Scalar>
00071 class DefaultAddedLinearOp
00072   : virtual public AddedLinearOpBase<Scalar>             // Public interface
00073   , virtual protected SingleScalarLinearOpBase<Scalar>   // Implementation detail
00074 {
00075 public:
00076 
00078   using SingleScalarLinearOpBase<Scalar>::apply;
00079 
00082 
00089   DefaultAddedLinearOp();
00090 
00096   DefaultAddedLinearOp(
00097     const int                                                   numOps
00098     ,const Teuchos::RCP<LinearOpBase<Scalar> >          Ops[]
00099     );
00100 
00106   DefaultAddedLinearOp(
00107     const int                                                   numOps
00108     ,const Teuchos::RCP<const LinearOpBase<Scalar> >    Ops[]
00109     );
00110 
00130   void initialize(
00131     const int                                                   numOps
00132     ,const Teuchos::RCP<LinearOpBase<Scalar> >          Ops[]
00133     );
00134 
00154   void initialize(
00155     const int                                                   numOps
00156     ,const Teuchos::RCP<const LinearOpBase<Scalar> >    Ops[]
00157     );
00158 
00165   void uninitialize();
00166 
00168 
00171 
00173   int numOps() const;
00175   bool opIsConst(const int k) const;
00177   Teuchos::RCP<LinearOpBase<Scalar> > getNonconstOp(const int k);
00179   Teuchos::RCP<const LinearOpBase<Scalar> > getOp(const int k) const;
00180 
00182 
00185 
00189   Teuchos::RCP< const VectorSpaceBase<Scalar> > range() const;
00190 
00194   Teuchos::RCP< const VectorSpaceBase<Scalar> > domain() const;
00195 
00197   Teuchos::RCP<const LinearOpBase<Scalar> > clone() const;
00198 
00200 
00203                                                 
00207   std::string description() const;
00208 
00216   void describe(
00217     Teuchos::FancyOStream                &out
00218     ,const Teuchos::EVerbosityLevel      verbLevel
00219     ) const;
00220 
00222 
00223 protected:
00224 
00227 
00231   bool opSupported(ETransp M_trans) const;
00232 
00234   void apply(
00235     const ETransp                     M_trans
00236     ,const MultiVectorBase<Scalar>    &X
00237     ,MultiVectorBase<Scalar>          *Y
00238     ,const Scalar                     alpha
00239     ,const Scalar                     beta
00240     ) const;
00241 
00243 
00244 private:
00245 
00246   std::vector<Teuchos::ConstNonconstObjectContainer<LinearOpBase<Scalar> > >   Ops_;
00247 
00248   void assertInitialized() const;
00249   void validateOps();
00250   void setupDefaultObjectLabel();
00251 
00252   // Not defined and not to be called
00253   DefaultAddedLinearOp(const DefaultAddedLinearOp&);
00254   DefaultAddedLinearOp& operator=(const DefaultAddedLinearOp&);
00255 
00256 };
00257 
00262 template<class Scalar>
00263 Teuchos::RCP<LinearOpBase<Scalar> >
00264 nonconstAdd(
00265   const Teuchos::RCP<LinearOpBase<Scalar> >    &A
00266   ,const Teuchos::RCP<LinearOpBase<Scalar> >   &B
00267   );
00268 
00273 template<class Scalar>
00274 Teuchos::RCP<const LinearOpBase<Scalar> >
00275 add(
00276   const Teuchos::RCP<const LinearOpBase<Scalar> >    &A
00277   ,const Teuchos::RCP<const LinearOpBase<Scalar> >   &B
00278   );
00279 
00280 // /////////////////////////////////
00281 // Inline members
00282 
00283 template<class Scalar>
00284 inline
00285 void DefaultAddedLinearOp<Scalar>::assertInitialized() const
00286 {
00287 #ifdef TEUCHOS_DEBUG
00288   TEST_FOR_EXCEPT( !( numOps() > 0 ) );
00289 #endif
00290 }
00291 
00292 } // end namespace Thyra
00293 
00294 #endif  // THYRA_DEFAULT_ADDED_LINEAR_OP_DECL_HPP

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