00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #ifndef IFPACK_SERIALTRIDIMATRIX_H
00045 #define IFPACK_SERIALTRIDIMATRIX_H
00046
00047 #include "Epetra_ConfigDefs.h"
00048 #include "Epetra_Object.h"
00049 #include "Epetra_CompObject.h"
00050 #include "Epetra_BLAS.h"
00051
00052 class Epetra_VbrMatrix;
00053
00055
00105
00106 class EPETRA_LIB_DLL_EXPORT Ifpack_SerialTriDiMatrix : public Epetra_CompObject, public Epetra_Object, public Epetra_BLAS {
00107
00108 public:
00109
00111
00112
00113
00118 Ifpack_SerialTriDiMatrix(bool set_object_label=true);
00119
00121
00130 Ifpack_SerialTriDiMatrix(int NumRowCol, bool set_object_label=true);
00131
00133
00144 Ifpack_SerialTriDiMatrix(Epetra_DataAccess CV, double* A_in, int NumRowCol,
00145 bool set_object_label=true);
00146
00148
00149 Ifpack_SerialTriDiMatrix(const Ifpack_SerialTriDiMatrix& Source);
00150
00152 virtual ~Ifpack_SerialTriDiMatrix ();
00154
00156
00157
00158
00168 int Shape(int NumRowCol);
00169
00170 int Reshape(int, int);
00171
00173
00174
00176
00195 int Multiply(char TransA, char TransB, double ScalarAB,
00196 const Ifpack_SerialTriDiMatrix& A,
00197 const Ifpack_SerialTriDiMatrix& B,
00198 double ScalarThis);
00199
00201
00202
00203
00204
00205
00206
00207
00208
00209
00211
00238 int Scale(double ScalarA);
00239
00241
00244 virtual double NormOne() const;
00245
00247 virtual double NormInf() const;
00248
00250
00252
00253
00255
00261 Ifpack_SerialTriDiMatrix & operator = (const Ifpack_SerialTriDiMatrix& Source);
00262
00264
00267 bool operator==(const Ifpack_SerialTriDiMatrix& rhs) const;
00268
00270
00272 bool operator!=(const Ifpack_SerialTriDiMatrix& rhs) const
00273 { return !(*this == rhs); }
00274
00276
00283 Ifpack_SerialTriDiMatrix & operator += (const Ifpack_SerialTriDiMatrix& Source);
00284
00286
00294 double& operator () (int RowIndex, int ColIndex);
00295
00297
00306 const double& operator () (int RowIndex, int ColIndex) const;
00307
00309
00319
00320
00322
00332
00333
00335
00341 int Random();
00342
00344 int N() const {return(N_);};
00345
00346 int LDA() const {return(LDA_);};
00347
00349 double* A() const {return(A_);};
00350
00352
00353
00354 double* DL() { return DL_;};
00355 double* DL() const { return DL_;};
00356 double* D() { return D_;};
00357 double* D() const { return D_;};
00358 double* DU() { return DU_;};
00359 double* DU() const { return DU_;};
00360 double* DU2() { return DU2_;};
00361 double* DU2() const { return DU2_;};
00362
00364 Epetra_DataAccess CV() const {return(CV_);};
00366
00368
00369
00370 virtual void Print(std::ostream& os) const;
00372
00374
00375
00377
00380 virtual double OneNorm() const {return(NormOne());};
00381
00383 virtual double InfNorm() const {return(NormInf());};
00385
00387
00388
00390
00399 virtual int SetUseTranspose(bool UseTranspose_in) { UseTranspose_ = UseTranspose_in; return (0); }
00400
00402
00411 virtual int ApplyInverse(const Ifpack_SerialTriDiMatrix & X, Ifpack_SerialTriDiMatrix & Y)
00412 {
00413 (void)X;
00414 (void)Y;
00415 return (-1);
00416 }
00417
00419 virtual const char * Label() const { return Epetra_Object::Label(); }
00420
00422 virtual bool UseTranspose() const { return UseTranspose_; }
00423
00425 virtual bool HasNormInf() const { return true; }
00426
00428 virtual int RowColDim() const { return N(); }
00430
00431 protected:
00432
00433 void CopyMat(const double* Source, int NumRowCol,
00434 double* Target, int NRC2, bool add=false);
00435 void CleanupData();
00436
00437 int N_;
00438 int LDA_;
00439 bool A_Copied_;
00440 Epetra_DataAccess CV_;
00441
00442
00443
00444
00445
00446
00447 friend class Epetra_VbrMatrix;
00448
00449 double* A_;
00450 double* DL_;
00451 double* D_;
00452 double* DU_;
00453 double* DU2_;
00454
00455 bool UseTranspose_;
00456 };
00457
00458
00459
00460 inline double& Ifpack_SerialTriDiMatrix::operator () (int RowIndex, int ColIndex) {
00461
00462 int diff = ColIndex - RowIndex;
00463
00464 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00465 if (ColIndex >= N_ || ColIndex < 0)
00466 throw ReportError("Column index = " +toString(ColIndex) +
00467 " Out of Range 0 - " + toString(N_-1),-2);
00468 if (RowIndex >= N_ || RowIndex < 0)
00469 throw ReportError("Row index = " +toString(RowIndex) +
00470 " Out of Range 0 - " + toString(N_-1),-2);
00471
00472 if ( diff > 1 || diff < -1 )
00473 throw ReportError("Row index = " +toString(RowIndex) + " differs from Col_Index " + toString(ColIndex) +
00474 " Out of Range -1 to 1",-2);
00475 #endif
00476
00477 switch (diff) {
00478 case -1:
00479
00480 return DL_[ColIndex];
00481 break;
00482 case 0:
00483 return D_[ColIndex];
00484 break;
00485 case 1:
00486 return DU_[RowIndex];
00487 break;
00488 default:
00489 throw ReportError("Row index = " +toString(RowIndex) + " differs from Col_Index " + toString(ColIndex) +" Out of Range -1 to 1",1);
00490 return D_[0];
00491 }
00492 throw ReportError("Row index = " +toString(RowIndex) + " differs from Col_Index " + toString(ColIndex) + " Out of Range -1 to 1",1);
00493 return D_[0];
00494 }
00495
00496 inline const double& Ifpack_SerialTriDiMatrix::operator () (int RowIndex, int ColIndex) const {
00497 int diff = ColIndex - RowIndex;
00498
00499 #ifdef HAVE_EPETRA_ARRAY_BOUNDS_CHECK
00500 if (ColIndex >= N_ || ColIndex < 0)
00501 throw ReportError("Column index = " +toString(ColIndex) +
00502 " Out of Range 0 - " + toString(N_-1),-2);
00503 if (RowIndex >= N_ || RowIndex < 0)
00504 throw ReportError("Row index = " +toString(RowIndex) +
00505 " Out of Range 0 - " + toString(N_-1),-2);
00506 if ( diff > 1 || diff < -1 )
00507 throw ReportError("Row index = " +toString(RowIndex) + " differs from Col_Index " + toString(ColIndex) + " Out of Range -1 to 1",-2);
00508 #endif
00509 switch (diff) {
00510 case -1:
00511
00512 return DL_[ColIndex];
00513 break;
00514 case 0:
00515 return D_[ColIndex];
00516 break;
00517 case 1:
00518 return DU_[RowIndex];
00519 break;
00520 default:
00521 throw ReportError("Row index = " +toString(RowIndex) + " differs from Col_Index " + toString(ColIndex) + " Out of Range -1 to 1",-2);
00522 return D_[0];
00523 }
00524 return D_[0];
00525 }
00526
00527
00528 #endif