00001
00002
00003
00004
00005 #ifndef _LA_BAND_MAT_DOUBLE_H_
00006 #define _LA_BAND_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
00014 #define BOUNDS_CHK
00015
00016 #ifdef LA_NO_BOUNDS_CHECK
00017 #undef BOUNDS_CHK
00018 #endif
00019 #ifdef LA_NO_SPARSE_CHECK
00020 #undef SPARSE_CHK
00021 #endif
00022
00023 class DLLIMPORT LaBandMatDouble
00024 {
00025 LaGenMatDouble data_;
00026
00027 int N_;
00028 int kl_;
00029 int ku_;
00030 static double outofbounds_;
00031 static int debug_;
00032 static int *info_;
00033
00034
00035
00036
00037 public:
00038
00039
00040
00041 LaBandMatDouble();
00042 LaBandMatDouble(int,int,int);
00043 LaBandMatDouble(const LaBandMatDouble &);
00044
00045
00046
00047 ~LaBandMatDouble();
00048
00049
00050
00051 LaBandMatDouble& operator=(double);
00052 LaBandMatDouble& operator=(const LaBandMatDouble&);
00053 inline double& operator()(int,int);
00054 inline double& operator()(int,int) const;
00055 friend std::ostream& operator<<(std::ostream &, const LaBandMatDouble &);
00056
00057
00058
00059
00060 inline int size(int) const;
00061 inline int inc(int d) const;
00062 inline int gdim(int d) const;
00063
00064 inline LaBandMatDouble& ref(LaBandMatDouble &);
00065 LaBandMatDouble copy(const LaBandMatDouble &);
00066 inline double* addr() const {
00067 return data_.addr();}
00068 inline int ref_count() const {
00069 return data_.ref_count();}
00070 inline LaIndex index(int d) const {
00071 return data_.index(d);}
00072 inline int superdiags() {
00073 return (ku_);}
00074 inline int superdiags() const {
00075 return (ku_);}
00076 inline int subdiags() {
00077 return (kl_);}
00078 inline int subdiags() const {
00079 return (kl_);}
00080 inline int shallow() const {
00081 return data_.shallow();}
00082 inline int debug() const {
00083 return debug_;}
00084 inline int debug(int d) {
00085 return debug_ = d;}
00086
00087 LaBandMatDouble& resize(const LaBandMatDouble&);
00088
00089 inline const LaBandMatDouble& info() const {
00090 int *t = info_;
00091 *t = 1;
00092 return *this;};
00093
00094 inline LaBandMatDouble print_data() const
00095 { std::cout << data_; return *this;}
00096
00097 };
00098
00099
00100
00101
00102
00103 inline LaBandMatDouble& LaBandMatDouble::ref(LaBandMatDouble &ob)
00104 {
00105
00106 data_.ref(ob.data_);
00107 N_ = ob.N_;
00108 kl_ = ob.kl_;
00109 ku_ = ob.ku_;
00110
00111 return *this;
00112 }
00113
00114 inline int LaBandMatDouble::size(int d) const
00115 {
00116 return(data_.size(d));
00117 }
00118
00119 inline int LaBandMatDouble::inc(int d) const
00120 {
00121 return(data_.inc(d));
00122 }
00123
00124 inline int LaBandMatDouble::gdim(int d) const
00125 {
00126 return(data_.gdim(d));
00127 }
00128
00129 inline double& LaBandMatDouble::operator()(int i, int j)
00130 {
00131 #ifdef LA_BOUNDS_CHECK
00132 assert(i >= 0);
00133 assert(i < N_);
00134 assert(j >= 0);
00135 assert(j < N_);
00136 #endif
00137
00138 if (i<0)
00139 {
00140 if (-i<=kl_)
00141 return data_(kl_+i-j,j);
00142 else
00143 {
00144 #ifdef LA_BOUNDS_CHECK
00145 assert(0);
00146 #else
00147 return outofbounds_;
00148 #endif
00149 }
00150 }
00151
00152 if (i>=j)
00153 {
00154 if (i-j<=kl_)
00155 return data_(kl_+ku_+i-j,j);
00156 else
00157 {
00158 #ifdef LA_BOUNDS_CHECK
00159 assert(0);
00160 #else
00161 return outofbounds_;
00162 #endif
00163 }
00164 }
00165
00166 else
00167 {
00168 if (j-i<=ku_)
00169 return data_(kl_+ku_+i-j,j);
00170 else
00171 {
00172 #ifdef LA_BOUNDS_CHECK
00173 assert(0);
00174 #else
00175 return outofbounds_;
00176 #endif
00177 }
00178 }
00179 }
00180
00181
00182 inline double& LaBandMatDouble::operator()(int i, int j) const
00183 {
00184 #ifdef LA_BOUNDS_CHECK
00185 assert(i >= 0);
00186 assert(i < N_);
00187 assert(j >= 0);
00188 assert(j < N_);
00189 #endif
00190
00191 if (i<0)
00192 {
00193 if (-i<=kl_)
00194 return data_(kl_+i-j,j);
00195 else
00196 {
00197 #ifdef LA_BOUNDS_CHECK
00198 assert(0);
00199 #else
00200 return outofbounds_;
00201 #endif
00202 }
00203 }
00204
00205 if (i>=j)
00206 {
00207 if (i-j<=kl_)
00208 return data_(kl_+ku_+i-j,j);
00209 else
00210 {
00211 #ifdef LA_BOUNDS_CHECK
00212 assert(0);
00213 #else
00214 return outofbounds_;
00215 #endif
00216 }
00217 }
00218
00219 else
00220 {
00221 if (j-i<=ku_)
00222 return data_(kl_+ku_+i-j,j);
00223 else
00224 {
00225 #ifdef LA_BOUNDS_CHECK
00226 assert(0);
00227 #else
00228 return outofbounds_;
00229 #endif
00230 }
00231 }
00232 }
00233
00234 #endif // _LA_BAND_MAT_DOUBLE_H_