42 #include "Ifpack_SerialTriDiSolver.h"
43 #include "Ifpack_SerialTriDiMatrix.h"
44 #include "Epetra_SerialDenseVector.h"
53 EstimateSolutionErrors_(false),
54 SolutionErrorsEstimated_(false),
57 ReciprocalConditionEstimated_(false),
58 RefineSolution_(false),
59 SolutionRefined_(false),
98 void Ifpack_SerialTriDiSolver::InitPointers()
112 void Ifpack_SerialTriDiSolver::DeleteArrays()
114 if (IWORK_ != 0) {
delete [] IWORK_;IWORK_ = 0;}
115 if (FERR_ != 0) {
delete [] FERR_; FERR_ = 0;}
116 if (BERR_ != 0) {
delete [] BERR_; BERR_ = 0;}
117 if (Factor_ != Matrix_ && Factor_ != 0) {
delete Factor_; Factor_ = 0;}
118 if (Factor_ !=0) Factor_ = 0;
120 if (IPIV_ != 0) {
delete [] IPIV_;IPIV_ = 0;}
121 if (WORK_ != 0) {
delete [] WORK_;WORK_ = 0;}
123 if (AF_ !=0) AF_ = 0;
129 void Ifpack_SerialTriDiSolver::ResetMatrix()
161 void Ifpack_SerialTriDiSolver::ResetVectors()
167 ReciprocalConditionEstimated_ =
false;
168 SolutionRefined_ =
false;
170 SolutionErrorsEstimated_ =
false;
178 if (B_in.
N() != X_in.
N()) EPETRA_CHK_ERR(-1);
179 if (B_in.
A()==0) EPETRA_CHK_ERR(-2);
180 if (X_in.
A()==0) EPETRA_CHK_ERR(-4);
193 EstimateSolutionErrors_ = Flag;
195 RefineSolution_ = RefineSolution_ || Flag;
201 if (
Inverted()) EPETRA_CHK_ERR(-100);
211 if (RefineSolution_ ) {
215 LDAF_ = Factor_->LDA();
218 if (IPIV_==0) IPIV_ =
new int[N_];
220 double * DL_ = F->
DL();
221 double * D_ = F->D();
222 double * DU_ = F->DU();
223 double * DU2_ = F->DU2();
225 lapack.GTTRF(N_, DL_, D_, DU_, DU2_, IPIV_, &INFO_);
229 UpdateFlops( (N_ == 1)? 1. : 4*(DN-1) );
231 EPETRA_CHK_ERR(INFO_);
249 if (B_==0) EPETRA_CHK_ERR(-3);
250 if (X_==0) EPETRA_CHK_ERR(-4);
253 double DNRHS = NRHS_;
256 EPETRA_CHK_ERR(-101);
274 double * DL_ = F->
DL();
275 double * D_ = F->D();
276 double * DU_ = F->DU();
277 double * DU2_ = F->DU2();
279 lapack.GTTRS(TRANS_,N_,NRHS_,DL_,D_,DU_,DU2_,IPIV_,X_,N_,&INFO_);
281 if (INFO_!=0) EPETRA_CHK_ERR(INFO_);
282 UpdateFlops(2.0*4*DN*DNRHS);
288 if (ierr1!=0) EPETRA_CHK_ERR(ierr1)
290 EPETRA_CHK_ERR(ierr);
297 std::cout<<
" SerialTriDiSolver::ApplyRefinement this function is not supported"<<std::endl;
298 EPETRA_CHK_ERR(-102);
310 lapack.GETRI ( N_, AF_, LDAF_, IPIV_, WORK_, LWORK_, &INFO_);
313 UpdateFlops((DN*DN*DN));
317 EPETRA_CHK_ERR(INFO_);
330 if (ANORM_<0.0) ANORM_ = Matrix_->
OneNorm();
332 if (ierr!=0) EPETRA_CHK_ERR(ierr-2);
337 lapack.GECON(
'1', N_, AF_, LDAF_, ANORM_, &RCOND_, WORK_, IWORK_, &INFO_);
338 ReciprocalConditionEstimated_ =
true;
340 UpdateFlops(2*N_*N_);
341 EPETRA_CHK_ERR(INFO_);
347 if (Matrix_!=0) os <<
"Solver Matrix" << std::endl << *Matrix_ << std::endl;
348 if (Factor_!=0) os <<
"Solver Factored Matrix" << std::endl << *Factor_ << std::endl;
349 if (LHS_ !=0) os <<
"Solver LHS" << std::endl << *LHS_ << std::endl;
350 if (RHS_ !=0) os <<
"Solver RHS" << std::endl << *RHS_ << std::endl;
virtual int Invert(void)
Inverts the this matrix.
Ifpack_SerialTriDiSolver()
Default constructor; matrix should be set using SetMatrix(), LHS and RHS set with SetVectors()...
virtual int Solve(void)
Computes the solution X to AX = B for the this matrix and the B provided to SetVectors()..
virtual int ApplyRefinement(void)
Apply Iterative Refinement.
virtual int Factor(void)
Computes the in-place LU factorization of the matrix using the LAPACK routine DGETRF.
int SetMatrix(Ifpack_SerialTriDiMatrix &A)
Sets the pointers for coefficient matrix.
virtual ~Ifpack_SerialTriDiSolver()
Ifpack_SerialTriDiSolver destructor.
bool Inverted()
Returns true if matrix inverse has been computed (inverse available via AF() and LDAF()).
void EstimateSolutionErrors(bool Flag)
Causes all solves to estimate the forward and backward solution error.
bool Factored()
Returns true if matrix is factored (factor available via AF() and LDAF()).
virtual double OneNorm() const
Computes the 1-Norm of the this matrix (identical to NormOne() method).
double * DL()
Returns pointer to the this matrix.
virtual int ReciprocalConditionEstimate(double &Value)
Unscales the solution vectors if equilibration was used to solve the system.
double * A() const
Returns pointer to the this matrix.
bool ReciprocalConditionEstimated()
Returns true if the condition number of the this matrix has been computed (value available via Recipr...
int N() const
Returns column dimension of system.
Ifpack_SerialTriDiMatrix: A class for constructing and using real double precision general TriDi matr...
int SetVectors(Epetra_SerialDenseMatrix &X, Epetra_SerialDenseMatrix &B)
Sets the pointers for left and right hand side vector(s).
virtual void Print(std::ostream &os) const
Print service methods; defines behavior of ostream << operator.