bmd.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_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 //#define SPARSE_CHK
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_;  // internal storage.
00026 
00027   int N_;       // N_ is (NxN)
00028   int kl_;      // kl_ = # subdiags
00029   int ku_;      // ku_ = # superdiags
00030   static double outofbounds_; // value returned if index is out of range.
00031   static int debug_;         // print debug info.
00032   static int *info_;         // print matrix info only, not values
00033                              //   originally 0, set to 1, and then
00034                              //   reset to 0 after use.
00035 
00036 
00037 public:
00038 
00039   // constructors
00040 
00041   LaBandMatDouble();
00042   LaBandMatDouble(int,int,int);
00043   LaBandMatDouble(const LaBandMatDouble &);
00044 
00045   // destructor
00046 
00047   ~LaBandMatDouble();
00048 
00049   // operators
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   // member functions
00059 
00060   inline int size(int) const;           // submatrix size
00061   inline int inc(int d) const;          // explicit increment
00062   inline int gdim(int d) const;         // global dimensions
00063 
00064   inline LaBandMatDouble& ref(LaBandMatDouble &);
00065   LaBandMatDouble copy(const LaBandMatDouble &);
00066   inline double* addr() const {        // return address of matrix.
00067         return data_.addr();}
00068   inline int ref_count() const {        // return ref_count of matrix.
00069         return data_.ref_count();}
00070   inline LaIndex index(int d) const {     // return indices of matrix.
00071         return data_.index(d);}
00072   inline int superdiags() {     // return # of superdiags of matrix.
00073         return (ku_);}
00074   inline int superdiags() const { // return # of superdiags of const matrix.
00075         return (ku_);}
00076   inline int subdiags() {     // return # of subdiags of matrix.
00077         return (kl_);}
00078   inline int subdiags() const {  // return # of subdiags of const matrix.
00079         return (kl_);}
00080   inline int shallow() const {      // return shallow flag.
00081         return data_.shallow();}
00082   inline int debug() const {    // return debug flag.
00083         return debug_;}
00084   inline int debug(int d) { // set debug flag for lagenmat.
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   // member functions and operators
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 //  (j>i)
00167    {
00168       if (j-i<=ku_)
00169          return data_(kl_+ku_+i-j,j); // kl_ is factorization storage here.
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 // (j>i)
00220    {
00221       if (j-i<=ku_)
00222          return data_(kl_+ku_+i-j,j); // kl_ is factorization storage here.
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_

Generated on Sat Jul 14 11:40:36 2007 for Lapack++ by  doxygen 1.5.0