Thyra_DefaultDiagonalLinearOpWithSolve.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_DIAGONAL_LINEAR_OP_WITH_SOLVE_HPP
00030 #define THYRA_DIAGONAL_LINEAR_OP_WITH_SOLVE_HPP
00031 
00032 #include "Thyra_DefaultDiagonalLinearOpWithSolveDecl.hpp"
00033 #include "Thyra_DefaultDiagonalLinearOp.hpp"
00034 #include "Thyra_SingleRhsLinearOpWithSolveBase.hpp"
00035 #include "Thyra_VectorBase.hpp"
00036 #include "Thyra_TestingTools.hpp" // ToDo: I need to have a better way to get eps()!
00037 
00038 namespace Thyra {
00039 
00040 // Constructors/initializers/accessors
00041 
00042 template<class Scalar>
00043 DefaultDiagonalLinearOpWithSolve<Scalar>::DefaultDiagonalLinearOpWithSolve()
00044 {}
00045 
00046 template<class Scalar>
00047 DefaultDiagonalLinearOpWithSolve<Scalar>::DefaultDiagonalLinearOpWithSolve(
00048   const Teuchos::RCP<const VectorBase<Scalar> >   &diag
00049   )
00050 {
00051   initialize(diag);
00052 }
00053 
00054 // protected
00055 
00056 // Overridden from SingleScalarLinearOpWithSolveBase
00057 
00058 template<class Scalar>
00059 bool DefaultDiagonalLinearOpWithSolve<Scalar>::solveSupportsTrans(ETransp M_trans) const
00060 {
00061   return true; // ToDo: Update this!
00062 }
00063 
00064 template<class Scalar>
00065 bool DefaultDiagonalLinearOpWithSolve<Scalar>::solveSupportsSolveMeasureType(ETransp M_trans, const SolveMeasureType& solveMeasureType) const
00066 {
00067   return true;
00068 }
00069 
00070 // Overridden from SingleRhsLinearOpWithSolveBase
00071 
00072 template<class Scalar>
00073 SolveStatus<Scalar> DefaultDiagonalLinearOpWithSolve<Scalar>::solve(
00074   const ETransp                         M_trans
00075   ,const VectorBase<Scalar>             &b
00076   ,VectorBase<Scalar>                   *x
00077   ,const SolveCriteria<Scalar>          *solveCriteria
00078   ) const
00079 {
00080   // RAB: 4/16/2005: Warning! this does not work if Scalar is a complex type
00081   // and M_trans==CONJTRANS!
00082   typedef Teuchos::ScalarTraits<Scalar> ST;
00083   typedef typename ST::magnitudeType ScalarMag;
00084   typedef Teuchos::ScalarTraits<ScalarMag> SMT;
00085   typedef SolveCriteria<Scalar> SC;
00086   typedef SolveStatus<Scalar>   SS;
00087   assign(x,ST::zero());
00088   ele_wise_divide( ST::one(), b, *this->getDiag(), x );
00089   SS solveStatus;
00090   solveStatus.solveStatus
00091     = (solveCriteria && !solveCriteria->solveMeasureType.useDefault()
00092        ? SOLVE_STATUS_CONVERGED : SOLVE_STATUS_UNKNOWN );
00093   solveStatus.achievedTol = SolveStatus<Scalar>::unknownTolerance();
00094   return solveStatus;
00095 }
00096 
00097 } // end namespace Thyra
00098 
00099 #endif  // THYRA_DIAGONAL_LINEAR_OP_WITH_SOLVE_HPP

Generated on Tue Oct 20 12:47:11 2009 for Thyra Operator Solve Support by doxygen 1.4.7