BandMatrix.h
Go to the documentation of this file.
00001 #ifndef __NEW_MAT_BAND_MATRIX_H__
00002 #define __NEW_MAT_BAND_MATRIX_H__
00003 
00004 // ***************************** band matrices ***************************/
00005 
00007 class BandMatrix : public GeneralMatrix
00008 {
00009    GeneralMatrix* Image() const;                // copy of matrix
00010 protected:
00011    void CornerClear() const;                    // set unused elements to zero
00012    short SimpleAddOK(const GeneralMatrix* gm);
00013 public:
00014    int lower_val, upper_val;                            // band widths
00015    BandMatrix() { lower_val=0; upper_val=0; CornerClear(); }
00016    ~BandMatrix() {}
00017    BandMatrix(int n,int lb,int ub) { resize(n,lb,ub); CornerClear(); }
00018                                                 // standard declaration
00019    BandMatrix(const BaseMatrix&);               // evaluate BaseMatrix
00020    void operator=(const BaseMatrix&);
00021    void operator=(Real f) { GeneralMatrix::operator=(f); }
00022    void operator=(const BandMatrix& m) { Eq(m); }
00023    MatrixType type() const;
00024    Real& operator()(int, int);                  // access element
00025    Real& element(int, int);                     // access element
00026    Real operator()(int, int) const;             // access element
00027    Real element(int, int) const;                // access element
00028 #ifdef SETUP_C_SUBSCRIPTS
00029    Real* operator[](int m) { return store+(upper_val+lower_val)*m+lower_val; }
00030    const Real* operator[](int m) const
00031       { return store+(upper_val+lower_val)*m+lower_val; }
00032 #endif
00033    BandMatrix(const BandMatrix& gm) : GeneralMatrix() { GetMatrix(&gm); }
00034    LogAndSign log_determinant() const;
00035    GeneralMatrix* MakeSolver();
00036    Real trace() const;
00037    Real sum_square() const
00038       { CornerClear(); return GeneralMatrix::sum_square(); }
00039    Real sum_absolute_value() const
00040       { CornerClear(); return GeneralMatrix::sum_absolute_value(); }
00041    Real sum() const
00042       { CornerClear(); return GeneralMatrix::sum(); }
00043    Real maximum_absolute_value() const
00044       { CornerClear(); return GeneralMatrix::maximum_absolute_value(); }
00045    Real minimum_absolute_value() const
00046       { int i, j; return GeneralMatrix::minimum_absolute_value2(i, j); }
00047    Real maximum() const { int i, j; return GeneralMatrix::maximum2(i, j); }
00048    Real minimum() const { int i, j; return GeneralMatrix::minimum2(i, j); }
00049    void GetRow(MatrixRowCol&);
00050    void GetCol(MatrixRowCol&);
00051    void GetCol(MatrixColX&);
00052    void RestoreCol(MatrixRowCol&);
00053    void RestoreCol(MatrixColX& c) { RestoreCol((MatrixRowCol&)c); }
00054    void NextRow(MatrixRowCol&);
00055    virtual void resize(int, int, int);             // change dimensions
00056    virtual void ReSize(int m, int n, int b) { resize(m, n, b); }
00057    void resize(const GeneralMatrix& A);
00058    void ReSize(const GeneralMatrix& A) { resize(A); }
00059    //bool SameStorageType(const GeneralMatrix& A) const;
00060    //void ReSizeForAdd(const GeneralMatrix& A, const GeneralMatrix& B);
00061    //void ReSizeForSP(const GeneralMatrix& A, const GeneralMatrix& B);
00062    MatrixBandWidth bandwidth() const;
00063    void SetParameters(const GeneralMatrix*);
00064    MatrixInput operator<<(double);                // will give error
00065    MatrixInput operator<<(float);                // will give error
00066    MatrixInput operator<<(int f);
00067    void operator<<(const double* r);              // will give error
00068    void operator<<(const float* r);              // will give error
00069    void operator<<(const int* r);               // will give error
00070       // the next is included because Zortech and Borland
00071       // cannot find the copy in GeneralMatrix
00072    void operator<<(const BaseMatrix& X) { GeneralMatrix::operator<<(X); }
00073    void swap(BandMatrix& gm);
00074    NEW_DELETE(BandMatrix)
00075 };
00076 
00078 class UpperBandMatrix : public BandMatrix
00079 {
00080    GeneralMatrix* Image() const;                // copy of matrix
00081 public:
00082    UpperBandMatrix() {}
00083    ~UpperBandMatrix() {}
00084    UpperBandMatrix(int n, int ubw)              // standard declaration
00085       : BandMatrix(n, 0, ubw) {}
00086    UpperBandMatrix(const BaseMatrix&);          // evaluate BaseMatrix
00087    void operator=(const BaseMatrix&);
00088    void operator=(Real f) { GeneralMatrix::operator=(f); }
00089    void operator=(const UpperBandMatrix& m) { Eq(m); }
00090    MatrixType type() const;
00091    UpperBandMatrix(const UpperBandMatrix& gm) : BandMatrix() { GetMatrix(&gm); }
00092    GeneralMatrix* MakeSolver() { return this; }
00093    void Solver(MatrixColX&, const MatrixColX&);
00094    LogAndSign log_determinant() const;
00095    void resize(int, int, int);             // change dimensions
00096    void ReSize(int m, int n, int b) { resize(m, n, b); }
00097    void resize(int n,int ubw)              // change dimensions
00098       { BandMatrix::resize(n,0,ubw); }
00099    void ReSize(int n,int ubw)              // change dimensions
00100       { BandMatrix::resize(n,0,ubw); }
00101    void resize(const GeneralMatrix& A) { BandMatrix::resize(A); }
00102    void ReSize(const GeneralMatrix& A) { BandMatrix::resize(A); }
00103    Real& operator()(int, int);
00104    Real operator()(int, int) const;
00105    Real& element(int, int);
00106    Real element(int, int) const;
00107 #ifdef SETUP_C_SUBSCRIPTS
00108    Real* operator[](int m) { return store+upper_val*m; }
00109    const Real* operator[](int m) const { return store+upper_val*m; }
00110 #endif
00111    void swap(UpperBandMatrix& gm)
00112       { BandMatrix::swap((BandMatrix&)gm); }
00113    NEW_DELETE(UpperBandMatrix)
00114 };
00115 
00117 class LowerBandMatrix : public BandMatrix
00118 {
00119    GeneralMatrix* Image() const;                // copy of matrix
00120 public:
00121    LowerBandMatrix() {}
00122    ~LowerBandMatrix() {}
00123    LowerBandMatrix(int n, int lbw)              // standard declaration
00124       : BandMatrix(n, lbw, 0) {}
00125    LowerBandMatrix(const BaseMatrix&);          // evaluate BaseMatrix
00126    void operator=(const BaseMatrix&);
00127    void operator=(Real f) { GeneralMatrix::operator=(f); }
00128    void operator=(const LowerBandMatrix& m) { Eq(m); }
00129    MatrixType type() const;
00130    LowerBandMatrix(const LowerBandMatrix& gm) : BandMatrix() { GetMatrix(&gm); }
00131    GeneralMatrix* MakeSolver() { return this; }
00132    void Solver(MatrixColX&, const MatrixColX&);
00133    LogAndSign log_determinant() const;
00134    void resize(int, int, int);             // change dimensions
00135    void ReSize(int m, int n, int b) { resize(m, n, b); }
00136    void resize(int n,int lbw)             // change dimensions
00137       { BandMatrix::resize(n,lbw,0); }
00138    void ReSize(int n,int lbw)             // change dimensions
00139       { BandMatrix::resize(n,lbw,0); }
00140    void resize(const GeneralMatrix& A) { BandMatrix::resize(A); }
00141    void ReSize(const GeneralMatrix& A) { BandMatrix::resize(A); }
00142    Real& operator()(int, int);
00143    Real operator()(int, int) const;
00144    Real& element(int, int);
00145    Real element(int, int) const;
00146 #ifdef SETUP_C_SUBSCRIPTS
00147    Real* operator[](int m) { return store+lower_val*(m+1); }
00148    const Real* operator[](int m) const { return store+lower_val*(m+1); }
00149 #endif
00150    void swap(LowerBandMatrix& gm)
00151       { BandMatrix::swap((BandMatrix&)gm); }
00152    NEW_DELETE(LowerBandMatrix)
00153 };
00154 
00156 class SymmetricBandMatrix : public GeneralMatrix
00157 {
00158    GeneralMatrix* Image() const;                // copy of matrix
00159    void CornerClear() const;                    // set unused elements to zero
00160    short SimpleAddOK(const GeneralMatrix* gm);
00161 public:
00162    int lower_val;                                   // lower band width
00163    SymmetricBandMatrix() { lower_val=0; CornerClear(); }
00164    ~SymmetricBandMatrix() {}
00165    SymmetricBandMatrix(int n, int lb) { resize(n,lb); CornerClear(); }
00166    SymmetricBandMatrix(const BaseMatrix&);
00167    void operator=(const BaseMatrix&);
00168    void operator=(Real f) { GeneralMatrix::operator=(f); }
00169    void operator=(const SymmetricBandMatrix& m) { Eq(m); }
00170    Real& operator()(int, int);                  // access element
00171    Real& element(int, int);                     // access element
00172    Real operator()(int, int) const;             // access element
00173    Real element(int, int) const;                // access element
00174 #ifdef SETUP_C_SUBSCRIPTS
00175    Real* operator[](int m) { return store+lower_val*(m+1); }
00176    const Real* operator[](int m) const { return store+lower_val*(m+1); }
00177 #endif
00178    MatrixType type() const;
00179    SymmetricBandMatrix(const SymmetricBandMatrix& gm)
00180       : GeneralMatrix() { GetMatrix(&gm); }
00181    GeneralMatrix* MakeSolver();
00182    Real sum_square() const;
00183    Real sum_absolute_value() const;
00184    Real sum() const;
00185    Real maximum_absolute_value() const
00186       { CornerClear(); return GeneralMatrix::maximum_absolute_value(); }
00187    Real minimum_absolute_value() const
00188       { int i, j; return GeneralMatrix::minimum_absolute_value2(i, j); }
00189    Real maximum() const { int i, j; return GeneralMatrix::maximum2(i, j); }
00190    Real minimum() const { int i, j; return GeneralMatrix::minimum2(i, j); }
00191    Real trace() const;
00192    LogAndSign log_determinant() const;
00193    void GetRow(MatrixRowCol&);
00194    void GetCol(MatrixRowCol&);
00195    void GetCol(MatrixColX&);
00196    void RestoreCol(MatrixRowCol&) {}
00197    void RestoreCol(MatrixColX&);
00198    GeneralMatrix* Transpose(TransposedMatrix*, MatrixType);
00199    void resize(int,int);                       // change dimensions
00200    void ReSize(int m,int b) { resize(m, b); }
00201    void resize(const GeneralMatrix& A);
00202    void ReSize(const GeneralMatrix& A) { resize(A); }
00203    //bool SameStorageType(const GeneralMatrix& A) const;
00204    //void ReSizeForAdd(const GeneralMatrix& A, const GeneralMatrix& B);
00205    //void ReSizeForSP(const GeneralMatrix& A, const GeneralMatrix& B);
00206    MatrixBandWidth bandwidth() const;
00207    void SetParameters(const GeneralMatrix*);
00208    void operator<<(const double* r);              // will give error
00209    void operator<<(const float* r);              // will give error
00210    void operator<<(const int* r);               // will give error
00211    void operator<<(const BaseMatrix& X) { GeneralMatrix::operator<<(X); }
00212    void swap(SymmetricBandMatrix& gm);
00213    NEW_DELETE(SymmetricBandMatrix)
00214 };
00215 
00217 class BandLUMatrix : public GeneralMatrix
00218 {
00219    int* indx;
00220    bool d;
00221    bool sing;                                   // true if singular
00222    Real* store2;
00223    int storage2;
00224    int m1,m2;                                   // lower and upper
00225    void ludcmp();
00226    void get_aux(BandLUMatrix&);                 // for copying indx[] etc
00227    GeneralMatrix* Image() const;                // copy of matrix
00228 public:
00229    BandLUMatrix(const BaseMatrix&);
00230    BandLUMatrix()
00231      : indx(0), d(true), sing(true), store2(0), storage2(0), m1(0), m2(0) {}
00232    BandLUMatrix(const BandLUMatrix&);
00233    void operator=(const BandLUMatrix&);
00234    GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
00235    MatrixType type() const;
00236    void lubksb(Real*, int=0);
00237    ~BandLUMatrix();
00238    GeneralMatrix* MakeSolver() { return this; } // for solving
00239    LogAndSign log_determinant() const;
00240    void Solver(MatrixColX&, const MatrixColX&);
00241    void GetRow(MatrixRowCol&);
00242    void GetCol(MatrixRowCol&);
00243    void GetCol(MatrixColX& c) { GetCol((MatrixRowCol&)c); }
00244    void cleanup();                                // to clear store
00245    void MiniCleanUp();
00246    bool IsEqual(const GeneralMatrix&) const;
00247    bool is_singular() const { return sing; }
00248    bool IsSingular() const { return sing; }
00249    const Real* const_data2() const { return store2; }
00250    int size2() const { return storage2; }
00251    const int* const_data_indx() const { return indx; }
00252    bool even_exchanges() const { return d; }
00253    MatrixBandWidth bandwidth() const;
00254    void swap(BandLUMatrix& gm);
00255    NEW_DELETE(BandLUMatrix)
00256 };
00257 
00258 #endif
00259 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


lo
Author(s): U. Klank
autogenerated on Thu May 23 2013 07:34:44