Thyra Package Browser (Single Doxygen Collection) Version of the Day
Thyra_DefaultInverseLinearOp_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_INVERSE_LINEAR_OP_DECL_HPP
00030 #define THYRA_DEFAULT_INVERSE_LINEAR_OP_DECL_HPP
00031 
00032 #include "Thyra_InverseLinearOpBase.hpp"
00033 #include "Teuchos_ConstNonconstObjectContainer.hpp"
00034 
00035 
00036 namespace Thyra {
00037 
00038 
00040 enum EThrowOnSolveFailure {
00041   THROW_ON_SOLVE_FAILURE=1 
00042   ,IGNORE_SOLVE_FAILURE=0  
00043 };
00044 
00045 
00069 template<class Scalar>
00070 class DefaultInverseLinearOp : virtual public InverseLinearOpBase<Scalar>
00071 {
00072 public:
00073 
00076 
00080   DefaultInverseLinearOp();
00081 
00084   DefaultInverseLinearOp(
00085     const RCP<LinearOpWithSolveBase<Scalar> > &lows,
00086     const SolveCriteria<Scalar> *fwdSolveCriteria = NULL,
00087     const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
00088     const SolveCriteria<Scalar> *adjSolveCriteria = NULL,
00089     const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
00090     );
00091 
00097   DefaultInverseLinearOp(
00098     const RCP<const LinearOpWithSolveBase<Scalar> > &lows,
00099     const SolveCriteria<Scalar> *fwdSolveCriteria = NULL,
00100     const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
00101     const SolveCriteria<Scalar> *adjSolveCriteria = NULL,
00102     const EThrowOnSolveFailure throwOnAdjSolveFailure  = THROW_ON_SOLVE_FAILURE
00103     );
00104 
00139   void initialize(
00140     const RCP<LinearOpWithSolveBase<Scalar> > &lows,
00141     const SolveCriteria<Scalar> *fwdSolveCriteria = NULL,
00142     const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
00143     const SolveCriteria<Scalar> *adjSolveCriteria = NULL,
00144     const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
00145     );
00146 
00181   void initialize(
00182     const RCP<const LinearOpWithSolveBase<Scalar> > &lows,
00183     const SolveCriteria<Scalar> *fwdSolveCriteria = NULL,
00184     const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
00185     const SolveCriteria<Scalar> *adjSolveCriteria = NULL,
00186     const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
00187     );
00188 
00197   void uninitialize();
00198 
00200 
00203 
00205   bool isLowsConst() const;
00207   RCP<LinearOpWithSolveBase<Scalar> >
00208   getNonconstLows(); 
00210   RCP<const LinearOpWithSolveBase<Scalar> >
00211   getLows() const; 
00212 
00214 
00217 
00222   RCP< const VectorSpaceBase<Scalar> > range() const;
00223 
00228   RCP< const VectorSpaceBase<Scalar> > domain() const;
00229 
00231   RCP<const LinearOpBase<Scalar> > clone() const;
00232 
00234 
00237                                                 
00239   std::string description() const;
00240 
00242   void describe(
00243     FancyOStream &out,
00244     const Teuchos::EVerbosityLevel verbLevel
00245     ) const;
00246 
00248 
00249 protected:
00250 
00253 
00257   bool opSupportedImpl(EOpTransp M_trans) const;
00258 
00260   void applyImpl(
00261     const EOpTransp M_trans,
00262     const MultiVectorBase<Scalar> &X,
00263     const Ptr<MultiVectorBase<Scalar> > &Y,
00264     const Scalar alpha,
00265     const Scalar beta
00266     ) const;
00267 
00269 
00270 private:
00271 
00272   Teuchos::ConstNonconstObjectContainer<LinearOpWithSolveBase<Scalar> > lows_;
00273   RCP<SolveCriteria<Scalar> > fwdSolveCriteria_;
00274   EThrowOnSolveFailure throwOnFwdSolveFailure_;
00275   RCP<SolveCriteria<Scalar> > adjSolveCriteria_;
00276   EThrowOnSolveFailure throwOnAdjSolveFailure_;
00277   
00278   void assertInitialized() const;
00279 
00280   template<class LOWS>
00281   void initializeImpl(
00282     const RCP<LOWS> &lows,
00283     const SolveCriteria<Scalar> *fwdSolveCriteria,
00284     const EThrowOnSolveFailure throwOnFwdSolveFailure,
00285     const SolveCriteria<Scalar> *adjSolveCriteria,
00286     const EThrowOnSolveFailure throwOnAdjSolveFailure
00287     );
00288 
00289   // Not defined and not to be called
00290   DefaultInverseLinearOp(const DefaultInverseLinearOp&);
00291   DefaultInverseLinearOp& operator=(const DefaultInverseLinearOp&);
00292 
00293 };
00294 
00295 
00300 template<class Scalar>
00301 RCP<LinearOpBase<Scalar> >
00302 nonconstInverse(
00303   const RCP<LinearOpWithSolveBase<Scalar> > &A,
00304   const Ptr<const SolveCriteria<Scalar> > &fwdSolveCriteria = Teuchos::null,
00305   const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
00306   const Ptr<const SolveCriteria<Scalar> > &adjSolveCriteria = Teuchos::null,
00307   const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
00308   );
00309 
00310 
00315 template<class Scalar>
00316 RCP<LinearOpBase<Scalar> >
00317 inverse(
00318   const RCP<const LinearOpWithSolveBase<Scalar> > &A,
00319   const Ptr<const SolveCriteria<Scalar> > &fwdSolveCriteria = Teuchos::null,
00320   const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
00321   const Ptr<const SolveCriteria<Scalar> > &adjSolveCriteria = Teuchos::null,
00322   const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
00323   );
00324 
00325 
00326 // /////////////////////////////////
00327 // Inline members
00328 
00329 
00330 template<class Scalar>
00331 inline
00332 void DefaultInverseLinearOp<Scalar>::assertInitialized() const
00333 {
00334 #ifdef TEUCHOS_DEBUG
00335   TEST_FOR_EXCEPT( !lows_.getConstObj().get() );
00336 #endif
00337 }
00338 
00339 
00340 //
00341 // Deprecated
00342 //
00343 
00344 
00349 template<class Scalar>
00350 RCP<LinearOpBase<Scalar> >
00351 nonconstInverse(
00352   const RCP<LinearOpWithSolveBase<Scalar> > &A,
00353   const SolveCriteria<Scalar> *fwdSolveCriteria,
00354   const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
00355   const SolveCriteria<Scalar> *adjSolveCriteria = NULL,
00356   const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
00357   )
00358 {
00359   using Teuchos::ptr;
00360   return nonconstInverse<Scalar>(A, ptr(fwdSolveCriteria), throwOnFwdSolveFailure,
00361     ptr(adjSolveCriteria), throwOnAdjSolveFailure);
00362 }
00363 
00364 
00369 template<class Scalar>
00370 RCP<LinearOpBase<Scalar> >
00371 inverse(
00372   const RCP<const LinearOpWithSolveBase<Scalar> > &A,
00373   const SolveCriteria<Scalar> *fwdSolveCriteria,
00374   const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
00375   const SolveCriteria<Scalar> *adjSolveCriteria = NULL,
00376   const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
00377   )
00378 {
00379   using Teuchos::ptr;
00380   return inverse<Scalar>(A, ptr(fwdSolveCriteria), throwOnFwdSolveFailure,
00381     ptr(adjSolveCriteria), throwOnAdjSolveFailure);
00382 }
00383 
00384 
00385 } // end namespace Thyra
00386 
00387 
00388 #endif  // THYRA_DEFAULT_INVERSE_LINEAR_OP_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines