ostream& InverseOperator::Print(std::ostream& os, const bool verbose) const { StackPush(); if (GetMyPID() == 0) { os << "***MLAPI::InverseOperator" << endl; os << "Label = " << GetLabel() << endl; os << "Number of rows = " << GetRangeSpace().GetNumGlobalElements() << endl; os << "Number of columns = " << GetRangeSpace().GetNumGlobalElements() << endl; os << "Flop count = " << GetFlops() << endl; os << "Cumulative time = " << GetTime() << endl; if (GetTime() != 0.0) os << "MFlops rate = " << 1.0e-6 * GetFlops() / GetTime() << endl; else os << "MFlops rate = 0.0" << endl; os << endl; } StackPop(); return(os); }
int InverseOperator::Apply(const MultiVector& x, MultiVector& y) const { ResetTimer(); StackPush(); if (GetDomainSpace() != x.GetVectorSpace()) ML_THROW("DomainSpace and x.GetVectorSpace() differ", -1); if (GetRangeSpace() != y.GetVectorSpace()) ML_THROW("RangeSpace and y.GetVectorSpace() differ", -1); int x_nv = x.GetNumVectors(); int y_nv = y.GetNumVectors(); double FL = 0.0; if (RCPData_ != Teuchos::null) FL = RCPData_->ComputeFlops(); if (x_nv != y_nv) ML_THROW("Number of vectors of x and y differ (" + GetString(x_nv) + " vs. " + GetString(x_nv), -1); for (int v = 0 ; v < x_nv ; ++v) { Epetra_Vector x_Epetra(View,RowMatrix()->OperatorDomainMap(), (double*)&(x(0,v))); Epetra_Vector y_Epetra(View,RowMatrix()->OperatorRangeMap(), (double*)&(y(0,v))); if (RCPData_ != Teuchos::null) RCPData_->ApplyInverse(x_Epetra,y_Epetra); else if (RCPMLPrec_ != Teuchos::null) RCPMLPrec_->ApplyInverse(x_Epetra,y_Epetra); else ML_THROW("Neither Ifpack nor ML smoother is properly set up", -1); } StackPop(); if (RCPData_ != Teuchos::null) UpdateFlops(RCPData_->ComputeFlops() - FL); UpdateTime(); return(0); }
std::ostream& MLAPI::DistributedMatrix:: Print(std::ostream& os, const bool verbose) const { if (GetMyPID() == 0) { os << std::endl; os << "*** MLAPI::DistributedMatrix ***" << std::endl; os << "Label = " << GetLabel() << std::endl; os << "Number of rows = " << GetRangeSpace().GetNumGlobalElements() << std::endl; os << "Number of columns = " << GetDomainSpace().GetNumGlobalElements() << std::endl; os << std::endl; os.width(10); os << "row ID"; os.width(10); os << "col ID"; os.width(30); os << "value"; os << std::endl; os << std::endl; } for (int iproc = 0 ; iproc < GetNumProcs() ; ++iproc) { if (GetMyPID() == iproc) { if (IsFillCompleted()) { for (int i = 0 ; i < NumMyRows() ; ++i) { int GRID = RangeMap_->GID(i); double* Values; int* Indices; int NumEntries; Matrix_->ExtractMyRowView(i, NumEntries, Values, Indices); for (int j = 0 ; j < NumEntries ; ++j) { os.width(10); os << GRID; os.width(10); os << Matrix_->RowMatrixColMap().GID(Indices[j]); os.width(30); os << Values[j]; os << std::endl; } } } else { for (int i = 0 ; i < NumMyRows() ; ++i) { int GRID = RangeMap_->GID(i); double* Values; int* Indices; int NumEntries; Matrix_->ExtractGlobalRowView(GRID, NumEntries, Values, Indices); for (int j = 0 ; j < NumEntries ; ++j) { os.width(10); os << GRID; os.width(10); os << Indices[j]; os.width(30); os << Values[j]; os << std::endl; } } } } Barrier(); } if (GetMyPID() == 0) os << std::endl; Barrier(); return(os); }