Thyra Package Browser (Single Doxygen Collection) Version of the Day
Thyra_DefaultMultipliedLinearOp_decl.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_MULTIPLIED_LINEAR_OP_DECL_HPP
00030 #define THYRA_DEFAULT_MULTIPLIED_LINEAR_OP_DECL_HPP
00031 
00032 #include "Thyra_MultipliedLinearOpBase.hpp"
00033 #include "Teuchos_ConstNonconstObjectContainer.hpp"
00034 
00035 
00036 namespace Thyra {
00037 
00038 
00106 template<class Scalar>
00107 class DefaultMultipliedLinearOp : virtual public MultipliedLinearOpBase<Scalar>
00108 {
00109 public:
00110 
00113 
00120   DefaultMultipliedLinearOp();
00121 
00139   void initialize(const ArrayView<const RCP<LinearOpBase<Scalar> > > &Ops);
00140 
00158   void initialize(const ArrayView<const RCP<const LinearOpBase<Scalar> > > &Ops );
00159 
00166   void uninitialize();
00167 
00169 
00172 
00174   int numOps() const;
00176   bool opIsConst(const int k) const;
00178   RCP<LinearOpBase<Scalar> > getNonconstOp(const int k);
00180   RCP<const LinearOpBase<Scalar> > getOp(const int k) const;
00181 
00183 
00186 
00190   RCP< const VectorSpaceBase<Scalar> > range() const;
00191 
00195   RCP< const VectorSpaceBase<Scalar> > domain() const;
00196 
00198   RCP<const LinearOpBase<Scalar> > clone() const;
00199 
00201 
00204                                                 
00208   std::string description() const;
00209 
00217   void describe(
00218     Teuchos::FancyOStream &out,
00219     const Teuchos::EVerbosityLevel verbLevel
00220     ) const;
00221 
00223 
00224 protected:
00225 
00228 
00232   bool opSupportedImpl(EOpTransp M_trans) const;
00233 
00235   void applyImpl(
00236     const EOpTransp M_trans,
00237     const MultiVectorBase<Scalar> &X,
00238     const Ptr<MultiVectorBase<Scalar> > &Y,
00239     const Scalar alpha,
00240     const Scalar beta
00241     ) const;
00242 
00244 
00245 public:
00246 
00249 
00250 
00252   DefaultMultipliedLinearOp(
00253     const int numOps_in,
00254     const RCP<LinearOpBase<Scalar> > Ops[]
00255     )
00256     {
00257       initialize(numOps_in, Ops);
00258     }
00259 
00261   DefaultMultipliedLinearOp(
00262     const int numOps_in,
00263     const RCP<const LinearOpBase<Scalar> > Ops[]
00264     )
00265     {
00266       initialize(numOps_in, Ops);
00267     }
00268 
00270   void initialize(
00271     const int numOps_in,
00272     const RCP<LinearOpBase<Scalar> > Ops[]
00273     )
00274     {
00275       initialize(Teuchos::arrayView(Ops, numOps_in));
00276     }
00277 
00279   void initialize(
00280     const int numOps_in,
00281     const RCP<const LinearOpBase<Scalar> > Ops[]
00282     )
00283     {
00284       initialize(Teuchos::arrayView(Ops, numOps_in));
00285     }
00286 
00288 
00289 private:
00290 
00291   Array<Teuchos::ConstNonconstObjectContainer<LinearOpBase<Scalar> > > Ops_;
00292 
00293   void assertInitialized() const;
00294   void validateOps();
00295   void setupDefaultObjectLabel();
00296 
00297   // Not defined and not to be called
00298   DefaultMultipliedLinearOp(const DefaultMultipliedLinearOp&);
00299   DefaultMultipliedLinearOp& operator=(const DefaultMultipliedLinearOp&);
00300 
00301 };
00302 
00303 
00308 template<class Scalar>
00309 inline
00310 RCP<DefaultMultipliedLinearOp<Scalar> >
00311 defaultMultipliedLinearOp()
00312 {
00313   return Teuchos::rcp(new DefaultMultipliedLinearOp<Scalar>);
00314 }
00315 
00316 
00321 template<class Scalar>
00322 RCP<DefaultMultipliedLinearOp<Scalar> >
00323 defaultMultipliedLinearOp(const ArrayView<const RCP<LinearOpBase<Scalar> > > &Ops)
00324 {
00325   RCP<DefaultMultipliedLinearOp<Scalar> > dmlo = defaultMultipliedLinearOp<Scalar>();
00326   dmlo->initialize(Ops);
00327   return dmlo;
00328 }
00329 
00330 
00335 template<class Scalar>
00336 RCP<DefaultMultipliedLinearOp<Scalar> >
00337 defaultMultipliedLinearOp(const ArrayView<const RCP<const LinearOpBase<Scalar> > > &Ops)
00338 {
00339   RCP<DefaultMultipliedLinearOp<Scalar> > dmlo = defaultMultipliedLinearOp<Scalar>();
00340   dmlo->initialize(Ops);
00341   return dmlo;
00342 }
00343 
00344 
00350 template<class Scalar>
00351 RCP<LinearOpBase<Scalar> >
00352 nonconstMultiply(
00353   const RCP<LinearOpBase<Scalar> > &A,
00354   const RCP<LinearOpBase<Scalar> > &B,
00355   const std::string &M_label = ""
00356   );
00357 
00358 
00364 template<class Scalar>
00365 RCP<const LinearOpBase<Scalar> >
00366 multiply(
00367   const RCP<const LinearOpBase<Scalar> > &A,
00368   const RCP<const LinearOpBase<Scalar> > &B,
00369   const std::string &M_label = ""
00370   );
00371 
00372 
00378 template<class Scalar>
00379 RCP<const LinearOpBase<Scalar> >
00380 multiply(
00381   const RCP<const LinearOpBase<Scalar> > &A,
00382   const RCP<const LinearOpBase<Scalar> > &B,
00383   const RCP<const LinearOpBase<Scalar> > &C,
00384   const std::string &M_label = ""
00385   );
00386 
00387 
00388 // /////////////////////////////////
00389 // Inline members
00390 
00391 
00392 template<class Scalar>
00393 inline
00394 void DefaultMultipliedLinearOp<Scalar>::assertInitialized() const
00395 {
00396 #ifdef TEUCHOS_DEBUG
00397   TEST_FOR_EXCEPT( !( numOps() > 0 ) );
00398 #endif
00399 }
00400 
00401 
00402 } // end namespace Thyra
00403 
00404 
00405 #endif  // THYRA_DEFAULT_MULTIPLIED_LINEAR_OP_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines