Thyra_DefaultMultipliedLinearOp_decl.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_MULTIPLIED_LINEAR_OP_DECL_HPP
00030 #define THYRA_DEFAULT_MULTIPLIED_LINEAR_OP_DECL_HPP
00031 
00032 #include "Thyra_MultipliedLinearOpBase.hpp"
00033 #include "Thyra_SingleScalarLinearOpBase.hpp"
00034 #include "Teuchos_ConstNonconstObjectContainer.hpp"
00035 #include "Teuchos_Handleable.hpp"
00036 
00037 
00038 namespace Thyra {
00039 
00040 
00108 template<class Scalar>
00109 class DefaultMultipliedLinearOp
00110   : virtual public MultipliedLinearOpBase<Scalar>,        // Public interface
00111     virtual protected SingleScalarLinearOpBase<Scalar>,   // Implementation detail
00112     virtual public Teuchos::Handleable<LinearOpBase<Scalar> >
00113 {
00114 public:
00115 
00116 #ifdef THYRA_INJECT_USING_DECLARATIONS
00117   using SingleScalarLinearOpBase<Scalar>::apply;
00118 #endif
00119 
00120   /* */
00121   TEUCHOS_GET_RCP(LinearOpBase<Scalar>);
00122 
00125 
00132   DefaultMultipliedLinearOp();
00133 
00153   void initialize(
00154     const ArrayView<const RCP<LinearOpBase<Scalar> > > &Ops );
00155 
00175   void initialize(
00176     const ArrayView<const RCP<const LinearOpBase<Scalar> > > &Ops );
00177 
00184   void uninitialize();
00185 
00187 
00190 
00192   int numOps() const;
00194   bool opIsConst(const int k) const;
00196   RCP<LinearOpBase<Scalar> > getNonconstOp(const int k);
00198   RCP<const LinearOpBase<Scalar> > getOp(const int k) const;
00199 
00201 
00204 
00208   RCP< const VectorSpaceBase<Scalar> > range() const;
00209 
00213   RCP< const VectorSpaceBase<Scalar> > domain() const;
00214 
00216   RCP<const LinearOpBase<Scalar> > clone() const;
00217 
00219 
00222                                                 
00226   std::string description() const;
00227 
00235   void describe(
00236     Teuchos::FancyOStream &out,
00237     const Teuchos::EVerbosityLevel verbLevel
00238     ) const;
00239 
00241 
00242 protected:
00243 
00246 
00250   bool opSupported(EOpTransp M_trans) const;
00251 
00253   void apply(
00254     const EOpTransp M_trans,
00255     const MultiVectorBase<Scalar> &X,
00256     MultiVectorBase<Scalar> *Y,
00257     const Scalar alpha,
00258     const Scalar beta
00259     ) const;
00260 
00262 
00263 public:
00264 
00267 
00268 
00270   DefaultMultipliedLinearOp(
00271     const int numOps_in,
00272     const RCP<LinearOpBase<Scalar> > Ops[]
00273     )
00274     {
00275       initialize(numOps_in, Ops);
00276     }
00277 
00279   DefaultMultipliedLinearOp(
00280     const int numOps_in,
00281     const RCP<const LinearOpBase<Scalar> > Ops[]
00282     )
00283     {
00284       initialize(numOps_in, Ops);
00285     }
00286 
00288   void initialize(
00289     const int numOps_in,
00290     const RCP<LinearOpBase<Scalar> > Ops[]
00291     )
00292     {
00293       initialize(Teuchos::arrayView(Ops, numOps_in));
00294     }
00295 
00297   void initialize(
00298     const int numOps_in,
00299     const RCP<const LinearOpBase<Scalar> > Ops[]
00300     )
00301     {
00302       initialize(Teuchos::arrayView(Ops, numOps_in));
00303     }
00304 
00306 
00307 private:
00308 
00309   Array<Teuchos::ConstNonconstObjectContainer<LinearOpBase<Scalar> > > Ops_;
00310 
00311   void assertInitialized() const;
00312   void validateOps();
00313   void setupDefaultObjectLabel();
00314 
00315   // Not defined and not to be called
00316   DefaultMultipliedLinearOp(const DefaultMultipliedLinearOp&);
00317   DefaultMultipliedLinearOp& operator=(const DefaultMultipliedLinearOp&);
00318 
00319 };
00320 
00321 
00326 template<class Scalar>
00327 RCP<DefaultMultipliedLinearOp<Scalar> >
00328 defaultMultipliedLinearOp()
00329 {
00330   return Teuchos::rcp(new DefaultMultipliedLinearOp<Scalar>);
00331 }
00332 
00333 
00339 template<class Scalar>
00340 RCP<LinearOpBase<Scalar> >
00341 nonconstMultiply(
00342   const RCP<LinearOpBase<Scalar> > &A,
00343   const RCP<LinearOpBase<Scalar> > &B,
00344   const std::string &M_label = ""
00345   );
00346 
00347 
00353 template<class Scalar>
00354 RCP<const LinearOpBase<Scalar> >
00355 multiply(
00356   const RCP<const LinearOpBase<Scalar> > &A,
00357   const RCP<const LinearOpBase<Scalar> > &B,
00358   const std::string &M_label = ""
00359   );
00360 
00361 
00367 template<class Scalar>
00368 RCP<const LinearOpBase<Scalar> >
00369 multiply(
00370   const RCP<const LinearOpBase<Scalar> > &A,
00371   const RCP<const LinearOpBase<Scalar> > &B,
00372   const RCP<const LinearOpBase<Scalar> > &C,
00373   const std::string &M_label = ""
00374   );
00375 
00376 
00377 // /////////////////////////////////
00378 // Inline members
00379 
00380 
00381 template<class Scalar>
00382 inline
00383 void DefaultMultipliedLinearOp<Scalar>::assertInitialized() const
00384 {
00385 #ifdef TEUCHOS_DEBUG
00386   TEST_FOR_EXCEPT( !( numOps() > 0 ) );
00387 #endif
00388 }
00389 
00390 
00391 } // end namespace Thyra
00392 
00393 
00394 #endif  // THYRA_DEFAULT_MULTIPLIED_LINEAR_OP_DECL_HPP

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