diff --git a/main.cpp b/main.cpp index 2f274f2d..ac06d7cf 100644 --- a/main.cpp +++ b/main.cpp @@ -117,19 +117,27 @@ PIKbdListener kbd(0, 0, false); int main(int argc, char * argv[]) { - PIMathMatrixd m = PIMathMatrixd::identity(3,3); - m*=33; - piCout << m; - PIMathMatrixd m2; - m2 = m; m2.resize(3,5, 99); - piCout << m2; - m2 = m; m2.resize(5,3, 88); - piCout << m2; - m2 = m; m2.resize(4,9, 77); - piCout << m2; - m2 = m; m2.resize(2,2, 66); - piCout << m2; - m2 = m; m2.resize(2,8, 66); - piCout << m2; + PIMathMatrixd m2(3,3); m2.fill(5); + PIMathVectord v(3); v.fill(4); + //m.fill(7); + piCout << v*m2; + //piCout << m1*m2.transposed(); +// PIMathMatrixd m2; +// m2 = m; m2.resize(3,5, 99); +// piCout << m2; +// m2 = m; m2.resize(5,3, 88); +// piCout << m2; +// m2 = m; m2.resize(4,9, 77); +// piCout << m2; +// m2 = m; m2.resize(2,2, 66); +// piCout << m2; +// m2 = m; m2.resize(2,8, 66); +// piCout << m2; +// piCout << m.transposed() << m.transposed()*m; +// piCout << "zzzzzzzz"; + PIMathMatrixT<3u, 3u, double> n1 = PIMathMatrixT<3u, 3u, double>::filled(5); + PIMathMatrixT<1u, 3u, double> n2 = PIMathMatrixT<1u, 3u, double>::filled(4); + piCout << n2*n1; +// piCout << n.transposed() << n.transposed()*n; return 0; } diff --git a/src_main/math/pimathmatrix.h b/src_main/math/pimathmatrix.h index 5ff9de26..71f3ae1c 100644 --- a/src_main/math/pimathmatrix.h +++ b/src_main/math/pimathmatrix.h @@ -328,10 +328,10 @@ class PIP_EXPORT PIMathMatrix : public PIVector2D { typedef PIMathMatrix _CMatrix; typedef PIMathVector _CMCol; public: - PIMathMatrix(const uint cols = 0, const uint rows = 0) {_V2D::resize(cols, rows);} - PIMathMatrix(const uint cols, const uint rows, const PIVector & val) {_V2D::resize(cols, rows); int i=0; PIMM_FOR_I(c, r) _V2D::element(r, c) = val[i++];} - PIMathMatrix(const PIVector > & 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 & 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 & val) {_V2D::resize(rows, cols); int i=0; PIMM_FOR_I(c, r) _V2D::element(r, c) = val[i++];} + PIMathMatrix(const PIVector > & 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 & 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 & val) {return _CMatrix(val.size(), 1, val.toVector());}