Merge branch 'issue-13/cwise' into 'main'
Implement unary cwiseXXX() member functions + associated free functions See merge request oss/rotgen!17
This commit is contained in:
commit
fbe54c9f2c
15 changed files with 207 additions and 6 deletions
|
|
@ -36,6 +36,10 @@ namespace rotgen
|
|||
using parent::prod;
|
||||
using parent::mean;
|
||||
using parent::trace;
|
||||
using parent::cwiseAbs;
|
||||
using parent::cwiseAbs2;
|
||||
using parent::cwiseInverse;
|
||||
using parent::cwiseSqrt;
|
||||
using parent::maxCoeff;
|
||||
using parent::minCoeff;
|
||||
using parent::norm;
|
||||
|
|
@ -104,6 +108,10 @@ namespace rotgen
|
|||
using parent::prod;
|
||||
using parent::mean;
|
||||
using parent::trace;
|
||||
using parent::cwiseAbs;
|
||||
using parent::cwiseAbs2;
|
||||
using parent::cwiseInverse;
|
||||
using parent::cwiseSqrt;
|
||||
using parent::maxCoeff;
|
||||
using parent::minCoeff;
|
||||
using parent::norm;
|
||||
|
|
|
|||
|
|
@ -132,8 +132,12 @@ namespace rotgen
|
|||
return concrete_type(static_cast<parent const&>(*this).adjoint());
|
||||
}
|
||||
|
||||
void transposeInPlace() requires(!is_immutable) { parent::transposeInPlace(); }
|
||||
concrete_type cwiseAbs() const { return concrete_type(base().cwiseAbs()); }
|
||||
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()); }
|
||||
|
||||
void transposeInPlace() requires(!is_immutable) { parent::transposeInPlace(); }
|
||||
void adjointInPlace() requires(!is_immutable) { parent::adjointInPlace(); }
|
||||
|
||||
friend bool operator==(block const& lhs, block const& rhs)
|
||||
|
|
|
|||
|
|
@ -105,6 +105,11 @@ namespace rotgen
|
|||
return concrete_type(static_cast<parent const &>(*this).adjoint());
|
||||
}
|
||||
|
||||
concrete_type cwiseAbs() const { return concrete_type(base().cwiseAbs()); }
|
||||
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()); }
|
||||
|
||||
void transposeInPlace() requires(!is_immutable) { parent::transposeInPlace(); }
|
||||
void adjointInPlace() requires(!is_immutable) { parent::adjointInPlace(); }
|
||||
|
||||
|
|
|
|||
|
|
@ -98,6 +98,11 @@ namespace rotgen
|
|||
void transposeInPlace() { parent::transposeInPlace(); }
|
||||
void adjointInPlace() { parent::adjointInPlace(); }
|
||||
|
||||
matrix cwiseAbs() const { return matrix(base().cwiseAbs()); }
|
||||
matrix cwiseAbs2() const { return matrix(base().cwiseAbs2()); }
|
||||
matrix cwiseInverse() const { return matrix(base().cwiseInverse()); }
|
||||
matrix cwiseSqrt() const { return matrix(base().cwiseSqrt()); }
|
||||
|
||||
friend bool operator==(matrix const& lhs, matrix const& rhs)
|
||||
{
|
||||
return static_cast<parent const&>(lhs) == static_cast<parent const&>(rhs);
|
||||
|
|
|
|||
|
|
@ -140,6 +140,30 @@ namespace rotgen
|
|||
void transposeInPlace() requires(!is_immutable) { parent::transposeInPlace(); }
|
||||
void adjointInPlace() requires(!is_immutable) { parent::adjointInPlace(); }
|
||||
|
||||
auto cwiseAbs() const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return concrete_type{parent::cwiseAbs()};
|
||||
else return base().cwiseAbs();
|
||||
}
|
||||
|
||||
auto cwiseAbs2() const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return concrete_type{parent::cwiseAbs2()};
|
||||
else return base().cwiseAbs2();
|
||||
}
|
||||
|
||||
auto cwiseInverse() const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return concrete_type{parent::cwiseInverse()};
|
||||
else return base().cwiseInverse();
|
||||
}
|
||||
|
||||
auto cwiseSqrt() const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return concrete_type{parent::cwiseSqrt()};
|
||||
else return base().cwiseSqrt();
|
||||
}
|
||||
|
||||
static concrete_type Constant(value_type value) requires (Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Constant(Rows, Cols, static_cast<value_type>(value));
|
||||
|
|
|
|||
|
|
@ -121,6 +121,30 @@ namespace rotgen
|
|||
return *this;
|
||||
}
|
||||
|
||||
auto cwiseAbs() const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return concrete_type{parent::cwiseAbs()};
|
||||
else return base().cwiseAbs();
|
||||
}
|
||||
|
||||
auto cwiseAbs2() const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return concrete_type{parent::cwiseAbs2()};
|
||||
else return base().cwiseAbs2();
|
||||
}
|
||||
|
||||
auto cwiseInverse() const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return concrete_type{parent::cwiseInverse()};
|
||||
else return base().cwiseInverse();
|
||||
}
|
||||
|
||||
auto cwiseSqrt() const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return concrete_type{parent::cwiseSqrt()};
|
||||
else return base().cwiseSqrt();
|
||||
}
|
||||
|
||||
auto transpose() const
|
||||
{
|
||||
if constexpr(use_expression_templates) return base().transpose();
|
||||
|
|
|
|||
|
|
@ -139,6 +139,30 @@ namespace rotgen
|
|||
void transposeInPlace() { parent::transposeInPlace(); }
|
||||
void adjointInPlace() { parent::adjointInPlace(); }
|
||||
|
||||
auto cwiseAbs() const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return matrix{parent::cwiseAbs()};
|
||||
else return base().cwiseAbs();
|
||||
}
|
||||
|
||||
auto cwiseAbs2() const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return matrix{parent::cwiseAbs2()};
|
||||
else return base().cwiseAbs2();
|
||||
}
|
||||
|
||||
auto cwiseInverse() const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return matrix{parent::cwiseInverse()};
|
||||
else return base().cwiseInverse();
|
||||
}
|
||||
|
||||
auto cwiseSqrt() const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return matrix{parent::cwiseSqrt()};
|
||||
else return base().cwiseSqrt();
|
||||
}
|
||||
|
||||
void resize(int new_rows, int new_cols) requires(Rows == -1 && Cols == -1)
|
||||
{
|
||||
parent::resize(new_rows, new_cols);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,18 @@ namespace rotgen
|
|||
void transposeInPlace(concepts::entity auto& arg) { arg.transposeInPlace(); }
|
||||
void adjointInPlace(concepts::entity auto& arg) { arg.adjointInPlace(); }
|
||||
|
||||
auto abs(concepts::entity auto const& arg) { return arg.cwiseAbs(); }
|
||||
auto abs2(concepts::entity auto const& arg) { return arg.cwiseAbs2(); }
|
||||
auto rec(concepts::entity auto const& arg) { return arg.cwiseInverse(); }
|
||||
auto sqrt(concepts::entity auto const& arg) { return arg.cwiseSqrt(); }
|
||||
|
||||
#if defined(ROTGEN_ENABLE_EXPRESSION_TEMPLATES)
|
||||
decltype(auto) abs(concepts::eigen_compatible auto const& arg) { return arg.cwiseAbs(); }
|
||||
decltype(auto) abs2(concepts::eigen_compatible auto const& arg) { return arg.cwiseAbs2(); }
|
||||
decltype(auto) rec(concepts::eigen_compatible auto const& arg) { return arg.cwiseInverse(); }
|
||||
decltype(auto) sqrt(concepts::eigen_compatible auto const& arg) { return arg.cwiseSqrt(); }
|
||||
#endif
|
||||
|
||||
auto trace(concepts::entity auto const& arg) { return arg.trace(); }
|
||||
auto squaredNorm(concepts::entity auto const& arg) { return arg.squaredNorm(); }
|
||||
auto norm(concepts::entity auto const& arg) { return arg.norm(); }
|
||||
|
|
|
|||
|
|
@ -50,6 +50,11 @@ class ROTGEN_EXPORT CLASSNAME
|
|||
SOURCENAME conjugate() const;
|
||||
SOURCENAME adjoint() const;
|
||||
|
||||
SOURCENAME cwiseAbs() const;
|
||||
SOURCENAME cwiseAbs2() const;
|
||||
SOURCENAME cwiseInverse() const;
|
||||
SOURCENAME cwiseSqrt() const;
|
||||
|
||||
#if !defined(USE_CONST)
|
||||
void transposeInPlace();
|
||||
void adjointInPlace();
|
||||
|
|
|
|||
|
|
@ -40,6 +40,11 @@ class ROTGEN_EXPORT CLASSNAME
|
|||
SOURCENAME conjugate() const;
|
||||
SOURCENAME adjoint() const;
|
||||
|
||||
SOURCENAME cwiseAbs() const;
|
||||
SOURCENAME cwiseAbs2() const;
|
||||
SOURCENAME cwiseInverse() const;
|
||||
SOURCENAME cwiseSqrt() const;
|
||||
|
||||
#if !defined(USE_CONST)
|
||||
void transposeInPlace();
|
||||
void adjointInPlace();
|
||||
|
|
|
|||
|
|
@ -38,6 +38,11 @@ class ROTGEN_EXPORT CLASSNAME
|
|||
CLASSNAME conjugate() const;
|
||||
CLASSNAME adjoint() const;
|
||||
|
||||
CLASSNAME cwiseAbs() const;
|
||||
CLASSNAME cwiseAbs2() const;
|
||||
CLASSNAME cwiseInverse() const;
|
||||
CLASSNAME cwiseSqrt() const;
|
||||
|
||||
void transposeInPlace();
|
||||
void adjointInPlace();
|
||||
|
||||
|
|
|
|||
|
|
@ -239,6 +239,34 @@ struct CLASSNAME::payload
|
|||
return result;
|
||||
}
|
||||
|
||||
SOURCENAME CLASSNAME::cwiseAbs() const
|
||||
{
|
||||
SOURCENAME result;
|
||||
storage_->apply([&](const auto& blk) { result.storage()->assign(blk.cwiseAbs().eval()); });
|
||||
return result;
|
||||
}
|
||||
|
||||
SOURCENAME CLASSNAME::cwiseAbs2() const
|
||||
{
|
||||
SOURCENAME result;
|
||||
storage_->apply([&](const auto& blk) { result.storage()->assign(blk.cwiseAbs2().eval()); });
|
||||
return result;
|
||||
}
|
||||
|
||||
SOURCENAME CLASSNAME::cwiseInverse() const
|
||||
{
|
||||
SOURCENAME result;
|
||||
storage_->apply([&](const auto& blk) { result.storage()->assign(blk.cwiseInverse().eval()); });
|
||||
return result;
|
||||
}
|
||||
|
||||
SOURCENAME CLASSNAME::cwiseSqrt() const
|
||||
{
|
||||
SOURCENAME result;
|
||||
storage_->apply([&](const auto& blk) { result.storage()->assign(blk.cwiseSqrt().eval()); });
|
||||
return result;
|
||||
}
|
||||
|
||||
SOURCENAME CLASSNAME::adjoint() const
|
||||
{
|
||||
SOURCENAME result;
|
||||
|
|
|
|||
|
|
@ -82,6 +82,34 @@
|
|||
return result;
|
||||
}
|
||||
|
||||
SOURCENAME CLASSNAME::cwiseAbs() const
|
||||
{
|
||||
SOURCENAME result;
|
||||
result.storage()->assign(storage_->data.cwiseAbs().eval());
|
||||
return result;
|
||||
}
|
||||
|
||||
SOURCENAME CLASSNAME::cwiseAbs2() const
|
||||
{
|
||||
SOURCENAME result;
|
||||
result.storage()->assign(storage_->data.cwiseAbs2().eval());
|
||||
return result;
|
||||
}
|
||||
|
||||
SOURCENAME CLASSNAME::cwiseInverse() const
|
||||
{
|
||||
SOURCENAME result;
|
||||
result.storage()->assign(storage_->data.cwiseInverse().eval());
|
||||
return result;
|
||||
}
|
||||
|
||||
SOURCENAME CLASSNAME::cwiseSqrt() const
|
||||
{
|
||||
SOURCENAME result;
|
||||
result.storage()->assign(storage_->data.cwiseSqrt().eval());
|
||||
return result;
|
||||
}
|
||||
|
||||
#if !defined(USE_CONST)
|
||||
void CLASSNAME::transposeInPlace()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -106,6 +106,34 @@ void CLASSNAME::adjointInPlace()
|
|||
storage_->data.adjointInPlace();
|
||||
}
|
||||
|
||||
CLASSNAME CLASSNAME::cwiseAbs() const
|
||||
{
|
||||
CLASSNAME result(*this);
|
||||
result.storage_->data = storage_->data.cwiseAbs();
|
||||
return result;
|
||||
}
|
||||
|
||||
CLASSNAME CLASSNAME::cwiseAbs2() const
|
||||
{
|
||||
CLASSNAME result(*this);
|
||||
result.storage_->data = storage_->data.cwiseAbs2();
|
||||
return result;
|
||||
}
|
||||
|
||||
CLASSNAME CLASSNAME::cwiseInverse() const
|
||||
{
|
||||
CLASSNAME result(*this);
|
||||
result.storage_->data = storage_->data.cwiseInverse();
|
||||
return result;
|
||||
}
|
||||
|
||||
CLASSNAME CLASSNAME::cwiseSqrt() const
|
||||
{
|
||||
CLASSNAME result(*this);
|
||||
result.storage_->data = storage_->data.cwiseSqrt();
|
||||
return result;
|
||||
}
|
||||
|
||||
TYPE CLASSNAME::sum() const { return storage_->data.sum(); }
|
||||
TYPE CLASSNAME::prod() const { return storage_->data.prod(); }
|
||||
TYPE CLASSNAME::mean() const { return storage_->data.mean(); }
|
||||
|
|
|
|||
|
|
@ -82,7 +82,3 @@ TTS_CASE("Matrix size-related operations")
|
|||
TTS_EXPECT_NOT_COMPILES(a, { rotgen::resize(a, 4, 5); });
|
||||
TTS_EXPECT_NOT_COMPILES(a, { rotgen::conservativeResize(a, 4, 5); });
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue