Closed RafalRoszkowski closed 6 years ago
Hi,
Well I used to do some matlab programming and there is .* operator witch multiplies corresponding elements of two matrices: https://www.mathworks.com/help/matlab/ref/times.html
Since I'm finding your library very helpful (thank you) I've just added this function:
template<int rows, int cols, class MemT, class opMemT, class retMemT> Matrix<rows,cols,retMemT> &ElementwiseMultiply(const Matrix<rows,cols,MemT> &A, const Matrix<rows,cols,opMemT> &B, Matrix<rows,cols,retMemT> &C) { for(int i = 0; i < rows; i++) for(int j = 0; j < cols; j++) C(i,j) = A(i,j) * B(i,j);
return C;
}
Just in case you'd like to add it to future versions of the library, go ahead . Regards and have a nice day Raffe :)
Hi Raffe, Glad to hear you're enjoying the library! Thanks for the suggestion, I'll try to add it in when I'm next making an update. Alternatively, feel free to make a PR! All the best, Tom
Hi,
Well I used to do some matlab programming and there is .* operator witch multiplies corresponding elements of two matrices: https://www.mathworks.com/help/matlab/ref/times.html
Since I'm finding your library very helpful (thank you) I've just added this function:
template<int rows, int cols, class MemT, class opMemT, class retMemT> Matrix<rows,cols,retMemT> &ElementwiseMultiply(const Matrix<rows,cols,MemT> &A, const Matrix<rows,cols,opMemT> &B, Matrix<rows,cols,retMemT> &C) { for(int i = 0; i < rows; i++) for(int j = 0; j < cols; j++) C(i,j) = A(i,j) * B(i,j);
}
Just in case you'd like to add it to future versions of the library, go ahead . Regards and have a nice day Raffe :)