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