Implements some missing functions

See merge request oss/rotgen!28
This commit is contained in:
Joel Falcou 2025-09-28 16:15:15 +02:00
parent 5d8a084070
commit b6fcd4b341
34 changed files with 972 additions and 139 deletions

View file

@ -136,13 +136,33 @@ namespace rotgen
concrete_type cwiseAbs2() const { return concrete_type(base().cwiseAbs2()); }
concrete_type cwiseInverse() const { return concrete_type(base().cwiseInverse()); }
concrete_type cwiseSqrt() const { return concrete_type(base().cwiseSqrt()); }
concrete_type cwiseMin (map const& rhs) const { return concrete_type(base().cwiseMin(rhs.base())); }
concrete_type cwiseMax (map const& rhs) const { return concrete_type(base().cwiseMax(rhs.base())); }
concrete_type cwiseQuotient (map const& rhs) const { return concrete_type(base().cwiseQuotient(rhs.base())); }
concrete_type cwiseMin(map const& rhs) const { return concrete_type(base().cwiseMin(rhs.base())); }
concrete_type cwiseMax(map const& rhs) const { return concrete_type(base().cwiseMax(rhs.base())); }
concrete_type cwiseQuotient(map const& rhs) const { return concrete_type(base().cwiseQuotient(rhs.base())); }
concrete_type cwiseProduct(map const& rhs) const { return concrete_type(base().cwiseProduct(rhs.base())); }
concrete_type cwiseMin(value_type s) const { return concrete_type(base().cwiseMin(s)); }
concrete_type cwiseMax(value_type s) const { return concrete_type(base().cwiseMax(s)); }
concrete_type inverse() const { return concrete_type(base().inverse()); }
concrete_type cross(map const& other) const
{
concrete_type that;
if constexpr(RowsAtCompileTime==-1)
{
that(0,0) = (*this)(1,0) * other(2,0) - (*this)(2,0) * other(1,0);
that(1,0) = (*this)(2,0) * other(0,0) - (*this)(0,0) * other(2,0);
that(2,0) = (*this)(0,0) * other(1,0) - (*this)(1,0) * other(0,0);
}
else
{
that(0,0) = (*this)(0,1) * other(0,2) - (*this)(0,2) * other(0,1);
that(0,1) = (*this)(0,2) * other(0,0) - (*this)(0,0) * other(0,2);
that(0,2) = (*this)(0,0) * other(0,1) - (*this)(0,1) * other(0,0);
}
return that;
}
void normalize() requires(!is_immutable && IsVectorAtCompileTime)
{
parent::normalize();
@ -150,15 +170,17 @@ namespace rotgen
void transposeInPlace() requires(!is_immutable) { parent::transposeInPlace(); }
void adjointInPlace() requires(!is_immutable) { parent::adjointInPlace(); }
map& operator+=(map const& rhs) requires(!is_immutable)
template<typename R2, int O2, typename S2>
map& operator+=(map<R2,O2,S2> const& rhs) requires(!is_immutable)
{
base() += static_cast<parent const&>(rhs);
base() += rhs.base();
return *this;
}
map& operator-=(map const& rhs) requires(!is_immutable)
template<typename R2, int O2, typename S2>
map& operator-=(map<R2,O2,S2> const& rhs) requires(!is_immutable)
{
base() -= static_cast<parent const&>(rhs);
base() -= rhs.base();
return *this;
}
@ -167,9 +189,10 @@ namespace rotgen
return concrete_type(base().operator-());
}
map& operator*=(map const& rhs) requires(!is_immutable)
template<typename R2, int O2, typename S2>
map& operator*=(map<R2,O2,S2> const& rhs) requires(!is_immutable)
{
base() *= static_cast<parent const&>(rhs);
base() *= rhs.base();
return *this;
}
@ -297,22 +320,26 @@ namespace rotgen
template<typename R1, typename R2, int O1, typename S1, int O2, typename S2>
typename map<R1,O1,S1>::concrete_type operator+(map<R1,O1,S1> const& lhs, map<R2,O2,S2> const& rhs)
{
using concrete_type = typename map<R1,O1,S1>::concrete_type;
return concrete_type(lhs.base().add(map<R1,O1,S1>(rhs)));
// REPLICATE TODO
using map_type = map<R1 const,O1,S1>;
using concrete_type = typename map_type::concrete_type;
return concrete_type(map_type(lhs).base().add(map_type(rhs)));
}
template<typename R1, typename R2, int O1, typename S1, int O2, typename S2>
typename map<R1,O1,S1>::concrete_type operator-(map<R1,O1,S1> const& lhs, map<R2,O2,S2> const& rhs)
{
using concrete_type = typename map<R1,O1,S1>::concrete_type;
return concrete_type(lhs.base().sub(map<R1,O1,S1>(rhs)));
using map_type = map<R1 const,O1,S1>;
using concrete_type = typename map_type::concrete_type;
return concrete_type(map_type(lhs).base().sub(map_type(rhs)));
}
template<typename R1, typename R2, int O1, typename S1, int O2, typename S2>
typename map<R1,O1,S1>::concrete_type operator*(map<R1,O1,S1> const& lhs, map<R2,O2,S2> const& rhs)
{
using concrete_type = typename map<R1,O1,S1>::concrete_type;
return concrete_type(lhs.base().mul(map<R1,O1,S1>(rhs)));
using map_type = map<R1 const,O1,S1>;
using concrete_type = typename map_type::concrete_type;
return concrete_type(map_type(lhs).base().mul(map_type(rhs)));
}
template<typename R, int O, typename S>