[ARITHMETIC OPERATORS][IMPLEMENTATION] implmeented the binary and compound / operator

This commit is contained in:
kallore 2025-05-19 10:28:10 +02:00
parent 12b867e1c9
commit ee3197a0a6
3 changed files with 20 additions and 0 deletions

View file

@ -47,6 +47,7 @@ namespace rotgen
matrix_impl64& operator-();
matrix_impl64& operator*=(matrix_impl64 const& rhs);
matrix_impl64& operator*=(double d);
matrix_impl64& operator/=(double d);
friend std::ostream& operator<<(std::ostream&,matrix_impl64 const&);
friend bool operator==(matrix_impl64 const& lhs, matrix_impl64 const& rhs);

View file

@ -91,6 +91,12 @@ namespace rotgen
static_cast<parent&>(*this) *= rhs;
return *this;
}
matrix& operator/=(double rhs)
{
static_cast<parent&>(*this) /= rhs;
return *this;
}
};
template<typename S, int R, int C, int O, int MR, int MC>
@ -126,4 +132,11 @@ namespace rotgen
{
return rhs * lhs;
}
template<typename S, int R, int C, int O, int MR, int MC>
matrix<S,R,C,O,MR,MC> operator/(matrix<S,R,C,O,MR,MC> const& lhs, double rhs)
{
matrix<S,R,C,O,MR,MC> that(lhs);
return that /= rhs;
}
}

View file

@ -119,4 +119,10 @@ namespace rotgen
storage_->data *= s;
return *this;
}
matrix_impl64& matrix_impl64::operator/=(double s)
{
storage_->data /= s;
return *this;
}
}