43 template<
int RowStr
ide,
int ColStr
ide>
struct Slice 46 template<
int Rows,
int Cols,
class Precision>
struct MLayout:
public GenericMBase<Rows, Cols, Precision, RowStride, ColStride, MatrixSlice<Rows, Cols, Precision> >
48 MLayout(Precision* p,
int rows,
int cols,
int rowstride,
int colstride)
49 :
GenericMBase<Rows,Cols,Precision,RowStride,ColStride,MatrixSlice<Rows, Cols, Precision> >(p, rows, cols, rowstride, colstride)
56 template<
int Rows,
int Cols,
bool D = (Rows == Dynamic || Cols == Dynamic)>
59 static const int size = Dynamic;
61 template<
int Rows,
int Cols>
64 static const int size = (Rows<Cols?Rows:Cols);
67 template<
int Rs,
int Cs,
bool D = (Rs == Dynamic || Cs == Dynamic)>
70 static const int stride = Dynamic;
72 template<
int Rs,
int Cs>
75 static const int stride = Rs + Cs;
79 template<
int Rows,
int Cols,
class Precision,
int RowStr
ide,
int ColStr
ide,
class Mem>
struct GenericMBase 85 static const int SliceRowStride = RowStride == -2?-1: RowStride;
86 static const int SliceColStride = ColStride == -2?-1: ColStride;
90 int rowstride()
const {
98 int colstride()
const {
114 GenericMBase(Precision* p,
int r,
int c,
int rowstride,
int colstride)
134 Precision& operator()(
int r,
int c){
135 Internal::check_index(
num_rows(), r);
136 Internal::check_index(
num_cols(), c);
137 return my_data[r*rowstride() + c*colstride()];
140 const Precision& operator()(
int r,
int c)
const {
141 Internal::check_index(
num_rows(), r);
142 Internal::check_index(
num_cols(), c);
143 return my_data[r*rowstride() + c*colstride()];
146 Precision& operator[](
const std::pair<int, int>& index) {
147 Internal::check_index(
num_rows(), index.first);
148 Internal::check_index(
num_cols(), index.second);
149 return (*
this)(index.first, index.second);
152 const Precision& operator[](
const std::pair<int, int>& index)
const {
153 Internal::check_index(
num_rows(), index.first);
154 Internal::check_index(
num_cols(), index.second);
155 return (*
this)(index.first, index.second);
162 Vec operator[](
int r) {
163 Internal::check_index(
num_rows(), r);
164 return Vec(my_data + rowstride()* r,
num_cols(), colstride(),
Slicing());
167 const CVec operator[](
int r)
const {
168 Internal::check_index(
num_rows(), r);
169 return CVec(my_data + rowstride()* r,
num_cols(), colstride(),
Slicing());
174 template<
int Rstart,
int Cstart,
int Rlength,
int Clength>
182 my_data+rowstride()*(Rstart==Dynamic?rs:Rstart) + colstride()*(Cstart==Dynamic?cs:Cstart),
183 Rlength==Dynamic?rl:Rlength,
184 Clength==Dynamic?cl:Clength,
185 rowstride(), colstride(),
Slicing());
188 template<
int Rstart,
int Cstart,
int Rlength,
int Clength>
196 my_data+rowstride()*(Rstart==Dynamic?rs:Rstart) + colstride()*(Cstart==Dynamic?cs:Cstart),
197 Rlength==Dynamic?rl:Rlength,
198 Clength==Dynamic?cl:Clength,
199 rowstride(), colstride(),
Slicing());
203 template<
int Rstart,
int Cstart,
int Rlength,
int Clength>
209 return slice<Rstart, Cstart, Rlength, Clength>(Rstart, Cstart, Rlength, Clength);
212 template<
int Rstart,
int Cstart,
int Rlength,
int Clength>
217 return slice<Rstart, Cstart, Rlength, Clength>(Rstart, Cstart, Rlength, Clength);
221 return slice<Dynamic, Dynamic, Dynamic, Dynamic>(rs, cs, rl, cl);
225 return slice<Dynamic, Dynamic, Dynamic, Dynamic>(rs, cs, rl, cl);
260 template<
int Rows,
int Cols,
class Precision>
struct MLayout:
public Internal::GenericMBase<Rows, Cols, Precision, (Cols==-1?-2:Cols), 1, Internal::MatrixAlloc<Rows, Cols, Precision> >
280 template<
int Rows,
int Cols,
class Precision>
struct MLayout:
public Internal::GenericMBase<Rows, Cols, Precision, 1, (Rows==-1?-2:Rows), Internal::MatrixAlloc<Rows, Cols, Precision> >
Definition: slice_error.hh:56
Pretty generic SFINAE introspection generator.
Definition: vec_test.cc:21
A vector.
Definition: vector.hh:126
Definition: allocator.hh:699
A matrix.
Definition: matrix.hh:105
Definition: allocator.hh:715
Definition: operators.hh:119
int num_rows() const
Return the number of rows.
Definition: allocator.hh:520
int num_cols() const
Return the number of columns.
Definition: allocator.hh:546
int size() const
Simply return the statcally known size.
Definition: allocator.hh:475