43 #include "Ifpack_ConfigDefs.h"
44 #include "Ifpack_TriDiContainer.h"
45 #include "Epetra_RowMatrix.h"
57 IsInitialized_ =
false;
59 IFPACK_CHK_ERR(LHS_.Reshape(NumRows_,NumVectors_));
60 IFPACK_CHK_ERR(RHS_.Reshape(NumRows_,NumVectors_));
61 IFPACK_CHK_ERR(ID_.Reshape(NumRows_,NumVectors_));
62 IFPACK_CHK_ERR(Matrix_.Reshape(NumRows_,NumRows_));
69 if(Matrix_.
A() == NULL ) Matrix_.
Shape(NumRows_);
70 int size = (NumRows_ == 1) ? 1 : 4*(NumRows_ -1);
71 memset(Matrix_.
A(),0,
sizeof(double)*size);
74 for (
int i = 0 ; i < NumRows_ ; ++i)
75 for (
int j = 0 ; j < NumVectors_ ; ++j) {
81 for (
int i = 0 ; i < NumRows_ ; ++i)
85 IFPACK_CHK_ERR(Solver_.
SetMatrix(Matrix_));
89 IsInitialized_ =
true;
97 return(LHS_.A()[Vector * NumRows_ + i]);
103 return(RHS_.A()[Vector * NumRows_ + i]);
113 if ((row < 0) || (row >=
NumRows())) {
117 if ((col < 0) || (col >=
NumRows())) {
121 Matrix_(row, col) = value;
136 IFPACK_CHK_ERR(Solver_.
Solve());
138 #ifdef IFPACK_FLOPCOUNTERS
139 ApplyInverseFlops_ += 2.0 * NumVectors_ * NumRows_ * NumRows_;
152 int Ifpack_TriDiContainer::Extract(
const Epetra_RowMatrix& Matrix_in)
155 for (
int j = 0 ; j < NumRows_ ; ++j) {
160 if (
ID(j) > Matrix_in.NumMyRows())
165 int Length = Matrix_in.MaxNumEntries();
166 std::vector<double> Values;
167 Values.resize(Length);
168 std::vector<int> Indices;
169 Indices.resize(Length);
171 for (
int j = 0 ; j < NumRows_ ; ++j) {
178 Matrix_in.ExtractMyRowCopy(LRID, Length, NumEntries,
179 &Values[0], &Indices[0]);
180 IFPACK_CHK_ERR(ierr);
182 for (
int k = 0 ; k < NumEntries ; ++k) {
184 int LCID = Indices[k];
187 if (LCID >= Matrix_in.NumMyRows())
194 for (
int kk = 0 ; kk < NumRows_ ; ++kk)
215 if (KeepNonFactoredMatrix_)
216 NonFactoredMatrix_ = Matrix_;
219 IFPACK_CHK_ERR(Extract(Matrix_in));
221 if (KeepNonFactoredMatrix_)
222 NonFactoredMatrix_ = Matrix_;
226 IFPACK_CHK_ERR(Solver_.
Factor());
228 Label_ =
"Ifpack_TriDiContainer";
231 #ifdef IFPACK_FLOPCOUNTERS
232 ComputeFlops_ += 4.0 * NumRows_ * NumRows_ * NumRows_ / 3;
242 IFPACK_CHK_ERR(-300);
263 os <<
"================================================================================" << endl;
264 os <<
"Ifpack_TriDiContainer" << endl;
265 os <<
"Number of rows = " <<
NumRows() << endl;
266 os <<
"Number of vectors = " <<
NumVectors() << endl;
268 os <<
"IsComputed() = " <<
IsComputed() << endl;
269 #ifdef IFPACK_FLOPCOUNTERS
270 os <<
"Flops in Compute() = " <<
ComputeFlops() << endl;
273 os <<
"================================================================================" << endl;