Thyra_LinearOpWithSolveBase_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_LINEAR_OP_WITH_SOLVE_BASE_DECL_HPP
00030 #define THYRA_LINEAR_OP_WITH_SOLVE_BASE_DECL_HPP
00031 
00032 #include "Thyra_OperatorSolveTypes.hpp"
00033 #include "Thyra_LinearOpBase.hpp"
00034 #include "Thyra_MultiVectorBase.hpp"
00035 #include "Thyra_VectorSpaceBase.hpp"
00036 #include "Thyra_SolveSupportTypes.hpp"
00037 #include "Teuchos_VerboseObject.hpp"
00038 
00039 
00040 namespace Thyra {
00041 
00042 
00294 template<class Scalar>
00295 class LinearOpWithSolveBase
00296   : virtual public LinearOpBase<Scalar>
00297   , virtual public Teuchos::VerboseObject<LinearOpWithSolveBase<Scalar> >
00298 {
00299 public:
00300 
00303 
00309   bool solveSupports(EOpTransp transp) const
00310     { return solveSupportsImpl(transp); }
00311 
00318   bool solveSupportsSolveMeasureType(EOpTransp transp,
00319     const SolveMeasureType& solveMeasureType
00320     ) const
00321     { return solveSupportsSolveMeasureTypeImpl(transp, solveMeasureType); }
00322 
00371   SolveStatus<Scalar> solve(
00372     const EOpTransp A_trans,
00373     const MultiVectorBase<Scalar> &B,
00374     const Ptr<MultiVectorBase<Scalar> > &X,
00375     const Ptr<const SolveCriteria<Scalar> > solveCriteria = Teuchos::null
00376     ) const 
00377     { return solveImpl(A_trans, B, X, solveCriteria); }
00378 
00380 
00383 
00385   THYRA_DEPRECATED
00386   bool solveSupportsConj(EConj conj) const;
00387 
00389   THYRA_DEPRECATED
00390   bool solveTransposeSupportsConj(EConj conj) const;
00391 
00393   THYRA_DEPRECATED
00394   void solve(
00395     const EConj conj,
00396     const MultiVectorBase<Scalar> &B,
00397     MultiVectorBase<Scalar> *X,
00398     const int numBlocks = 0,
00399     const BlockSolveCriteria<Scalar> blockSolveCriteria[] = NULL,
00400     SolveStatus<Scalar> blockSolveStatus[] = NULL
00401     ) const;
00402 
00404   THYRA_DEPRECATED
00405   bool solveSupportsSolveMeasureType(EConj conj,
00406     const SolveMeasureType& solveMeasureType) const;
00407 
00409   THYRA_DEPRECATED
00410   bool solveTransposeSupportsSolveMeasureType(EConj conj,
00411     const SolveMeasureType& solveMeasureType) const;
00412 
00414   THYRA_DEPRECATED
00415   void solveTranspose(
00416     const EConj conj,
00417     const MultiVectorBase<Scalar> &B,
00418     MultiVectorBase<Scalar> *X,
00419     const int numBlocks = 0,
00420     const BlockSolveCriteria<Scalar> blockSolveCriteria[] = NULL,
00421     SolveStatus<Scalar> blockSolveStatus[] = NULL
00422     ) const;
00423 
00425 
00426 protected:
00427 
00430 
00432   virtual bool solveSupportsImpl(EOpTransp transp) const;
00433 
00435   virtual bool solveSupportsSolveMeasureTypeImpl(EOpTransp transp,
00436     const SolveMeasureType& solveMeasureType) const;
00437 
00439   virtual SolveStatus<Scalar> solveImpl(
00440     const EOpTransp transp,
00441     const MultiVectorBase<Scalar> &B,
00442     const Ptr<MultiVectorBase<Scalar> > &X,
00443     const Ptr<const SolveCriteria<Scalar> > solveCriteria
00444     ) const = 0;
00445 
00447 
00448 private:
00449 
00450   static Ptr<const SolveCriteria<Scalar> >
00451   converToBlockSolveCriteriaToSolveCritiera(
00452     const int numBlocks,
00453     const BlockSolveCriteria<Scalar> blockSolveCriteria[]
00454     );
00455 
00456 };
00457 
00458 
00463 template<class Scalar>
00464 inline
00465 bool solveSupports(
00466   const LinearOpWithSolveBase<Scalar> &A,
00467   const EOpTransp transp
00468   )
00469 {
00470   return A.solveSupports(transp);
00471 }
00472 
00473 
00479 template<class Scalar>
00480 inline
00481 bool solveSupportsSolveMeasureType(
00482   const LinearOpWithSolveBase<Scalar> &A,
00483   const EOpTransp transp,
00484   const SolveMeasureType &solveMeasureType
00485   )
00486 {
00487   return A.solveSupportsSolveMeasureType(transp, solveMeasureType);
00488 }
00489 
00490 
00495 template<class Scalar>
00496 inline
00497 SolveStatus<Scalar> solve(
00498   const LinearOpWithSolveBase<Scalar> &A,
00499   const EOpTransp A_trans,
00500   const MultiVectorBase<Scalar> &B,
00501   const Ptr<MultiVectorBase<Scalar> > &X,
00502   const Ptr<const SolveCriteria<Scalar> > solveCriteria = Teuchos::null
00503   )
00504 {
00505   return A.solve(A_trans, B, X, solveCriteria);
00506 }
00507 
00508 
00509 // Deprecated
00510 
00511 
00516 template<class Scalar>
00517 THYRA_DEPRECATED
00518 void solve(
00519   const LinearOpWithSolveBase<Scalar> &M,
00520   const EOpTransp M_trans,
00521   const MultiVectorBase<Scalar> &B,
00522   MultiVectorBase<Scalar> *X,
00523   const int numBlocks,
00524   const BlockSolveCriteria<Scalar> blockSolveCriteria[],
00525   SolveStatus<Scalar> blockSolveStatus[]
00526   )
00527 {
00528   if (real_trans(M_trans) == NOTRANS) {
00529     M.solve(transToConj(M_trans),
00530       B,X,numBlocks,blockSolveCriteria,blockSolveStatus);
00531   }
00532   else {
00533     M.solveTranspose(transToConj(M_trans),
00534       B,X,numBlocks,blockSolveCriteria,blockSolveStatus);
00535   }
00536 }
00537 
00538 
00543 template<class Scalar>
00544 THYRA_DEPRECATED
00545 SolveStatus<Scalar> solve(
00546   const LinearOpWithSolveBase<Scalar> &A,
00547   const EOpTransp A_trans,
00548   const MultiVectorBase<Scalar> &B,
00549   MultiVectorBase<Scalar> *X,
00550   const SolveCriteria<Scalar> *solveCriteria = NULL
00551   )
00552 {
00553   using Teuchos::ptr;
00554   return A.solve(A_trans, B, ptr(X), ptr(solveCriteria));
00555 }
00556 
00557 
00565 template<class Scalar>
00566 THYRA_DEPRECATED
00567 SolveStatus<Scalar>
00568 solve(
00569   const LinearOpWithSolveBase<Scalar> &A,
00570   const EConj conj,
00571   const MultiVectorBase<Scalar> &B,
00572   MultiVectorBase<Scalar> *X,
00573   const SolveCriteria<Scalar> *solveCriteria = NULL
00574   )
00575 {
00576   typedef SolveCriteria<Scalar> SC;
00577   typedef BlockSolveCriteria<Scalar> BSC;
00578   typedef SolveStatus<Scalar> BSS;
00579   SC defaultSolveCriteria;
00580   BSC blockSolveCriteria[1];
00581   BSS blockSolveStatus[1];
00582   blockSolveCriteria[0] = BSC(
00583     solveCriteria ? *solveCriteria : defaultSolveCriteria,
00584     B.domain()->dim() );
00585   A.solve(
00586     conj,B,X,1,
00587     blockSolveCriteria,
00588     blockSolveStatus
00589     );
00590   return blockSolveStatus[0];
00591 }
00592 
00593 
00601 template<class Scalar>
00602 THYRA_DEPRECATED
00603 SolveStatus<Scalar>
00604 solveTranspose(
00605   const LinearOpWithSolveBase<Scalar> &A,
00606   const EConj conj,
00607   const MultiVectorBase<Scalar> &B,
00608   MultiVectorBase<Scalar> *X,
00609   const SolveCriteria<Scalar> *solveCriteria = NULL
00610   )
00611 {
00612   typedef SolveCriteria<Scalar> SC;
00613   typedef BlockSolveCriteria<Scalar> BSC;
00614   typedef SolveStatus<Scalar> BSS;
00615   SC defaultSolveCriteria;
00616   BSC blockSolveCriteria[1];
00617   BSS blockSolveStatus[1];
00618   blockSolveCriteria[0] = BSC(
00619     solveCriteria ? *solveCriteria : defaultSolveCriteria,
00620     B.domain()->dim());
00621   A.solveTranspose(
00622     conj,B,X,1,
00623     blockSolveCriteria,
00624     blockSolveStatus
00625     );
00626   return blockSolveStatus[0];
00627 }
00628 
00629 
00637 template<class Scalar>
00638 THYRA_DEPRECATED
00639 void solve(
00640   const LinearOpWithSolveBase<Scalar> &A,
00641   const EConj conj,
00642   const MultiVectorBase<Scalar> &B,
00643   MultiVectorBase<Scalar> *X,
00644   const int numBlocks,
00645   const BlockSolveCriteria<Scalar> blockSolveCriteria[] = NULL,
00646   SolveStatus<Scalar> blockSolveStatus[] = NULL
00647   )
00648 {
00649   A.solve(conj,B,X,numBlocks,blockSolveCriteria,blockSolveStatus);
00650 }
00651 
00652 
00660 template<class Scalar>
00661 THYRA_DEPRECATED
00662 void solveTranspose(
00663   const LinearOpWithSolveBase<Scalar> &A,
00664   const EConj conj,
00665   const MultiVectorBase<Scalar> &B,
00666   MultiVectorBase<Scalar> *X,
00667   const int numBlocks,
00668   const BlockSolveCriteria<Scalar> blockSolveCriteria[] = NULL,
00669   SolveStatus<Scalar> blockSolveStatus[] = NULL
00670   )
00671 {
00672   A.solveTranspose(conj,B,X,numBlocks,blockSolveCriteria,blockSolveStatus);
00673 }
00674 
00675 
00676 } // namespace Thyra
00677 
00678 
00679 #endif // THYRA_LINEAR_OP_WITH_SOLVE_BASE_DECL_HPP

Generated on Wed Feb 10 16:27:56 2010 for Thyra ANA Operator Solve Interfaces by  doxygen 1.4.7