43 #include "Ifpack_ConfigDefs.h"
44 #include "Ifpack_DenseContainer.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_));
65 for (
int i = 0 ; i < NumRows_ ; ++i)
66 for (
int j = 0 ; j < NumRows_ ; ++j)
70 for (
int i = 0 ; i < NumRows_ ; ++i)
71 for (
int j = 0 ; j < NumVectors_ ; ++j) {
77 for (
int i = 0 ; i < NumRows_ ; ++i)
81 IFPACK_CHK_ERR(Solver_.SetMatrix(Matrix_));
82 IFPACK_CHK_ERR(Solver_.SetVectors(LHS_,RHS_));
85 IsInitialized_ =
true;
93 return(LHS_.A()[Vector * NumRows_ + i]);
99 return(RHS_.A()[Vector * NumRows_ + i]);
109 if ((row < 0) || (row >=
NumRows())) {
113 if ((col < 0) || (col >=
NumRows())) {
117 Matrix_(row, col) = value;
132 IFPACK_CHK_ERR(Solver_.Solve());
134 #ifdef IFPACK_FLOPCOUNTERS
135 ApplyInverseFlops_ += 2.0 * NumVectors_ * NumRows_ * NumRows_;
148 int Ifpack_DenseContainer::Extract(
const Epetra_RowMatrix& Matrix_in)
151 for (
int j = 0 ; j < NumRows_ ; ++j) {
156 if (
ID(j) > Matrix_in.NumMyRows())
161 int Length = Matrix_in.MaxNumEntries();
162 std::vector<double> Values;
163 Values.resize(Length);
164 std::vector<int> Indices;
165 Indices.resize(Length);
167 for (
int j = 0 ; j < NumRows_ ; ++j) {
174 Matrix_in.ExtractMyRowCopy(LRID, Length, NumEntries,
175 &Values[0], &Indices[0]);
176 IFPACK_CHK_ERR(ierr);
178 for (
int k = 0 ; k < NumEntries ; ++k) {
180 int LCID = Indices[k];
183 if (LCID >= Matrix_in.NumMyRows())
190 for (
int kk = 0 ; kk < NumRows_ ; ++kk)
211 if (KeepNonFactoredMatrix_)
212 NonFactoredMatrix_ = Matrix_;
215 IFPACK_CHK_ERR(Extract(Matrix_in));
217 if (KeepNonFactoredMatrix_)
218 NonFactoredMatrix_ = Matrix_;
222 IFPACK_CHK_ERR(Solver_.Factor());
224 Label_ =
"Ifpack_DenseContainer";
227 #ifdef IFPACK_FLOPCOUNTERS
228 ComputeFlops_ += 4.0 * NumRows_ * NumRows_ * NumRows_ / 3;
241 if (KeepNonFactoredMatrix_) {
242 IFPACK_CHK_ERR(RHS_.Multiply(
'N',
'N', 1.0,NonFactoredMatrix_,LHS_,0.0));
245 IFPACK_CHK_ERR(RHS_.Multiply(
'N',
'N', 1.0,Matrix_,LHS_,0.0));
247 #ifdef IFPACK_FLOPCOUNTERS
248 ApplyFlops_ += 2 * NumRows_ * NumRows_;
258 os <<
"================================================================================" << endl;
259 os <<
"Ifpack_DenseContainer" << endl;
260 os <<
"Number of rows = " <<
NumRows() << endl;
261 os <<
"Number of vectors = " <<
NumVectors() << endl;
263 os <<
"IsComputed() = " <<
IsComputed() << endl;
264 #ifdef IFPACK_FLOPCOUNTERS
265 os <<
"Flops in Compute() = " <<
ComputeFlops() << endl;
268 os <<
"================================================================================" << endl;