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   THYRA_DEPRECATED
00451   static Ptr<const SolveCriteria<Scalar> >
00452   convertBlockSolveCriteriaToSolveCritiera(
00453     const int numBlocks,
00454     const BlockSolveCriteria<Scalar> blockSolveCriteria[]
00455     );
00456 
00457 private:
00458   
00459   // Not defined and not to be called
00460   LinearOpWithSolveBase<Scalar>&
00461   operator=(const LinearOpWithSolveBase<Scalar>&);
00462 
00463 };
00464 
00465 
00470 template<class Scalar>
00471 inline
00472 bool solveSupports(
00473   const LinearOpWithSolveBase<Scalar> &A,
00474   const EOpTransp transp
00475   )
00476 {
00477   return A.solveSupports(transp);
00478 }
00479 
00480 
00486 template<class Scalar>
00487 inline
00488 bool solveSupportsSolveMeasureType(
00489   const LinearOpWithSolveBase<Scalar> &A,
00490   const EOpTransp transp,
00491   const SolveMeasureType &solveMeasureType
00492   )
00493 {
00494   return A.solveSupportsSolveMeasureType(transp, solveMeasureType);
00495 }
00496 
00497 
00502 template<class Scalar>
00503 inline
00504 SolveStatus<Scalar> solve(
00505   const LinearOpWithSolveBase<Scalar> &A,
00506   const EOpTransp A_trans,
00507   const MultiVectorBase<Scalar> &B,
00508   const Ptr<MultiVectorBase<Scalar> > &X,
00509   const Ptr<const SolveCriteria<Scalar> > solveCriteria = Teuchos::null
00510   )
00511 {
00512   return A.solve(A_trans, B, X, solveCriteria);
00513 }
00514 
00515 
00516 // Deprecated
00517 
00518 
00523 template<class Scalar>
00524 THYRA_DEPRECATED
00525 void solve(
00526   const LinearOpWithSolveBase<Scalar> &M,
00527   const EOpTransp M_trans,
00528   const MultiVectorBase<Scalar> &B,
00529   MultiVectorBase<Scalar> *X,
00530   const int numBlocks,
00531   const BlockSolveCriteria<Scalar> blockSolveCriteria[],
00532   SolveStatus<Scalar> blockSolveStatus[]
00533   )
00534 {
00535   if (real_trans(M_trans) == NOTRANS) {
00536     M.solve(transToConj(M_trans),
00537       B,X,numBlocks,blockSolveCriteria,blockSolveStatus);
00538   }
00539   else {
00540     M.solveTranspose(transToConj(M_trans),
00541       B,X,numBlocks,blockSolveCriteria,blockSolveStatus);
00542   }
00543 }
00544 
00545 
00550 template<class Scalar>
00551 THYRA_DEPRECATED
00552 SolveStatus<Scalar> solve(
00553   const LinearOpWithSolveBase<Scalar> &A,
00554   const EOpTransp A_trans,
00555   const MultiVectorBase<Scalar> &B,
00556   MultiVectorBase<Scalar> *X,
00557   const SolveCriteria<Scalar> *solveCriteria = NULL
00558   )
00559 {
00560   using Teuchos::ptr;
00561   return A.solve(A_trans, B, ptr(X), ptr(solveCriteria));
00562 }
00563 
00564 
00572 template<class Scalar>
00573 THYRA_DEPRECATED
00574 SolveStatus<Scalar>
00575 solve(
00576   const LinearOpWithSolveBase<Scalar> &A,
00577   const EConj conj,
00578   const MultiVectorBase<Scalar> &B,
00579   MultiVectorBase<Scalar> *X,
00580   const SolveCriteria<Scalar> *solveCriteria = NULL
00581   )
00582 {
00583   typedef SolveCriteria<Scalar> SC;
00584   typedef BlockSolveCriteria<Scalar> BSC;
00585   typedef SolveStatus<Scalar> BSS;
00586   SC defaultSolveCriteria;
00587   BSC blockSolveCriteria[1];
00588   BSS blockSolveStatus[1];
00589   blockSolveCriteria[0] = BSC(
00590     solveCriteria ? *solveCriteria : defaultSolveCriteria,
00591     B.domain()->dim() );
00592   A.solve(
00593     conj,B,X,1,
00594     blockSolveCriteria,
00595     blockSolveStatus
00596     );
00597   return blockSolveStatus[0];
00598 }
00599 
00600 
00608 template<class Scalar>
00609 THYRA_DEPRECATED
00610 SolveStatus<Scalar>
00611 solveTranspose(
00612   const LinearOpWithSolveBase<Scalar> &A,
00613   const EConj conj,
00614   const MultiVectorBase<Scalar> &B,
00615   MultiVectorBase<Scalar> *X,
00616   const SolveCriteria<Scalar> *solveCriteria = NULL
00617   )
00618 {
00619   typedef SolveCriteria<Scalar> SC;
00620   typedef BlockSolveCriteria<Scalar> BSC;
00621   typedef SolveStatus<Scalar> BSS;
00622   SC defaultSolveCriteria;
00623   BSC blockSolveCriteria[1];
00624   BSS blockSolveStatus[1];
00625   blockSolveCriteria[0] = BSC(
00626     solveCriteria ? *solveCriteria : defaultSolveCriteria,
00627     B.domain()->dim());
00628   A.solveTranspose(
00629     conj,B,X,1,
00630     blockSolveCriteria,
00631     blockSolveStatus
00632     );
00633   return blockSolveStatus[0];
00634 }
00635 
00636 
00644 template<class Scalar>
00645 THYRA_DEPRECATED
00646 void solve(
00647   const LinearOpWithSolveBase<Scalar> &A,
00648   const EConj conj,
00649   const MultiVectorBase<Scalar> &B,
00650   MultiVectorBase<Scalar> *X,
00651   const int numBlocks,
00652   const BlockSolveCriteria<Scalar> blockSolveCriteria[] = NULL,
00653   SolveStatus<Scalar> blockSolveStatus[] = NULL
00654   )
00655 {
00656   A.solve(conj,B,X,numBlocks,blockSolveCriteria,blockSolveStatus);
00657 }
00658 
00659 
00667 template<class Scalar>
00668 THYRA_DEPRECATED
00669 void solveTranspose(
00670   const LinearOpWithSolveBase<Scalar> &A,
00671   const EConj conj,
00672   const MultiVectorBase<Scalar> &B,
00673   MultiVectorBase<Scalar> *X,
00674   const int numBlocks,
00675   const BlockSolveCriteria<Scalar> blockSolveCriteria[] = NULL,
00676   SolveStatus<Scalar> blockSolveStatus[] = NULL
00677   )
00678 {
00679   A.solveTranspose(conj,B,X,numBlocks,blockSolveCriteria,blockSolveStatus);
00680 }
00681 
00682 
00683 } // namespace Thyra
00684 
00685 
00686 #endif // THYRA_LINEAR_OP_WITH_SOLVE_BASE_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:00:13 2011 for Thyra by  doxygen 1.6.3