|
Thyra Package Browser (Single Doxygen Collection) Version of the Day
|
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_DIAGONAL_LINEAR_OP_WITH_SOLVE_HPP 00030 #define THYRA_DIAGONAL_LINEAR_OP_WITH_SOLVE_HPP 00031 00032 #include "Thyra_DefaultDiagonalLinearOpWithSolve_decl.hpp" 00033 #include "Thyra_DefaultDiagonalLinearOp.hpp" 00034 #include "Thyra_MultiVectorStdOps.hpp" 00035 #include "Thyra_VectorBase.hpp" 00036 #include "Thyra_TestingTools.hpp" // ToDo: I need to have a better way to get eps()! 00037 #include "Teuchos_Assert.hpp" 00038 00039 00040 namespace Thyra { 00041 00042 00043 // Constructors/initializers/accessors 00044 00045 00046 template<class Scalar> 00047 DefaultDiagonalLinearOpWithSolve<Scalar>::DefaultDiagonalLinearOpWithSolve() 00048 {} 00049 00050 00051 template<class Scalar> 00052 DefaultDiagonalLinearOpWithSolve<Scalar>::DefaultDiagonalLinearOpWithSolve( 00053 const RCP<const VectorBase<Scalar> > &diag 00054 ) 00055 { 00056 initialize(diag); 00057 } 00058 00059 00060 // protected 00061 00062 00063 // Overridden from LinearOpWithSolveBase 00064 00065 00066 template<class Scalar> 00067 bool 00068 DefaultDiagonalLinearOpWithSolve<Scalar>::solveSupportsImpl( 00069 EOpTransp M_trans) const 00070 { 00071 typedef Teuchos::ScalarTraits<Scalar> ST; 00072 return (ST::isComplex ? M_trans==NOTRANS || M_trans==TRANS : true); 00073 } 00074 00075 00076 template<class Scalar> 00077 bool 00078 DefaultDiagonalLinearOpWithSolve<Scalar>::solveSupportsSolveMeasureTypeImpl( 00079 EOpTransp M_trans, const SolveMeasureType& solveMeasureType) const 00080 { 00081 return this->solveSupportsImpl(M_trans); // I am a direct solver! 00082 } 00083 00084 00085 template<class Scalar> 00086 SolveStatus<Scalar> 00087 DefaultDiagonalLinearOpWithSolve<Scalar>::solveImpl( 00088 const EOpTransp transp, 00089 const MultiVectorBase<Scalar> &B, 00090 const Ptr<MultiVectorBase<Scalar> > &X, 00091 const Ptr<const SolveCriteria<Scalar> > solveCriteria 00092 ) const 00093 { 00094 00095 #ifdef THYRA_DEBUG 00096 TEUCHOS_ASSERT(this->solveSupportsImpl(transp)); 00097 #endif 00098 00099 typedef Teuchos::ScalarTraits<Scalar> ST; 00100 00101 assign(X, ST::zero()); 00102 00103 const Ordinal numCols = B.domain()->dim(); 00104 SolveStatus<Scalar> overallSolveStatus; 00105 00106 for (Ordinal col_j = 0; col_j < numCols; ++col_j) { 00107 00108 const RCP<const VectorBase<Scalar> > b = B.col(col_j); 00109 const RCP<VectorBase<Scalar> > x = X->col(col_j); 00110 00111 ele_wise_divide( ST::one(), *b, *this->getDiag(), x.ptr() ); 00112 00113 } 00114 00115 SolveStatus<Scalar> solveStatus; 00116 solveStatus.solveStatus = 00117 (nonnull(solveCriteria) && !solveCriteria->solveMeasureType.useDefault() 00118 ? SOLVE_STATUS_CONVERGED : SOLVE_STATUS_UNKNOWN ); 00119 solveStatus.achievedTol = SolveStatus<Scalar>::unknownTolerance(); 00120 return solveStatus; 00121 00122 } 00123 00124 00125 } // end namespace Thyra 00126 00127 00128 #endif // THYRA_DIAGONAL_LINEAR_OP_WITH_SOLVE_HPP
1.7.4