|
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 00030 #ifndef THYRA_DEFAULT_SERIAL_DENSE_LINEAR_OP_WITH_SOLVE_DECL_HPP 00031 #define THYRA_DEFAULT_SERIAL_DENSE_LINEAR_OP_WITH_SOLVE_DECL_HPP 00032 00033 00034 #include "Thyra_LinearOpWithSolveBase.hpp" 00035 #include "RTOpPack_LapackWrappers.hpp" 00036 00037 00038 namespace Thyra { 00039 00040 00041 /* \brief . */ 00042 inline RTOpPack::ETransp convertToRTOpPackETransp( const EOpTransp transp ) 00043 { 00044 #ifdef TEUCHOS_DEBUG 00045 TEST_FOR_EXCEPT(transp == CONJ); 00046 #endif 00047 switch(transp) { 00048 case NOTRANS: 00049 return RTOpPack::NOTRANS; 00050 case TRANS: 00051 return RTOpPack::TRANS; 00052 case CONJTRANS: 00053 return RTOpPack::CONJTRANS; 00054 default: 00055 TEST_FOR_EXCEPT(true); 00056 } 00057 return RTOpPack::NOTRANS; // will never be called! 00058 } 00059 // ToDo: Move the above function into Thyra_OperatorVectorTypes.hpp 00060 00061 00077 template<class Scalar> 00078 class DefaultSerialDenseLinearOpWithSolve 00079 : virtual public LinearOpWithSolveBase<Scalar> 00080 { 00081 public: 00082 00085 00087 DefaultSerialDenseLinearOpWithSolve(); 00088 00090 void initialize( const RCP<const MultiVectorBase<Scalar> > &M ); 00091 00093 RCP<const LinearOpBase<Scalar> > getFwdOp() const; 00094 00096 00099 00101 RCP<const VectorSpaceBase<Scalar> > range() const; 00103 RCP<const VectorSpaceBase<Scalar> > domain() const; 00104 00106 00107 protected: 00108 00111 00113 bool opSupportedImpl(EOpTransp M_trans) const; 00115 void applyImpl( 00116 const EOpTransp M_trans, 00117 const MultiVectorBase<Scalar> &X, 00118 const Ptr<MultiVectorBase<Scalar> > &Y, 00119 const Scalar alpha, 00120 const Scalar beta 00121 ) const; 00122 00124 00127 00129 bool solveSupportsImpl(EOpTransp M_trans) const; 00131 bool solveSupportsSolveMeasureTypeImpl( 00132 EOpTransp M_trans, const SolveMeasureType& solveMeasureType) const; 00134 SolveStatus<Scalar> solveImpl( 00135 const EOpTransp transp, 00136 const MultiVectorBase<Scalar> &B, 00137 const Ptr<MultiVectorBase<Scalar> > &X, 00138 const Ptr<const SolveCriteria<Scalar> > solveCriteria 00139 ) const; 00140 00142 00143 private: 00144 00145 // ///////////////////////// 00146 // Private data members 00147 00148 RCP<const MultiVectorBase<Scalar> > M_; 00149 RTOpPack::ConstSubMultiVectorView<Scalar> LU_; 00150 Array<int> ipiv_; 00151 00152 // ///////////////////////// 00153 // Private member functions 00154 00155 static void factorize( 00156 const MultiVectorBase<Scalar> &M, 00157 const Ptr<RTOpPack::ConstSubMultiVectorView<Scalar> > &LU, 00158 const Ptr<Array<int> > &ipiv 00159 ); 00160 00161 static void backsolve( 00162 const RTOpPack::ConstSubMultiVectorView<Scalar> &LU, 00163 const ArrayView<const int> ipiv, 00164 const EOpTransp transp, 00165 const MultiVectorBase<Scalar> &B, 00166 const Ptr<MultiVectorBase<Scalar> > &X 00167 ); 00168 00169 // Not defined and not to be called 00170 DefaultSerialDenseLinearOpWithSolve(const DefaultSerialDenseLinearOpWithSolve&); 00171 DefaultSerialDenseLinearOpWithSolve& operator=(const DefaultSerialDenseLinearOpWithSolve&); 00172 00173 }; 00174 00175 00180 template<class Scalar> 00181 RCP<DefaultSerialDenseLinearOpWithSolve<Scalar> > 00182 defaultSerialDenseLinearOpWithSolve() 00183 { 00184 return Teuchos::rcp(new DefaultSerialDenseLinearOpWithSolve<Scalar>); 00185 } 00186 00187 00192 template<class Scalar> 00193 RCP<DefaultSerialDenseLinearOpWithSolve<Scalar> > 00194 defaultSerialDenseLinearOpWithSolve( const RCP<const MultiVectorBase<Scalar> > &M ) 00195 { 00196 RCP<DefaultSerialDenseLinearOpWithSolve<Scalar> > 00197 M_lows = Teuchos::rcp(new DefaultSerialDenseLinearOpWithSolve<Scalar>()); 00198 M_lows->initialize(M); // With throw if singular 00199 return M_lows; 00200 } 00201 00202 00203 } // end namespace Thyra 00204 00205 00206 #endif // THYRA_DEFAULT_SERIAL_DENSE_LINEAR_OP_WITH_SOLVE_DECL_HPP
1.7.4