00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 template<class Rep, class ExtraTParam> class StaticConstSubVecView;
00025 template<class Rep> class DynConstSubVecView;
00026
00028 template<class Rep, class ExtraTParam>
00029 class StaticSubVecView : public StaticSubVecViewTag
00030 {
00031 public:
00032 typedef StaticSubVecView<Rep, ExtraTParam> self_type;
00033 typedef StaticSubVecViewTag exp_tag;
00034 typedef ExtraTParam extra_param_type;
00035 typedef StaticConstSubVecView<Rep, ExtraTParam> const_view_type;
00036 COMMON_VIEW_TYPEDEFS();
00037
00038 enum {
00039 BEGIN = ExtraTParam::INT1,
00040 SIZE = ExtraTParam::INT2,
00041 ROWS = super_type::ROWS == 1 ? 1 : SIZE,
00042 COLS = super_type::COLS == 1 ? 1 : SIZE,
00043 IsLinear = true,
00044 IsLinearRecursive = IsLinear && super_type::IsLinearRecursive,
00045 TNOP = 0,
00046 ENOP = 0,
00047 EXPLevel = Rep::EXPLevel + 1
00048 };
00049
00051 typedef Vec<DenseMatCon<value_type,ROWS,COLS>, EmptyErrorChecker> temp_type;
00052
00053
00054
00055 EXMAT_INLINE2 StaticSubVecView(const self_type& self)
00056 : rep(self.rep) {}
00057 EXMAT_INLINE2 StaticSubVecView(Rep& vec)
00058 : rep(vec) { ComErrCheck(); }
00060 template<class Rep2> EXMAT_INLINE2
00061 StaticSubVecView(const Rep2& self, Rep& vec)
00062 : rep(vec) {
00063 THROWMSG(ROWS==Rep2::ROWS && COLS==Rep2::COLS, InternalErrMsg, __FILE__);
00064 ComErrCheck();
00065 }
00066
00067
00068
00069 EXMAT_INLINE2 size_t size() const { return SIZE; }
00070 EXMAT_INLINE2 size_t rows() const { return ROWS; }
00071 EXMAT_INLINE2 size_t cols() const { return COLS; }
00072
00073
00074 EXMAT_INLINE2 reference setAt(index_type i)
00075 { return rep.setAt(BEGIN+i); }
00076 EXMAT_INLINE2 const_reference getAt(index_type i) const
00077 { return rep.getAt(BEGIN+i); }
00078 EXMAT_INLINE2 reference setAt(index_type i, index_type j)
00079 { return rep.setAt(ROWS==1?0:BEGIN+i, COLS==1?0:BEGIN+j); }
00080 EXMAT_INLINE2 const_reference getAt(index_type i, index_type j) const
00081 { return rep.getAt(ROWS==1?0:BEGIN+i, COLS==1?0:BEGIN+j); }
00082
00083 private:
00084
00085 EXMAT_INLINE2 void ComErrCheck() {
00086 enum { SuperSIZE = (super_type::ROWS * super_type::COLS) };
00087 #if EXMAT_STATIC_CHECK
00088 StaticAssert1(super_type::ROWS == 1 || super_type::COLS == 1, NotAVec);
00089 StaticAssert1(BEGIN < SuperSIZE, BeginOutOfRange);
00090 StaticAssert1(SIZE > 0 && BEGIN + SIZE <= SuperSIZE, SizeOutOfRange);
00091 #else
00092 DefaultErrorChecker::AssertCompat(
00093 (super_type::ROWS == 1 || super_type::COLS == 1) &&
00094 int(BEGIN) < int(SuperSIZE) &&
00095 (SIZE > 0 && BEGIN + SIZE <= SuperSIZE)
00096 );
00097 #endif // EXMAT_STATIC_CHECK
00098 }
00099 };
00100 #if !EXMAT_VC6
00101
00104 template<class Rep, class ErrChk, int BEGIN, int SIZE> EXMAT_INLINE2 static
00105 Vec<ExpMat<StaticSubVecView<Rep,TParamINT2<BEGIN,SIZE> > >, ErrChk>
00106 subVec(Vec<Rep, ErrChk>& vec, Int2Type<BEGIN>, Int2Type<SIZE>) {
00107 return Vec<ExpMat<StaticSubVecView<Rep,TParamINT2<BEGIN,SIZE> > >, ErrChk>(
00108 ExpMat<StaticSubVecView<Rep,TParamINT2<BEGIN,SIZE> > >(vec)
00109 );
00110 }
00111 #endif // !EXMAT_VC6
00112
00113
00115 template<class Rep, class ExtraTParam>
00116 class StaticConstSubVecView : public StaticSubVecViewTag
00117 {
00118 public:
00119 typedef StaticConstSubVecView<Rep, ExtraTParam> self_type;
00120 typedef StaticSubVecViewTag exp_tag;
00121 typedef ExtraTParam extra_param_type;
00122 COMMON_CONST_VIEW_TYPEDEFS();
00123
00124 enum {
00125 BEGIN = ExtraTParam::INT1,
00126 SIZE = ExtraTParam::INT2,
00127 ROWS = super_type::ROWS == 1 ? 1 : SIZE,
00128 COLS = super_type::COLS == 1 ? 1 : SIZE,
00129 IsLinear = true,
00130 IsLinearRecursive = IsLinear && super_type::IsLinearRecursive,
00131 TNOP = 0,
00132 ENOP = 0,
00133 EXPLevel = Rep::EXPLevel + 1
00134 };
00135
00137 typedef Vec<DenseMatCon<value_type,ROWS,COLS>, EmptyErrorChecker> temp_type;
00138
00139
00140
00141 EXMAT_INLINE2 StaticConstSubVecView(const self_type& self)
00142 : rep(self.rep) {}
00143 EXMAT_INLINE2 StaticConstSubVecView(const Rep& vec)
00144 : rep(vec) { ComErrCheck(); }
00146 template<class Rep2> EXMAT_INLINE2
00147 StaticConstSubVecView(const Rep2& self, const Rep& vec)
00148 : rep(vec) {
00149 THROWMSG(ROWS==Rep2::ROWS && COLS==Rep2::COLS, InternalErrMsg, __FILE__);
00150 ComErrCheck();
00151 }
00152
00153
00154
00155 EXMAT_INLINE2 size_t size() const { return SIZE; }
00156 EXMAT_INLINE2 size_t rows() const { return ROWS; }
00157 EXMAT_INLINE2 size_t cols() const { return COLS; }
00158
00159
00160 EXMAT_INLINE2 const_reference getAt(index_type i) const
00161 { return rep.getAt(BEGIN+i); }
00162 EXMAT_INLINE2 const_reference getAt(index_type i, index_type j) const
00163 { return rep.getAt(ROWS==1?0:BEGIN+i, COLS==1?0:BEGIN+j); }
00164
00165 private:
00166
00167 EXMAT_INLINE2 void ComErrCheck() {
00168 enum { SuperSIZE = (super_type::ROWS * super_type::COLS) };
00169 #if EXMAT_STATIC_CHECK
00170 StaticAssert1(super_type::ROWS == 1 || super_type::COLS == 1, NotAVec);
00171 StaticAssert1(BEGIN < SuperSIZE, BeginOutOfRange);
00172 StaticAssert1(SIZE > 0 && BEGIN + SIZE <= SuperSIZE, SizeOutOfRange);
00173 #else
00174 DefaultErrorChecker::AssertCompat(
00175 (super_type::ROWS == 1 || super_type::COLS == 1) &&
00176 int(BEGIN) < int(SuperSIZE) &&
00177 (SIZE > 0 && BEGIN + SIZE <= SuperSIZE)
00178 );
00179 #endif // EXMAT_STATIC_CHECK
00180 }
00181 };
00182 #if !EXMAT_VC6
00183
00186 template<class Rep, class ErrChk, int BEGIN, int SIZE> EXMAT_INLINE2 static
00187 const Vec<ExpMat<StaticConstSubVecView<Rep,TParamINT2<BEGIN,SIZE> > >, ErrChk>
00188 subVec(const Vec<Rep, ErrChk>& vec, Int2Type<BEGIN>, Int2Type<SIZE>) {
00189 return Vec<ExpMat<StaticConstSubVecView<Rep,TParamINT2<BEGIN,SIZE> > >, ErrChk>(
00190 ExpMat<StaticConstSubVecView<Rep,TParamINT2<BEGIN,SIZE> > >(vec)
00191 );
00192 }
00193 #endif // !EXMAT_VC6
00194
00195
00197 template<class Rep>
00198 class DynSubVecView : public DynSubVecViewTag
00199 {
00200 public:
00201 typedef DynSubVecView<Rep> self_type;
00202 typedef DynSubVecViewTag exp_tag;
00203 typedef NullTag extra_param_type;
00204 typedef DynConstSubVecView<Rep> const_view_type;
00205 COMMON_VIEW_TYPEDEFS();
00206
00207 enum {
00208 ROWS = (Rep::ROWS == 1) ? 1 : 0,
00209 COLS = (Rep::COLS == 1) ? 1 : 0,
00210 IsLinear = true,
00211 IsLinearRecursive = IsLinear && super_type::IsLinearRecursive,
00212 TNOP = 0,
00213 ENOP = 0,
00214 EXPLevel = Rep::EXPLevel + 1
00215 };
00216
00218 typedef Vec<DenseMatCon<value_type,ROWS,COLS>, EmptyErrorChecker> temp_type;
00219
00220
00221
00222 EXMAT_INLINE2 DynSubVecView(const self_type& self)
00223 : rep(self.rep), begin_(self.begin_), size_(self.size_) {}
00224 EXMAT_INLINE2 DynSubVecView(Rep& vec, size_t b, size_t s)
00225 : rep(vec), begin_(b), size_(s) { ComErrCheck(); }
00227 template<class Rep2> EXMAT_INLINE2
00228 DynSubVecView(const Rep2& self, Rep& vec)
00229 : rep(vec), begin_(self.begin_), size_(self.size_) { ComErrCheck(); }
00230
00231
00232
00233 EXMAT_INLINE2 size_t size() const { return size_; }
00234 EXMAT_INLINE2 size_t rows() const { return rep.rows() == 1 ? 1 : size_; }
00235 EXMAT_INLINE2 size_t cols() const { return rep.cols() == 1 ? 1 : size_; }
00236
00237
00238 EXMAT_INLINE2 reference setAt(index_type i)
00239 { return rep.setAt(begin_+i); }
00240 EXMAT_INLINE2 const_reference getAt(index_type i) const
00241 { return rep.getAt(begin_+i); }
00242 EXMAT_INLINE2 reference setAt(index_type i, index_type j)
00243 { return rep.setAt(rep.rows()==1?0:begin_+i, rep.cols()==1?0:begin_+j); }
00244 EXMAT_INLINE2 const_reference getAt(index_type i, index_type j) const
00245 { return rep.getAt(rep.rows()==1?0:begin_+i, rep.cols()==1?0:begin_+j); }
00246
00247 public:
00248 const size_t begin_, size_;
00249
00250 private:
00251
00252 EXMAT_INLINE2 void ComErrCheck() {
00253 DefaultErrorChecker::AssertCompat(
00254 (rep.rows() == 1 || rep.cols() == 1) &&
00255 begin_ < rep.size() &&
00256 (size_ > 0 && begin_ + size_ <= rep.size())
00257 );
00258 }
00259 };
00263 template<class Rep, class ErrChk> EXMAT_INLINE2 static
00264 Vec<ExpMat<DynSubVecView<Rep> >, ErrChk>
00265 subVec(Vec<Rep, ErrChk>& vec, size_t begin, size_t size) {
00266 return Vec<ExpMat<DynSubVecView<Rep> >, ErrChk>(ExpMat<DynSubVecView<Rep> >(vec, begin, size));
00267 }
00268
00269
00271 template<class Rep>
00272 class DynConstSubVecView : public DynSubVecViewTag
00273 {
00274 public:
00275 typedef DynConstSubVecView<Rep> self_type;
00276 typedef DynSubVecViewTag exp_tag;
00277 typedef NullTag extra_param_type;
00278 COMMON_CONST_VIEW_TYPEDEFS();
00279
00280 enum {
00281 ROWS = (Rep::ROWS == 1) ? 1 : 0,
00282 COLS = (Rep::COLS == 1) ? 1 : 0,
00283 IsLinear = true,
00284 IsLinearRecursive = IsLinear && super_type::IsLinearRecursive,
00285 TNOP = 0,
00286 ENOP = 0,
00287 EXPLevel = Rep::EXPLevel + 1
00288 };
00289
00291 typedef Vec<DenseMatCon<value_type,ROWS,COLS>, EmptyErrorChecker> temp_type;
00292
00293
00294
00295 EXMAT_INLINE2 DynConstSubVecView(const self_type& self)
00296 : rep(self.rep), begin_(self.begin_), size_(self.size_) {}
00297 EXMAT_INLINE2 DynConstSubVecView(const Rep& vec, size_t b, size_t s)
00298 : rep(vec), begin_(b), size_(s) { ComErrCheck(); }
00300 template<class Rep2> EXMAT_INLINE2
00301 DynConstSubVecView(const Rep2& self, const Rep& vec)
00302 : rep(vec), begin_(self.begin_), size_(self.size_) { ComErrCheck(); }
00303
00304
00305
00306 EXMAT_INLINE2 size_t size() const { return size_; }
00307 EXMAT_INLINE2 size_t rows() const { return rep.rows() == 1 ? 1 : size_; }
00308 EXMAT_INLINE2 size_t cols() const { return rep.cols() == 1 ? 1 : size_; }
00309
00310
00311 EXMAT_INLINE2 const_reference getAt(index_type i) const
00312 { return rep.getAt(begin_+i); }
00313 EXMAT_INLINE2 const_reference getAt(index_type i, index_type j) const
00314 { return rep.getAt(rep.rows()==1?0:begin_+i, rep.cols()==1?0:begin_+j); }
00315
00316 public:
00317 const size_t begin_, size_;
00318
00319 private:
00320
00321 EXMAT_INLINE2 void ComErrCheck() {
00322 DefaultErrorChecker::AssertCompat(
00323 (rep.rows() == 1 || rep.cols() == 1) &&
00324 begin_ < rep.size() &&
00325 (size_ > 0 && begin_ + size_ <= rep.size())
00326 );
00327 }
00328 };
00332 template<class Rep, class ErrChk> EXMAT_INLINE2 static
00333 const Vec<ExpMat<DynConstSubVecView<Rep> >, ErrChk>
00334 subVec(const Vec<Rep, ErrChk>& vec, size_t begin, size_t size) {
00335 return Vec<ExpMat<DynConstSubVecView<Rep> >, ErrChk>(ExpMat<DynConstSubVecView<Rep> >(vec, begin, size));
00336 }