104 template <
int Rows=Dynamic,
int Cols=Rows,
class Precision=DefaultPrecision,
class Layout = RowMajor>
105 struct Matrix :
public Layout::template MLayout<Rows, Cols, Precision>
109 using Layout::template MLayout<Rows, Cols, Precision>::my_data;
110 using Layout::template MLayout<Rows, Cols, Precision>::num_rows;
111 using Layout::template MLayout<Rows, Cols, Precision>::num_cols;
123 Layout::template MLayout<Rows,Cols,Precision>(rows, cols)
128 Layout::template MLayout<Rows, Cols, Precision>(p)
133 Layout::template MLayout<Rows, Cols, Precision>(p, r, c)
139 :Layout::template MLayout<Rows, Cols, Precision>(data, rows, cols, rowstride, colstride){}
147 :Layout::template MLayout<Rows,Cols,Precision>(op)
153 template<
int Rows2,
int Cols2,
typename Precision2,
typename Base2>
155 :Layout::template MLayout<Rows,Cols,Precision>(from.num_rows(), from.num_cols())
169 for(
int r=0; r < num_rows(); r++)
170 for(
int c=0; c < num_cols(); c++)
171 (*
this)[r][c] = from[r][c];
184 template<
int Rows2,
int Cols2,
typename Precision2,
typename Base2>
190 for(
int r=0; r < num_rows(); r++)
191 for(
int c=0; c < num_cols(); c++)
192 (*
this)[r][c] = from[r][c];
201 Matrix& operator*=(
const Precision rhs)
203 for(
int r=0; r < num_rows(); r++)
204 for(
int c=0; c < num_cols(); c++)
205 (*
this)[r][c] *= rhs;
210 Matrix& operator/=(
const Precision rhs)
212 for(
int r=0; r < num_rows(); r++)
213 for(
int c=0; c < num_cols(); c++)
214 (*
this)[r][c] /= rhs;
219 template<
int Rows2,
int Cols2,
typename Precision2,
typename Base2>
225 for(
int r=0; r < num_rows(); r++)
226 for(
int c=0; c < num_cols(); c++)
227 (*
this)[r][c] += from[r][c];
235 op.plusequals(*
this);
242 op.minusequals(*
this);
246 template<
int Rows2,
int Cols2,
typename Precision2,
typename Base2>
252 for(
int r=0; r < num_rows(); r++)
253 for(
int c=0; c < num_cols(); c++)
254 (*
this)[r][c] -= from[r][c];
259 template<
int Rows2,
int Cols2,
typename Precision2,
typename Base2>
265 for(
int r=0; r < num_rows(); r++)
266 for(
int c=0; c < num_cols(); c++)
267 if((*
this)[r][c] != rhs[r][c])
272 template<
int Rows2,
int Cols2,
typename Precision2,
typename Base2>
278 for(
int r=0; r < num_rows(); r++)
279 for(
int c=0; c < num_cols(); c++)
280 if((*
this)[r][c] != rhs[r][c])
288 return op.notequal(*
this);
304 #ifdef DOXYGEN_INCLUDE_ONLY_FOR_DOCS 318 const double& operator() (
int r,
int c)
const;
326 const double& operator[](
const std::pair<int,int>& row_col)
const;
330 double& operator[](
const std::pair<int,int>& row_col);
347 double& operator() (
int r,
int c);
367 const Vector& operator[] (
int r)
const;
389 Vector& operator[] (
int r);
394 int num_rows()
const;
399 int num_cols()
const;
461 template<Rstart, Cstart, Rsize, Csize>
479 template<Rstart, Cstart, Rsize, Csize>
494 const Matrix<>& slice(
int rstart,
int cstart,
int rsize,
int csize)
const;
507 Matrix<>& slice(
int rstart,
int cstart,
int rsize,
int csize);
Matrix(int rows, int cols)
Construction of dynamic matrices. Values are not initialized.
Definition: matrix.hh:122
Matrix(Precision *data, int rows, int cols, int rowstride, int colstride, Internal::Slicing)
Advanced construction of dynamically sized slice matrices.
Definition: matrix.hh:138
Matrix & ref()
return me as a non const reference - useful for temporaries
Definition: matrix.hh:298
Pretty generic SFINAE introspection generator.
Definition: vec_test.cc:21
A vector.
Definition: vector.hh:126
A matrix.
Definition: matrix.hh:105
Matrix(const Operator< Op > &op)
Construction from an operator.
Definition: matrix.hh:146
Definition: operators.hh:119
Matrix(const Matrix< Rows2, Cols2, Precision2, Base2 > &from)
constructor from arbitrary matrix
Definition: matrix.hh:154
Matrix(Precision *p, int r, int c)
Construction of dynamically sized slice matrices.
Definition: matrix.hh:132
Matrix(Precision *p)
Construction of statically sized slice matrices.
Definition: matrix.hh:127
Matrix()
Construction of static matrices. Values are not initialized.
Definition: matrix.hh:119
Definition: size_mismatch.hh:103