diff --git a/src_main/math/pimathmatrix.h b/src_main/math/pimathmatrix.h index 09e6905c..43dab5d1 100644 --- a/src_main/math/pimathmatrix.h +++ b/src_main/math/pimathmatrix.h @@ -536,6 +536,23 @@ inline PIMathVector operator *(const PIMathMatrix & fm, return tv; } + +/// Multiply vector {Rows} on matrix {Rows x Cols}, result is vector {Cols} +template +inline PIMathVector operator *(const PIMathVector & sv, + const PIMathMatrix & fm) { + uint c = fm.cols(), r = fm.rows(); + PIMathVector tv(c); + Type t; + for (uint j = 0; j < c; ++j) { + t = Type(0); + for (uint i = 0; i < r; ++i) + t += fm.element(i, j) * sv[i]; + tv[j] = t; + } + return tv; +} + /// Multiply value(T) on matrix {Rows x Cols}, result is vector {Rows} template inline PIMathMatrix operator *(const Type & x, const PIMathMatrix & v) {