Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Matrix Matrix::operator*(const mat_vec::Matrix &rhs) const {
- Matrix tmp(*this);
- for (size_t i = 0;i<tmp.cols*tmp.rows;++i) {
- tmp.matrixData[i]*=rhs.matrixData[i];
- }
- return tmp;
- }
- Matrix& Matrix::operator*=(const mat_vec::Matrix &rhs) {
- Matrix tmp = *this * rhs;
- *this = tmp;
- return *this;
- }
- SECTION("Matrix'*'Matrix operator test"){
- Matrix a(4,5.0);
- Matrix b(4,2.0);
- Matrix c = a * b;
- for (size_t i = 0;i < c.shape().first;++i){
- for (size_t j= 0; j < c.shape().second;++j){
- REQUIRE(c.get(i,j) == a.get(i,j) * b.get(i,j));
- }
- }
- }
- SECTION("Matrix'*='Matrix operator test"){
- Matrix a(4,5.0);
- Matrix b(4,2.0);
- Matrix c(a);
- c*=b;
- for (size_t i = 0;i < c.shape().first;++i){
- for (size_t j= 0; j < c.shape().second;++j){
- REQUIRE(c.get(i,j) == a.get(i,j) * b.get(i,j));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement