Lapack++
trmd.h
Go to the documentation of this file.
00001 // -*-C++-*-
00002 //      LAPACK++ (V. 1.1)
00003 //      (C) 1992-1996 All Rights Reserved.
00004 
00005 
00006 #include "arch.h"
00007 #ifndef _LA_TRIDIAG_MAT_DOUBLE_
00008 #define _LA_TRIDIAG_MAT_DOUBLE_
00009 
00010 #include "lafnames.h"
00011 #include LA_VECTOR_DOUBLE_H
00012 
00042 class DLLIMPORT LaTridiagMatDouble
00043 {
00044     LaVectorDouble du2_;    /* second upper diag, N-2 */
00045     LaVectorDouble du_;     /* upper diag, N-1 */
00046     LaVectorDouble d_;      /* main diag, N */
00047     LaVectorDouble dl_;     /* lower diag, N-1 */
00048     int size_;
00049 
00050     static double outofbounds_; /* return this address, when addresing out
00051                                      of bounds */
00052     static int debug_;        // print debug info.
00053     static int *info_;        // print matrix info only, not values
00054     //   originally 0, set to 1, and then
00055     //   reset to 0 after use.
00056 
00057 public:
00058 
00062     LaTridiagMatDouble();
00065     LaTridiagMatDouble(int N);
00068     LaTridiagMatDouble(const LaTridiagMatDouble &);
00073     LaTridiagMatDouble(const LaVectorDouble& diag,
00074                        const LaVectorDouble& diaglower,
00075                        const LaVectorDouble& diagupper);
00076 
00079     ~LaTridiagMatDouble();
00081 
00086     int size() const
00087     {
00088         return size_;
00089     }
00091 
00117     inline double &operator()(int i, int j);
00118 
00142     inline double operator()(int i, int j) const;
00143 
00171     LaVectorDouble& diag(int diag_selection);
00172 
00195     const LaVectorDouble& diag(int diag_selection) const;
00197 
00198 
00205     LaTridiagMatDouble& copy(const LaTridiagMatDouble& s);
00206 
00215     LaTridiagMatDouble& inject(const LaTridiagMatDouble& s);
00216 
00224     inline LaTridiagMatDouble& ref(LaTridiagMatDouble&);
00226 
00240     const LaTridiagMatDouble& info() const
00241     {
00242         int *t = info_;
00243         *t = 1;
00244         return *this;
00245     }
00247     int debug() const
00248     {
00249         return debug_;
00250     }
00252 
00263     friend DLLIMPORT std::ostream& operator<<(std::ostream&, const LaTridiagMatDouble&);
00264 
00265 
00266 };
00267 
00268 DLLIMPORT std::ostream& operator<<(std::ostream& s, const LaTridiagMatDouble& td);
00269 
00270 
00271 // operators and member functions
00272 
00273 inline double& LaTridiagMatDouble::operator()(int i, int j)
00274 {
00275     switch (i - j)
00276     {
00277     case 0:   // main
00278 #ifdef LA_BOUNDS_CHECK
00279         if (i > d_.size() - 1)
00280             return outofbounds_;
00281         else
00282 #endif
00283             return d_(i);
00284     case 1:  // lower
00285 #ifdef LA_BOUNDS_CHECK
00286         if (i > dl_.size() - 1)
00287             return outofbounds_;
00288         else
00289 #endif
00290             // Before lapackpp-2.4.12 this was dl_(i) but that was WRONG!
00291             return dl_(j);
00292     case -1:   // upper
00293 #ifdef LA_BOUNDS_CHECK
00294         if (i > du_.size() - 1)
00295             return outofbounds_;
00296         else
00297 #endif
00298             return du_(i);
00299     default:
00300         return outofbounds_;
00301     }
00302 }
00303 
00304 
00305 inline double LaTridiagMatDouble::operator()(int i, int j) const
00306 {
00307     switch (i - j)
00308     {
00309     case 0:   // main
00310 #ifdef LA_BOUNDS_CHECK
00311         if (i > d_.size() - 1)
00312             return outofbounds_;
00313         else
00314 #endif
00315             return d_(i);
00316     case 1:  // lower
00317 #ifdef LA_BOUNDS_CHECK
00318         if (i > dl_.size() - 1)
00319             return outofbounds_;
00320         else
00321 #endif
00322             // Before lapackpp-2.4.12 this was dl_(i) but that was WRONG!
00323             return dl_(j);
00324     case -1:   // upper
00325 #ifdef LA_BOUNDS_CHECK
00326         if (i > du_.size() - 1)
00327             return outofbounds_;
00328         else
00329 #endif
00330             return du_(i);
00331     default:
00332         return outofbounds_;
00333     }
00334 }
00335 
00336 inline LaTridiagMatDouble& LaTridiagMatDouble::ref(LaTridiagMatDouble&T)
00337 {
00338     du2_.ref(T.du2_);
00339     du_.ref(T.du_);
00340     d_.ref(T.d_);
00341     dl_.ref(T.dl_);
00342     size_ = T.size_;
00343 
00344     return *this;
00345 }
00346 
00347 
00348 
00349 
00350 
00351 
00352 
00353 #endif
00354 // _LA_TRIDIAG_MAT_DOUBLE_