[ARITHMETIC OP][IMPLEMENTATION] rectifie dthe implementation of the unary - operator

This commit is contained in:
kallore 2025-05-19 16:59:10 +02:00
parent ee3197a0a6
commit 721550d0f8
3 changed files with 6 additions and 5 deletions

View file

@ -44,7 +44,7 @@ namespace rotgen
matrix_impl64& operator+=(matrix_impl64 const& rhs); matrix_impl64& operator+=(matrix_impl64 const& rhs);
matrix_impl64& operator-=(matrix_impl64 const& rhs); matrix_impl64& operator-=(matrix_impl64 const& rhs);
matrix_impl64& operator-(); matrix_impl64 operator-() const;
matrix_impl64& operator*=(matrix_impl64 const& rhs); matrix_impl64& operator*=(matrix_impl64 const& rhs);
matrix_impl64& operator*=(double d); matrix_impl64& operator*=(double d);
matrix_impl64& operator/=(double d); matrix_impl64& operator/=(double d);

View file

@ -29,6 +29,8 @@ namespace rotgen
if constexpr(Cols != -1) assert(c == Cols && "Mismatched between dynamic and static column size"); if constexpr(Cols != -1) assert(c == Cols && "Mismatched between dynamic and static column size");
} }
matrix(parent const& base) : parent(base) {}
matrix(std::initializer_list<std::initializer_list<Scalar>> init) : parent(init) matrix(std::initializer_list<std::initializer_list<Scalar>> init) : parent(init)
{ {
if constexpr(Rows != -1) assert(init.size() == Rows && "Mismatched between dynamic and static row size"); if constexpr(Rows != -1) assert(init.size() == Rows && "Mismatched between dynamic and static row size");
@ -75,9 +77,9 @@ namespace rotgen
return *this; return *this;
} }
matrix& operator-() matrix operator-() const
{ {
return static_cast<parent const&>(*this).operator-(); return matrix(static_cast<parent const&>(*this).operator-());
} }
matrix& operator*=(matrix const& rhs) matrix& operator*=(matrix const& rhs)

View file

@ -101,8 +101,7 @@ namespace rotgen
return *this; return *this;
} }
matrix_impl64& matrix_impl64::operator-() matrix_impl64 matrix_impl64::operator-() const {
{
matrix_impl64 result(*this); matrix_impl64 result(*this);
result.storage_->data = -result.storage_->data; result.storage_->data = -result.storage_->data;
return result; return result;