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_));
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_;
151 for (
int j = 0 ; j < NumRows_ ; ++j) {
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) {
175 &Values[0], &Indices[0]);
176 IFPACK_CHK_ERR(ierr);
178 for (
int k = 0 ; k < NumEntries ; ++k) {
180 int LCID = Indices[k];
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;
virtual double ComputeFlops() const
Returns the flops in Compute().
virtual const Epetra_IntSerialDenseVector & ID() const
Returns the integer dense vector of IDs.
virtual int Compute(const Epetra_RowMatrix &Matrix_in)
Finalizes the linear system matrix and prepares for the application of the inverse.
virtual std::ostream & Print(std::ostream &os) const
Prints basic information on iostream. This function is used by operator<<.
virtual int SetMatrixElement(const int row, const int col, const double value)
Set the matrix element (row,col) to value.
int SetVectors(Epetra_SerialDenseMatrix &X, Epetra_SerialDenseMatrix &B)
virtual int NumVectors() const
Returns the number of vectors in LHS/RHS.
virtual double ApplyInverseFlops() const
Returns the flops in ApplyInverse().
virtual bool IsInitialized() const
Returns true is the container has been successfully initialized.
virtual int MaxNumEntries() const =0
virtual int Apply()
Apply the matrix to RHS, results are stored in LHS.
virtual bool IsComputed() const
Returns true is the container has been successfully computed.
virtual const Epetra_SerialDenseMatrix & LHS() const
Returns the dense vector containing the LHS.
virtual int NumMyRows() const =0
virtual int Initialize()
Initialize the container.
int Reshape(int NumRows, int NumCols)
virtual int ApplyInverse()
Apply the inverse of the matrix to RHS, results are stored in LHS.
virtual int NumRows() const
Returns the number of rows of the matrix and LHS/RHS.
int SetMatrix(Epetra_SerialDenseMatrix &A)
int Multiply(char TransA, char TransB, double ScalarAB, const Epetra_SerialDenseMatrix &A, const Epetra_SerialDenseMatrix &B, double ScalarThis)
int Reshape(int NumRows, int NumCols)
virtual int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const =0
virtual const Epetra_SerialDenseMatrix & RHS() const
Returns the dense vector containing the RHS.