Resolve "[API-#2] Pseudo-privatization of rotgen entity member functions"

Closes #18

Co-authored-by: Jules Pénuchot <jules@penuchot.com>

See merge request oss/rotgen!50
This commit is contained in:
Jules Pénuchot 2025-12-17 20:48:00 +01:00 committed by Joel Falcou
parent 6489697c05
commit e151e136d6
52 changed files with 2212 additions and 1556 deletions

View file

@ -34,7 +34,7 @@ CLASSNAME::CLASSNAME(Index r, Index c, std::initializer_list<TYPE> init)
for (std::size_t i = 0; i < init.size(); i++) (*this)(i) = first[i];
}
CLASSNAME::CLASSNAME(CLASSNAME const& o) : CLASSNAME(o.rows(), o.cols())
CLASSNAME::CLASSNAME(CLASSNAME const& o) : CLASSNAME(o._rows(), o._cols())
{
storage_->data = o.storage_->data;
}
@ -54,27 +54,27 @@ CLASSNAME::~CLASSNAME() = default;
//==================================================================================================
// Matrix API
//==================================================================================================
rotgen::Index CLASSNAME::rows() const
rotgen::Index CLASSNAME::size() const
{
return storage_->data.size();
}
rotgen::Index CLASSNAME::_rows() const
{
return storage_->data.rows();
}
rotgen::Index CLASSNAME::cols() const
rotgen::Index CLASSNAME::_cols() const
{
return storage_->data.cols();
}
rotgen::Index CLASSNAME::size() const
{
return storage_->data.size();
}
void CLASSNAME::resize(Index new_rows, Index new_cols)
{
storage_->data.resize(new_rows, new_cols);
}
void CLASSNAME::conservativeResize(Index new_rows, Index new_cols)
void CLASSNAME::_conservativeResize(Index new_rows, Index new_cols)
{
storage_->data.conservativeResize(new_rows, new_cols);
}
@ -109,128 +109,128 @@ TYPE* CLASSNAME::data()
return storage_->data.data();
}
CLASSNAME CLASSNAME::normalized() const
CLASSNAME CLASSNAME::_normalized() const
{
CLASSNAME result(*this);
result.storage_->data.normalize();
return result;
}
CLASSNAME CLASSNAME::transpose() const
CLASSNAME CLASSNAME::_transpose() const
{
CLASSNAME result;
result.storage()->data = storage_->data.transpose();
return result;
}
CLASSNAME CLASSNAME::conjugate() const
CLASSNAME CLASSNAME::_conjugate() const
{
CLASSNAME result(*this);
result.storage_->data = storage_->data.conjugate();
return result;
}
CLASSNAME CLASSNAME::adjoint() const
CLASSNAME CLASSNAME::_adjoint() const
{
CLASSNAME result;
result.storage()->data = storage_->data.adjoint();
return result;
}
void CLASSNAME::normalize()
void CLASSNAME::_normalize()
{
storage_->data.normalize();
}
void CLASSNAME::transposeInPlace()
void CLASSNAME::_transposeInPlace()
{
storage_->data.transposeInPlace();
}
void CLASSNAME::adjointInPlace()
void CLASSNAME::_adjointInPlace()
{
storage_->data.adjointInPlace();
}
CLASSNAME CLASSNAME::cwiseAbs() const
CLASSNAME CLASSNAME::_cwiseAbs() const
{
CLASSNAME result(*this);
result.storage_->data = storage_->data.cwiseAbs();
return result;
}
CLASSNAME CLASSNAME::cwiseAbs2() const
CLASSNAME CLASSNAME::_cwiseAbs2() const
{
CLASSNAME result(*this);
result.storage_->data = storage_->data.cwiseAbs2();
return result;
}
CLASSNAME CLASSNAME::cwiseInverse() const
CLASSNAME CLASSNAME::_cwiseInverse() const
{
CLASSNAME result(*this);
result.storage_->data = storage_->data.cwiseInverse();
return result;
}
CLASSNAME CLASSNAME::cwiseSqrt() const
CLASSNAME CLASSNAME::_cwiseSqrt() const
{
CLASSNAME result(*this);
result.storage_->data = storage_->data.cwiseSqrt();
return result;
}
TYPE CLASSNAME::sum() const
TYPE CLASSNAME::_sum() const
{
return storage_->data.sum();
}
TYPE CLASSNAME::prod() const
TYPE CLASSNAME::_prod() const
{
return storage_->data.prod();
}
TYPE CLASSNAME::mean() const
TYPE CLASSNAME::_mean() const
{
return storage_->data.mean();
}
TYPE CLASSNAME::trace() const
TYPE CLASSNAME::_trace() const
{
return storage_->data.trace();
}
TYPE CLASSNAME::minCoeff() const
TYPE CLASSNAME::_minCoeff() const
{
return storage_->data.minCoeff();
}
TYPE CLASSNAME::maxCoeff() const
TYPE CLASSNAME::_maxCoeff() const
{
return storage_->data.maxCoeff();
}
TYPE CLASSNAME::minCoeff(Index* row, Index* col) const
TYPE CLASSNAME::_minCoeff(Index* row, Index* col) const
{
return storage_->data.minCoeff(row, col);
}
TYPE CLASSNAME::maxCoeff(Index* row, Index* col) const
TYPE CLASSNAME::_maxCoeff(Index* row, Index* col) const
{
return storage_->data.maxCoeff(row, col);
}
TYPE CLASSNAME::squaredNorm() const
TYPE CLASSNAME::_squaredNorm() const
{
return storage_->data.squaredNorm();
}
TYPE CLASSNAME::norm() const
TYPE CLASSNAME::_norm() const
{
return storage_->data.norm();
}
TYPE CLASSNAME::lp_norm(int p) const
TYPE CLASSNAME::_lp_norm(int p) const
{
if (p == 1) return storage_->data.lpNorm<1>();
else if (p == 2) return storage_->data.lpNorm<2>();
@ -301,27 +301,27 @@ CLASSNAME& CLASSNAME::operator/=(TYPE s)
//==============================================================================
// Generators functions
//==============================================================================
void CLASSNAME::setOnes(Index rows, Index cols)
void CLASSNAME::_setOnes(Index rows, Index cols)
{
storage_->assign(payload::data_type::Ones(rows, cols).eval());
}
void CLASSNAME::setZero(Index rows, Index cols)
void CLASSNAME::_setZero(Index rows, Index cols)
{
storage_->assign(payload::data_type::Zero(rows, cols).eval());
}
void CLASSNAME::setConstant(Index rows, Index cols, TYPE value)
void CLASSNAME::_setConstant(Index rows, Index cols, TYPE value)
{
storage_->assign(payload::data_type::Constant(rows, cols, value).eval());
}
void CLASSNAME::setRandom(Index rows, Index cols)
void CLASSNAME::_setRandom(Index rows, Index cols)
{
storage_->assign(payload::data_type::Random(rows, cols).eval());
}
void CLASSNAME::setIdentity(Index rows, Index cols)
void CLASSNAME::_setIdentity(Index rows, Index cols)
{
storage_->assign(payload::data_type::Identity(rows, cols).eval());
}
@ -329,21 +329,21 @@ void CLASSNAME::setIdentity(Index rows, Index cols)
//==============================================================================
// Static functions
//==============================================================================
CLASSNAME CLASSNAME::Ones(Index rows, Index cols)
CLASSNAME CLASSNAME::_Ones(Index rows, Index cols)
{
CLASSNAME m;
m.storage_ = std::make_unique<payload>(payload::data_type::Ones(rows, cols));
return m;
}
CLASSNAME CLASSNAME::Zero(Index rows, Index cols)
CLASSNAME CLASSNAME::_Zero(Index rows, Index cols)
{
CLASSNAME m;
m.storage_ = std::make_unique<payload>(payload::data_type::Zero(rows, cols));
return m;
}
CLASSNAME CLASSNAME::Constant(Index rows, Index cols, TYPE value)
CLASSNAME CLASSNAME::_Constant(Index rows, Index cols, TYPE value)
{
CLASSNAME m;
m.storage_ =
@ -351,7 +351,7 @@ CLASSNAME CLASSNAME::Constant(Index rows, Index cols, TYPE value)
return m;
}
CLASSNAME CLASSNAME::Random(Index rows, Index cols)
CLASSNAME CLASSNAME::_Random(Index rows, Index cols)
{
CLASSNAME m;
m.storage_ =
@ -359,7 +359,7 @@ CLASSNAME CLASSNAME::Random(Index rows, Index cols)
return m;
}
CLASSNAME CLASSNAME::Identity(Index rows, Index cols)
CLASSNAME CLASSNAME::_Identity(Index rows, Index cols)
{
CLASSNAME m;
m.storage_ =