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

Generated on Tue Jul 13 09:26:22 2010 for Thyra by  doxygen 1.4.7