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() { return start_;}
00136 inline int& inc() { return inc_;}
00142 inline int& end() { return end_;}
00143 public:
00144
00147 inline int start() const { return start_;}
00148
00150 inline int inc() const { return inc_;}
00151
00160 inline int end() const { return end_;}
00161
00164 inline int length() const { return ((end()-start())/inc() + 1);}
00165
00168 inline bool null() const { return (start() == 0 &&
00169 inc() == 0 && end() == 0);}
00170
00171 protected:
00184 inline LaIndex& operator()(int start, int end){
00185 start_=start; inc_=1; end_=end; return *this;}
00186 public:
00187
00197 inline LaIndex& set(int start, int end) {
00198 start_=start; inc_=1; end_=end; return *this;}
00199
00221 LaIndex& set(int start, int end, int increment);
00222
00227 inline LaIndex& operator+(int i) {
00228 start_+=i; end_+=i; return *this;}
00229
00231 inline LaIndex& operator=(const LaIndex& i) {
00232 start_=i.start_; inc_=i.inc_; end_=i.end_;
00233 return *this;}
00234
00236 inline bool operator==(const LaIndex& s) {
00237 return start_ == s.start_ && inc_ == s.inc_ && end_ == s.end_;
00238 }
00240 inline bool operator!=(const LaIndex& s) {
00241 return !operator==(s);
00242 }
00243 };
00244
00245 inline std::ostream& operator<<(std::ostream& s, const LaIndex& i)
00246 {
00247 s << "(" << i.start() << ":" << i.inc() << ":" << i.end() << ")";
00248
00249 return s;
00250 }
00251
00252 #endif
00253
00254