109 template <
int Rows=-1,
int Cols=Rows,
class Precision=
DefaultPrecision,
class Layout = RowMajor>
110 struct Matrix :
public Layout::template MLayout<Rows, Cols, Precision>
114 using Layout::template MLayout<Rows, Cols, Precision>::my_data;
115 using Layout::template MLayout<Rows, Cols, Precision>::num_rows;
116 using Layout::template MLayout<Rows, Cols, Precision>::num_cols;
128 Layout::template MLayout<Rows,Cols,Precision>(rows, cols)
133 Layout::template MLayout<Rows, Cols, Precision>(p)
138 Layout::template MLayout<Rows, Cols, Precision>(p, r, c)
144 :Layout::template MLayout<Rows, Cols, Precision>(data, rows, cols, rowstride, colstride){}
152 :Layout::template MLayout<Rows,Cols,Precision>(op)
158 template<
int Rows2,
int Cols2,
typename Precision2,
typename Base2>
160 :Layout::template MLayout<Rows,Cols,Precision>(from.num_rows(), from.num_cols())
174 for(
int r=0; r < num_rows(); r++)
175 for(
int c=0; c < num_cols(); c++)
176 (*
this)[r][c] = from[r][c];
189 template<
int Rows2,
int Cols2,
typename Precision2,
typename Base2>
195 for(
int r=0; r < num_rows(); r++)
196 for(
int c=0; c < num_cols(); c++)
197 (*
this)[r][c] = from[r][c];
208 for(
int r=0; r < num_rows(); r++)
209 for(
int c=0; c < num_cols(); c++)
210 (*
this)[r][c] *= rhs;
217 for(
int r=0; r < num_rows(); r++)
218 for(
int c=0; c < num_cols(); c++)
219 (*
this)[r][c] /= rhs;
224 template<
int Rows2,
int Cols2,
typename Precision2,
typename Base2>
230 for(
int r=0; r < num_rows(); r++)
231 for(
int c=0; c < num_cols(); c++)
232 (*
this)[r][c] += from[r][c];
240 op.plusequals(*
this);
247 op.minusequals(*
this);
251 template<
int Rows2,
int Cols2,
typename Precision2,
typename Base2>
257 for(
int r=0; r < num_rows(); r++)
258 for(
int c=0; c < num_cols(); c++)
259 (*
this)[r][c] -= from[r][c];
264 template<
int Rows2,
int Cols2,
typename Precision2,
typename Base2>
270 for(
int r=0; r < num_rows(); r++)
271 for(
int c=0; c < num_cols(); c++)
272 if((*
this)[r][c] != rhs[r][c])
277 template<
int Rows2,
int Cols2,
typename Precision2,
typename Base2>
283 for(
int r=0; r < num_rows(); r++)
284 for(
int c=0; c < num_cols(); c++)
285 if((*
this)[r][c] != rhs[r][c])
302 #ifdef DOXYGEN_INCLUDE_ONLY_FOR_DOCS
315 const double& operator() (
int r,
int c)
const;
323 const double& operator[](
const std::pair<int,int>& row_col)
const;
327 double& operator[](
const std::pair<int,int>& row_col);
342 double& operator() (
int r,
int c);
360 const Vector& operator[] (
int r)
const;
380 Vector& operator[] (
int r);
385 int num_rows()
const;
390 int num_cols()
const;
445 template<Rstart, Cstart, Rsize, Csize>
461 template<Rstart, Cstart, Rsize, Csize>
476 const Matrix<>& slice(
int rstart,
int cstart,
int rsize,
int csize)
const;
489 Matrix<>& slice(
int rstart,
int cstart,
int rsize,
int csize);
Matrix & operator=(const Matrix &from)
Matrix & ref()
return me as a non const reference - useful for temporaries
Matrix & operator*=(const Precision &rhs)
Everything lives inside this namespace.
bool operator==(const Matrix< Rows2, Cols2, Precision2, Base2 > &rhs) const
static void test(int s1, int s2)
bool operator!=(const Matrix< Rows2, Cols2, Precision2, Base2 > &rhs) const
Matrix()
Construction of static matrices. Values are not initialized.
double DefaultPrecision
All TooN classes default to using this precision for computations and storage.
Matrix(int rows, int cols)
Construction of dynamic matrices. Values are not initialized.
Matrix & operator/=(const Precision &rhs)
Matrix & operator-=(const Operator< Op > &op)
Matrix & operator+=(const Matrix< Rows2, Cols2, Precision2, Base2 > &from)
Matrix(Precision *data, int rows, int cols, int rowstride, int colstride, Internal::Slicing)
Matrix & operator+=(const Operator< Op > &op)
Matrix(const Operator< Op > &op)
Construction from an operator.
Matrix(const Matrix< Rows2, Cols2, Precision2, Base2 > &from)
constructor from arbitrary matrix
Matrix(Precision *p, int r, int c)
Construction of dynamically sized slice matrices.
Matrix(Precision *p)
Construction of statically sized slice matrices.