Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00028 #ifndef _LA_INDEX_H_
00029 #define _LA_INDEX_H_
00030
00031 #include <iostream>
00032 #include "arch.h"
00033
00043 class DLLIMPORT LaIndex
00044 {
00045 private:
00046 friend class LaGenMatDouble;
00047 friend class LaGenMatFloat;
00048 friend class LaGenMatInt;
00049 friend class LaGenMatLongInt;
00050 friend class LaGenMatComplex;
00051 int start_;
00052 int inc_;
00053 int end_;
00054 public:
00065 inline LaIndex()
00066 : start_(0)
00067 , inc_(0)
00068 , end_(0)
00069 {}
00070
00076 inline LaIndex(int start)
00077 : start_(start)
00078 , inc_(1)
00079 , end_(start)
00080 {}
00081
00091 LaIndex(int start, int end);
00092
00112 LaIndex(int start, int end, int increment);
00113
00115 inline LaIndex(const LaIndex &s)
00116 : start_(s.start_)
00117 , inc_(s.inc_)
00118 , end_(s.end_)
00119 {}
00120
00121 protected:
00122
00123
00124
00125
00126
00127
00132 inline int& start()
00133 {
00134 return start_;
00135 }
00139 inline int& inc()
00140 {
00141 return inc_;
00142 }
00148 inline int& end()
00149 {
00150 return end_;
00151 }
00152 public:
00153
00156 inline int start() const
00157 {
00158 return start_;
00159 }
00160
00162 inline int inc() const
00163 {
00164 return inc_;
00165 }
00166
00175 inline int end() const
00176 {
00177 return end_;
00178 }
00179
00182 inline int length() const
00183 {
00184 return ((end() - start()) / inc() + 1);
00185 }
00186
00189 inline bool null() const
00190 {
00191 return (start() == 0 &&
00192 inc() == 0 && end() == 0);
00193 }
00194
00195 protected:
00208 inline LaIndex& operator()(int start, int end)
00209 {
00210 start_ = start;
00211 inc_ = 1;
00212 end_ = end;
00213 return *this;
00214 }
00215 public:
00216
00226 inline LaIndex& set(int start, int end)
00227 {
00228 start_ = start;
00229 inc_ = 1;
00230 end_ = end;
00231 return *this;
00232 }
00233
00255 LaIndex& set(int start, int end, int increment);
00256
00261 inline LaIndex& operator+=(int i)
00262 {
00263 start_ += i;
00264 end_ += i;
00265 return *this;
00266 }
00267
00272 inline LaIndex operator+(int i)
00273 {
00274 LaIndex r(*this);
00275 r.start_ += i;
00276 r.end_ += i;
00277 return r;
00278 }
00279
00281 inline LaIndex& operator=(const LaIndex& i)
00282 {
00283 start_ = i.start_;
00284 inc_ = i.inc_;
00285 end_ = i.end_;
00286 return *this;
00287 }
00288
00290 inline bool operator==(const LaIndex& s)
00291 {
00292 return start_ == s.start_ && inc_ == s.inc_ && end_ == s.end_;
00293 }
00295 inline bool operator!=(const LaIndex& s)
00296 {
00297 return !operator==(s);
00298 }
00299 };
00300
00301 inline std::ostream& operator<<(std::ostream& s, const LaIndex& i)
00302 {
00303 s << "(" << i.start() << ":" << i.inc() << ":" << i.end() << ")";
00304
00305 return s;
00306 }
00307
00308 #endif
00309
00310