43 #include "Ifpack_SerialTriDiMatrix.h" 
   44 #include "Epetra_Util.h" 
   56   if (set_object_label) {
 
   57     SetLabel(
"Epetra::SerialTriDiMatrix");
 
   63                                                    bool set_object_label)
 
   72   if (set_object_label) {
 
   73     SetLabel(
"Epetra::SerialTriDiMatrix");
 
   76         throw ReportError(
"NumRows = " + toString(NumRowCol) + 
". Should be >= 0", -1);
 
   78   int errorcode = 
Shape(NumRowCol);
 
   80     throw ReportError(
"Shape returned non-zero value", errorcode);
 
   86                                                    bool set_object_label)
 
   95   if (set_object_label) {
 
   96     SetLabel(
"Epetra::SerialTriDiMatrix");
 
   99         throw ReportError(
"Null pointer passed as A parameter.", -3);
 
  101     throw ReportError(
"NumRowCol = " + toString(NumRowCol) + 
". Should be >= 0", -1);
 
  104     const int newsize = (N_ == 1) ? 1 : 4*(N_-1);
 
  106       A_ = 
new double[newsize];
 
  107       CopyMat(A_in, N_, A_, N_);
 
  128   SetLabel(Source.
Label());
 
  130     const int newsize =  (N_ == 1)? 1 : 4*(N_-1);
 
  132       A_ = 
new double[newsize];
 
  133       CopyMat(Source.A_, Source.
N() , A_, N_);
 
  147 int Ifpack_SerialTriDiMatrix::Reshape(
int NumRows, 
int NumCols) {
 
  148         if(NumRows < 0 || NumCols < 0)
 
  150         if(NumRows != NumCols)
 
  154         const int newsize = (N_ == 1)? 1 : 4*(N_-1);
 
  157                 A_tmp = 
new double[newsize];
 
  158                 for (
int k = 0; k < newsize; k++)
 
  161                   CopyMat(A_, N_, A_tmp, NumRows); 
 
  180         if(NumRowCol < 0 || NumRowCol < 0)
 
  186   const int newsize = (N_ == 1)? 1 : 4*(N_-1);
 
  188     A_ = 
new double[newsize];
 
  189     for (
int k = 0; k < newsize; k++)
 
  209 void Ifpack_SerialTriDiMatrix::CleanupData()
 
  213         A_ = DL_ = D_ = DU_ = DU2_ =  0;
 
  221         if((CV_ == 
View) && (Source.CV_ == 
View) && (A_ == Source.A_))
 
  225                 throw ReportError(
"operator= type mismatch (lhs = " + std::string(
Label()) +
 
  226       ", rhs = " + std::string(Source.
Label()) + 
").", -5);
 
  228         if(Source.CV_ == 
View) {
 
  244                         const int newsize = 4*N_ - 4;
 
  246                                 A_ = 
new double[newsize];
 
  255                                 DL_ = D_ = DU_ = DU2_ = 0;
 
  260                         if(Source.N_ == N_) { 
 
  266                                 const int newsize = (N_ == 1)? 1 : 4*(N_-1);
 
  268                                         A_ = 
new double[newsize];
 
  277                 CopyMat(Source.A_, Source.
N(), A_, N_); 
 
  287   if (N_ != rhs.N_) 
return(
false);
 
  289   const double* A_tmp = A_;
 
  290   const double* rhsA = rhs.A_;
 
  292   const int size = (N_ == 1)? 1 : 4*(N_-1);
 
  294   for(
int j=0; j<size; ++j) {
 
  295     if (std::abs(A_tmp[j] - rhsA[j]) > Epetra_MinDouble) {
 
  305     if (
N() != Source.
N())
 
  306                 throw ReportError(
"Column dimension of source = " + toString(Source.
N()) +
 
  307                                                                                         " is different than column dimension of target = " + toString(
N()), -2);
 
  309     CopyMat(Source.
A(), Source.
N(), 
A(), 
N(),
true);
 
  313 void Ifpack_SerialTriDiMatrix::CopyMat(
const double* Source,
 
  319   int lmax = EPETRA_MIN(nrowcol,tN);
 
  322     for(
int j=0; j<lmax; ++j) {
 
  323       Target[(tN-1)+j] += Source[(nrowcol-1)+j];  
 
  325         Target[j] += Source[j];  
 
  326         Target[(tN-1)+tN + j] += Source[(nrowcol-1)+ nrowcol + j]; 
 
  328       if(j<tN-2) Target[(tN-1)*2 + tN + j] += Source[ (nrowcol-1)*2 +nrowcol  + j]; 
 
  332     for(
int j=0; j<lmax; ++j) {
 
  333       Target[(tN-1)+j] = Source[(nrowcol-1)+j];  
 
  335         Target[j] = Source[j];  
 
  336         Target[(tN-1)+tN + j] = Source[(nrowcol-1)+ nrowcol + j]; 
 
  338       if(j<tN-2) Target[(tN-1)*2 + tN + j] = Source[ (nrowcol-1)*2 +nrowcol  + j]; 
 
  350   const int size = (N_ == 1)? 1 : 4*(N_-1);
 
  352   for (i=0; i<size; i++) sum += std::abs(*ptr++);
 
  354   anorm = EPETRA_MAX(anorm, sum);
 
  355   UpdateFlops((
double)size );
 
  370   const int size = (N_ == 1)? 1 : 4*(N_-1);
 
  372   for (i=0; i<size ; i++) { *ptr = ScalarA * (*ptr); ptr++; }
 
  374   UpdateFlops((
double)N_*(
double)N_);
 
  384   throw ReportError(
"Ifpack_SerialTriDiMatrix::Multiply not implimented ",-2);
 
  393   double* arrayPtr = A_;
 
  394   const int size = (N_ == 1)? 1 : 4*(N_-1);
 
  395   for(
int j = 0; j < size ; j++) {
 
  403     os <<
" square format:"<<std::endl;
 
  405       os <<
" empty matrix "<<std::endl;
 
  408     for(
int i=0 ; i < N_ ; ++i)  {
 
  409     for(
int j=0 ; j < N_ ; ++j)  {
 
  410       if ( j >= i-1  && j <= i+1) {
 
  411         os << (*this)(i,j)<<
" ";
 
int Shape(int NumRowCol)
Set dimensions of a Ifpack_SerialTriDiMatrix object; init values to zero. 
bool operator==(const Ifpack_SerialTriDiMatrix &rhs) const 
Comparison operator. 
virtual double NormOne() const 
Computes the 1-Norm of the this matrix. 
double * A() const 
Returns pointer to the this matrix. 
Ifpack_SerialTriDiMatrix & operator+=(const Ifpack_SerialTriDiMatrix &Source)
Add one matrix to another. 
virtual double NormInf() const 
Computes the Infinity-Norm of the this matrix. 
int N() const 
Returns column dimension of system. 
virtual void Print(std::ostream &os) const 
Print service methods; defines behavior of ostream << operator. 
Ifpack_SerialTriDiMatrix: A class for constructing and using real double precision general TriDi matr...
virtual const char * Label() const 
Returns a character string describing the operator. 
Ifpack_SerialTriDiMatrix & operator=(const Ifpack_SerialTriDiMatrix &Source)
Value copy from one matrix to another. 
int Random()
Column access function. 
int Scale(double ScalarA)
Matrix-Vector multiplication, y = A*x, where 'this' == A. 
Ifpack_SerialTriDiMatrix(bool set_object_label=true)
Default constructor; defines a zero size object. 
virtual ~Ifpack_SerialTriDiMatrix()
Ifpack_SerialTriDiMatrix destructor. 
int Multiply(char TransA, char TransB, double ScalarAB, const Ifpack_SerialTriDiMatrix &A, const Ifpack_SerialTriDiMatrix &B, double ScalarThis)
Matrix-Matrix multiplication, this = ScalarThis*this + ScalarAB*A*B.