Lapack++
ltgmd.h
Go to the documentation of this file.
00001 //      LAPACK++ (V. 1.1)
00002 //      (C) 1992-1996 All Rights Reserved.
00003 
00004 
00005 #ifndef _LA_LOWER_TRIANG_MAT_DOUBLE_H_
00006 #define _LA_LOWER_TRIANG_MAT_DOUBLE_H_
00007 
00008 #include "arch.h"
00009 #ifndef _LA_GEN_MAT_DOUBLE_H_
00010 #include LA_GEN_MAT_DOUBLE_H
00011 #endif
00012 
00013 //#define LOWER_INDEX_CHK
00014 
00015 class DLLIMPORT LaLowerTriangMatDouble
00016 {
00017     LaGenMatDouble data_;
00018     static double outofbounds_;
00019     static int debug_;         // print debug info.
00020     static int *info_;         // print matrix info only, not values
00021     //   originally 0, set to 1, and then
00022     //   reset to 0 after use.
00023 public:
00024 
00025     // constructors
00026 
00027     inline LaLowerTriangMatDouble();
00028     inline LaLowerTriangMatDouble(int, int);
00029     inline LaLowerTriangMatDouble(double*, int, int);
00030     inline LaLowerTriangMatDouble(const LaLowerTriangMatDouble &);
00031 
00032     // operators
00033 
00034     inline LaLowerTriangMatDouble& ref(LaLowerTriangMatDouble &);
00035     inline LaLowerTriangMatDouble& ref(LaGenMatDouble &);
00036     LaLowerTriangMatDouble& copy(const LaLowerTriangMatDouble &);
00037     LaLowerTriangMatDouble& operator=(double);
00038     inline LaLowerTriangMatDouble& operator=(const LaLowerTriangMatDouble &);
00039     inline double& operator()(int, int);
00040     inline const double& operator()(int, int) const;
00041 
00042 //  inline operator LaGenMatDouble();
00043 
00044     inline int size(int) const;           // submatrix size
00045     inline int inc(int d) const;          // explicit increment
00046     inline int gdim(int d) const;         // global dimensions
00047     inline double* addr() const          // return address of matrix.
00048     {
00049         return data_.addr();
00050     }
00051     inline int ref_count() const          // return ref_count of matrix.
00052     {
00053         return data_.ref_count();
00054     }
00055     inline LaIndex index(int d) const       // return indices of matrix.
00056     {
00057         return data_.index(d);
00058     }
00059     inline int shallow() const        // return indices of matrix.
00060     {
00061         return data_.shallow();
00062     }
00063     inline int debug() const      // return debug flag.
00064     {
00065         return debug_;
00066     }
00067     inline int debug(int d)   // set debug flag for lagenmat.
00068     {
00069         return debug_ = d;
00070     }
00071 
00072     inline LaLowerTriangMatDouble& resize(const LaLowerTriangMatDouble&);
00074     inline LaLowerTriangMatDouble& resize(int m, int n);
00075 
00076     inline const LaLowerTriangMatDouble& info() const
00077     {
00078         int *t = info_;
00079         *t = 1;
00080         return *this;
00081     };
00082 
00083 
00084 
00085     friend DLLIMPORT std::ostream &operator<<(std::ostream &, const LaLowerTriangMatDouble &);
00086 
00087     // destructor
00088 
00089     inline ~LaLowerTriangMatDouble();
00090 };
00091 
00092 DLLIMPORT std::ostream &operator<<(std::ostream &s, const LaLowerTriangMatDouble &ob);
00093 // constructor functions
00094 
00095 inline LaLowerTriangMatDouble::LaLowerTriangMatDouble() : data_()
00096 {
00097     *info_ = 0;
00098 }
00099 
00100 inline LaLowerTriangMatDouble::LaLowerTriangMatDouble(int i, int j): data_(i, j)
00101 {
00102     *info_ = 0;
00103 }
00104 
00105 inline LaLowerTriangMatDouble::LaLowerTriangMatDouble(double *d, int i, int j):
00106     data_(d, i, j)
00107 {
00108     *info_ = 0;
00109 }
00110 
00111 inline LaLowerTriangMatDouble::LaLowerTriangMatDouble(const LaLowerTriangMatDouble &A)
00112 {
00113 
00114     data_.copy(A.data_);
00115 }
00116 
00117 
00118 // operator functions
00119 
00120 inline LaLowerTriangMatDouble& LaLowerTriangMatDouble::ref(LaLowerTriangMatDouble &ob)
00121 {
00122 
00123     data_.ref(ob.data_);
00124 
00125     return *this;
00126 }
00127 
00128 
00129 inline LaLowerTriangMatDouble& LaLowerTriangMatDouble::ref(LaGenMatDouble &ob)
00130 {
00131 
00132     data_.ref(ob);
00133 
00134     return *this;
00135 }
00136 
00137 
00138 inline LaLowerTriangMatDouble& LaLowerTriangMatDouble::resize(const LaLowerTriangMatDouble &ob)
00139 {
00140 
00141     data_.resize(ob.data_);
00142 
00143     return *this;
00144 }
00145 
00146 inline LaLowerTriangMatDouble& LaLowerTriangMatDouble::resize(int m, int n)
00147 {
00148 
00149     data_.resize(m, n);
00150 
00151     return *this;
00152 }
00153 
00154 
00155 inline LaLowerTriangMatDouble& LaLowerTriangMatDouble::operator=(const LaLowerTriangMatDouble &L)
00156 {
00157 
00158     data_ = L.data_;
00159 
00160     return *this;
00161 }
00162 
00163 
00164 inline double& LaLowerTriangMatDouble::operator()(int i, int j)
00165 {
00166 
00167 
00168 #ifdef LOWER_INDEX_CHK
00169     if (i < j)
00170     {
00171         std::cout << "Warning, index to Lower Triular matrix out of range!\n";
00172         std::cout << " i = " << i << " " << " j = " << j << std::endl;
00173     }
00174 #endif
00175 
00176     if (i < j)
00177         return outofbounds_;
00178     else
00179         return data_(i, j);
00180 }
00181 
00182 
00183 inline const double& LaLowerTriangMatDouble::operator()(int i, int j) const
00184 {
00185 
00186 #ifdef LOWER_INDEX_CHK
00187     if (i < j)
00188     {
00189         std::cout << "Warning, index to Lower Triular matrix out of range!\n";
00190         std::cout << " i = " << i << " " << " j = " << j << std::endl;
00191     }
00192 #endif
00193 
00194     if (i < j)
00195         return outofbounds_;
00196     else
00197         return data_(i, j);
00198 }
00199 
00200 
00201 // destructor function
00202 
00203 inline LaLowerTriangMatDouble::~LaLowerTriangMatDouble()
00204 {
00205 }
00206 
00207 inline int LaLowerTriangMatDouble::size(int d) const
00208 {
00209     return(data_.size(d));
00210 }
00211 
00212 inline int LaLowerTriangMatDouble::inc(int d) const
00213 {
00214     return(data_.inc(d));
00215 }
00216 
00217 inline int LaLowerTriangMatDouble::gdim(int d) const
00218 {
00219     return(data_.gdim(d));
00220 }
00221 
00222 
00223 #if 0
00224 // type conversions between LaGenMat and LaUpTriMat
00225 
00226 inline LaLowerTriangMatDouble::operator LaGenMatDouble()
00227 {
00228     LaGenMatDouble G;
00229 
00230     G.ref((*this).data_);
00231 
00232     return G;
00233 }
00234 #endif
00235 
00236 
00237 #endif
00238 // _LA_LOWER_TRIANG_MAT_DOUBLE_H_