google / mathfu

C++ math library developed primarily for games focused on simplicity and efficiency.

Home Page:http://google.github.io/mathfu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

method HadamardProduct of Matrix can not compile

DamonsJ opened this issue · comments

static inline Matrix<T, Rows, Cols> HadamardProduct( const Matrix<T, Rows, Cols>& m1, const Matrix<T, Rows, Cols>& m2) {
MATHFU_MAT_OPERATOR(m1[i] * m2[i]);
}

this function can not compile because MATHFU_MAT_OPERATOR expand as :
Matrix<T, Rows, Cols> result;
MATHFU_TOOL_MAT_OPERATION(result.data_[i] = (OP));

where result.data_[i] is a vector and m1[i] * m2[i] is a scalar

this shoud be implemented as below:
static inline Matrix<T, Rows, Cols> HadamardProduct( const Matrix<T, Rows, Cols>& m1, const Matrix<T, Rows, Cols>& m2) {
Matrix<T, Rows, Cols> result;
for (int i = 0; i < kElements;++i) {
result[i] = (m1[i] * m2[i]);
}
return result;
}