Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

method HadamardProduct of Matrix can not compile #47

Open
DamonsJ opened this issue Jun 1, 2021 · 0 comments
Open

method HadamardProduct of Matrix can not compile #47

DamonsJ opened this issue Jun 1, 2021 · 0 comments

Comments

@DamonsJ
Copy link

DamonsJ commented Jun 1, 2021

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;
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant