fix math/pimathmatrix.h

This commit is contained in:
2020-06-02 13:05:35 +03:00
parent 988ebac3b7
commit a01c3144f3
2 changed files with 26 additions and 18 deletions

View File

@@ -328,10 +328,10 @@ class PIP_EXPORT PIMathMatrix : public PIVector2D<Type> {
typedef PIMathMatrix<Type> _CMatrix;
typedef PIMathVector<Type> _CMCol;
public:
PIMathMatrix(const uint cols = 0, const uint rows = 0) {_V2D::resize(cols, rows);}
PIMathMatrix(const uint cols, const uint rows, const PIVector<Type> & val) {_V2D::resize(cols, rows); int i=0; PIMM_FOR_I(c, r) _V2D::element(r, c) = val[i++];}
PIMathMatrix(const PIVector<PIVector<Type> > & val) {if(!val.isEmpty()) {_V2D::resize(val[0].size(), val.size()); PIMM_FOR_I(c, r) _V2D::element(r, c) = val[r][c];}}
PIMathMatrix(const PIVector2D<Type> & val) {if(!val.isEmpty()) {_V2D::resize(val.cols(), val.rows()); PIMM_FOR_I(c, r) _V2D::element(r, c) = val.element(r, c);}}
PIMathMatrix(const uint cols = 0, const uint rows = 0, const Type & f = Type()) {_V2D::resize(rows, cols, f);}
PIMathMatrix(const uint cols, const uint rows, const PIVector<Type> & val) {_V2D::resize(rows, cols); int i=0; PIMM_FOR_I(c, r) _V2D::element(r, c) = val[i++];}
PIMathMatrix(const PIVector<PIVector<Type> > & val) {if(!val.isEmpty()) {_V2D::resize(val.size(), val[0].size()); PIMM_FOR_I(c, r) _V2D::element(r, c) = val[r][c];}}
PIMathMatrix(const PIVector2D<Type> & val) {if(!val.isEmpty()) {_V2D::resize(val.rows(), val.cols()); PIMM_FOR_I(c, r) _V2D::element(r, c) = val.element(r, c);}}
static _CMatrix identity(const uint cols, const uint rows) {_CMatrix tm(cols, rows); for (uint r = 0; r < rows; ++r) for (uint c = 0; c < cols; ++c) tm.element(r, c) = (c == r ? Type(1) : Type(0)); return tm;}
static _CMatrix matrixRow(const PIMathVector<Type> & val) {return _CMatrix(val.size(), 1, val.toVector());}