IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends
Ifpack_SerialTriDiSolver.h
00001 /*
00002 //@HEADER
00003 // ************************************************************************
00004 //
00005 //               Epetra: Linear Algebra Services Package
00006 //                 Copyright 2011 Sandia Corporation
00007 //
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00039 //
00040 // ************************************************************************
00041 //@HEADER
00042 */
00043 
00044 #ifndef IFPACK_SERIALTRIDISOLVER_H
00045 #define IFPACK_SERIALTRIDISOLVER_H
00046 class Ifpack_SerialTriDiMatrix;
00047 //class Epetra_SerialDenseVector;
00048 class Epetra_SerialDenseMatrix;
00049 
00050 #include "Epetra_Object.h"
00051 #include "Epetra_CompObject.h"
00052 #include "Epetra_BLAS.h"
00053 #include "Teuchos_LAPACK.hpp"
00054 
00055 
00057 
00129 //=========================================================================
00130 class EPETRA_LIB_DLL_EXPORT Ifpack_SerialTriDiSolver :
00131   public Epetra_CompObject, public Epetra_BLAS,
00132   public Epetra_Object    {
00133   public:
00134   
00136 
00137 
00138   Ifpack_SerialTriDiSolver();
00139 
00140 
00142   virtual ~Ifpack_SerialTriDiSolver();
00144 
00146 
00147 
00149   int SetMatrix(Ifpack_SerialTriDiMatrix & A);
00150 
00152 
00155   int SetVectors(Epetra_SerialDenseMatrix & X, Epetra_SerialDenseMatrix & B);
00157 
00158 
00160 
00161 
00163 
00165   //  void FactorWithEquilibration(bool Flag) {Equilibrate_ = Flag; return;};
00166 
00168   void SolveWithTranspose(bool Flag) {Transpose_ = Flag; if (Flag) TRANS_ = 'T'; else TRANS_ = 'N'; return;};
00169 
00171   void SolveToRefinedSolution(bool Flag) {RefineSolution_ = Flag; return;};
00172 
00174 
00177   void EstimateSolutionErrors(bool Flag) ;
00179 
00181 
00182 
00184 
00187   virtual int Factor(void);
00188 
00190 
00193   virtual int Solve(void);
00194 
00196 
00199   virtual int Invert(void);
00200 
00202 
00205   virtual int ApplyRefinement(void);
00206 
00208 
00211   // int UnequilibrateLHS(void);
00212 
00214 
00220   virtual int ReciprocalConditionEstimate(double & Value);
00222 
00224 
00225 
00227   bool Transpose() {return(Transpose_);};
00228 
00230   bool Factored() {return(Factored_);};
00231 
00233   bool SolutionErrorsEstimated() {return(SolutionErrorsEstimated_);};
00234 
00236   bool Inverted() {return(Inverted_);};
00237 
00239   bool ReciprocalConditionEstimated() {return(ReciprocalConditionEstimated_);};
00240 
00242   bool Solved() {return(Solved_);};
00243 
00245   bool SolutionRefined() {return(SolutionRefined_);};
00247 
00249 
00250 
00252    Ifpack_SerialTriDiMatrix * Matrix()  const {return(Matrix_);};
00253 
00255    Ifpack_SerialTriDiMatrix * FactoredMatrix()  const {return(Factor_);};
00256 
00258   Epetra_SerialDenseMatrix * LHS()  const {return(LHS_);};
00259 
00261   Epetra_SerialDenseMatrix * RHS()  const {return(RHS_);};
00262 
00264   int N()  const {return(N_);};
00265 
00267   double * A()  const {return(A_);};
00268 
00270   int LDA()  const {return(LDA_);};
00271 
00273   double * B()  const {return(B_);};
00274 
00276   int LDB()  const {return(LDB_);};
00277 
00279   int NRHS()  const {return(NRHS_);};
00280 
00282   double * X()  const {return(X_);};
00283 
00285   int LDX()  const {return(LDX_);};
00286 
00288   double * AF()  const {return(AF_);};
00289 
00291   int LDAF()  const {return(LDAF_);};
00292 
00294   int * IPIV()  const {return(IPIV_);};
00295 
00297   double ANORM()  const {return(ANORM_);};
00298 
00300   double RCOND()  const {return(RCOND_);};
00301 
00303 
00305   double ROWCND()  const {return(ROWCND_);};
00306 
00308 
00310   double COLCND()  const {return(COLCND_);};
00311 
00313   double AMAX()  const {return(AMAX_);};
00314 
00316   double * FERR()  const {return(FERR_);};
00317 
00319   double * BERR()  const {return(BERR_);};
00320 
00322 
00324 
00325 
00326   virtual void Print(std::ostream& os) const;
00328  protected:
00329 
00330   void AllocateWORK() {if (WORK_==0) {LWORK_ = 4*N_; WORK_ = new double[LWORK_];} return;};
00331   void AllocateIWORK() {if (IWORK_==0) IWORK_ = new int[N_]; return;};
00332   void InitPointers();
00333   void DeleteArrays();
00334   void ResetMatrix();
00335   void ResetVectors();
00336 
00337   bool Transpose_;
00338   bool Factored_;
00339   bool EstimateSolutionErrors_;
00340   bool SolutionErrorsEstimated_;
00341   bool Solved_;
00342   bool Inverted_;
00343   bool ReciprocalConditionEstimated_;
00344   bool RefineSolution_;
00345   bool SolutionRefined_;
00346 
00347   char TRANS_;
00348 
00349   int N_;
00350   int Min_MN_;
00351   int NRHS_;
00352   int LDA_;
00353   int LDAF_;
00354   int LDB_;
00355   int LDX_;
00356   int INFO_;
00357   int LWORK_;
00358 
00359   int * IPIV_;
00360   int * IWORK_;
00361 
00362   double ANORM_;
00363   double RCOND_;
00364   double ROWCND_;
00365   double COLCND_;
00366   double AMAX_;
00367 
00368   Ifpack_SerialTriDiMatrix * Matrix_;
00369   Epetra_SerialDenseMatrix * LHS_;
00370   Epetra_SerialDenseMatrix * RHS_;
00371   Ifpack_SerialTriDiMatrix * Factor_;
00372 
00373   double * A_;
00374   double * FERR_;
00375   double * BERR_;
00376   double * AF_;
00377   double * WORK_;
00378 
00379   double * B_;
00380   double * X_;
00381 
00382 
00383  private:
00384   Teuchos::LAPACK<int,double> lapack;
00385   // Ifpack_SerialTriDiSolver copy constructor (put here because we don't want user access)
00386 
00387   Ifpack_SerialTriDiSolver(const Ifpack_SerialTriDiSolver& Source);
00388   Ifpack_SerialTriDiSolver & operator=(const Ifpack_SerialTriDiSolver& Source);
00389 };
00390 
00391 #endif /* EPETRA_SERIALTRIDISOLVER_H */
 All Classes Files Functions Variables Enumerations Friends