Thyra_LinearOpWithSolveBaseDecl.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_LINEAR_OP_WITH_SOLVE_BASE_DECL_HPP
00030 #define THYRA_LINEAR_OP_WITH_SOLVE_BASE_DECL_HPP
00031 
00032 #include "Thyra_LinearOpBaseDecl.hpp"
00033 #include "Thyra_SolveSupportTypes.hpp"
00034 #include "Teuchos_VerboseObject.hpp"
00035 
00036 namespace Thyra {
00037 
00337 template <class RangeScalar, class DomainScalar = RangeScalar>
00338 class LinearOpWithSolveBase
00339   : virtual public LinearOpBase<RangeScalar,DomainScalar>
00340   , virtual public Teuchos::VerboseObject<LinearOpWithSolveBase<RangeScalar,DomainScalar> >
00341 {
00342 public:
00343 
00345   typedef typename Teuchos::PromotionTraits<RangeScalar,DomainScalar>::promote PromotedScalar;
00346   
00349 
00405   virtual void solve(
00406     const EConj                                   conj
00407     ,const MultiVectorBase<RangeScalar>           &B
00408     ,MultiVectorBase<DomainScalar>                *X
00409     ,const int                                    numBlocks             = 0
00410     ,const BlockSolveCriteria<PromotedScalar>     blockSolveCriteria[]  = NULL
00411     ,SolveStatus<PromotedScalar>                  blockSolveStatus[]    = NULL
00412     ) const = 0;
00413 
00415 
00418 
00424   virtual bool solveSupportsConj(EConj conj) const;
00425 
00430   virtual bool solveTransposeSupportsConj(EConj conj) const;
00431 
00438   virtual bool solveSupportsSolveMeasureType(EConj conj, const SolveMeasureType& solveMeasureType) const;
00439 
00446   virtual bool solveTransposeSupportsSolveMeasureType(EConj conj, const SolveMeasureType& solveMeasureType) const;
00447 
00504   virtual void solveTranspose(
00505     const EConj                                   conj
00506     ,const MultiVectorBase<DomainScalar>          &B
00507     ,MultiVectorBase<RangeScalar>                 *X
00508     ,const int                                    numBlocks             = 0
00509     ,const BlockSolveCriteria<PromotedScalar>     blockSolveCriteria[]  = NULL
00510     ,SolveStatus<PromotedScalar>                  blockSolveStatus[]    = NULL
00511     ) const;
00512 
00514 
00515 };
00516 
00527 
00533 template<class Scalar>
00534 bool solveSupports(
00535   const LinearOpWithSolveBase<Scalar>   &A
00536   ,const ETransp                        A_trans
00537   )
00538 {
00539   if( real_trans(A_trans) == NOTRANS ) {
00540     return A.solveSupportsConj(
00541       A_trans == NOTRANS ? NONCONJ_ELE : CONJ_ELE
00542       );
00543   }
00544   return A.solveTransposeSupportsConj(
00545     A_trans == TRANS ? NONCONJ_ELE : CONJ_ELE
00546     );
00547 }
00548 
00561 template<class Scalar>
00562 SolveStatus<Scalar>
00563 solve(
00564   const LinearOpWithSolveBase<Scalar>   &A
00565   ,const ETransp                        A_trans
00566   ,const MultiVectorBase<Scalar>        &B
00567   ,MultiVectorBase<Scalar>              *X
00568   ,const SolveCriteria<Scalar>          *solveCriteria
00569 #ifndef __sun
00570                                                         = NULL
00571 #endif
00572   )
00573 {
00574   if(real_trans(A_trans)==NOTRANS)
00575     return solve(A,transToConj(A_trans),B,X,solveCriteria);
00576   return solveTranspose(A,transToConj(A_trans),B,X,solveCriteria);
00577 }
00578 
00579 #ifdef __sun
00580 
00581 template<class Scalar>
00582 SolveStatus<Scalar>
00583 solve(
00584   const LinearOpWithSolveBase<Scalar>   &A
00585   ,const ETransp                        A_trans
00586   ,const MultiVectorBase<Scalar>        &B
00587   ,MultiVectorBase<Scalar>              *X
00588   )
00589 {
00590   return solve(A,A_trans,B,X,NULL);
00591 }
00592 
00593 #endif // __sun
00594 
00602 template<class RangeScalar, class DomainScalar>
00603 SolveStatus<typename LinearOpWithSolveBase<RangeScalar,DomainScalar>::PromotedScalar>
00604 solve(
00605   const LinearOpWithSolveBase<RangeScalar,DomainScalar>   &A
00606   ,const EConj                                            conj
00607   ,const MultiVectorBase<RangeScalar>                     &B
00608   ,MultiVectorBase<DomainScalar>                          *X
00609   ,const SolveCriteria<typename LinearOpWithSolveBase<RangeScalar,DomainScalar>::PromotedScalar>
00610                                                           *solveCriteria
00611 #ifndef __sun
00612                                                                           = NULL
00613 #endif
00614   )
00615 {
00616   typedef SolveCriteria<typename LinearOpWithSolveBase<RangeScalar,DomainScalar>::PromotedScalar>       SC;
00617   typedef BlockSolveCriteria<typename LinearOpWithSolveBase<RangeScalar,DomainScalar>::PromotedScalar>  BSC;
00618   typedef SolveStatus<typename LinearOpWithSolveBase<RangeScalar,DomainScalar>::PromotedScalar>         BSS;
00619   SC  defaultSolveCriteria;
00620   BSC blockSolveCriteria[1];
00621   BSS blockSolveStatus[1];
00622   blockSolveCriteria[0] = BSC(solveCriteria?*solveCriteria:defaultSolveCriteria,B.domain()->dim());
00623   A.solve(
00624     conj,B,X,1
00625     ,blockSolveCriteria
00626     ,blockSolveStatus
00627     );
00628   return blockSolveStatus[0];
00629 }
00630 
00631 #ifdef __sun
00632 
00633 template<class RangeScalar, class DomainScalar>
00634 SolveStatus<typename LinearOpWithSolveBase<RangeScalar,DomainScalar>::PromotedScalar>
00635 solve(
00636   const LinearOpWithSolveBase<RangeScalar,DomainScalar>   &A
00637   ,const EConj                                            conj
00638   ,const MultiVectorBase<RangeScalar>                     &B
00639   ,MultiVectorBase<DomainScalar>                          *X
00640   )
00641 {
00642   return solve(A,conj,B,X,NULL);
00643 }
00644 
00645 #endif // __sun
00646 
00654 template <class RangeScalar, class DomainScalar>
00655 SolveStatus<typename LinearOpWithSolveBase<RangeScalar,DomainScalar>::PromotedScalar>
00656 solveTranspose(
00657   const LinearOpWithSolveBase<RangeScalar,DomainScalar>   &A
00658   ,const EConj                                            conj
00659   ,const MultiVectorBase<DomainScalar>                    &B
00660   ,MultiVectorBase<RangeScalar>                           *X
00661   ,const SolveCriteria<typename LinearOpWithSolveBase<RangeScalar,DomainScalar>::PromotedScalar>
00662                                                           *solveCriteria
00663 #ifndef __sun
00664                                                                           = NULL
00665 #endif
00666   )
00667 {
00668   typedef SolveCriteria<typename LinearOpWithSolveBase<RangeScalar,DomainScalar>::PromotedScalar>       SC;
00669   typedef BlockSolveCriteria<typename LinearOpWithSolveBase<RangeScalar,DomainScalar>::PromotedScalar>  BSC;
00670   typedef SolveStatus<typename LinearOpWithSolveBase<RangeScalar,DomainScalar>::PromotedScalar>         BSS;
00671   SC  defaultSolveCriteria;
00672   BSC blockSolveCriteria[1];
00673   BSS blockSolveStatus[1];
00674   blockSolveCriteria[0] = BSC(solveCriteria?*solveCriteria:defaultSolveCriteria,B.domain()->dim());
00675   A.solveTranspose(
00676     conj,B,X,1
00677     ,blockSolveCriteria
00678     ,blockSolveStatus
00679     );
00680   return blockSolveStatus[0];
00681 }
00682 
00683 #ifdef __sun
00684 
00685 template <class RangeScalar, class DomainScalar>
00686 SolveStatus<typename LinearOpWithSolveBase<RangeScalar,DomainScalar>::PromotedScalar>
00687 solveTranspose(
00688   const LinearOpWithSolveBase<RangeScalar,DomainScalar>   &A
00689   ,const EConj                                            conj
00690   ,const MultiVectorBase<DomainScalar>                    &B
00691   ,MultiVectorBase<RangeScalar>                           *X
00692   )
00693 {
00694   return solveTranspose(A,conj,B,X,NULL);
00695 }
00696 
00697 #endif // __sun
00698 
00706 template<class RangeScalar, class DomainScalar>
00707 void solve(
00708   const LinearOpWithSolveBase<RangeScalar,DomainScalar>   &A
00709   ,const EConj                                            conj
00710   ,const MultiVectorBase<RangeScalar>                     &B
00711   ,MultiVectorBase<DomainScalar>                          *X
00712   ,const int                                              numBlocks
00713   ,const BlockSolveCriteria<typename LinearOpWithSolveBase<RangeScalar,DomainScalar>::PromotedScalar>
00714                                                           blockSolveCriteria[]
00715 #ifndef __sun
00716                                                                                 = NULL
00717 #endif
00718   ,SolveStatus<typename LinearOpWithSolveBase<RangeScalar,DomainScalar>::PromotedScalar>
00719                                                           blockSolveStatus[]
00720 #ifndef __sun
00721                                                                                 = NULL
00722 #endif
00723   )
00724 {
00725   A.solve(conj,B,X,numBlocks,blockSolveCriteria,blockSolveStatus);
00726 }
00727 
00728 #ifdef __sun
00729 
00730 template<class RangeScalar, class DomainScalar>
00731 void solve(
00732   const LinearOpWithSolveBase<RangeScalar,DomainScalar>   &A
00733   ,const EConj                                            conj
00734   ,const MultiVectorBase<RangeScalar>                     &B
00735   ,MultiVectorBase<DomainScalar>                          *X
00736   ,const int                                              numBlocks
00737   ,const BlockSolveCriteria<typename LinearOpWithSolveBase<RangeScalar,DomainScalar>::PromotedScalar>
00738                                                           blockSolveCriteria[]
00739   )
00740 {
00741   solve(A,conj,B,X,numBlcoks,blockSolveCriteria,NULL);
00742 }
00743 
00744 template<class RangeScalar, class DomainScalar>
00745 void solve(
00746   const LinearOpWithSolveBase<RangeScalar,DomainScalar>   &A
00747   ,const EConj                                            conj
00748   ,const MultiVectorBase<RangeScalar>                     &B
00749   ,MultiVectorBase<DomainScalar>                          *X
00750   ,const int                                              numBlocks
00751   )
00752 {
00753   solve(A,conj,B,X,numBlcoks,NULL,NULL);
00754 }
00755 
00756 #endif // __sun
00757 
00765 template <class RangeScalar, class DomainScalar>
00766 void solveTranspose(
00767   const LinearOpWithSolveBase<RangeScalar,DomainScalar>   &A
00768   ,const EConj                                            conj
00769   ,const MultiVectorBase<DomainScalar>                    &B
00770   ,MultiVectorBase<RangeScalar>                           *X
00771   ,const int                                              numBlocks
00772   ,const BlockSolveCriteria<typename LinearOpWithSolveBase<RangeScalar,DomainScalar>::PromotedScalar>
00773                                                           blockSolveCriteria[]
00774 #ifndef __sun
00775                                                                                 = NULL
00776 #endif
00777   ,SolveStatus<typename LinearOpWithSolveBase<RangeScalar,DomainScalar>::PromotedScalar>
00778                                                           blockSolveStatus[]
00779 #ifndef __sun
00780                                                                                 = NULL
00781 #endif
00782   )
00783 {
00784   A.solveTranspose(conj,B,X,numBlocks,blockSolveCriteria,blockSolveStatus);
00785 }
00786 
00787 #ifdef __sun
00788 
00789 template <class RangeScalar, class DomainScalar>
00790 void solveTranspose(
00791   const LinearOpWithSolveBase<RangeScalar,DomainScalar>   &A
00792   ,const EConj                                            conj
00793   ,const MultiVectorBase<DomainScalar>                    &B
00794   ,MultiVectorBase<RangeScalar>                           *X
00795   ,const int                                              numBlocks
00796   ,const BlockSolveCriteria<typename LinearOpWithSolveBase<RangeScalar,DomainScalar>::PromotedScalar>
00797                                                           blockSolveCriteria[]
00798   )
00799 {
00800   solveTranspose(A,conj,B,X,numBlocks,blockSolveCriteria,NULL);
00801 }
00802 
00803 template <class RangeScalar, class DomainScalar>
00804 void solveTranspose(
00805   const LinearOpWithSolveBase<RangeScalar,DomainScalar>   &A
00806   ,const EConj                                            conj
00807   ,const MultiVectorBase<DomainScalar>                    &B
00808   ,MultiVectorBase<RangeScalar>                           *X
00809   ,const int                                              numBlocks
00810   )
00811 {
00812   solveTranspose(A,conj,B,X,numBlocks,NULL,NULL);
00813 }
00814 
00815 #endif // __sun
00816 
00818 
00819 } // namespace Thyra
00820 
00821 #endif // THYRA_LINEAR_OP_WITH_SOLVE_BASE_DECL_HPP
00822 
00823 
00824 
00825 
00826 

Generated on Thu Sep 18 12:33:02 2008 for Thyra Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1