Adding clang-format configuration file and formatting all source files
Co-authored-by: Jules Pénuchot <jules@penuchot.com> Co-authored-by: Joel FALCOU <jfalcou@codereckons.com> See merge request oss/rotgen!41
This commit is contained in:
parent
e92e824a18
commit
648dd768ee
94 changed files with 6778 additions and 4722 deletions
|
|
@ -13,4 +13,4 @@
|
|||
#include <rotgen/algebra/svd/dynamic.hpp>
|
||||
#else
|
||||
#include <rotgen/algebra/svd/fixed.hpp>
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@
|
|||
namespace rotgen::solver
|
||||
{
|
||||
template<typename X, typename M, typename RHS>
|
||||
void qr(X& x, M const& m, RHS const& rhs )
|
||||
void qr(X& x, M const& m, RHS const& rhs)
|
||||
{
|
||||
auto r_x = generalize_t<X>(x);
|
||||
auto r_m = generalize_t<M const>(m);
|
||||
auto r_x = generalize_t<X>(x);
|
||||
auto r_m = generalize_t<M const>(m);
|
||||
auto r_rhs = generalize_t<RHS const>(rhs);
|
||||
r_x = r_m.base().qr_solve(r_rhs.base());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,26 +11,34 @@
|
|||
|
||||
namespace rotgen
|
||||
{
|
||||
template<typename M>
|
||||
struct svd : find_svd<typename M::value_type,M::Options>
|
||||
template<typename M> struct svd : find_svd<typename M::value_type, M::Options>
|
||||
{
|
||||
using parent = find_svd<typename M::value_type,M::Options>;
|
||||
using parent = find_svd<typename M::value_type, M::Options>;
|
||||
|
||||
using m_type = matrix<typename M::value_type,Dynamic,Dynamic,M::Options>;
|
||||
using d_type = matrix<typename M::value_type,M::ColsAtCompileTime,1>;
|
||||
using m_type = matrix<typename M::value_type, Dynamic, Dynamic, M::Options>;
|
||||
using d_type = matrix<typename M::value_type, M::ColsAtCompileTime, 1>;
|
||||
|
||||
svd(M const& m, int options = ComputeThinU | ComputeThinV) : parent(m,options) {}
|
||||
svd(M const& m, int options = ComputeThinU | ComputeThinV)
|
||||
: parent(m, options)
|
||||
{
|
||||
}
|
||||
|
||||
int rank() const { return parent::rank(); }
|
||||
int rank() const { return parent::rank(); }
|
||||
|
||||
m_type U() const { return parent::U(); }
|
||||
m_type D() const { return parent::D(); }
|
||||
m_type V() const { return parent::V(); }
|
||||
d_type singular_values() const { return parent::singular_values(); }
|
||||
m_type U() const { return parent::U(); }
|
||||
|
||||
m_type U(int r) const { return parent::U(r); }
|
||||
m_type D(int r) const { return parent::D(r); }
|
||||
m_type V(int r) const { return parent::V(r); }
|
||||
m_type singular_values(int r) const { return parent::singular_values(r); }
|
||||
m_type D() const { return parent::D(); }
|
||||
|
||||
m_type V() const { return parent::V(); }
|
||||
|
||||
d_type singular_values() const { return parent::singular_values(); }
|
||||
|
||||
m_type U(int r) const { return parent::U(r); }
|
||||
|
||||
m_type D(int r) const { return parent::D(r); }
|
||||
|
||||
m_type V(int r) const { return parent::V(r); }
|
||||
|
||||
m_type singular_values(int r) const { return parent::singular_values(r); }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,50 +19,64 @@ namespace rotgen
|
|||
class matrix_impl32_row;
|
||||
class matrix_impl32_col;
|
||||
|
||||
#define SIZE 64
|
||||
#define TYPE double
|
||||
#define SIZE 64
|
||||
#define TYPE double
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(svd_impl,SIZE,_col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#include <rotgen/algebra/svd/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef SOURCENAME
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(svd_impl, SIZE, _col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _col)
|
||||
#include <rotgen/algebra/svd/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef SOURCENAME
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(svd_impl,SIZE,_row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#include <rotgen/algebra/svd/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef SOURCENAME
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(svd_impl, SIZE, _row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _row)
|
||||
#include <rotgen/algebra/svd/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef SOURCENAME
|
||||
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
|
||||
#define SIZE 32
|
||||
#define TYPE float
|
||||
#define SIZE 32
|
||||
#define TYPE float
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(svd_impl,SIZE,_col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#include <rotgen/algebra/svd/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef SOURCENAME
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(svd_impl, SIZE, _col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _col)
|
||||
#include <rotgen/algebra/svd/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef SOURCENAME
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(svd_impl,SIZE,_row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#include <rotgen/algebra/svd/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef SOURCENAME
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(svd_impl, SIZE, _row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _row)
|
||||
#include <rotgen/algebra/svd/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef SOURCENAME
|
||||
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
|
||||
template<typename Scalar, int Options> struct find_svd_impl;
|
||||
|
||||
template<typename Scalar,int Options> struct find_svd_impl;
|
||||
template<> struct find_svd_impl<float, ColMajor>
|
||||
{
|
||||
using type = svd_impl32_col;
|
||||
};
|
||||
|
||||
template<> struct find_svd_impl<float , ColMajor> { using type = svd_impl32_col; };
|
||||
template<> struct find_svd_impl<float , RowMajor> { using type = svd_impl32_row; };
|
||||
template<> struct find_svd_impl<double, ColMajor> { using type = svd_impl64_col; };
|
||||
template<> struct find_svd_impl<double, RowMajor> { using type = svd_impl64_row; };
|
||||
template<> struct find_svd_impl<float, RowMajor>
|
||||
{
|
||||
using type = svd_impl32_row;
|
||||
};
|
||||
|
||||
template<typename Scalar,int Options>
|
||||
using find_svd = typename find_svd_impl<Scalar,(Options & 1)>::type;
|
||||
}
|
||||
template<> struct find_svd_impl<double, ColMajor>
|
||||
{
|
||||
using type = svd_impl64_col;
|
||||
};
|
||||
|
||||
template<> struct find_svd_impl<double, RowMajor>
|
||||
{
|
||||
using type = svd_impl64_row;
|
||||
};
|
||||
|
||||
template<typename Scalar, int Options>
|
||||
using find_svd = typename find_svd_impl<Scalar, (Options & 1)>::type;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
//==================================================================================================
|
||||
class ROTGEN_EXPORT CLASSNAME
|
||||
{
|
||||
public:
|
||||
public:
|
||||
CLASSNAME(SOURCENAME const& m, int options);
|
||||
CLASSNAME(CLASSNAME const& other);
|
||||
CLASSNAME(CLASSNAME&&) noexcept;
|
||||
|
|
@ -23,22 +23,23 @@ class ROTGEN_EXPORT CLASSNAME
|
|||
|
||||
~CLASSNAME();
|
||||
|
||||
int rank() const;
|
||||
SOURCENAME U() const;
|
||||
SOURCENAME D() const;
|
||||
SOURCENAME singular_values() const;
|
||||
SOURCENAME V() const;
|
||||
int rank() const;
|
||||
SOURCENAME U() const;
|
||||
SOURCENAME D() const;
|
||||
SOURCENAME singular_values() const;
|
||||
SOURCENAME V() const;
|
||||
|
||||
SOURCENAME U(int) const;
|
||||
SOURCENAME D(int) const;
|
||||
SOURCENAME singular_values(int) const;
|
||||
SOURCENAME V(int) const;
|
||||
SOURCENAME U(int) const;
|
||||
SOURCENAME D(int) const;
|
||||
SOURCENAME singular_values(int) const;
|
||||
SOURCENAME V(int) const;
|
||||
|
||||
private:
|
||||
private:
|
||||
struct payload;
|
||||
std::unique_ptr<payload> storage_;
|
||||
|
||||
public:
|
||||
std::unique_ptr<payload>& storage() { return storage_; }
|
||||
public:
|
||||
std::unique_ptr<payload>& storage() { return storage_; }
|
||||
|
||||
std::unique_ptr<payload> const& storage() const { return storage_; }
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,77 +12,84 @@
|
|||
|
||||
namespace rotgen
|
||||
{
|
||||
template<typename M>
|
||||
struct svd
|
||||
template<typename M> struct svd
|
||||
{
|
||||
using base = Eigen::JacobiSVD<typename M::parent>;
|
||||
using u_type = typename base::MatrixUType;
|
||||
using v_type = typename base::MatrixVType;
|
||||
using d_type = typename base::SingularValuesType;
|
||||
using base = Eigen::JacobiSVD<typename M::parent>;
|
||||
using u_type = typename base::MatrixUType;
|
||||
using v_type = typename base::MatrixVType;
|
||||
using d_type = typename base::SingularValuesType;
|
||||
|
||||
svd(M const& m, int options = ComputeThinU | ComputeThinV) : svd_(m.base(),options) {}
|
||||
svd(M const& m, int options = ComputeThinU | ComputeThinV)
|
||||
: svd_(m.base(), options)
|
||||
{
|
||||
}
|
||||
|
||||
int rank() const { return svd_.rank(); }
|
||||
int rank() const { return svd_.rank(); }
|
||||
|
||||
auto singular_values() const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return detail::as_concrete_t<d_type, matrix>{svd_.singularValues()};
|
||||
if constexpr (!use_expression_templates)
|
||||
return detail::as_concrete_t<d_type, matrix>{svd_.singularValues()};
|
||||
else return svd_.singularValues();
|
||||
}
|
||||
|
||||
auto U() const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return detail::as_concrete_t<u_type, matrix>{svd_.matrixU()};
|
||||
if constexpr (!use_expression_templates)
|
||||
return detail::as_concrete_t<u_type, matrix>{svd_.matrixU()};
|
||||
else return svd_.matrixU();
|
||||
}
|
||||
|
||||
auto V() const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return detail::as_concrete_t<v_type, matrix>{svd_.matrixV()};
|
||||
if constexpr (!use_expression_templates)
|
||||
return detail::as_concrete_t<v_type, matrix>{svd_.matrixV()};
|
||||
else return svd_.matrixV();
|
||||
}
|
||||
|
||||
auto D() const
|
||||
{
|
||||
auto d = svd_.singularValues().asDiagonal();
|
||||
if constexpr(!use_expression_templates)
|
||||
return detail::as_concrete_t<decltype(d.toDenseMatrix()), matrix>{d.toDenseMatrix ()};
|
||||
else
|
||||
return d;
|
||||
if constexpr (!use_expression_templates)
|
||||
return detail::as_concrete_t<decltype(d.toDenseMatrix()), matrix>{
|
||||
d.toDenseMatrix()};
|
||||
else return d;
|
||||
}
|
||||
|
||||
|
||||
auto singular_values(int r) const
|
||||
{
|
||||
auto that = svd_.singularValues().head(r);
|
||||
if constexpr(!use_expression_templates) return detail::as_concrete_t<decltype(that), matrix>{that};
|
||||
if constexpr (!use_expression_templates)
|
||||
return detail::as_concrete_t<decltype(that), matrix>{that};
|
||||
else return svd_.singularValues();
|
||||
}
|
||||
|
||||
auto U(int r) const
|
||||
{
|
||||
auto that = svd_.matrixU().leftCols(r);
|
||||
if constexpr(!use_expression_templates) return detail::as_concrete_t<decltype(that), matrix>{that};
|
||||
if constexpr (!use_expression_templates)
|
||||
return detail::as_concrete_t<decltype(that), matrix>{that};
|
||||
else return that;
|
||||
}
|
||||
|
||||
auto V(int r) const
|
||||
{
|
||||
auto that = svd_.matrixV().leftCols(r);
|
||||
if constexpr(!use_expression_templates) return detail::as_concrete_t<decltype(that), matrix>{that};
|
||||
if constexpr (!use_expression_templates)
|
||||
return detail::as_concrete_t<decltype(that), matrix>{that};
|
||||
else return that;
|
||||
}
|
||||
|
||||
auto D(int r) const
|
||||
{
|
||||
auto d = svd_.singularValues().head(r).asDiagonal();
|
||||
if constexpr(!use_expression_templates)
|
||||
return detail::as_concrete_t<decltype(d.toDenseMatrix()), matrix>{d.toDenseMatrix ()};
|
||||
else
|
||||
return d;
|
||||
if constexpr (!use_expression_templates)
|
||||
return detail::as_concrete_t<decltype(d.toDenseMatrix()), matrix>{
|
||||
d.toDenseMatrix()};
|
||||
else return d;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
base svd_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,25 +8,25 @@
|
|||
namespace rotgen
|
||||
{
|
||||
// matrix aliases (float and double, fixed and dynamic)
|
||||
using matrix2f = rotgen::matrix<float, 2, 2>;
|
||||
using matrix3f = rotgen::matrix<float, 3, 3>;
|
||||
using matrix4f = rotgen::matrix<float, 4, 4>;
|
||||
using matrix2d = rotgen::matrix<double, 2, 2>;
|
||||
using matrix3d = rotgen::matrix<double, 3, 3>;
|
||||
using matrix4d = rotgen::matrix<double, 4, 4>;
|
||||
using matrixXf = rotgen::matrix<float, rotgen::Dynamic, rotgen::Dynamic>;
|
||||
using matrixXd = rotgen::matrix<double, rotgen::Dynamic, rotgen::Dynamic>;
|
||||
using matrixXi = rotgen::matrix<int, rotgen::Dynamic, rotgen::Dynamic>;
|
||||
using matrix2f = rotgen::matrix<float, 2, 2>;
|
||||
using matrix3f = rotgen::matrix<float, 3, 3>;
|
||||
using matrix4f = rotgen::matrix<float, 4, 4>;
|
||||
using matrix2d = rotgen::matrix<double, 2, 2>;
|
||||
using matrix3d = rotgen::matrix<double, 3, 3>;
|
||||
using matrix4d = rotgen::matrix<double, 4, 4>;
|
||||
using matrixXf = rotgen::matrix<float, rotgen::Dynamic, rotgen::Dynamic>;
|
||||
using matrixXd = rotgen::matrix<double, rotgen::Dynamic, rotgen::Dynamic>;
|
||||
using matrixXi = rotgen::matrix<int, rotgen::Dynamic, rotgen::Dynamic>;
|
||||
|
||||
// Column vector aliases
|
||||
using vector2f = rotgen::matrix<float, 2, 1>;
|
||||
using vector3f = rotgen::matrix<float, 3, 1>;
|
||||
using vector4f = rotgen::matrix<float, 4, 1>;
|
||||
using vector2d = rotgen::matrix<double, 2, 1>;
|
||||
using vector3d = rotgen::matrix<double, 3, 1>;
|
||||
using vector4d = rotgen::matrix<double, 4, 1>;
|
||||
using vectorXf = rotgen::matrix<float, rotgen::Dynamic, 1>;
|
||||
using vectorXd = rotgen::matrix<double, rotgen::Dynamic, 1>;
|
||||
using vector2f = rotgen::matrix<float, 2, 1>;
|
||||
using vector3f = rotgen::matrix<float, 3, 1>;
|
||||
using vector4f = rotgen::matrix<float, 4, 1>;
|
||||
using vector2d = rotgen::matrix<double, 2, 1>;
|
||||
using vector3d = rotgen::matrix<double, 3, 1>;
|
||||
using vector4d = rotgen::matrix<double, 4, 1>;
|
||||
using vectorXf = rotgen::matrix<float, rotgen::Dynamic, 1>;
|
||||
using vectorXd = rotgen::matrix<double, rotgen::Dynamic, 1>;
|
||||
|
||||
// Row vector aliases
|
||||
using row_vector2f = rotgen::matrix<float, 1, 2>;
|
||||
|
|
@ -37,4 +37,4 @@ namespace rotgen
|
|||
using row_vector4d = rotgen::matrix<double, 1, 4>;
|
||||
using row_vectorXf = rotgen::matrix<float, 1, rotgen::Dynamic>;
|
||||
using row_vectorXd = rotgen::matrix<double, 1, rotgen::Dynamic>;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,26 +13,27 @@ namespace rotgen::concepts
|
|||
//! @brief Check if a type is a Rotgen reference.
|
||||
//================================================================================================
|
||||
template<typename T>
|
||||
concept reference = requires { typename std::remove_cvref_t<T>::rotgen_ref_tag; };
|
||||
concept reference =
|
||||
requires { typename std::remove_cvref_t<T>::rotgen_ref_tag; };
|
||||
|
||||
//================================================================================================
|
||||
//! @brief Check if a type is a vector.
|
||||
//================================================================================================
|
||||
template<typename T>
|
||||
concept vector = T::IsVectorAtCompileTime;
|
||||
concept vector = T::IsVectorAtCompileTime;
|
||||
|
||||
//================================================================================================
|
||||
//! @brief Check if a type is a 3D vector.
|
||||
//================================================================================================
|
||||
template<typename T, int N>
|
||||
concept vectorND = vector<T> && (T::RowsAtCompileTime == N || T::ColsAtCompileTime == N);
|
||||
concept vectorND =
|
||||
vector<T> && (T::RowsAtCompileTime == N || T::ColsAtCompileTime == N);
|
||||
|
||||
//================================================================================================
|
||||
//! @brief Check if a type is a ROTGEN type.
|
||||
//================================================================================================
|
||||
template<typename T>
|
||||
concept entity = requires(T const&)
|
||||
{
|
||||
concept entity = requires(T const&) {
|
||||
typename std::remove_cvref_t<T>::rotgen_tag;
|
||||
typename std::remove_cvref_t<T>::parent;
|
||||
};
|
||||
|
|
@ -41,15 +42,18 @@ namespace rotgen::concepts
|
|||
//! @brief Check if a type is an EIGEN type.
|
||||
//================================================================================================
|
||||
template<typename T>
|
||||
concept eigen_compatible = requires(T const& a)
|
||||
{
|
||||
concept eigen_compatible = requires(T const& a) {
|
||||
typename std::remove_cvref_t<T>::Scalar;
|
||||
|
||||
{ std::remove_cvref_t<T>::RowsAtCompileTime } -> std::convertible_to<int>;
|
||||
{ std::remove_cvref_t<T>::ColsAtCompileTime } -> std::convertible_to<int>;
|
||||
{ std::remove_cvref_t<T>::MaxRowsAtCompileTime } -> std::convertible_to<int>;
|
||||
{ std::remove_cvref_t<T>::MaxColsAtCompileTime } -> std::convertible_to<int>;
|
||||
{ std::remove_cvref_t<T>::RowsAtCompileTime } -> std::convertible_to<int>;
|
||||
{ std::remove_cvref_t<T>::ColsAtCompileTime } -> std::convertible_to<int>;
|
||||
{
|
||||
std::remove_cvref_t<T>::MaxRowsAtCompileTime
|
||||
} -> std::convertible_to<int>;
|
||||
{
|
||||
std::remove_cvref_t<T>::MaxColsAtCompileTime
|
||||
} -> std::convertible_to<int>;
|
||||
|
||||
{ a.eval() };
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ namespace rotgen
|
|||
{
|
||||
using Index = std::ptrdiff_t;
|
||||
|
||||
inline constexpr std::ptrdiff_t default_alignment = []()
|
||||
{
|
||||
inline constexpr std::ptrdiff_t default_alignment = []() {
|
||||
constexpr auto w = spy::simd_instruction_set.width;
|
||||
return w == -1 ? 0 : w / 8;
|
||||
}();
|
||||
|
|
@ -27,30 +26,31 @@ namespace rotgen
|
|||
inline constexpr int ComputeFullV = 0x10;
|
||||
inline constexpr int ComputeThinV = 0x20;
|
||||
|
||||
inline constexpr int Dynamic = -1;
|
||||
inline constexpr int Infinity = -1;
|
||||
inline constexpr int AutoAlign = 0;
|
||||
inline constexpr int ColMajor = 0;
|
||||
inline constexpr int RowMajor = 1;
|
||||
inline constexpr int DontAlign = 2;
|
||||
inline constexpr int Dynamic = -1;
|
||||
inline constexpr int Infinity = -1;
|
||||
inline constexpr int AutoAlign = 0;
|
||||
inline constexpr int ColMajor = 0;
|
||||
inline constexpr int RowMajor = 1;
|
||||
inline constexpr int DontAlign = 2;
|
||||
|
||||
inline constexpr int Unaligned = 0;
|
||||
inline constexpr int Aligned8 = 8;
|
||||
inline constexpr int Aligned16 = 16;
|
||||
inline constexpr int Aligned32 = 32;
|
||||
inline constexpr int Aligned64 = 64;
|
||||
inline constexpr int Unaligned = 0;
|
||||
inline constexpr int Aligned8 = 8;
|
||||
inline constexpr int Aligned16 = 16;
|
||||
inline constexpr int Aligned32 = 32;
|
||||
inline constexpr int Aligned64 = 64;
|
||||
inline constexpr int Aligned128 = 128;
|
||||
inline constexpr int Aligned = default_alignment;
|
||||
inline constexpr int Aligned = default_alignment;
|
||||
|
||||
inline constexpr int DontAlignCols = 1;
|
||||
inline constexpr int StreamPrecision = -1;
|
||||
inline constexpr int FullPrecision = -2;
|
||||
inline constexpr int DontAlignCols = 1;
|
||||
inline constexpr int StreamPrecision = -1;
|
||||
inline constexpr int FullPrecision = -2;
|
||||
}
|
||||
|
||||
namespace rotgen::detail
|
||||
{
|
||||
template<Index R, Index C>
|
||||
inline constexpr int force_order = AutoAlign | ((R==1 && C!=1) ? RowMajor : ColMajor);
|
||||
inline constexpr int force_order =
|
||||
AutoAlign | ((R == 1 && C != 1) ? RowMajor : ColMajor);
|
||||
}
|
||||
|
||||
#if !defined(ROTGEN_MAX_SIZE) && defined(ROTGEN_ENABLE_EXPRESSION_TEMPLATES)
|
||||
|
|
@ -58,15 +58,15 @@ namespace rotgen::detail
|
|||
#endif
|
||||
|
||||
#if !defined(ROTGEN_FORCE_DYNAMIC)
|
||||
#if !defined(ROTGEN_MAX_SIZE)
|
||||
#define ROTGEN_FORCE_DYNAMIC
|
||||
#endif
|
||||
#if !defined(ROTGEN_MAX_SIZE)
|
||||
#define ROTGEN_FORCE_DYNAMIC
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(ROTGEN_FORCE_DYNAMIC)
|
||||
#define ROTGEN_HAS_STATIC_LIMIT false
|
||||
#define ROTGEN_HAS_STATIC_LIMIT false
|
||||
#else
|
||||
#define ROTGEN_HAS_STATIC_LIMIT true
|
||||
#define ROTGEN_HAS_STATIC_LIMIT true
|
||||
#endif
|
||||
|
||||
namespace rotgen
|
||||
|
|
@ -77,8 +77,8 @@ namespace rotgen
|
|||
inline constexpr bool use_expression_templates = false;
|
||||
#endif
|
||||
|
||||
inline constexpr bool has_static_limit = ROTGEN_HAS_STATIC_LIMIT;
|
||||
inline constexpr bool is_forcing_dynamic_status = !has_static_limit;
|
||||
inline constexpr bool has_static_limit = ROTGEN_HAS_STATIC_LIMIT;
|
||||
inline constexpr bool is_forcing_dynamic_status = !has_static_limit;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
|
@ -91,8 +91,7 @@ namespace rotgen
|
|||
{
|
||||
inline constexpr Index max_static_size = -1;
|
||||
|
||||
template<int Rows, int Cols>
|
||||
inline constexpr bool storage_status = false;
|
||||
template<int Rows, int Cols> inline constexpr bool storage_status = false;
|
||||
}
|
||||
#else
|
||||
namespace rotgen
|
||||
|
|
@ -100,19 +99,18 @@ namespace rotgen
|
|||
inline constexpr Index max_static_size = ROTGEN_MAX_SIZE;
|
||||
|
||||
template<int Rows, int Cols, int MaxRows, int MaxCols>
|
||||
inline constexpr bool storage_status =
|
||||
[]()
|
||||
{
|
||||
inline constexpr bool storage_status = []() {
|
||||
// Actual static size - vector 1xN
|
||||
if(Rows == 1 && Cols == -1) return true;
|
||||
if (Rows == 1 && Cols == -1) return true;
|
||||
// Actual static size - vector Nx1
|
||||
else if(Rows == -1 && Cols == 1) return true;
|
||||
else if (Rows == -1 && Cols == 1) return true;
|
||||
// Actual static size - matrix
|
||||
else if(Rows > 0 && Cols > 0) return (Rows*Cols) <= max_static_size;
|
||||
else if (Rows > 0 && Cols > 0) return (Rows * Cols) <= max_static_size;
|
||||
// Dynamic size but static Max Size
|
||||
else if(MaxRows > 0 && MaxCols > 0) return (MaxRows*MaxCols) <= max_static_size;
|
||||
else if (MaxRows > 0 && MaxCols > 0)
|
||||
return (MaxRows * MaxCols) <= max_static_size;
|
||||
// Everything dynamic already
|
||||
else return false;
|
||||
else return false;
|
||||
}();
|
||||
}
|
||||
#endif
|
||||
|
|
@ -122,16 +120,17 @@ namespace rotgen
|
|||
inline std::ostream& setup_summary(std::ostream& os)
|
||||
{
|
||||
detail::dynamic_info(os);
|
||||
os << " * Default alignment: " << default_alignment << " bytes." << std::endl;
|
||||
if(!is_forcing_dynamic_status)
|
||||
os << " * Default alignment: " << default_alignment << " bytes."
|
||||
<< std::endl;
|
||||
if (!is_forcing_dynamic_status)
|
||||
{
|
||||
if constexpr(use_expression_templates)
|
||||
if constexpr (use_expression_templates)
|
||||
os << " * Expression templates : Enabled." << std::endl;
|
||||
else
|
||||
os << " * Expression templates : Disabled." << std::endl;
|
||||
else os << " * Expression templates : Disabled." << std::endl;
|
||||
|
||||
if constexpr(rotgen::max_static_size)
|
||||
os << " * Static/Dynamic mode with maximum size: " << rotgen::max_static_size << std::endl;
|
||||
if constexpr (rotgen::max_static_size)
|
||||
os << " * Static/Dynamic mode with maximum size: "
|
||||
<< rotgen::max_static_size << std::endl;
|
||||
}
|
||||
|
||||
return os;
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@
|
|||
#include <rotgen/container/matrix.hpp>
|
||||
#include <rotgen/container/block.hpp>
|
||||
#include <rotgen/container/map.hpp>
|
||||
#include <rotgen/container/ref.hpp>
|
||||
#include <rotgen/container/ref.hpp>
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@
|
|||
#include <rotgen/container/block/dynamic.hpp>
|
||||
#else
|
||||
#include <rotgen/container/block/fixed.hpp>
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -18,38 +18,43 @@ namespace rotgen
|
|||
template<typename T, int Options = T::storage_order, typename Stride = stride>
|
||||
class ref;
|
||||
|
||||
template<typename Ref, int Rows = Dynamic, int Cols = Dynamic, bool Inner = false>
|
||||
template<typename Ref,
|
||||
int Rows = Dynamic,
|
||||
int Cols = Dynamic,
|
||||
bool Inner = false>
|
||||
class block : public find_block<Ref>
|
||||
{
|
||||
public:
|
||||
static_assert ( concepts::entity<Ref>
|
||||
, "[ROTGEN][CRITICAL] - Block of non-rotgen type instanciated"
|
||||
);
|
||||
public:
|
||||
static_assert(concepts::entity<Ref>,
|
||||
"[ROTGEN][CRITICAL] - Block of non-rotgen type instanciated");
|
||||
|
||||
using parent = find_block<Ref>;
|
||||
using rotgen_tag = void;
|
||||
using rotgen_block_tag = void;
|
||||
using value_type = typename std::remove_const_t<Ref>::value_type;
|
||||
using parent = find_block<Ref>;
|
||||
using rotgen_tag = void;
|
||||
using rotgen_block_tag = void;
|
||||
using value_type = typename std::remove_const_t<Ref>::value_type;
|
||||
|
||||
static constexpr int storage_order = Ref::storage_order;
|
||||
static constexpr bool is_immutable = std::is_const_v<Ref>;
|
||||
using concrete_type = matrix<value_type,Rows,Cols,storage_order>;
|
||||
using transposed_type = matrix<value_type,Cols,Rows, storage_order>;
|
||||
using concrete_dynamic_type = matrix<value_type,Dynamic,Dynamic,storage_order>;
|
||||
static constexpr int storage_order = Ref::storage_order;
|
||||
static constexpr bool is_immutable = std::is_const_v<Ref>;
|
||||
using concrete_type = matrix<value_type, Rows, Cols, storage_order>;
|
||||
using transposed_type = matrix<value_type, Cols, Rows, storage_order>;
|
||||
using concrete_dynamic_type =
|
||||
matrix<value_type, Dynamic, Dynamic, storage_order>;
|
||||
|
||||
static constexpr int RowsAtCompileTime = Rows;
|
||||
static constexpr int ColsAtCompileTime = Cols;
|
||||
static constexpr int MaxRowsAtCompileTime = Rows;
|
||||
static constexpr int MaxColsAtCompileTime = Cols;
|
||||
static constexpr bool IsVectorAtCompileTime = Ref::IsVectorAtCompileTime;
|
||||
static constexpr int Options = Ref::Options;
|
||||
static constexpr bool IsRowMajor = (storage_order & RowMajor) == RowMajor;
|
||||
static constexpr int RowsAtCompileTime = Rows;
|
||||
static constexpr int ColsAtCompileTime = Cols;
|
||||
static constexpr int MaxRowsAtCompileTime = Rows;
|
||||
static constexpr int MaxColsAtCompileTime = Cols;
|
||||
static constexpr bool IsVectorAtCompileTime = Ref::IsVectorAtCompileTime;
|
||||
static constexpr int Options = Ref::Options;
|
||||
static constexpr bool IsRowMajor = (storage_order & RowMajor) == RowMajor;
|
||||
|
||||
static constexpr bool is_defined_static = false;
|
||||
static constexpr bool has_static_storage = false;
|
||||
static constexpr bool is_defined_static = false;
|
||||
static constexpr bool has_static_storage = false;
|
||||
|
||||
using parent::operator=;
|
||||
block& operator=(concepts::entity auto const& other) requires(!is_immutable)
|
||||
|
||||
block& operator=(concepts::entity auto const& other)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
assert(parent::rows() == other.rows() && parent::cols() == other.cols());
|
||||
for (rotgen::Index r = 0; r < parent::rows(); ++r)
|
||||
|
|
@ -59,117 +64,191 @@ namespace rotgen
|
|||
return *this;
|
||||
}
|
||||
|
||||
block(Ref const& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj)
|
||||
requires( !requires{typename Ref::rotgen_block_tag; } && is_immutable)
|
||||
: parent(r.base(),i0,j0,ni,nj)
|
||||
{}
|
||||
block(Ref const& r,
|
||||
std::size_t i0,
|
||||
std::size_t j0,
|
||||
std::size_t ni,
|
||||
std::size_t nj)
|
||||
requires(!requires { typename Ref::rotgen_block_tag; } && is_immutable)
|
||||
: parent(r.base(), i0, j0, ni, nj)
|
||||
{
|
||||
}
|
||||
|
||||
block(Ref const& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj)
|
||||
requires( requires{typename Ref::rotgen_block_tag; } && is_immutable)
|
||||
: parent(*r.storage(),i0,j0,ni,nj)
|
||||
{}
|
||||
block(Ref const& r,
|
||||
std::size_t i0,
|
||||
std::size_t j0,
|
||||
std::size_t ni,
|
||||
std::size_t nj)
|
||||
requires(requires { typename Ref::rotgen_block_tag; } && is_immutable)
|
||||
: parent(*r.storage(), i0, j0, ni, nj)
|
||||
{
|
||||
}
|
||||
|
||||
block(Ref const& r, std::size_t i0, std::size_t j0)
|
||||
requires(!requires{typename Ref::rotgen_block_tag; } && Rows != -1 && Cols != -1 && is_immutable)
|
||||
: parent(r.base(),i0,j0,Rows,Cols)
|
||||
{}
|
||||
requires(!requires { typename Ref::rotgen_block_tag; } && Rows != -1 &&
|
||||
Cols != -1 && is_immutable)
|
||||
: parent(r.base(), i0, j0, Rows, Cols)
|
||||
{
|
||||
}
|
||||
|
||||
block(Ref const& r, std::size_t i0, std::size_t j0)
|
||||
requires(requires{typename Ref::rotgen_block_tag; } && Rows != -1 && Cols != -1 && is_immutable)
|
||||
: parent(*r.storage(),i0,j0,Rows,Cols)
|
||||
{}
|
||||
requires(requires { typename Ref::rotgen_block_tag; } && Rows != -1 &&
|
||||
Cols != -1 && is_immutable)
|
||||
: parent(*r.storage(), i0, j0, Rows, Cols)
|
||||
{
|
||||
}
|
||||
|
||||
block(Ref& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj)
|
||||
requires( !requires{typename Ref::rotgen_block_tag; } && !is_immutable)
|
||||
: parent(r.base(),i0,j0,ni,nj)
|
||||
{}
|
||||
block(
|
||||
Ref& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj)
|
||||
requires(!requires { typename Ref::rotgen_block_tag; } && !is_immutable)
|
||||
: parent(r.base(), i0, j0, ni, nj)
|
||||
{
|
||||
}
|
||||
|
||||
block(Ref& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj)
|
||||
requires( requires{typename Ref::rotgen_block_tag; } && !is_immutable)
|
||||
: parent(*r.storage(),i0,j0,ni,nj)
|
||||
{}
|
||||
block(
|
||||
Ref& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj)
|
||||
requires(requires { typename Ref::rotgen_block_tag; } && !is_immutable)
|
||||
: parent(*r.storage(), i0, j0, ni, nj)
|
||||
{
|
||||
}
|
||||
|
||||
block(Ref& r, std::size_t i0, std::size_t j0)
|
||||
requires(!requires{typename Ref::rotgen_block_tag; } && Rows != -1 && Cols != -1 && !is_immutable)
|
||||
: parent(r.base(),i0,j0,Rows,Cols)
|
||||
{}
|
||||
requires(!requires { typename Ref::rotgen_block_tag; } && Rows != -1 &&
|
||||
Cols != -1 && !is_immutable)
|
||||
: parent(r.base(), i0, j0, Rows, Cols)
|
||||
{
|
||||
}
|
||||
|
||||
block(Ref& r, std::size_t i0, std::size_t j0)
|
||||
requires(requires{typename Ref::rotgen_block_tag; } && Rows != -1 && Cols != -1 && !is_immutable)
|
||||
: parent(*r.storage(),i0,j0,Rows,Cols)
|
||||
{}
|
||||
requires(requires { typename Ref::rotgen_block_tag; } && Rows != -1 &&
|
||||
Cols != -1 && !is_immutable)
|
||||
: parent(*r.storage(), i0, j0, Rows, Cols)
|
||||
{
|
||||
}
|
||||
|
||||
block(parent const& base) : parent(base) {}
|
||||
|
||||
bool is_contiguous_linear() const
|
||||
{
|
||||
if(parent::innerStride() != 1) return false;
|
||||
if constexpr(storage_order) return parent::outerStride() == parent::cols();
|
||||
else return parent::outerStride() == parent::rows();
|
||||
if (parent::innerStride() != 1) return false;
|
||||
if constexpr (storage_order)
|
||||
return parent::outerStride() == parent::cols();
|
||||
else return parent::outerStride() == parent::rows();
|
||||
}
|
||||
|
||||
value_type& operator()(Index i, Index j) requires(!is_immutable) { return parent::operator()(i,j); }
|
||||
value_type& operator()(Index i, Index j)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
return parent::operator()(i, j);
|
||||
}
|
||||
|
||||
value_type& operator()(Index i) requires(!is_immutable && IsVectorAtCompileTime)
|
||||
value_type& operator()(Index i)
|
||||
requires(!is_immutable && IsVectorAtCompileTime)
|
||||
{
|
||||
assert(is_contiguous_linear());
|
||||
return parent::operator()(i);
|
||||
}
|
||||
|
||||
value_type& operator[](Index i) requires(!is_immutable && IsVectorAtCompileTime)
|
||||
value_type& operator[](Index i)
|
||||
requires(!is_immutable && IsVectorAtCompileTime)
|
||||
{
|
||||
return (*this)(i);
|
||||
}
|
||||
|
||||
value_type operator()(Index i, Index j) const { return parent::operator()(i,j); }
|
||||
value_type operator()(Index i, Index j) const
|
||||
{
|
||||
return parent::operator()(i, j);
|
||||
}
|
||||
|
||||
value_type operator()(Index i) const requires(IsVectorAtCompileTime)
|
||||
value_type operator()(Index i) const
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
assert(is_contiguous_linear());
|
||||
return parent::operator()(i);
|
||||
}
|
||||
|
||||
value_type operator[](Index i) const requires(IsVectorAtCompileTime)
|
||||
value_type operator[](Index i) const
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
return (*this)(i);
|
||||
}
|
||||
|
||||
auto evaluate() const { return *this; }
|
||||
decltype(auto) noalias() const { return *this; }
|
||||
decltype(auto) noalias() { return *this; }
|
||||
auto evaluate() const { return *this; }
|
||||
|
||||
concrete_type normalized() const requires(IsVectorAtCompileTime)
|
||||
decltype(auto) noalias() const { return *this; }
|
||||
|
||||
decltype(auto) noalias() { return *this; }
|
||||
|
||||
concrete_type normalized() const
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
return concrete_type(base().normalized());
|
||||
}
|
||||
transposed_type transpose() const { return transposed_type(base().transpose());}
|
||||
concrete_type conjugate() const { return concrete_type(base().conjugate());}
|
||||
transposed_type adjoint() const { return transposed_type(base().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()); }
|
||||
transposed_type transpose() const
|
||||
{
|
||||
return transposed_type(base().transpose());
|
||||
}
|
||||
|
||||
void normalize() requires(!is_immutable && IsVectorAtCompileTime)
|
||||
concrete_type conjugate() const
|
||||
{
|
||||
return concrete_type(base().conjugate());
|
||||
}
|
||||
|
||||
transposed_type adjoint() const
|
||||
{
|
||||
return transposed_type(base().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 normalize()
|
||||
requires(!is_immutable && IsVectorAtCompileTime)
|
||||
{
|
||||
parent::normalize();
|
||||
}
|
||||
void transposeInPlace() requires(!is_immutable) { parent::transposeInPlace(); }
|
||||
void adjointInPlace() requires(!is_immutable) { parent::adjointInPlace(); }
|
||||
|
||||
void transposeInPlace()
|
||||
requires(!is_immutable)
|
||||
{
|
||||
parent::transposeInPlace();
|
||||
}
|
||||
|
||||
void adjointInPlace()
|
||||
requires(!is_immutable)
|
||||
{
|
||||
parent::adjointInPlace();
|
||||
}
|
||||
|
||||
friend bool operator==(block const& lhs, block const& rhs)
|
||||
{
|
||||
return static_cast<parent const&>(lhs) == static_cast<parent const&>(rhs);
|
||||
}
|
||||
|
||||
block& operator+=(block const& rhs) requires(!is_immutable)
|
||||
block& operator+=(block const& rhs)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
base() += static_cast<parent const&>(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& operator-=(block const& rhs) requires(!is_immutable)
|
||||
block& operator-=(block const& rhs)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
base() -= static_cast<parent const&>(rhs);
|
||||
return *this;
|
||||
|
|
@ -180,31 +259,35 @@ namespace rotgen
|
|||
return concrete_type(static_cast<parent const&>(*this).operator-());
|
||||
}
|
||||
|
||||
block& operator*=(block const& rhs) requires(!is_immutable)
|
||||
block& operator*=(block const& rhs)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
base() *= static_cast<parent const&>(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& operator*=(value_type rhs) requires(!is_immutable)
|
||||
block& operator*=(value_type rhs)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
base() *= rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& operator/=(value_type rhs) requires(!is_immutable)
|
||||
block& operator/=(value_type rhs)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
base() /= rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto minCoeff() const { return parent::minCoeff(); }
|
||||
|
||||
auto maxCoeff() const { return parent::maxCoeff(); }
|
||||
|
||||
template<std::integral IndexType>
|
||||
auto minCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
Index r, c;
|
||||
auto result = parent::minCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
|
|
@ -214,7 +297,7 @@ namespace rotgen
|
|||
template<std::integral IndexType>
|
||||
auto maxCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
Index r, c;
|
||||
auto result = parent::maxCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
|
|
@ -222,109 +305,134 @@ namespace rotgen
|
|||
}
|
||||
|
||||
static concrete_type Zero()
|
||||
requires (Rows != -1 && Cols != -1)
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Zero(Rows, Cols);
|
||||
}
|
||||
|
||||
static concrete_type Zero(int rows, int cols)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Zero(rows, cols);
|
||||
}
|
||||
|
||||
static concrete_type Ones()
|
||||
requires (Rows != -1 && Cols != -1)
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Ones(Rows, Cols);
|
||||
}
|
||||
|
||||
static concrete_type Ones(int rows, int cols)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Ones(rows, cols);
|
||||
}
|
||||
|
||||
static concrete_type Constant(value_type value)
|
||||
requires (Rows != -1 && Cols != -1)
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Constant(Rows, Cols, static_cast<double>(value));
|
||||
}
|
||||
|
||||
static concrete_type Constant(int rows, int cols, value_type value)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Constant(rows, cols, static_cast<double>(value));
|
||||
}
|
||||
|
||||
static concrete_type Random()
|
||||
requires (Rows != -1 && Cols != -1)
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Random(Rows, Cols);
|
||||
}
|
||||
|
||||
static concrete_type Random(int rows, int cols)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Random(rows, cols);
|
||||
}
|
||||
|
||||
static concrete_type Identity()
|
||||
requires (Rows != -1 && Cols != -1)
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Identity(Rows, Cols);
|
||||
}
|
||||
|
||||
static concrete_type Identity(int rows, int cols)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Identity(rows, cols);
|
||||
}
|
||||
|
||||
block& setOnes() requires(!is_immutable)
|
||||
block& setOnes()
|
||||
requires(!is_immutable)
|
||||
{
|
||||
parent::assign(parent::Ones(parent::rows(), parent::cols()));
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& setZero() requires(!is_immutable)
|
||||
block& setZero()
|
||||
requires(!is_immutable)
|
||||
{
|
||||
parent::assign(parent::Zero(parent::rows(), parent::cols()));
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& setConstant(value_type value) requires(!is_immutable)
|
||||
block& setConstant(value_type value)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
parent::assign(parent::Constant(parent::rows(), parent::cols(), value));
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& setRandom() requires(!is_immutable)
|
||||
block& setRandom()
|
||||
requires(!is_immutable)
|
||||
{
|
||||
parent::assign(parent::Random(parent::rows(), parent::cols()));
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& setIdentity() requires(!is_immutable)
|
||||
block& setIdentity()
|
||||
requires(!is_immutable)
|
||||
{
|
||||
parent::assign(parent::Identity(parent::rows(), parent::cols()));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<int P>
|
||||
value_type lpNorm() const
|
||||
template<int P> value_type lpNorm() const
|
||||
{
|
||||
assert(P == 1 || P == 2 || P == Infinity);
|
||||
return parent::lpNorm(P);
|
||||
}
|
||||
|
||||
parent& base() { return static_cast<parent&>(*this); }
|
||||
parent const& base() const { return static_cast<parent const&>(*this); }
|
||||
parent& base() { return static_cast<parent&>(*this); }
|
||||
|
||||
parent const& base() const { return static_cast<parent const&>(*this); }
|
||||
};
|
||||
|
||||
template<typename Ref, int R, int C, bool I>
|
||||
|
|
@ -368,4 +476,4 @@ namespace rotgen
|
|||
using concrete_type = typename block<Ref, R, C, I>::concrete_type;
|
||||
return concrete_type(lhs.base().div(rhs));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,39 +21,69 @@ namespace rotgen
|
|||
class matrix_impl32_row;
|
||||
class matrix_impl32_col;
|
||||
|
||||
#define USE_CONST
|
||||
#define CONST const
|
||||
#define BASENAME block_const_impl
|
||||
#define BASEMAP map_const_impl
|
||||
#include <rotgen/container/block/dynamic/indirect.hpp>
|
||||
#undef BASENAME
|
||||
#undef BASEMAP
|
||||
#undef CONST
|
||||
#undef USE_CONST
|
||||
|
||||
#define USE_CONST
|
||||
#define CONST const
|
||||
#define BASENAME block_const_impl
|
||||
#define BASEMAP map_const_impl
|
||||
#include <rotgen/container/block/dynamic/indirect.hpp>
|
||||
#undef BASENAME
|
||||
#undef BASEMAP
|
||||
#undef CONST
|
||||
#undef USE_CONST
|
||||
#define CONST
|
||||
#define BASENAME block_impl
|
||||
#define BASEMAP map_impl
|
||||
#include <rotgen/container/block/dynamic/indirect.hpp>
|
||||
#undef BASENAME
|
||||
#undef BASEMAP
|
||||
#undef CONST
|
||||
|
||||
#define CONST
|
||||
#define BASENAME block_impl
|
||||
#define BASEMAP map_impl
|
||||
#include <rotgen/container/block/dynamic/indirect.hpp>
|
||||
#undef BASENAME
|
||||
#undef BASEMAP
|
||||
#undef CONST
|
||||
template<typename Scalar, int Options, bool isConst> struct find_block_impl;
|
||||
|
||||
template<typename Scalar,int Options, bool isConst> struct find_block_impl;
|
||||
template<> struct find_block_impl<float, ColMajor, true>
|
||||
{
|
||||
using type = block_const_impl32_col;
|
||||
};
|
||||
|
||||
template<> struct find_block_impl<float , ColMajor, true> { using type = block_const_impl32_col; };
|
||||
template<> struct find_block_impl<float , RowMajor, true> { using type = block_const_impl32_row; };
|
||||
template<> struct find_block_impl<double, ColMajor, true> { using type = block_const_impl64_col; };
|
||||
template<> struct find_block_impl<double, RowMajor, true> { using type = block_const_impl64_row; };
|
||||
template<> struct find_block_impl<float , ColMajor, false> { using type = block_impl32_col; };
|
||||
template<> struct find_block_impl<float , RowMajor, false> { using type = block_impl32_row; };
|
||||
template<> struct find_block_impl<double, ColMajor, false> { using type = block_impl64_col; };
|
||||
template<> struct find_block_impl<double, RowMajor, false> { using type = block_impl64_row; };
|
||||
template<> struct find_block_impl<float, RowMajor, true>
|
||||
{
|
||||
using type = block_const_impl32_row;
|
||||
};
|
||||
|
||||
template<> struct find_block_impl<double, ColMajor, true>
|
||||
{
|
||||
using type = block_const_impl64_col;
|
||||
};
|
||||
|
||||
template<> struct find_block_impl<double, RowMajor, true>
|
||||
{
|
||||
using type = block_const_impl64_row;
|
||||
};
|
||||
|
||||
template<> struct find_block_impl<float, ColMajor, false>
|
||||
{
|
||||
using type = block_impl32_col;
|
||||
};
|
||||
|
||||
template<> struct find_block_impl<float, RowMajor, false>
|
||||
{
|
||||
using type = block_impl32_row;
|
||||
};
|
||||
|
||||
template<> struct find_block_impl<double, ColMajor, false>
|
||||
{
|
||||
using type = block_impl64_col;
|
||||
};
|
||||
|
||||
template<> struct find_block_impl<double, RowMajor, false>
|
||||
{
|
||||
using type = block_impl64_row;
|
||||
};
|
||||
|
||||
template<typename Ref>
|
||||
using find_block = typename find_block_impl < typename std::remove_const_t<Ref>::value_type
|
||||
, Ref::storage_order
|
||||
, std::is_const_v<Ref>
|
||||
>::type;
|
||||
using find_block =
|
||||
typename find_block_impl<typename std::remove_const_t<Ref>::value_type,
|
||||
Ref::storage_order,
|
||||
std::is_const_v<Ref>>::type;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,51 +1,51 @@
|
|||
#define SIZE 64
|
||||
#define TYPE double
|
||||
#define SIZE 64
|
||||
#define TYPE double
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#define MAPNAME ROTGEN_MATRIX_NAME(BASEMAP,SIZE,_col)
|
||||
#include <rotgen/container/block/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
#undef SOURCENAME
|
||||
#undef MAPNAME
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME, SIZE, _col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _col)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _row)
|
||||
#define MAPNAME ROTGEN_MATRIX_NAME(BASEMAP, SIZE, _col)
|
||||
#include <rotgen/container/block/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
#undef SOURCENAME
|
||||
#undef MAPNAME
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#define MAPNAME ROTGEN_MATRIX_NAME(BASEMAP,SIZE,_row)
|
||||
#include <rotgen/container/block/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
#undef SOURCENAME
|
||||
#undef MAPNAME
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME, SIZE, _row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _row)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _col)
|
||||
#define MAPNAME ROTGEN_MATRIX_NAME(BASEMAP, SIZE, _row)
|
||||
#include <rotgen/container/block/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
#undef SOURCENAME
|
||||
#undef MAPNAME
|
||||
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
|
||||
#define SIZE 32
|
||||
#define TYPE float
|
||||
#define SIZE 32
|
||||
#define TYPE float
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#define MAPNAME ROTGEN_MATRIX_NAME(BASEMAP,SIZE,_col)
|
||||
#include <rotgen/container/block/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
#undef SOURCENAME
|
||||
#undef MAPNAME
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME, SIZE, _col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _col)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _row)
|
||||
#define MAPNAME ROTGEN_MATRIX_NAME(BASEMAP, SIZE, _col)
|
||||
#include <rotgen/container/block/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
#undef SOURCENAME
|
||||
#undef MAPNAME
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#define MAPNAME ROTGEN_MATRIX_NAME(BASEMAP,SIZE,_row)
|
||||
#include <rotgen/container/block/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
#undef SOURCENAME
|
||||
#undef MAPNAME
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME, SIZE, _row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _row)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _col)
|
||||
#define MAPNAME ROTGEN_MATRIX_NAME(BASEMAP, SIZE, _row)
|
||||
#include <rotgen/container/block/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
#undef SOURCENAME
|
||||
#undef MAPNAME
|
||||
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
|
|
|
|||
|
|
@ -13,28 +13,28 @@
|
|||
//==================================================================================================
|
||||
class ROTGEN_EXPORT CLASSNAME
|
||||
{
|
||||
private:
|
||||
private:
|
||||
struct payload;
|
||||
std::unique_ptr<payload> storage_;
|
||||
|
||||
public:
|
||||
CLASSNAME(SOURCENAME CONST& r , Index i0, Index j0, Index ni, Index nj);
|
||||
CLASSNAME(MAPNAME CONST& r, Index i0, Index j0, Index ni, Index nj);
|
||||
public:
|
||||
CLASSNAME(SOURCENAME CONST& r, Index i0, Index j0, Index ni, Index nj);
|
||||
CLASSNAME(MAPNAME CONST& r, Index i0, Index j0, Index ni, Index nj);
|
||||
CLASSNAME(payload const& r, Index i0, Index j0, Index ni, Index nj);
|
||||
|
||||
CLASSNAME(CLASSNAME const& other);
|
||||
CLASSNAME(CLASSNAME&&) noexcept;
|
||||
|
||||
#if !defined(USE_CONST)
|
||||
#if !defined(USE_CONST)
|
||||
CLASSNAME& operator=(CLASSNAME const& other);
|
||||
CLASSNAME& operator=(CLASSNAME&&) noexcept;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
~CLASSNAME();
|
||||
|
||||
#if !defined(USE_CONST)
|
||||
#if !defined(USE_CONST)
|
||||
void assign(SOURCENAME const&);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Index rows() const;
|
||||
Index cols() const;
|
||||
|
|
@ -46,44 +46,44 @@ class ROTGEN_EXPORT CLASSNAME
|
|||
Index startRow() const;
|
||||
Index startCol() const;
|
||||
|
||||
SOURCENAME normalized() const;
|
||||
SOURCENAME transpose() const;
|
||||
SOURCENAME conjugate() const;
|
||||
SOURCENAME adjoint() const;
|
||||
SOURCENAME normalized() const;
|
||||
SOURCENAME transpose() const;
|
||||
SOURCENAME conjugate() const;
|
||||
SOURCENAME adjoint() const;
|
||||
|
||||
SOURCENAME cwiseAbs() const;
|
||||
SOURCENAME cwiseAbs2() const;
|
||||
SOURCENAME cwiseAbs() const;
|
||||
SOURCENAME cwiseAbs2() const;
|
||||
SOURCENAME cwiseInverse() const;
|
||||
SOURCENAME cwiseSqrt() const;
|
||||
SOURCENAME cwiseSqrt() const;
|
||||
|
||||
#if !defined(USE_CONST)
|
||||
#if !defined(USE_CONST)
|
||||
void normalize();
|
||||
void transposeInPlace();
|
||||
void adjointInPlace();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
TYPE sum() const;
|
||||
TYPE prod() const;
|
||||
TYPE mean() const;
|
||||
TYPE trace() const;
|
||||
TYPE sum() const;
|
||||
TYPE prod() const;
|
||||
TYPE mean() const;
|
||||
TYPE trace() const;
|
||||
TYPE maxCoeff() const;
|
||||
TYPE minCoeff() const;
|
||||
TYPE maxCoeff(Index* row, Index* col) const;
|
||||
TYPE minCoeff(Index* row, Index* col) const;
|
||||
|
||||
TYPE squaredNorm() const;
|
||||
TYPE norm() const;
|
||||
TYPE lpNorm(int p) const;
|
||||
TYPE squaredNorm() const;
|
||||
TYPE norm() const;
|
||||
TYPE lpNorm(int p) const;
|
||||
|
||||
#if !defined(USE_CONST)
|
||||
TYPE& operator()(Index i, Index j);
|
||||
TYPE& operator()(Index index);
|
||||
#if !defined(USE_CONST)
|
||||
TYPE& operator()(Index i, Index j);
|
||||
TYPE& operator()(Index index);
|
||||
CLASSNAME& operator+=(CLASSNAME const& rhs);
|
||||
CLASSNAME& operator-=(CLASSNAME const& rhs);
|
||||
CLASSNAME& operator*=(CLASSNAME const& rhs);
|
||||
CLASSNAME& operator*=(TYPE d);
|
||||
CLASSNAME& operator/=(TYPE d);
|
||||
#endif
|
||||
CLASSNAME& operator*=(TYPE d);
|
||||
CLASSNAME& operator/=(TYPE d);
|
||||
#endif
|
||||
|
||||
TYPE operator()(Index i, Index j) const;
|
||||
TYPE operator()(Index index) const;
|
||||
|
|
@ -95,26 +95,43 @@ class ROTGEN_EXPORT CLASSNAME
|
|||
SOURCENAME mul(TYPE s) const;
|
||||
SOURCENAME div(TYPE s) const;
|
||||
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&,CLASSNAME const&);
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&, format<CLASSNAME> const&);
|
||||
friend ROTGEN_EXPORT bool operator==(CLASSNAME const& lhs, CLASSNAME const& rhs);
|
||||
friend ROTGEN_EXPORT bool operator!=(CLASSNAME const& lhs, CLASSNAME const& rhs);
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&,
|
||||
CLASSNAME const&);
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&,
|
||||
format<CLASSNAME> const&);
|
||||
friend ROTGEN_EXPORT bool operator==(CLASSNAME const& lhs,
|
||||
CLASSNAME const& rhs);
|
||||
friend ROTGEN_EXPORT bool operator!=(CLASSNAME const& lhs,
|
||||
CLASSNAME const& rhs);
|
||||
|
||||
#if !defined(USE_CONST)
|
||||
TYPE* data();
|
||||
#endif
|
||||
#if !defined(USE_CONST)
|
||||
TYPE* data();
|
||||
#endif
|
||||
const TYPE* data() const;
|
||||
|
||||
static SOURCENAME Zero(Index r, Index c) { return SOURCENAME::Zero(r,c); }
|
||||
static SOURCENAME Ones(Index r, Index c) { return SOURCENAME::Ones(r,c); }
|
||||
static SOURCENAME Constant(Index r, Index c, TYPE v) { return SOURCENAME::Constant(r,c,v); }
|
||||
static SOURCENAME Random(Index r, Index c) { return SOURCENAME::Random(r,c); }
|
||||
static SOURCENAME Identity(Index r, Index c) { return SOURCENAME::Identity(r,c); }
|
||||
static SOURCENAME Zero(Index r, Index c) { return SOURCENAME::Zero(r, c); }
|
||||
|
||||
public:
|
||||
#if !defined(USE_CONST)
|
||||
std::unique_ptr<payload>& storage() { return storage_; }
|
||||
#endif
|
||||
static SOURCENAME Ones(Index r, Index c) { return SOURCENAME::Ones(r, c); }
|
||||
|
||||
static SOURCENAME Constant(Index r, Index c, TYPE v)
|
||||
{
|
||||
return SOURCENAME::Constant(r, c, v);
|
||||
}
|
||||
|
||||
static SOURCENAME Random(Index r, Index c)
|
||||
{
|
||||
return SOURCENAME::Random(r, c);
|
||||
}
|
||||
|
||||
static SOURCENAME Identity(Index r, Index c)
|
||||
{
|
||||
return SOURCENAME::Identity(r, c);
|
||||
}
|
||||
|
||||
public:
|
||||
#if !defined(USE_CONST)
|
||||
std::unique_ptr<payload>& storage() { return storage_; }
|
||||
#endif
|
||||
|
||||
std::unique_ptr<payload> const& storage() const { return storage_; }
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,99 +21,136 @@ namespace rotgen
|
|||
template<typename Ref, int Rows, int Cols, bool Inner, bool IsConst>
|
||||
struct compute_block_type
|
||||
{
|
||||
using ref_t = std::conditional_t<IsConst, typename Ref::parent const, typename Ref::parent>;
|
||||
using ref_t = std::conditional_t<IsConst,
|
||||
typename Ref::parent const,
|
||||
typename Ref::parent>;
|
||||
|
||||
using type = std::conditional_t < storage_status<Rows,Cols,Rows,Cols>
|
||||
, Eigen::Block<ref_t, Rows, Cols, Inner>
|
||||
, Eigen::Block<ref_t, Eigen::Dynamic, Eigen::Dynamic, Inner>
|
||||
>;
|
||||
using type = std::conditional_t<
|
||||
storage_status<Rows, Cols, Rows, Cols>,
|
||||
Eigen::Block<ref_t, Rows, Cols, Inner>,
|
||||
Eigen::Block<ref_t, Eigen::Dynamic, Eigen::Dynamic, Inner>>;
|
||||
};
|
||||
|
||||
template<typename T, int O, typename S, int Rows, int Cols, bool Inner, bool IsConst>
|
||||
struct compute_block_type<ref<T,O,S>,Rows,Cols,Inner,IsConst>
|
||||
: compute_block_type<typename ref<T,O,S>::parent,Rows,Cols,Inner,IsConst>
|
||||
template<typename T,
|
||||
int O,
|
||||
typename S,
|
||||
int Rows,
|
||||
int Cols,
|
||||
bool Inner,
|
||||
bool IsConst>
|
||||
struct compute_block_type<ref<T, O, S>, Rows, Cols, Inner, IsConst>
|
||||
: compute_block_type<typename ref<T, O, S>::parent,
|
||||
Rows,
|
||||
Cols,
|
||||
Inner,
|
||||
IsConst>
|
||||
{
|
||||
};
|
||||
|
||||
template<typename Ref, int Rows, int Cols, bool Inner, bool IsConst>
|
||||
using block_type = typename compute_block_type<Ref,Rows,Cols,Inner,IsConst>::type;
|
||||
using block_type =
|
||||
typename compute_block_type<Ref, Rows, Cols, Inner, IsConst>::type;
|
||||
}
|
||||
|
||||
template< typename Ref
|
||||
, int Rows = Dynamic, int Cols = Dynamic
|
||||
, bool Inner = false , int ForceStorageOrder = -1
|
||||
>
|
||||
class block : private detail::block_type<std::remove_const_t<Ref>, Rows, Cols, Inner,std::is_const_v<Ref> >
|
||||
template<typename Ref,
|
||||
int Rows = Dynamic,
|
||||
int Cols = Dynamic,
|
||||
bool Inner = false,
|
||||
int ForceStorageOrder = -1>
|
||||
class block : private detail::block_type<std::remove_const_t<Ref>,
|
||||
Rows,
|
||||
Cols,
|
||||
Inner,
|
||||
std::is_const_v<Ref>>
|
||||
{
|
||||
static_assert ( concepts::entity<Ref>
|
||||
, "[ROTGEN][CRITICAL] - Block of non-rotgen type instanciated"
|
||||
);
|
||||
static_assert(concepts::entity<Ref>,
|
||||
"[ROTGEN][CRITICAL] - Block of non-rotgen type instanciated");
|
||||
|
||||
public:
|
||||
using rotgen_tag = void;
|
||||
using rotgen_block_tag = void;
|
||||
using parent = detail::block_type<std::remove_const_t<Ref>, Rows, Cols, Inner,std::is_const_v<Ref>>;
|
||||
using value_type = typename parent::value_type;
|
||||
using Index = typename parent::Index;
|
||||
public:
|
||||
using rotgen_tag = void;
|
||||
using rotgen_block_tag = void;
|
||||
using parent = detail::block_type<std::remove_const_t<Ref>,
|
||||
Rows,
|
||||
Cols,
|
||||
Inner,
|
||||
std::is_const_v<Ref>>;
|
||||
using value_type = typename parent::value_type;
|
||||
using Index = typename parent::Index;
|
||||
|
||||
static constexpr int storage_order = (ForceStorageOrder == -1) ? Ref::storage_order : ForceStorageOrder;
|
||||
static constexpr bool is_immutable = std::is_const_v<Ref>;
|
||||
static constexpr int storage_order =
|
||||
(ForceStorageOrder == -1) ? Ref::storage_order : ForceStorageOrder;
|
||||
static constexpr bool is_immutable = std::is_const_v<Ref>;
|
||||
|
||||
static constexpr bool IsRowMajor = parent::IsRowMajor;
|
||||
static constexpr bool IsRowMajor = parent::IsRowMajor;
|
||||
|
||||
using concrete_type = matrix<value_type,Rows,Cols,storage_order>;
|
||||
using concrete_dynamic_type = matrix<value_type,Dynamic,Dynamic,storage_order>;
|
||||
using concrete_type = matrix<value_type, Rows, Cols, storage_order>;
|
||||
using concrete_dynamic_type =
|
||||
matrix<value_type, Dynamic, Dynamic, storage_order>;
|
||||
|
||||
template<typename ET>
|
||||
using as_concrete_type = detail::as_concrete_t<ET, matrix>;
|
||||
|
||||
static constexpr int Options = Ref::Options;
|
||||
static constexpr int RowsAtCompileTime = Rows;
|
||||
static constexpr int ColsAtCompileTime = Cols;
|
||||
static constexpr int MaxRowsAtCompileTime = Ref::MaxRowsAtCompileTime;
|
||||
static constexpr int MaxColsAtCompileTime = Ref::MaxColsAtCompileTime;
|
||||
static constexpr bool IsVectorAtCompileTime = Ref::IsVectorAtCompileTime;
|
||||
static constexpr bool is_defined_static = Rows!=-1 && Cols!=-1;
|
||||
static constexpr bool has_static_storage = storage_status<Rows,Cols,Rows,Cols>;
|
||||
static constexpr int Options = Ref::Options;
|
||||
static constexpr int RowsAtCompileTime = Rows;
|
||||
static constexpr int ColsAtCompileTime = Cols;
|
||||
static constexpr int MaxRowsAtCompileTime = Ref::MaxRowsAtCompileTime;
|
||||
static constexpr int MaxColsAtCompileTime = Ref::MaxColsAtCompileTime;
|
||||
static constexpr bool IsVectorAtCompileTime = Ref::IsVectorAtCompileTime;
|
||||
static constexpr bool is_defined_static = Rows != -1 && Cols != -1;
|
||||
static constexpr bool has_static_storage =
|
||||
storage_status<Rows, Cols, Rows, Cols>;
|
||||
|
||||
public:
|
||||
block(const block& other) = default;
|
||||
block(block&& other) = default;
|
||||
block& operator=(const block&) = default;
|
||||
block& operator=(block&&) = default;
|
||||
public:
|
||||
block(block const& other) = default;
|
||||
block(block&& other) = default;
|
||||
block& operator=(block const&) = default;
|
||||
block& operator=(block&&) = default;
|
||||
|
||||
block(Ref const& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj)
|
||||
block(Ref const& r,
|
||||
std::size_t i0,
|
||||
std::size_t j0,
|
||||
std::size_t ni,
|
||||
std::size_t nj)
|
||||
requires(is_immutable)
|
||||
: parent(r.base(),i0,j0,ni,nj)
|
||||
{}
|
||||
: parent(r.base(), i0, j0, ni, nj)
|
||||
{
|
||||
}
|
||||
|
||||
block(Ref const& r, std::size_t i0, std::size_t j0)
|
||||
requires(Rows != -1 && Cols != -1 && is_immutable)
|
||||
: parent(r.base(),i0,j0,Rows,Cols)
|
||||
{}
|
||||
: parent(r.base(), i0, j0, Rows, Cols)
|
||||
{
|
||||
}
|
||||
|
||||
block(Ref& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj)
|
||||
block(
|
||||
Ref& r, std::size_t i0, std::size_t j0, std::size_t ni, std::size_t nj)
|
||||
requires(!is_immutable)
|
||||
: parent(r.base(),i0,j0,ni,nj)
|
||||
{}
|
||||
: parent(r.base(), i0, j0, ni, nj)
|
||||
{
|
||||
}
|
||||
|
||||
block(Ref& r, std::size_t i0, std::size_t j0)
|
||||
requires(Rows != -1 && Cols != -1 && !is_immutable)
|
||||
: parent(r.base(),i0,j0,Rows,Cols)
|
||||
{}
|
||||
: parent(r.base(), i0, j0, Rows, Cols)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename B, Index R, Index C, bool I, int FS>
|
||||
block(block<B,R,C,I,FS> const& other) : parent(other.base())
|
||||
{}
|
||||
block(block<B, R, C, I, FS> const& other) : parent(other.base())
|
||||
{
|
||||
}
|
||||
|
||||
template<typename OtherDerived>
|
||||
block(const Eigen::MatrixBase<OtherDerived>& other) : parent(other) {}
|
||||
block(Eigen::MatrixBase<OtherDerived> const& other) : parent(other)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename OtherDerived>
|
||||
block(const Eigen::EigenBase<OtherDerived>& other) : parent(other) {}
|
||||
block(Eigen::EigenBase<OtherDerived> const& other) : parent(other)
|
||||
{
|
||||
}
|
||||
|
||||
block(concepts::entity auto const& other) : parent(other.base())
|
||||
{}
|
||||
block(concepts::entity auto const& other) : parent(other.base()) {}
|
||||
|
||||
block& operator=(concepts::entity auto const& other)
|
||||
{
|
||||
|
|
@ -122,21 +159,22 @@ namespace rotgen
|
|||
}
|
||||
|
||||
template<typename OtherDerived>
|
||||
block& operator=(const Eigen::MatrixBase<OtherDerived>& other)
|
||||
block& operator=(Eigen::MatrixBase<OtherDerived> const& other)
|
||||
{
|
||||
parent::operator=(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename OtherDerived>
|
||||
block& operator=(const Eigen::EigenBase<OtherDerived>& other)
|
||||
block& operator=(Eigen::EigenBase<OtherDerived> const& other)
|
||||
{
|
||||
parent::operator=(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
parent& base() { return static_cast<parent&>(*this); }
|
||||
parent const& base() const { return static_cast<parent const&>(*this); }
|
||||
parent& base() { return static_cast<parent&>(*this); }
|
||||
|
||||
parent const& base() const { return static_cast<parent const&>(*this); }
|
||||
|
||||
auto evaluate() const
|
||||
{
|
||||
|
|
@ -146,239 +184,308 @@ namespace rotgen
|
|||
|
||||
decltype(auto) noalias() const
|
||||
{
|
||||
if constexpr(use_expression_templates) return base().noalias();
|
||||
else return *this;
|
||||
if constexpr (use_expression_templates) return base().noalias();
|
||||
else return *this;
|
||||
}
|
||||
|
||||
decltype(auto) noalias()
|
||||
{
|
||||
if constexpr(use_expression_templates) return base().noalias();
|
||||
else return *this;
|
||||
if constexpr (use_expression_templates) return base().noalias();
|
||||
else return *this;
|
||||
}
|
||||
|
||||
auto normalized() const requires(IsVectorAtCompileTime)
|
||||
auto normalized() const
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
if constexpr(use_expression_templates) return base().normalized();
|
||||
else return as_concrete_type<decltype(base().normalized())>(base().normalized());
|
||||
if constexpr (use_expression_templates) return base().normalized();
|
||||
else
|
||||
return as_concrete_type<decltype(base().normalized())>(
|
||||
base().normalized());
|
||||
}
|
||||
|
||||
auto transpose() const
|
||||
{
|
||||
if constexpr(use_expression_templates) return base().transpose();
|
||||
else return as_concrete_type<decltype(base().transpose())>(base().transpose());
|
||||
if constexpr (use_expression_templates) return base().transpose();
|
||||
else
|
||||
return as_concrete_type<decltype(base().transpose())>(
|
||||
base().transpose());
|
||||
}
|
||||
|
||||
auto adjoint() const
|
||||
{
|
||||
if constexpr(use_expression_templates) return base().adjoint();
|
||||
else return as_concrete_type<decltype(base().adjoint())>(base().adjoint());
|
||||
if constexpr (use_expression_templates) return base().adjoint();
|
||||
else
|
||||
return as_concrete_type<decltype(base().adjoint())>(base().adjoint());
|
||||
}
|
||||
|
||||
auto conjugate() const
|
||||
{
|
||||
if constexpr(use_expression_templates) return base().conjugate();
|
||||
else return as_concrete_type<decltype(base().conjugate())>(base().conjugate());
|
||||
if constexpr (use_expression_templates) return base().conjugate();
|
||||
else
|
||||
return as_concrete_type<decltype(base().conjugate())>(
|
||||
base().conjugate());
|
||||
}
|
||||
|
||||
void normalize() requires(!is_immutable && IsVectorAtCompileTime)
|
||||
void normalize()
|
||||
requires(!is_immutable && IsVectorAtCompileTime)
|
||||
{
|
||||
parent::normalize();
|
||||
}
|
||||
|
||||
void transposeInPlace() requires(!is_immutable) { parent::transposeInPlace(); }
|
||||
void adjointInPlace() requires(!is_immutable) { parent::adjointInPlace(); }
|
||||
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();
|
||||
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();
|
||||
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();
|
||||
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();
|
||||
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)
|
||||
static concrete_type Constant(value_type value)
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Constant(Rows, Cols, static_cast<value_type>(value));
|
||||
}
|
||||
|
||||
static concrete_type Constant(int rows, int cols, value_type value)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Constant(rows, cols, static_cast<value_type>(value));
|
||||
}
|
||||
|
||||
static concrete_type Identity() requires (Rows != -1 && Cols != -1)
|
||||
static concrete_type Identity()
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Identity(Rows, Cols);
|
||||
}
|
||||
|
||||
static concrete_type Identity(int rows, int cols)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Identity(rows, cols);
|
||||
}
|
||||
|
||||
static concrete_type Zero() requires (Rows != -1 && Cols != -1)
|
||||
static concrete_type Zero()
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Zero(Rows, Cols);
|
||||
}
|
||||
|
||||
static concrete_type Zero(int rows, int cols)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Zero(rows, cols);
|
||||
}
|
||||
|
||||
static concrete_type Ones() requires (Rows != -1 && Cols != -1)
|
||||
static concrete_type Ones()
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Ones(Rows, Cols);
|
||||
}
|
||||
|
||||
static concrete_type Ones(int rows, int cols)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Ones(rows, cols);
|
||||
}
|
||||
|
||||
static concrete_type Random() requires (Rows != -1 && Cols != -1)
|
||||
static concrete_type Random()
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Random(Rows, Cols);
|
||||
}
|
||||
|
||||
static concrete_type Random(int rows, int cols)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Random(rows, cols);
|
||||
}
|
||||
|
||||
block& setOnes() requires(!is_immutable)
|
||||
block& setOnes()
|
||||
requires(!is_immutable)
|
||||
{
|
||||
*this = parent::Ones(rows(), cols());
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& setOnes(int r, int c) requires(!is_immutable)
|
||||
block& setOnes(int r, int c)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
*this = parent::Ones(r, c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& setZero() requires(!is_immutable)
|
||||
block& setZero()
|
||||
requires(!is_immutable)
|
||||
{
|
||||
*this = parent::Zero(rows(), cols());
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& setZero(int r, int c) requires(!is_immutable)
|
||||
block& setZero(int r, int c)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
*this = parent::Zero(r,c);
|
||||
*this = parent::Zero(r, c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& setConstant(value_type value) requires(!is_immutable)
|
||||
block& setConstant(value_type value)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
*this = parent::Constant(rows(), cols(), value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& setConstant(int r, int c, value_type value) requires(!is_immutable)
|
||||
block& setConstant(int r, int c, value_type value)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
*this = parent::Constant(r,c, value);
|
||||
*this = parent::Constant(r, c, value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& setRandom() requires(!is_immutable)
|
||||
block& setRandom()
|
||||
requires(!is_immutable)
|
||||
{
|
||||
*this = parent::Random(rows(),cols());
|
||||
*this = parent::Random(rows(), cols());
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& setRandom(int r, int c) requires(!is_immutable)
|
||||
block& setRandom(int r, int c)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
*this = parent::Random(r,c);
|
||||
*this = parent::Random(r, c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& setIdentity() requires(!is_immutable)
|
||||
block& setIdentity()
|
||||
requires(!is_immutable)
|
||||
{
|
||||
*this = parent::Identity(rows(),cols());
|
||||
*this = parent::Identity(rows(), cols());
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& setIdentity(int r, int c) requires(!is_immutable)
|
||||
block& setIdentity(int r, int c)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
*this = parent::Identity(r,c);
|
||||
*this = parent::Identity(r, c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<int P>
|
||||
value_type lpNorm() const
|
||||
template<int P> value_type lpNorm() const
|
||||
{
|
||||
static_assert(P == 1 || P == 2 || P == Infinity);
|
||||
return parent::template lpNorm<P>();
|
||||
}
|
||||
|
||||
value_type& operator()(Index i, Index j) requires(!is_immutable)
|
||||
value_type& operator()(Index i, Index j)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
return base()(i,j);
|
||||
return base()(i, j);
|
||||
}
|
||||
|
||||
value_type& operator()(Index i) requires(!is_immutable && IsVectorAtCompileTime)
|
||||
value_type& operator()(Index i)
|
||||
requires(!is_immutable && IsVectorAtCompileTime)
|
||||
{
|
||||
return base().data()[i];
|
||||
}
|
||||
|
||||
value_type& operator[](Index i) requires(!is_immutable && IsVectorAtCompileTime)
|
||||
value_type& operator[](Index i)
|
||||
requires(!is_immutable && IsVectorAtCompileTime)
|
||||
{
|
||||
return (*this)(i);
|
||||
}
|
||||
|
||||
value_type operator()(Index i, Index j) const { return base()(i,j); }
|
||||
value_type operator()(Index i) const requires(IsVectorAtCompileTime) { return base().data()[i]; }
|
||||
value_type operator[](Index i) const requires(IsVectorAtCompileTime) { return (*this)(i); }
|
||||
value_type operator()(Index i, Index j) const { return base()(i, j); }
|
||||
|
||||
value_type operator()(Index i) const
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
return base().data()[i];
|
||||
}
|
||||
|
||||
value_type operator[](Index i) const
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
return (*this)(i);
|
||||
}
|
||||
|
||||
using parent::innerStride;
|
||||
using parent::outerStride;
|
||||
using parent::rows;
|
||||
using parent::cols;
|
||||
using parent::size;
|
||||
using parent::prod;
|
||||
using parent::mean;
|
||||
using parent::trace;
|
||||
using parent::squaredNorm;
|
||||
using parent::norm;
|
||||
using parent::sum;
|
||||
using parent::data;
|
||||
|
||||
using parent::innerStride;
|
||||
using parent::mean;
|
||||
using parent::norm;
|
||||
using parent::outerStride;
|
||||
using parent::prod;
|
||||
using parent::rows;
|
||||
using parent::size;
|
||||
using parent::squaredNorm;
|
||||
using parent::sum;
|
||||
using parent::trace;
|
||||
|
||||
auto minCoeff() const { return parent::minCoeff(); }
|
||||
|
||||
auto maxCoeff() const { return parent::maxCoeff(); }
|
||||
|
||||
template<std::integral IndexType>
|
||||
auto minCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
Index r, c;
|
||||
auto result = parent::minCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
|
|
@ -388,7 +495,7 @@ namespace rotgen
|
|||
template<std::integral IndexType>
|
||||
auto maxCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
Index r, c;
|
||||
auto result = parent::maxCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
|
|
@ -396,15 +503,18 @@ namespace rotgen
|
|||
}
|
||||
|
||||
Index startRow() const { return base().startRow(); }
|
||||
|
||||
Index startCol() const { return base().startCol(); }
|
||||
|
||||
block& operator+=(block const& rhs) requires(!is_immutable)
|
||||
block& operator+=(block const& rhs)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
static_cast<parent&>(*this) += static_cast<parent const&>(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& operator-=(block const& rhs) requires(!is_immutable)
|
||||
block& operator-=(block const& rhs)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
static_cast<parent&>(*this) -= static_cast<parent const&>(rhs);
|
||||
return *this;
|
||||
|
|
@ -415,22 +525,25 @@ namespace rotgen
|
|||
return concrete_type(static_cast<parent const&>(*this).operator-());
|
||||
}
|
||||
|
||||
block& operator*=(block const& rhs) requires(!is_immutable)
|
||||
block& operator*=(block const& rhs)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
static_cast<parent&>(*this) *= static_cast<parent const&>(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& operator*=(value_type rhs) requires(!is_immutable)
|
||||
block& operator*=(value_type rhs)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
static_cast<parent&>(*this) *= rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
block& operator/=(value_type rhs) requires(!is_immutable)
|
||||
block& operator/=(value_type rhs)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
static_cast<parent&>(*this) /= rhs;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@
|
|||
#include <rotgen/container/map/dynamic.hpp>
|
||||
#else
|
||||
#include <rotgen/container/map/fixed.hpp>
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -14,88 +14,106 @@
|
|||
|
||||
namespace rotgen
|
||||
{
|
||||
template<typename Ref, int Options = Unaligned, typename Stride = rotgen::stride>
|
||||
template<typename Ref,
|
||||
int Options = Unaligned,
|
||||
typename Stride = rotgen::stride>
|
||||
class map : public find_map<Ref>
|
||||
{
|
||||
public:
|
||||
public:
|
||||
static_assert(concepts::entity<Ref>,
|
||||
"[ROTGEN][CRITICAL] - Map of non-rotgen type instanciated");
|
||||
|
||||
static_assert ( concepts::entity<Ref>
|
||||
, "[ROTGEN][CRITICAL] - Map of non-rotgen type instanciated"
|
||||
);
|
||||
using parent = find_map<Ref>;
|
||||
using rotgen_tag = void;
|
||||
using value_type = typename std::remove_const_t<Ref>::value_type;
|
||||
using concrete_type = typename std::remove_const_t<Ref>::concrete_type;
|
||||
|
||||
using parent = find_map<Ref>;
|
||||
using rotgen_tag = void;
|
||||
using value_type = typename std::remove_const_t<Ref>::value_type;
|
||||
using concrete_type = typename std::remove_const_t<Ref>::concrete_type;
|
||||
|
||||
static constexpr bool IsRowMajor = Ref::IsRowMajor;
|
||||
static constexpr int storage_order = Ref::storage_order;
|
||||
static constexpr bool has_static_storage = false;
|
||||
static constexpr bool IsRowMajor = Ref::IsRowMajor;
|
||||
static constexpr int storage_order = Ref::storage_order;
|
||||
static constexpr bool has_static_storage = false;
|
||||
|
||||
static constexpr bool is_immutable = std::is_const_v<Ref>;
|
||||
static constexpr bool is_defined_static = false;
|
||||
|
||||
using ptr_type = std::conditional_t<is_immutable, value_type const*, value_type*>;
|
||||
using ptr_type =
|
||||
std::conditional_t<is_immutable, value_type const*, value_type*>;
|
||||
using stride_type = Stride;
|
||||
|
||||
static constexpr int RowsAtCompileTime = Ref::RowsAtCompileTime;
|
||||
static constexpr int ColsAtCompileTime = Ref::ColsAtCompileTime;
|
||||
static constexpr int MaxRowsAtCompileTime = Ref::MaxRowsAtCompileTime;
|
||||
static constexpr int MaxColsAtCompileTime = Ref::MaxColsAtCompileTime;
|
||||
static constexpr int RowsAtCompileTime = Ref::RowsAtCompileTime;
|
||||
static constexpr int ColsAtCompileTime = Ref::ColsAtCompileTime;
|
||||
static constexpr int MaxRowsAtCompileTime = Ref::MaxRowsAtCompileTime;
|
||||
static constexpr int MaxColsAtCompileTime = Ref::MaxColsAtCompileTime;
|
||||
static constexpr bool IsVectorAtCompileTime = Ref::IsVectorAtCompileTime;
|
||||
static constexpr bool IsCompileTimeSized = RowsAtCompileTime != -1 && ColsAtCompileTime != -1;
|
||||
static constexpr bool IsCompileTimeSized =
|
||||
RowsAtCompileTime != -1 && ColsAtCompileTime != -1;
|
||||
|
||||
using transposed_type = matrix<value_type,ColsAtCompileTime,RowsAtCompileTime, storage_order>;
|
||||
using transposed_type =
|
||||
matrix<value_type, ColsAtCompileTime, RowsAtCompileTime, storage_order>;
|
||||
|
||||
map(ptr_type ptr, Index r, Index c, stride_type s) : parent(ptr, r, c, strides<storage_order>(s,r,c))
|
||||
map(ptr_type ptr, Index r, Index c, stride_type s)
|
||||
: parent(ptr, r, c, strides<storage_order>(s, r, c))
|
||||
{
|
||||
if constexpr(RowsAtCompileTime != -1)
|
||||
assert(r == RowsAtCompileTime && "Mismatched between dynamic and static row size");
|
||||
if constexpr (RowsAtCompileTime != -1)
|
||||
assert(r == RowsAtCompileTime &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
|
||||
if constexpr(ColsAtCompileTime != -1)
|
||||
assert(c == ColsAtCompileTime && "Mismatched between dynamic and static column size");
|
||||
if constexpr (ColsAtCompileTime != -1)
|
||||
assert(c == ColsAtCompileTime &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
}
|
||||
|
||||
map(ptr_type ptr, Index r, Index c)
|
||||
: parent( ptr, r, c
|
||||
, [&]()
|
||||
{
|
||||
if constexpr(!std::same_as<Stride,stride>) return strides<storage_order>(Stride{},r,c);
|
||||
else return strides<storage_order>(r,c);
|
||||
}()
|
||||
)
|
||||
{}
|
||||
: parent(ptr, r, c, [&]() {
|
||||
if constexpr (!std::same_as<Stride, stride>)
|
||||
return strides<storage_order>(Stride{}, r, c);
|
||||
else return strides<storage_order>(r, c);
|
||||
}())
|
||||
{
|
||||
}
|
||||
|
||||
map(ptr_type ptr, stride_type s) requires(IsCompileTimeSized)
|
||||
: parent(ptr,RowsAtCompileTime,ColsAtCompileTime, strides<storage_order>(s))
|
||||
{}
|
||||
map(ptr_type ptr, stride_type s)
|
||||
requires(IsCompileTimeSized)
|
||||
: parent(
|
||||
ptr, RowsAtCompileTime, ColsAtCompileTime, strides<storage_order>(s))
|
||||
{
|
||||
}
|
||||
|
||||
map(ptr_type ptr, Index size) requires(RowsAtCompileTime==1 || ColsAtCompileTime==1)
|
||||
: map( ptr, RowsAtCompileTime==1?1:size, ColsAtCompileTime==1?1:size)
|
||||
{}
|
||||
map(ptr_type ptr, Index size)
|
||||
requires(RowsAtCompileTime == 1 || ColsAtCompileTime == 1)
|
||||
: map(ptr,
|
||||
RowsAtCompileTime == 1 ? 1 : size,
|
||||
ColsAtCompileTime == 1 ? 1 : size)
|
||||
{
|
||||
}
|
||||
|
||||
map(ptr_type ptr) requires(IsCompileTimeSized)
|
||||
: map( ptr, RowsAtCompileTime, ColsAtCompileTime )
|
||||
{}
|
||||
map(ptr_type ptr)
|
||||
requires(IsCompileTimeSized)
|
||||
: map(ptr, RowsAtCompileTime, ColsAtCompileTime)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename R2, int O2, typename S2>
|
||||
map(map<R2,O2,S2> const& other) : map ( other.data(), other.rows(), other.cols()
|
||||
, stride{other.outerStride(),other.innerStride()}
|
||||
)
|
||||
{}
|
||||
map(map<R2, O2, S2> const& other)
|
||||
: map(other.data(),
|
||||
other.rows(),
|
||||
other.cols(),
|
||||
stride{other.outerStride(), other.innerStride()})
|
||||
{
|
||||
}
|
||||
|
||||
map(parent const& base) : parent(base) {}
|
||||
|
||||
map(map const& other) : parent(other)
|
||||
{}
|
||||
map(map const& other) : parent(other) {}
|
||||
|
||||
map& operator=(map const& other) requires(!is_immutable)
|
||||
map& operator=(map const& other)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
base() = static_cast<parent const &>(other);
|
||||
base() = static_cast<parent const&>(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
map& operator=(concepts::entity auto const& other) requires(!is_immutable)
|
||||
map& operator=(concepts::entity auto const& other)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
assert(parent::rows() == other.rows() && parent::cols() == other.cols());
|
||||
for (rotgen::Index r = 0; r < parent::rows(); ++r)
|
||||
|
|
@ -105,94 +123,170 @@ namespace rotgen
|
|||
return *this;
|
||||
}
|
||||
|
||||
value_type& operator()(Index i, Index j) requires(!is_immutable) { return parent::operator()(i,j); }
|
||||
value_type& operator()(Index i) requires(!is_immutable && IsVectorAtCompileTime)
|
||||
value_type& operator()(Index i, Index j)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
assert( parent::innerStride() == 1
|
||||
&& parent::outerStride() ==(storage_order == RowMajor ? parent::cols() : parent::rows())
|
||||
);
|
||||
return parent::operator()(i, j);
|
||||
}
|
||||
|
||||
value_type& operator()(Index i)
|
||||
requires(!is_immutable && IsVectorAtCompileTime)
|
||||
{
|
||||
assert(parent::innerStride() == 1 &&
|
||||
parent::outerStride() ==
|
||||
(storage_order == RowMajor ? parent::cols() : parent::rows()));
|
||||
return parent::operator()(i);
|
||||
}
|
||||
|
||||
value_type& operator[](Index i) requires(!is_immutable && IsVectorAtCompileTime)
|
||||
value_type& operator[](Index i)
|
||||
requires(!is_immutable && IsVectorAtCompileTime)
|
||||
{
|
||||
return (*this)(i);
|
||||
}
|
||||
|
||||
value_type operator()(Index i, Index j) const { return parent::operator()(i,j); }
|
||||
value_type operator()(Index i) const requires(IsVectorAtCompileTime)
|
||||
value_type operator()(Index i, Index j) const
|
||||
{
|
||||
assert( parent::innerStride() == 1
|
||||
&& parent::outerStride() ==(storage_order == RowMajor ? parent::cols() : parent::rows())
|
||||
);
|
||||
return parent::operator()(i, j);
|
||||
}
|
||||
|
||||
value_type operator()(Index i) const
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
assert(parent::innerStride() == 1 &&
|
||||
parent::outerStride() ==
|
||||
(storage_order == RowMajor ? parent::cols() : parent::rows()));
|
||||
return parent::operator()(i);
|
||||
}
|
||||
|
||||
value_type operator[](Index i) const requires(IsVectorAtCompileTime)
|
||||
value_type operator[](Index i) const
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
return (*this)(i);
|
||||
}
|
||||
|
||||
auto evaluate() const { return *this; }
|
||||
decltype(auto) noalias() const { return *this; }
|
||||
decltype(auto) noalias() { return *this; }
|
||||
auto evaluate() const { return *this; }
|
||||
|
||||
concrete_type normalized() const requires(IsVectorAtCompileTime)
|
||||
decltype(auto) noalias() const { return *this; }
|
||||
|
||||
decltype(auto) noalias() { return *this; }
|
||||
|
||||
concrete_type normalized() const
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
return concrete_type(base().normalized());
|
||||
}
|
||||
|
||||
transposed_type transpose() const { return transposed_type(base().transpose()); }
|
||||
concrete_type conjugate() const { return concrete_type(base().conjugate()); }
|
||||
transposed_type adjoint() const { return transposed_type(base().adjoint()); }
|
||||
transposed_type transpose() const
|
||||
{
|
||||
return transposed_type(base().transpose());
|
||||
}
|
||||
|
||||
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()); }
|
||||
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 conjugate() const
|
||||
{
|
||||
return concrete_type(base().conjugate());
|
||||
}
|
||||
|
||||
transposed_type adjoint() const
|
||||
{
|
||||
return transposed_type(base().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());
|
||||
}
|
||||
|
||||
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 cross(map const& other) const
|
||||
{
|
||||
concrete_type that;
|
||||
if constexpr(RowsAtCompileTime==-1)
|
||||
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);
|
||||
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);
|
||||
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)
|
||||
void normalize()
|
||||
requires(!is_immutable && IsVectorAtCompileTime)
|
||||
{
|
||||
parent::normalize();
|
||||
}
|
||||
void transposeInPlace() requires(!is_immutable) { parent::transposeInPlace(); }
|
||||
void adjointInPlace() requires(!is_immutable) { parent::adjointInPlace(); }
|
||||
|
||||
void transposeInPlace()
|
||||
requires(!is_immutable)
|
||||
{
|
||||
parent::transposeInPlace();
|
||||
}
|
||||
|
||||
void adjointInPlace()
|
||||
requires(!is_immutable)
|
||||
{
|
||||
parent::adjointInPlace();
|
||||
}
|
||||
|
||||
template<typename R2, int O2, typename S2>
|
||||
map& operator+=(map<R2,O2,S2> const& rhs) requires(!is_immutable)
|
||||
map& operator+=(map<R2, O2, S2> const& rhs)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
base() += rhs.base();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename R2, int O2, typename S2>
|
||||
map& operator-=(map<R2,O2,S2> const& rhs) requires(!is_immutable)
|
||||
map& operator-=(map<R2, O2, S2> const& rhs)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
base() -= rhs.base();
|
||||
return *this;
|
||||
|
|
@ -204,31 +298,35 @@ namespace rotgen
|
|||
}
|
||||
|
||||
template<typename R2, int O2, typename S2>
|
||||
map& operator*=(map<R2,O2,S2> const& rhs) requires(!is_immutable)
|
||||
map& operator*=(map<R2, O2, S2> const& rhs)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
base() *= rhs.base();
|
||||
return *this;
|
||||
}
|
||||
|
||||
map& operator*=(value_type rhs) requires(!is_immutable)
|
||||
map& operator*=(value_type rhs)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
base() *= rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
map& operator/=(value_type rhs) requires(!is_immutable)
|
||||
map& operator/=(value_type rhs)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
base() /= rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto minCoeff() const { return parent::minCoeff(); }
|
||||
|
||||
auto maxCoeff() const { return parent::maxCoeff(); }
|
||||
|
||||
template<std::integral IndexType>
|
||||
auto minCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
Index r, c;
|
||||
auto result = parent::minCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
|
|
@ -238,24 +336,23 @@ namespace rotgen
|
|||
template<std::integral IndexType>
|
||||
auto maxCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
Index r, c;
|
||||
auto result = parent::maxCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
return result;
|
||||
}
|
||||
|
||||
static auto Zero() requires( requires {Ref::Zero();} )
|
||||
static auto Zero()
|
||||
requires(requires { Ref::Zero(); })
|
||||
{
|
||||
return Ref::Zero();
|
||||
}
|
||||
|
||||
static auto Zero(int rows, int cols)
|
||||
{
|
||||
return Ref::Zero(rows,cols);
|
||||
}
|
||||
static auto Zero(int rows, int cols) { return Ref::Zero(rows, cols); }
|
||||
|
||||
static auto Constant(value_type value) requires( requires {Ref::Constant(value);} )
|
||||
static auto Constant(value_type value)
|
||||
requires(requires { Ref::Constant(value); })
|
||||
{
|
||||
return Ref::Constant(value);
|
||||
}
|
||||
|
|
@ -265,17 +362,16 @@ namespace rotgen
|
|||
return Ref::Constant(rows, cols, value);
|
||||
}
|
||||
|
||||
static auto Random() requires( requires {Ref::Random();} )
|
||||
static auto Random()
|
||||
requires(requires { Ref::Random(); })
|
||||
{
|
||||
return Ref::Random();
|
||||
}
|
||||
|
||||
static auto Random(int rows, int cols)
|
||||
{
|
||||
return Ref::Random(rows, cols);
|
||||
}
|
||||
static auto Random(int rows, int cols) { return Ref::Random(rows, cols); }
|
||||
|
||||
static auto Identity() requires( requires {Ref::Identity();} )
|
||||
static auto Identity()
|
||||
requires(requires { Ref::Identity(); })
|
||||
{
|
||||
return Ref::Identity();
|
||||
}
|
||||
|
|
@ -285,51 +381,56 @@ namespace rotgen
|
|||
return Ref::Identity(rows, cols);
|
||||
}
|
||||
|
||||
map& setZero() requires(!is_immutable)
|
||||
map& setZero()
|
||||
requires(!is_immutable)
|
||||
{
|
||||
parent::setZero();
|
||||
return *this;
|
||||
}
|
||||
|
||||
map& setOnes() requires(!is_immutable)
|
||||
map& setOnes()
|
||||
requires(!is_immutable)
|
||||
{
|
||||
parent::setOnes();
|
||||
return *this;
|
||||
}
|
||||
|
||||
map& setIdentity() requires(!is_immutable)
|
||||
map& setIdentity()
|
||||
requires(!is_immutable)
|
||||
{
|
||||
parent::setIdentity();
|
||||
return *this;
|
||||
}
|
||||
|
||||
map& setRandom() requires(!is_immutable)
|
||||
map& setRandom()
|
||||
requires(!is_immutable)
|
||||
{
|
||||
parent::setRandom();
|
||||
return *this;
|
||||
}
|
||||
|
||||
map& setConstant(value_type s) requires(!is_immutable)
|
||||
map& setConstant(value_type s)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
parent::setConstant(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename R2, int O2, typename S2>
|
||||
value_type dot(map<R2,O2,S2> const& rhs) const
|
||||
value_type dot(map<R2, O2, S2> const& rhs) const
|
||||
{
|
||||
return base().dot(rhs.base());
|
||||
}
|
||||
|
||||
template<int P>
|
||||
value_type lpNorm() const
|
||||
template<int P> value_type lpNorm() const
|
||||
{
|
||||
assert(P == 1 || P == 2 || P == Infinity);
|
||||
return parent::lpNorm(P);
|
||||
}
|
||||
|
||||
parent& base() { return static_cast<parent&>(*this); }
|
||||
parent const& base() const { return static_cast<parent const&>(*this); }
|
||||
parent& base() { return static_cast<parent&>(*this); }
|
||||
|
||||
parent const& base() const { return static_cast<parent const&>(*this); }
|
||||
|
||||
concrete_type qr_solve(map const& rhs) const
|
||||
{
|
||||
|
|
@ -338,69 +439,73 @@ namespace rotgen
|
|||
};
|
||||
|
||||
template<typename R1, typename R2, int O1, typename S1, int O2, typename S2>
|
||||
detail::composite_type<R1,R2,matrix> operator+(map<R1,O1,S1> const& lhs, map<R2,O2,S2> const& rhs)
|
||||
detail::composite_type<R1, R2, matrix> operator+(map<R1, O1, S1> const& lhs,
|
||||
map<R2, O2, S2> const& rhs)
|
||||
{
|
||||
using map1_type = map<R1 const,O1,S1>;
|
||||
using map2_type = map<R2 const,O2,S2>;
|
||||
using concrete_type = detail::composite_type<R1,R2,matrix>;
|
||||
using map1_type = map<R1 const, O1, S1>;
|
||||
using map2_type = map<R2 const, O2, S2>;
|
||||
using concrete_type = detail::composite_type<R1, R2, matrix>;
|
||||
return concrete_type(map1_type(lhs).base().add(map2_type(rhs)));
|
||||
}
|
||||
|
||||
template<typename R1, typename R2, int O1, typename S1, int O2, typename S2>
|
||||
detail::composite_type<R1,R2,matrix> operator-(map<R1,O1,S1> const& lhs, map<R2,O2,S2> const& rhs)
|
||||
detail::composite_type<R1, R2, matrix> operator-(map<R1, O1, S1> const& lhs,
|
||||
map<R2, O2, S2> const& rhs)
|
||||
{
|
||||
using map1_type = map<R1 const,O1,S1>;
|
||||
using map2_type = map<R2 const,O2,S2>;
|
||||
using concrete_type = detail::composite_type<R1,R2,matrix>;
|
||||
using map1_type = map<R1 const, O1, S1>;
|
||||
using map2_type = map<R2 const, O2, S2>;
|
||||
using concrete_type = detail::composite_type<R1, R2, matrix>;
|
||||
return concrete_type(map1_type(lhs).base().sub(map2_type(rhs)));
|
||||
}
|
||||
|
||||
template<typename R1, typename R2, int O1, typename S1, int O2, typename S2>
|
||||
matrix<typename R1::value_type,R1::RowsAtCompileTime,R2::ColsAtCompileTime,R1::storage_order>
|
||||
operator*(map<R1,O1,S1> const& lhs, map<R2,O2,S2> const& rhs)
|
||||
matrix<typename R1::value_type,
|
||||
R1::RowsAtCompileTime,
|
||||
R2::ColsAtCompileTime,
|
||||
R1::storage_order>
|
||||
operator*(map<R1, O1, S1> const& lhs, map<R2, O2, S2> const& rhs)
|
||||
{
|
||||
using map1_type = map<R1 const,O1,S1>;
|
||||
using map2_type = map<R2 const,O2,S2>;
|
||||
using concrete_type = matrix< typename R1::value_type
|
||||
, R1::RowsAtCompileTime,R2::ColsAtCompileTime
|
||||
, R1::storage_order
|
||||
>;
|
||||
using map1_type = map<R1 const, O1, S1>;
|
||||
using map2_type = map<R2 const, O2, S2>;
|
||||
using concrete_type = matrix<typename R1::value_type, R1::RowsAtCompileTime,
|
||||
R2::ColsAtCompileTime, R1::storage_order>;
|
||||
|
||||
return concrete_type(map1_type(lhs).base().mul(map2_type(rhs).base()));
|
||||
}
|
||||
|
||||
template<typename R, int O, typename S>
|
||||
typename map<R,O,S>::concrete_type
|
||||
operator*(map<R,O,S> const& lhs, std::convertible_to<typename R::value_type> auto s)
|
||||
typename map<R, O, S>::concrete_type operator*(
|
||||
map<R, O, S> const& lhs, std::convertible_to<typename R::value_type> auto s)
|
||||
{
|
||||
using concrete_type = typename map<R,O,S>::concrete_type;
|
||||
using concrete_type = typename map<R, O, S>::concrete_type;
|
||||
return concrete_type(lhs.base().mul(s));
|
||||
}
|
||||
|
||||
template<typename R, int O, typename S>
|
||||
typename map<R,O,S>::concrete_type
|
||||
operator*(std::convertible_to<typename R::value_type> auto s, map<R,O,S> const& rhs)
|
||||
typename map<R, O, S>::concrete_type operator*(
|
||||
std::convertible_to<typename R::value_type> auto s, map<R, O, S> const& rhs)
|
||||
{
|
||||
using concrete_type = typename map<R,O,S>::concrete_type;
|
||||
using concrete_type = typename map<R, O, S>::concrete_type;
|
||||
return concrete_type(rhs.base().mul(s));
|
||||
}
|
||||
|
||||
template<typename R, int O, typename S>
|
||||
typename map<R,O,S>::concrete_type
|
||||
operator/(map<R,O,S> const& lhs, std::convertible_to<typename R::value_type> auto s)
|
||||
typename map<R, O, S>::concrete_type operator/(
|
||||
map<R, O, S> const& lhs, std::convertible_to<typename R::value_type> auto s)
|
||||
{
|
||||
using concrete_type = typename map<R,O,S>::concrete_type;
|
||||
using concrete_type = typename map<R, O, S>::concrete_type;
|
||||
return concrete_type(lhs.base().div(s));
|
||||
}
|
||||
|
||||
template<typename R1, int O1, typename S1, typename R2, int O2, typename S2>
|
||||
bool operator==(map<R1,O1,S1> const& lhs, map<R2,O2,S2> const& rhs)
|
||||
bool operator==(map<R1, O1, S1> const& lhs, map<R2, O2, S2> const& rhs)
|
||||
{
|
||||
return lhs.base() == rhs.base();
|
||||
}
|
||||
|
||||
template<typename R1, int O1, typename S1, typename R2, int O2, typename S2>
|
||||
bool operator!=(map<R1,O1,S1> const& lhs, map<R2,O2,S2> const& rhs)
|
||||
bool operator!=(map<R1, O1, S1> const& lhs, map<R2, O2, S2> const& rhs)
|
||||
{
|
||||
return lhs.base() != rhs.base();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,36 +25,67 @@ namespace rotgen
|
|||
class map_impl32_col;
|
||||
class map_const_impl32_col;
|
||||
|
||||
#define USE_CONST
|
||||
#define CONST const
|
||||
#define BASENAME map_const_impl
|
||||
#include <rotgen/container/map/dynamic/indirect.hpp>
|
||||
#undef BASENAME
|
||||
#undef CONST
|
||||
#undef USE_CONST
|
||||
#define USE_CONST
|
||||
#define CONST const
|
||||
#define BASENAME map_const_impl
|
||||
#include <rotgen/container/map/dynamic/indirect.hpp>
|
||||
#undef BASENAME
|
||||
#undef CONST
|
||||
#undef USE_CONST
|
||||
|
||||
#define CONST
|
||||
#define BASENAME map_impl
|
||||
#include <rotgen/container/map/dynamic/indirect.hpp>
|
||||
#undef BASENAME
|
||||
#undef CONST
|
||||
#define CONST
|
||||
#define BASENAME map_impl
|
||||
#include <rotgen/container/map/dynamic/indirect.hpp>
|
||||
#undef BASENAME
|
||||
#undef CONST
|
||||
|
||||
template<typename Scalar,int Options, bool isConst> struct find_map_impl;
|
||||
template<typename Scalar, int Options, bool isConst> struct find_map_impl;
|
||||
|
||||
template<> struct find_map_impl<float , ColMajor, true> { using type = map_const_impl32_col; };
|
||||
template<> struct find_map_impl<float , RowMajor, true> { using type = map_const_impl32_row; };
|
||||
template<> struct find_map_impl<double, ColMajor, true> { using type = map_const_impl64_col; };
|
||||
template<> struct find_map_impl<double, RowMajor, true> { using type = map_const_impl64_row; };
|
||||
template<> struct find_map_impl<float , ColMajor, false> { using type = map_impl32_col; };
|
||||
template<> struct find_map_impl<float , RowMajor, false> { using type = map_impl32_row; };
|
||||
template<> struct find_map_impl<double, ColMajor, false> { using type = map_impl64_col; };
|
||||
template<> struct find_map_impl<double, RowMajor, false> { using type = map_impl64_row; };
|
||||
template<> struct find_map_impl<float, ColMajor, true>
|
||||
{
|
||||
using type = map_const_impl32_col;
|
||||
};
|
||||
|
||||
template<> struct find_map_impl<float, RowMajor, true>
|
||||
{
|
||||
using type = map_const_impl32_row;
|
||||
};
|
||||
|
||||
template<> struct find_map_impl<double, ColMajor, true>
|
||||
{
|
||||
using type = map_const_impl64_col;
|
||||
};
|
||||
|
||||
template<> struct find_map_impl<double, RowMajor, true>
|
||||
{
|
||||
using type = map_const_impl64_row;
|
||||
};
|
||||
|
||||
template<> struct find_map_impl<float, ColMajor, false>
|
||||
{
|
||||
using type = map_impl32_col;
|
||||
};
|
||||
|
||||
template<> struct find_map_impl<float, RowMajor, false>
|
||||
{
|
||||
using type = map_impl32_row;
|
||||
};
|
||||
|
||||
template<> struct find_map_impl<double, ColMajor, false>
|
||||
{
|
||||
using type = map_impl64_col;
|
||||
};
|
||||
|
||||
template<> struct find_map_impl<double, RowMajor, false>
|
||||
{
|
||||
using type = map_impl64_row;
|
||||
};
|
||||
|
||||
template<typename Ref>
|
||||
using find_map = typename find_map_impl < typename std::remove_const_t<Ref>::value_type
|
||||
, Ref::storage_order
|
||||
, std::is_const_v<Ref>
|
||||
>::type;
|
||||
using find_map =
|
||||
typename find_map_impl<typename std::remove_const_t<Ref>::value_type,
|
||||
Ref::storage_order,
|
||||
std::is_const_v<Ref>>::type;
|
||||
}
|
||||
|
||||
#include <rotgen/container/map/dynamic/operators.hpp>
|
||||
|
|
|
|||
|
|
@ -1,59 +1,59 @@
|
|||
#define SIZE 64
|
||||
#define TYPE double
|
||||
#define SIZE 64
|
||||
#define TYPE double
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_col)
|
||||
#define TRANSCLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_row)
|
||||
#define CLASSCONSTNAME ROTGEN_MATRIX_NAME(map_const_impl,SIZE,_col)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#include <rotgen/container/map/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSCLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
#undef SOURCENAME
|
||||
#undef CLASSCONSTNAME
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME, SIZE, _col)
|
||||
#define TRANSCLASSNAME ROTGEN_MATRIX_NAME(BASENAME, SIZE, _row)
|
||||
#define CLASSCONSTNAME ROTGEN_MATRIX_NAME(map_const_impl, SIZE, _col)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _col)
|
||||
#include <rotgen/container/map/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSCLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
#undef SOURCENAME
|
||||
#undef CLASSCONSTNAME
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_row)
|
||||
#define TRANSCLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_col)
|
||||
#define CLASSCONSTNAME ROTGEN_MATRIX_NAME(map_const_impl,SIZE,_row)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#include <rotgen/container/map/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSCLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
#undef SOURCENAME
|
||||
#undef CLASSCONSTNAME
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME, SIZE, _row)
|
||||
#define TRANSCLASSNAME ROTGEN_MATRIX_NAME(BASENAME, SIZE, _col)
|
||||
#define CLASSCONSTNAME ROTGEN_MATRIX_NAME(map_const_impl, SIZE, _row)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _row)
|
||||
#include <rotgen/container/map/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSCLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
#undef SOURCENAME
|
||||
#undef CLASSCONSTNAME
|
||||
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
|
||||
#define SIZE 32
|
||||
#define TYPE float
|
||||
#define SIZE 32
|
||||
#define TYPE float
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_col)
|
||||
#define TRANSCLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_row)
|
||||
#define CLASSCONSTNAME ROTGEN_MATRIX_NAME(map_const_impl,SIZE,_col)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#include <rotgen/container/map/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSCLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
#undef SOURCENAME
|
||||
#undef CLASSCONSTNAME
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME, SIZE, _col)
|
||||
#define TRANSCLASSNAME ROTGEN_MATRIX_NAME(BASENAME, SIZE, _row)
|
||||
#define CLASSCONSTNAME ROTGEN_MATRIX_NAME(map_const_impl, SIZE, _col)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _row)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _col)
|
||||
#include <rotgen/container/map/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSCLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
#undef SOURCENAME
|
||||
#undef CLASSCONSTNAME
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_row)
|
||||
#define TRANSCLASSNAME ROTGEN_MATRIX_NAME(BASENAME,SIZE,_col)
|
||||
#define CLASSCONSTNAME ROTGEN_MATRIX_NAME(map_const_impl,SIZE,_row)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#include <rotgen/container/map/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSCLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
#undef SOURCENAME
|
||||
#undef CLASSCONSTNAME
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(BASENAME, SIZE, _row)
|
||||
#define TRANSCLASSNAME ROTGEN_MATRIX_NAME(BASENAME, SIZE, _col)
|
||||
#define CLASSCONSTNAME ROTGEN_MATRIX_NAME(map_const_impl, SIZE, _row)
|
||||
#define TRANSSOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _col)
|
||||
#define SOURCENAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _row)
|
||||
#include <rotgen/container/map/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSCLASSNAME
|
||||
#undef TRANSSOURCENAME
|
||||
#undef SOURCENAME
|
||||
#undef CLASSCONSTNAME
|
||||
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
|
|
|
|||
|
|
@ -13,17 +13,17 @@
|
|||
//==================================================================================================
|
||||
class ROTGEN_EXPORT CLASSNAME
|
||||
{
|
||||
public:
|
||||
public:
|
||||
CLASSNAME(TYPE CONST* ptr, Index r, Index c);
|
||||
CLASSNAME(TYPE CONST* ptr, Index r, Index c, stride s);
|
||||
|
||||
CLASSNAME(CLASSNAME const& other);
|
||||
CLASSNAME(CLASSNAME&&) noexcept;
|
||||
|
||||
#if !defined(USE_CONST)
|
||||
#if !defined(USE_CONST)
|
||||
CLASSNAME& operator=(CLASSNAME const& other);
|
||||
CLASSNAME& operator=(CLASSNAME&& other);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
~CLASSNAME();
|
||||
|
||||
|
|
@ -34,65 +34,64 @@ class ROTGEN_EXPORT CLASSNAME
|
|||
Index innerStride() const;
|
||||
Index outerStride() const;
|
||||
|
||||
SOURCENAME normalized() const;
|
||||
SOURCENAME transpose() const;
|
||||
SOURCENAME conjugate() const;
|
||||
SOURCENAME adjoint() const;
|
||||
SOURCENAME normalized() const;
|
||||
SOURCENAME transpose() const;
|
||||
SOURCENAME conjugate() const;
|
||||
SOURCENAME adjoint() const;
|
||||
|
||||
SOURCENAME cwiseAbs() const;
|
||||
SOURCENAME cwiseAbs2() const;
|
||||
SOURCENAME cwiseAbs() const;
|
||||
SOURCENAME cwiseAbs2() const;
|
||||
SOURCENAME cwiseInverse() const;
|
||||
SOURCENAME cwiseSqrt() const;
|
||||
SOURCENAME cwiseSqrt() const;
|
||||
|
||||
SOURCENAME cwiseMax (CLASSNAME const&) const;
|
||||
SOURCENAME cwiseMin (CLASSNAME const&) const;
|
||||
SOURCENAME cwiseProduct (CLASSNAME const&) const;
|
||||
SOURCENAME cwiseQuotient (CLASSNAME const&) const;
|
||||
SOURCENAME cwiseMax(TYPE) const;
|
||||
SOURCENAME cwiseMin(TYPE) const;
|
||||
SOURCENAME cwiseMax(CLASSNAME const&) const;
|
||||
SOURCENAME cwiseMin(CLASSNAME const&) const;
|
||||
SOURCENAME cwiseProduct(CLASSNAME const&) const;
|
||||
SOURCENAME cwiseQuotient(CLASSNAME const&) const;
|
||||
SOURCENAME cwiseMax(TYPE) const;
|
||||
SOURCENAME cwiseMin(TYPE) const;
|
||||
|
||||
#if !defined(USE_CONST)
|
||||
#if !defined(USE_CONST)
|
||||
void normalize();
|
||||
void transposeInPlace();
|
||||
void adjointInPlace();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
TYPE sum() const;
|
||||
TYPE prod() const;
|
||||
TYPE mean() const;
|
||||
TYPE trace() const;
|
||||
TYPE sum() const;
|
||||
TYPE prod() const;
|
||||
TYPE mean() const;
|
||||
TYPE trace() const;
|
||||
TYPE maxCoeff() const;
|
||||
TYPE minCoeff() const;
|
||||
TYPE maxCoeff(Index*, Index*) const;
|
||||
TYPE minCoeff(Index*, Index*) const;
|
||||
TYPE dot(CLASSNAME const&) const;
|
||||
TYPE maxCoeff(Index*, Index*) const;
|
||||
TYPE minCoeff(Index*, Index*) const;
|
||||
TYPE dot(CLASSNAME const&) const;
|
||||
TYPE dot(TRANSCLASSNAME const&) const;
|
||||
|
||||
TYPE squaredNorm() const;
|
||||
TYPE norm() const;
|
||||
TYPE lpNorm(int p) const;
|
||||
TYPE squaredNorm() const;
|
||||
TYPE norm() const;
|
||||
TYPE lpNorm(int p) const;
|
||||
|
||||
SOURCENAME qr_solve(CLASSNAME const& rhs) const;
|
||||
SOURCENAME qr_solve(CLASSNAME const& rhs) const;
|
||||
|
||||
#if !defined(USE_CONST)
|
||||
TYPE& operator()(Index i, Index j);
|
||||
TYPE& operator()(Index i);
|
||||
#endif
|
||||
#if !defined(USE_CONST)
|
||||
TYPE& operator()(Index i, Index j);
|
||||
TYPE& operator()(Index i);
|
||||
#endif
|
||||
|
||||
TYPE operator()(Index i, Index j) const;
|
||||
TYPE operator()(Index i) const;
|
||||
|
||||
|
||||
#if !defined(USE_CONST)
|
||||
#if !defined(USE_CONST)
|
||||
CLASSNAME& operator+=(CLASSNAME const& rhs);
|
||||
CLASSNAME& operator+=(CLASSCONSTNAME const& rhs);
|
||||
CLASSNAME& operator-=(CLASSNAME const& rhs);
|
||||
CLASSNAME& operator-=(CLASSCONSTNAME const& rhs);
|
||||
CLASSNAME& operator*=(CLASSNAME const& rhs);
|
||||
CLASSNAME& operator*=(CLASSCONSTNAME const& rhs);
|
||||
CLASSNAME& operator*=(TYPE d);
|
||||
CLASSNAME& operator/=(TYPE d);
|
||||
#endif
|
||||
CLASSNAME& operator*=(TYPE d);
|
||||
CLASSNAME& operator/=(TYPE d);
|
||||
#endif
|
||||
|
||||
SOURCENAME operator-() const;
|
||||
SOURCENAME add(CLASSNAME const& rhs) const;
|
||||
|
|
@ -106,27 +105,32 @@ class ROTGEN_EXPORT CLASSNAME
|
|||
|
||||
SOURCENAME inverse() const;
|
||||
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&, CLASSNAME const&);
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&, format<CLASSNAME> const&);
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&,
|
||||
CLASSNAME const&);
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&,
|
||||
format<CLASSNAME> const&);
|
||||
const TYPE* data() const;
|
||||
|
||||
#if !defined(USE_CONST)
|
||||
#if !defined(USE_CONST)
|
||||
TYPE* data();
|
||||
void setZero();
|
||||
void setOnes();
|
||||
void setRandom();
|
||||
void setIdentity();
|
||||
void setConstant(TYPE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
friend ROTGEN_EXPORT bool operator==(CLASSNAME const& lhs, CLASSNAME const& rhs);
|
||||
friend ROTGEN_EXPORT bool operator!=(CLASSNAME const& lhs, CLASSNAME const& rhs);
|
||||
friend ROTGEN_EXPORT bool operator==(CLASSNAME const& lhs,
|
||||
CLASSNAME const& rhs);
|
||||
friend ROTGEN_EXPORT bool operator!=(CLASSNAME const& lhs,
|
||||
CLASSNAME const& rhs);
|
||||
|
||||
private:
|
||||
private:
|
||||
struct payload;
|
||||
std::unique_ptr<payload> storage_;
|
||||
|
||||
public:
|
||||
std::unique_ptr<payload>& storage() { return storage_; }
|
||||
public:
|
||||
std::unique_ptr<payload>& storage() { return storage_; }
|
||||
|
||||
std::unique_ptr<payload> const& storage() const { return storage_; }
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,24 +7,28 @@
|
|||
//==================================================================================================
|
||||
#pragma once
|
||||
|
||||
#define ROTGEN_DEF_RELOP_PAIR(OP, T1, T2) \
|
||||
ROTGEN_EXPORT bool operator OP (T1 const&, T2 const&); \
|
||||
inline bool operator OP (T2 const& a, T1 const& b) { return b OP a; } \
|
||||
/**/
|
||||
#define ROTGEN_DEF_RELOP_PAIR(OP, T1, T2) \
|
||||
ROTGEN_EXPORT bool operator OP(T1 const&, T2 const&); \
|
||||
inline bool operator OP(T2 const& a, T1 const& b) \
|
||||
{ \
|
||||
return b OP a; \
|
||||
} \
|
||||
/**/
|
||||
|
||||
#define ROTGEN_DEF_RELOP(OP) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl32_col, map_impl32_col) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl32_col, map_impl32_row) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl32_col, map_const_impl32_row) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl32_row, map_impl32_row) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl32_row, map_impl32_col) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_impl32_col, map_impl32_row) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl64_col, map_impl64_col) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl64_col, map_impl64_row) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl64_col, map_const_impl64_row) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl64_row, map_impl64_row) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl64_row, map_impl64_col) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_impl64_col, map_impl64_row)
|
||||
|
||||
#define ROTGEN_DEF_RELOP(OP) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl32_col, map_impl32_col) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl32_col, map_impl32_row) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl32_col, map_const_impl32_row) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl32_row, map_impl32_row) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl32_row, map_impl32_col) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_impl32_col, map_impl32_row) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl64_col, map_impl64_col) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl64_col, map_impl64_row) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl64_col, map_const_impl64_row) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl64_row, map_impl64_row) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_const_impl64_row, map_impl64_col) \
|
||||
ROTGEN_DEF_RELOP_PAIR(OP, map_impl64_col, map_impl64_row) \
|
||||
/**/
|
||||
|
||||
namespace rotgen
|
||||
|
|
@ -34,4 +38,4 @@ namespace rotgen
|
|||
}
|
||||
|
||||
#undef ROTGEN_DEF_RELOP_PAIR
|
||||
#undef ROTGEN_DEF_RELOP
|
||||
#undef ROTGEN_DEF_RELOP
|
||||
|
|
|
|||
|
|
@ -14,77 +14,90 @@ namespace rotgen
|
|||
{
|
||||
namespace detail
|
||||
{
|
||||
template<typename Ref, int Options, bool isConst>
|
||||
struct compute_map_type
|
||||
template<typename Ref, int Options, bool isConst> struct compute_map_type
|
||||
{
|
||||
using base = Eigen::Matrix< typename Ref::value_type
|
||||
, Ref::RowsAtCompileTime, Ref::ColsAtCompileTime
|
||||
, Ref::storage_order
|
||||
>;
|
||||
using base = Eigen::Matrix<typename Ref::value_type,
|
||||
Ref::RowsAtCompileTime,
|
||||
Ref::ColsAtCompileTime,
|
||||
Ref::storage_order>;
|
||||
|
||||
using ref_t = std::conditional_t<isConst, base const, base>;
|
||||
using type = Eigen::Map<ref_t, Options, Eigen::Stride<-1,-1>>;
|
||||
using type = Eigen::Map<ref_t, Options, Eigen::Stride<-1, -1>>;
|
||||
};
|
||||
|
||||
template<typename Ref, int Options, bool isConst>
|
||||
using map_type = typename compute_map_type<Ref,Options,isConst>::type;
|
||||
using map_type = typename compute_map_type<Ref, Options, isConst>::type;
|
||||
}
|
||||
|
||||
template<typename Ref, int Options = Unaligned, typename Stride = stride>
|
||||
class map : private detail::map_type<std::remove_const_t<Ref>, Options, std::is_const_v<Ref>>
|
||||
class map : private detail::map_type<std::remove_const_t<Ref>,
|
||||
Options,
|
||||
std::is_const_v<Ref>>
|
||||
{
|
||||
public:
|
||||
using rotgen_tag = void;
|
||||
using parent = detail::map_type<std::remove_const_t<Ref>, Options, std::is_const_v<Ref>>;
|
||||
using value_type = typename std::remove_const_t<Ref>::value_type;
|
||||
public:
|
||||
using rotgen_tag = void;
|
||||
using parent =
|
||||
detail::map_type<std::remove_const_t<Ref>, Options, std::is_const_v<Ref>>;
|
||||
using value_type = typename std::remove_const_t<Ref>::value_type;
|
||||
using concrete_type = typename std::remove_const_t<Ref>::concrete_type;
|
||||
|
||||
static constexpr int RowsAtCompileTime = Ref::RowsAtCompileTime;
|
||||
static constexpr int ColsAtCompileTime = Ref::ColsAtCompileTime;
|
||||
static constexpr int MaxRowsAtCompileTime = Ref::MaxRowsAtCompileTime;
|
||||
static constexpr int MaxColsAtCompileTime = Ref::MaxColsAtCompileTime;
|
||||
static constexpr int RowsAtCompileTime = Ref::RowsAtCompileTime;
|
||||
static constexpr int ColsAtCompileTime = Ref::ColsAtCompileTime;
|
||||
static constexpr int MaxRowsAtCompileTime = Ref::MaxRowsAtCompileTime;
|
||||
static constexpr int MaxColsAtCompileTime = Ref::MaxColsAtCompileTime;
|
||||
static constexpr bool IsVectorAtCompileTime = Ref::IsVectorAtCompileTime;
|
||||
static constexpr bool has_static_storage = Ref::has_static_storage;
|
||||
static constexpr int storage_order = Ref::storage_order;
|
||||
static constexpr bool is_immutable = std::is_const_v<Ref>;
|
||||
static constexpr bool is_defined_static = Ref::is_defined_static;
|
||||
static constexpr bool has_static_storage = Ref::has_static_storage;
|
||||
static constexpr int storage_order = Ref::storage_order;
|
||||
static constexpr bool is_immutable = std::is_const_v<Ref>;
|
||||
static constexpr bool is_defined_static = Ref::is_defined_static;
|
||||
|
||||
template<typename ET>
|
||||
using as_concrete_type = detail::as_concrete_t<ET, matrix>;
|
||||
|
||||
using ptr_type = std::conditional_t<is_immutable, value_type const*, value_type*>;
|
||||
using ptr_type =
|
||||
std::conditional_t<is_immutable, value_type const*, value_type*>;
|
||||
using stride_type = Stride;
|
||||
|
||||
map(const map&) = default;
|
||||
map(map&&) = default;
|
||||
map& operator=(const map&) = default;
|
||||
map& operator=(map&&) = default;
|
||||
map(map const&) = default;
|
||||
map(map&&) = default;
|
||||
map& operator=(map const&) = default;
|
||||
map& operator=(map&&) = default;
|
||||
|
||||
map(ptr_type ptr, Index r, Index c, stride_type s)
|
||||
: parent(ptr, r, c, strides<storage_order>(s, r, c))
|
||||
{
|
||||
}
|
||||
|
||||
map(ptr_type ptr, Index r, Index c, stride_type s) : parent(ptr, r, c, strides<storage_order>(s,r,c)) {}
|
||||
map(ptr_type ptr, Index r, Index c)
|
||||
: parent( ptr, r, c
|
||||
, [&]()
|
||||
{
|
||||
if constexpr(!std::same_as<Stride,stride>) return strides<storage_order>(Stride{},r,c);
|
||||
else return strides<storage_order>(r,c);
|
||||
}()
|
||||
)
|
||||
{}
|
||||
: parent(ptr, r, c, [&]() {
|
||||
if constexpr (!std::same_as<Stride, stride>)
|
||||
return strides<storage_order>(Stride{}, r, c);
|
||||
else return strides<storage_order>(r, c);
|
||||
}())
|
||||
{
|
||||
}
|
||||
|
||||
map(ptr_type ptr, stride_type s) requires(RowsAtCompileTime!=-1 && ColsAtCompileTime!=-1)
|
||||
: parent(ptr, strides<storage_order>(s,RowsAtCompileTime,ColsAtCompileTime))
|
||||
{}
|
||||
map(ptr_type ptr, stride_type s)
|
||||
requires(RowsAtCompileTime != -1 && ColsAtCompileTime != -1)
|
||||
: parent(ptr,
|
||||
strides<storage_order>(s, RowsAtCompileTime, ColsAtCompileTime))
|
||||
{
|
||||
}
|
||||
|
||||
map(ptr_type ptr, Index sz) requires(RowsAtCompileTime==1 || ColsAtCompileTime==1)
|
||||
: map(ptr, RowsAtCompileTime==1?1:sz, ColsAtCompileTime==1?1:sz)
|
||||
{}
|
||||
map(ptr_type ptr, Index sz)
|
||||
requires(RowsAtCompileTime == 1 || ColsAtCompileTime == 1)
|
||||
: map(
|
||||
ptr, RowsAtCompileTime == 1 ? 1 : sz, ColsAtCompileTime == 1 ? 1 : sz)
|
||||
{
|
||||
}
|
||||
|
||||
map(ptr_type ptr) requires(RowsAtCompileTime!=-1 && ColsAtCompileTime!=-1)
|
||||
: map( ptr, RowsAtCompileTime, ColsAtCompileTime )
|
||||
{}
|
||||
map(ptr_type ptr)
|
||||
requires(RowsAtCompileTime != -1 && ColsAtCompileTime != -1)
|
||||
: map(ptr, RowsAtCompileTime, ColsAtCompileTime)
|
||||
{
|
||||
}
|
||||
|
||||
map(concepts::entity auto const& other) : parent(other.base())
|
||||
{}
|
||||
map(concepts::entity auto const& other) : parent(other.base()) {}
|
||||
|
||||
map& operator=(concepts::entity auto const& other)
|
||||
{
|
||||
|
|
@ -92,62 +105,79 @@ namespace rotgen
|
|||
return *this;
|
||||
}
|
||||
|
||||
parent& base() { return static_cast<parent&>(*this); }
|
||||
parent const& base() const { return static_cast<const parent&>(*this); }
|
||||
parent& base() { return static_cast<parent&>(*this); }
|
||||
|
||||
parent const& base() const { return static_cast<parent const&>(*this); }
|
||||
|
||||
auto evaluate() const
|
||||
{
|
||||
auto res = static_cast<parent const &>(*this).eval();
|
||||
auto res = static_cast<parent const&>(*this).eval();
|
||||
return as_concrete_type<decltype(res)>(res);
|
||||
}
|
||||
|
||||
decltype(auto) noalias() const
|
||||
{
|
||||
if constexpr(use_expression_templates) return base().noalias();
|
||||
else return *this;
|
||||
if constexpr (use_expression_templates) return base().noalias();
|
||||
else return *this;
|
||||
}
|
||||
|
||||
decltype(auto) noalias()
|
||||
{
|
||||
if constexpr(use_expression_templates) return base().noalias();
|
||||
else return *this;
|
||||
if constexpr (use_expression_templates) return base().noalias();
|
||||
else return *this;
|
||||
}
|
||||
|
||||
value_type& operator()(Index i, Index j) requires(!is_immutable)
|
||||
value_type& operator()(Index i, Index j)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
return base()(i,j);
|
||||
return base()(i, j);
|
||||
}
|
||||
|
||||
value_type& operator()(Index i) requires(!is_immutable && IsVectorAtCompileTime)
|
||||
value_type& operator()(Index i)
|
||||
requires(!is_immutable && IsVectorAtCompileTime)
|
||||
{
|
||||
return base().data()[i];
|
||||
}
|
||||
|
||||
value_type& operator[](Index i) requires(!is_immutable && IsVectorAtCompileTime)
|
||||
value_type& operator[](Index i)
|
||||
requires(!is_immutable && IsVectorAtCompileTime)
|
||||
{
|
||||
return (*this)(i);
|
||||
}
|
||||
|
||||
value_type operator()(Index i, Index j) const { return base()(i,j); }
|
||||
value_type operator()(Index i) const requires(IsVectorAtCompileTime) { return base().data()[i]; }
|
||||
value_type operator[](Index i) const requires(IsVectorAtCompileTime) { return (*this)(i); }
|
||||
value_type operator()(Index i, Index j) const { return base()(i, j); }
|
||||
|
||||
value_type operator()(Index i) const
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
return base().data()[i];
|
||||
}
|
||||
|
||||
value_type operator[](Index i) const
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
return (*this)(i);
|
||||
}
|
||||
|
||||
template<typename R2, int O2, typename S2>
|
||||
map& operator+=(map<R2,O2,S2> const& rhs) requires(!is_immutable)
|
||||
map& operator+=(map<R2, O2, S2> const& rhs)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
base() += rhs.base();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename R2, int O2, typename S2>
|
||||
map& operator-=(map<R2,O2,S2> const& rhs) requires(!is_immutable)
|
||||
map& operator-=(map<R2, O2, S2> const& rhs)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
base() -= rhs.base();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename R2, int O2, typename S2>
|
||||
map& operator*=(map<R2,O2,S2> const& rhs) requires(!is_immutable)
|
||||
map& operator*=(map<R2, O2, S2> const& rhs)
|
||||
requires(!is_immutable)
|
||||
{
|
||||
base() *= rhs.base();
|
||||
return *this;
|
||||
|
|
@ -167,129 +197,180 @@ namespace rotgen
|
|||
|
||||
auto cwiseMin(map const& rhs) const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return concrete_type{parent::cwiseMin(rhs.base())};
|
||||
else return base().cwiseMin(rhs.base());
|
||||
if constexpr (!use_expression_templates)
|
||||
return concrete_type{parent::cwiseMin(rhs.base())};
|
||||
else return base().cwiseMin(rhs.base());
|
||||
}
|
||||
|
||||
auto cwiseMin(value_type rhs) const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return concrete_type{parent::cwiseMin(rhs)};
|
||||
else return base().cwiseMin(rhs);
|
||||
if constexpr (!use_expression_templates)
|
||||
return concrete_type{parent::cwiseMin(rhs)};
|
||||
else return base().cwiseMin(rhs);
|
||||
}
|
||||
|
||||
auto cwiseMax(map const& rhs) const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return concrete_type{parent::cwiseMax(rhs.base())};
|
||||
else return base().cwiseMax(rhs.base());
|
||||
if constexpr (!use_expression_templates)
|
||||
return concrete_type{parent::cwiseMax(rhs.base())};
|
||||
else return base().cwiseMax(rhs.base());
|
||||
}
|
||||
|
||||
auto cwiseMax(value_type rhs) const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return concrete_type{parent::cwiseMax(rhs)};
|
||||
else return base().cwiseMax(rhs);
|
||||
if constexpr (!use_expression_templates)
|
||||
return concrete_type{parent::cwiseMax(rhs)};
|
||||
else return base().cwiseMax(rhs);
|
||||
}
|
||||
|
||||
auto cwiseProduct(map const& rhs) const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return concrete_type{parent::cwiseProduct(rhs.base())};
|
||||
else return base().cwiseProduct(rhs.base());
|
||||
if constexpr (!use_expression_templates)
|
||||
return concrete_type{parent::cwiseProduct(rhs.base())};
|
||||
else return base().cwiseProduct(rhs.base());
|
||||
}
|
||||
|
||||
auto cwiseQuotient(map const& rhs) const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return concrete_type{parent::cwiseQuotient(rhs.base())};
|
||||
else return base().cwiseQuotient(rhs.base());
|
||||
if constexpr (!use_expression_templates)
|
||||
return concrete_type{parent::cwiseQuotient(rhs.base())};
|
||||
else return base().cwiseQuotient(rhs.base());
|
||||
}
|
||||
|
||||
auto cwiseAbs() const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return concrete_type{parent::cwiseAbs()};
|
||||
else return base().cwiseAbs();
|
||||
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();
|
||||
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();
|
||||
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();
|
||||
if constexpr (!use_expression_templates)
|
||||
return concrete_type{parent::cwiseSqrt()};
|
||||
else return base().cwiseSqrt();
|
||||
}
|
||||
|
||||
auto cross(map const& rhs) const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return concrete_type{parent::cross(rhs.base())};
|
||||
else return base().cross(rhs.base());
|
||||
if constexpr (!use_expression_templates)
|
||||
return concrete_type{parent::cross(rhs.base())};
|
||||
else return base().cross(rhs.base());
|
||||
}
|
||||
|
||||
auto inverse() const
|
||||
{
|
||||
if constexpr(use_expression_templates) return base().inverse();
|
||||
else return as_concrete_type<decltype(base().inverse())>(base().inverse());
|
||||
if constexpr (use_expression_templates) return base().inverse();
|
||||
else
|
||||
return as_concrete_type<decltype(base().inverse())>(base().inverse());
|
||||
}
|
||||
|
||||
auto normalized() const requires(IsVectorAtCompileTime)
|
||||
auto normalized() const
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
if constexpr(use_expression_templates) return base().normalized();
|
||||
else return as_concrete_type<decltype(base().normalized())>(base().normalized());
|
||||
if constexpr (use_expression_templates) return base().normalized();
|
||||
else
|
||||
return as_concrete_type<decltype(base().normalized())>(
|
||||
base().normalized());
|
||||
}
|
||||
|
||||
auto transpose() const
|
||||
{
|
||||
if constexpr(use_expression_templates) return base().transpose();
|
||||
else return as_concrete_type<decltype(base().transpose())>(base().transpose());
|
||||
if constexpr (use_expression_templates) return base().transpose();
|
||||
else
|
||||
return as_concrete_type<decltype(base().transpose())>(
|
||||
base().transpose());
|
||||
}
|
||||
|
||||
auto adjoint() const
|
||||
{
|
||||
if constexpr(use_expression_templates) return base().adjoint();
|
||||
else return as_concrete_type<decltype(base().adjoint())>(base().adjoint());
|
||||
if constexpr (use_expression_templates) return base().adjoint();
|
||||
else
|
||||
return as_concrete_type<decltype(base().adjoint())>(base().adjoint());
|
||||
}
|
||||
|
||||
auto conjugate() const
|
||||
{
|
||||
if constexpr(use_expression_templates) return base().conjugate();
|
||||
else return as_concrete_type<decltype(base().conjugate())>(base().conjugate());
|
||||
if constexpr (use_expression_templates) return base().conjugate();
|
||||
else
|
||||
return as_concrete_type<decltype(base().conjugate())>(
|
||||
base().conjugate());
|
||||
}
|
||||
|
||||
void normalize() requires(IsVectorAtCompileTime)
|
||||
void normalize()
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
base().normalize();
|
||||
}
|
||||
|
||||
void transposeInPlace() { base().transposeInPlace(); }
|
||||
void adjointInPlace() { base().adjointInPlace(); }
|
||||
void transposeInPlace() { base().transposeInPlace(); }
|
||||
|
||||
void adjointInPlace() { base().adjointInPlace(); }
|
||||
|
||||
auto qr_solve(auto const& rhs) const
|
||||
{
|
||||
return concrete_type(base().colPivHouseholderQr().solve(rhs.base()));
|
||||
};
|
||||
|
||||
static auto Zero() requires( requires {Ref::Zero();} ) { return Ref::Zero(); }
|
||||
static auto Zero(int rows, int cols) { return Ref::Zero(rows,cols); }
|
||||
static auto Zero()
|
||||
requires(requires { Ref::Zero(); })
|
||||
{
|
||||
return Ref::Zero();
|
||||
}
|
||||
|
||||
static auto Ones() requires( requires {Ref::Ones();} ) { return Ref::Ones(); }
|
||||
static auto Ones(int rows, int cols) { return Ref::Ones(rows,cols); }
|
||||
static auto Zero(int rows, int cols) { return Ref::Zero(rows, cols); }
|
||||
|
||||
static auto Constant(value_type value) requires( requires {Ref::Constant(value);} )
|
||||
{ return Ref::Constant(value); }
|
||||
static auto Ones()
|
||||
requires(requires { Ref::Ones(); })
|
||||
{
|
||||
return Ref::Ones();
|
||||
}
|
||||
|
||||
static auto Constant(int rows, int cols, value_type value) { return Ref::Constant(rows, cols, value); }
|
||||
static auto Ones(int rows, int cols) { return Ref::Ones(rows, cols); }
|
||||
|
||||
static auto Random() requires( requires {Ref::Random();} ) { return Ref::Random(); }
|
||||
static auto Random(int rows, int cols) { return Ref::Random(rows, cols); }
|
||||
static auto Constant(value_type value)
|
||||
requires(requires { Ref::Constant(value); })
|
||||
{
|
||||
return Ref::Constant(value);
|
||||
}
|
||||
|
||||
static auto Identity() requires( requires {Ref::Identity();} ) { return Ref::Identity(); }
|
||||
static auto Identity(int rows, int cols) { return Ref::Identity(rows, cols); }
|
||||
static auto Constant(int rows, int cols, value_type value)
|
||||
{
|
||||
return Ref::Constant(rows, cols, value);
|
||||
}
|
||||
|
||||
static auto Random()
|
||||
requires(requires { Ref::Random(); })
|
||||
{
|
||||
return Ref::Random();
|
||||
}
|
||||
|
||||
static auto Random(int rows, int cols) { return Ref::Random(rows, cols); }
|
||||
|
||||
static auto Identity()
|
||||
requires(requires { Ref::Identity(); })
|
||||
{
|
||||
return Ref::Identity();
|
||||
}
|
||||
|
||||
static auto Identity(int rows, int cols)
|
||||
{
|
||||
return Ref::Identity(rows, cols);
|
||||
}
|
||||
|
||||
map& setOnes()
|
||||
{
|
||||
|
|
@ -321,27 +402,27 @@ namespace rotgen
|
|||
return *this;
|
||||
}
|
||||
|
||||
using parent::innerStride;
|
||||
using parent::outerStride;
|
||||
using parent::rows;
|
||||
using parent::cols;
|
||||
using parent::size;
|
||||
using parent::data;
|
||||
using parent::sum;
|
||||
using parent::innerStride;
|
||||
using parent::mean;
|
||||
using parent::prod;
|
||||
using parent::trace;
|
||||
using parent::norm;
|
||||
using parent::outerStride;
|
||||
using parent::prod;
|
||||
using parent::rows;
|
||||
using parent::size;
|
||||
using parent::squaredNorm;
|
||||
|
||||
using parent::sum;
|
||||
using parent::trace;
|
||||
|
||||
auto minCoeff() const { return parent::minCoeff(); }
|
||||
|
||||
auto maxCoeff() const { return parent::maxCoeff(); }
|
||||
|
||||
template<std::integral IndexType>
|
||||
auto minCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
Index r, c;
|
||||
auto result = parent::minCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
|
|
@ -351,7 +432,7 @@ namespace rotgen
|
|||
template<std::integral IndexType>
|
||||
auto maxCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
Index r, c;
|
||||
auto result = parent::maxCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
|
|
@ -359,7 +440,7 @@ namespace rotgen
|
|||
}
|
||||
|
||||
template<typename R2, int O2, typename S2>
|
||||
value_type dot(map<R2,O2,S2> const& rhs) const
|
||||
value_type dot(map<R2, O2, S2> const& rhs) const
|
||||
{
|
||||
return base().dot(rhs.base());
|
||||
}
|
||||
|
|
@ -372,103 +453,104 @@ namespace rotgen
|
|||
};
|
||||
|
||||
template<typename R1, typename R2, int O1, typename S1, int O2, typename S2>
|
||||
bool operator==(map<R1, O1, S1> const& lhs, map<R2,O2,S2> const& rhs)
|
||||
bool operator==(map<R1, O1, S1> const& lhs, map<R2, O2, S2> const& rhs)
|
||||
{
|
||||
return lhs.base() == rhs.base();
|
||||
}
|
||||
|
||||
template<typename R1, typename R2, int O1, typename S1, int O2, typename S2>
|
||||
bool operator!=(map<R1, O1, S1> const& lhs, map<R2,O2,S2> const& rhs)
|
||||
bool operator!=(map<R1, O1, S1> const& lhs, map<R2, O2, S2> const& rhs)
|
||||
{
|
||||
return lhs.base() != rhs.base();
|
||||
}
|
||||
|
||||
#if defined(ROTGEN_ENABLE_EXPRESSION_TEMPLATES)
|
||||
template<typename R1, typename R2, int O1, typename S1, int O2, typename S2>
|
||||
auto operator+(map<R1, O1, S1> const& lhs, map<R2,O2,S2> const& rhs)
|
||||
auto operator+(map<R1, O1, S1> const& lhs, map<R2, O2, S2> const& rhs)
|
||||
{
|
||||
return lhs.base() + rhs.base();
|
||||
}
|
||||
|
||||
template<typename R1, typename R2, int O1, typename S1, int O2, typename S2>
|
||||
auto operator-(map<R1, O1, S1> const& lhs, map<R2,O2,S2> const& rhs)
|
||||
auto operator-(map<R1, O1, S1> const& lhs, map<R2, O2, S2> const& rhs)
|
||||
{
|
||||
return lhs.base() - rhs.base();
|
||||
}
|
||||
|
||||
template<typename R1, typename R2, int O1, typename S1, int O2, typename S2>
|
||||
auto operator*(map<R1, O1, S1> const& lhs, map<R2,O2,S2> const& rhs)
|
||||
auto operator*(map<R1, O1, S1> const& lhs, map<R2, O2, S2> const& rhs)
|
||||
{
|
||||
return lhs.base() * rhs.base();
|
||||
}
|
||||
|
||||
template<typename R, int O, typename S>
|
||||
auto operator*( map<R, O, S> const& lhs, std::convertible_to<typename R::value_type> auto s)
|
||||
auto operator*(map<R, O, S> const& lhs,
|
||||
std::convertible_to<typename R::value_type> auto s)
|
||||
{
|
||||
return lhs.base() * s;
|
||||
}
|
||||
|
||||
template<typename R, int O, typename S>
|
||||
auto operator*(std::convertible_to<typename R::value_type> auto s, map<R, O, S> const& rhs)
|
||||
auto operator*(std::convertible_to<typename R::value_type> auto s,
|
||||
map<R, O, S> const& rhs)
|
||||
{
|
||||
return s * rhs.base();
|
||||
}
|
||||
|
||||
template<typename R, int O, typename S>
|
||||
auto operator/(map<R, O, S> const& lhs, std::convertible_to<typename R::value_type> auto s)
|
||||
auto operator/(map<R, O, S> const& lhs,
|
||||
std::convertible_to<typename R::value_type> auto s)
|
||||
{
|
||||
return lhs.base() / s;
|
||||
}
|
||||
#else
|
||||
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)
|
||||
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;
|
||||
using concrete_type = typename map<R1, O1, S1>::concrete_type;
|
||||
return concrete_type(lhs.base() + rhs.base());
|
||||
}
|
||||
|
||||
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)
|
||||
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;
|
||||
using concrete_type = typename map<R1, O1, S1>::concrete_type;
|
||||
return concrete_type(lhs.base() - rhs.base());
|
||||
}
|
||||
|
||||
template<typename R1, typename R2, int O1, typename S1, int O2, typename S2>
|
||||
matrix<typename R1::value_type,R1::RowsAtCompileTime,R2::ColsAtCompileTime>
|
||||
operator*(map<R1,O1,S1> const& lhs, map<R2,O2,S2> const& rhs)
|
||||
matrix<typename R1::value_type, R1::RowsAtCompileTime, R2::ColsAtCompileTime>
|
||||
operator*(map<R1, O1, S1> const& lhs, map<R2, O2, S2> const& rhs)
|
||||
{
|
||||
using concrete_type = matrix< typename R1::value_type
|
||||
, R1::RowsAtCompileTime,R2::ColsAtCompileTime
|
||||
>;
|
||||
using concrete_type = matrix<typename R1::value_type, R1::RowsAtCompileTime,
|
||||
R2::ColsAtCompileTime>;
|
||||
|
||||
return concrete_type(lhs.base() * rhs.base());
|
||||
}
|
||||
|
||||
template<typename R, int O, typename S>
|
||||
typename map<R,O,S>::concrete_type operator*( map<R, O, S> const& lhs
|
||||
, std::convertible_to<typename R::value_type> auto s
|
||||
)
|
||||
typename map<R, O, S>::concrete_type operator*(
|
||||
map<R, O, S> const& lhs, std::convertible_to<typename R::value_type> auto s)
|
||||
{
|
||||
using concrete_type = typename map<R,O,S>::concrete_type;
|
||||
using concrete_type = typename map<R, O, S>::concrete_type;
|
||||
return concrete_type(lhs.base() * s);
|
||||
}
|
||||
|
||||
template<typename R, int O, typename S>
|
||||
typename map<R,O,S>::concrete_type operator*( std::convertible_to<typename R::value_type> auto s
|
||||
, map<R, O, S> const& rhs
|
||||
)
|
||||
typename map<R, O, S>::concrete_type operator*(
|
||||
std::convertible_to<typename R::value_type> auto s, map<R, O, S> const& rhs)
|
||||
{
|
||||
using concrete_type = typename map<R,O,S>::concrete_type;
|
||||
using concrete_type = typename map<R, O, S>::concrete_type;
|
||||
return concrete_type(rhs.base() * s);
|
||||
}
|
||||
|
||||
template<typename R, int O, typename S>
|
||||
typename map<R,O,S>::concrete_type operator/( map<R, O, S> const& lhs
|
||||
, std::convertible_to<typename R::value_type> auto s
|
||||
)
|
||||
typename map<R, O, S>::concrete_type operator/(
|
||||
map<R, O, S> const& lhs, std::convertible_to<typename R::value_type> auto s)
|
||||
{
|
||||
using concrete_type = typename map<R,O,S>::concrete_type;
|
||||
using concrete_type = typename map<R, O, S>::concrete_type;
|
||||
return concrete_type(lhs.base() / s);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@
|
|||
#include <rotgen/container/matrix/dynamic.hpp>
|
||||
#else
|
||||
#include <rotgen/container/matrix/fixed.hpp>
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -14,134 +14,171 @@
|
|||
|
||||
namespace rotgen
|
||||
{
|
||||
template< typename Scalar
|
||||
, int Rows = Dynamic , int Cols = Dynamic
|
||||
, int Opts = detail::force_order<Rows,Cols>
|
||||
, int MaxRows = Rows , int MaxCols = Cols
|
||||
>
|
||||
class matrix : public find_matrix<Scalar,Opts>
|
||||
template<typename Scalar,
|
||||
int Rows = Dynamic,
|
||||
int Cols = Dynamic,
|
||||
int Opts = detail::force_order<Rows, Cols>,
|
||||
int MaxRows = Rows,
|
||||
int MaxCols = Cols>
|
||||
class matrix : public find_matrix<Scalar, Opts>
|
||||
{
|
||||
public:
|
||||
using parent = find_matrix<Scalar,Opts>;
|
||||
using rotgen_tag = void;
|
||||
using concrete_type = matrix;
|
||||
using value_type = Scalar;
|
||||
public:
|
||||
using parent = find_matrix<Scalar, Opts>;
|
||||
using rotgen_tag = void;
|
||||
using concrete_type = matrix;
|
||||
using value_type = Scalar;
|
||||
|
||||
static constexpr auto storage_order = Opts & 1;
|
||||
static constexpr int RowsAtCompileTime = Rows;
|
||||
static constexpr int ColsAtCompileTime = Cols;
|
||||
static constexpr int MaxRowsAtCompileTime = MaxRows;
|
||||
static constexpr int MaxColsAtCompileTime = MaxCols;
|
||||
static constexpr bool IsCompileTimeSized = Rows != -1 && Cols != -1;
|
||||
static constexpr bool IsVectorAtCompileTime = (RowsAtCompileTime == 1) || (ColsAtCompileTime == 1);
|
||||
static constexpr int Options = Opts;
|
||||
static constexpr bool IsRowMajor = (Opts & RowMajor) == RowMajor;
|
||||
static constexpr bool is_defined_static = false;
|
||||
static constexpr bool has_static_storage = false;
|
||||
static constexpr bool is_immutable = false;
|
||||
static constexpr auto storage_order = Opts & 1;
|
||||
static constexpr int RowsAtCompileTime = Rows;
|
||||
static constexpr int ColsAtCompileTime = Cols;
|
||||
static constexpr int MaxRowsAtCompileTime = MaxRows;
|
||||
static constexpr int MaxColsAtCompileTime = MaxCols;
|
||||
static constexpr bool IsCompileTimeSized = Rows != -1 && Cols != -1;
|
||||
static constexpr bool IsVectorAtCompileTime =
|
||||
(RowsAtCompileTime == 1) || (ColsAtCompileTime == 1);
|
||||
static constexpr int Options = Opts;
|
||||
static constexpr bool IsRowMajor = (Opts & RowMajor) == RowMajor;
|
||||
static constexpr bool is_defined_static = false;
|
||||
static constexpr bool has_static_storage = false;
|
||||
static constexpr bool is_immutable = false;
|
||||
|
||||
using transposed_type = matrix<value_type,Cols,Rows,storage_order>;
|
||||
using transposed_type = matrix<value_type, Cols, Rows, storage_order>;
|
||||
|
||||
matrix() : parent(Rows==-1?0:Rows,Cols==-1?0:Cols) {}
|
||||
matrix() : parent(Rows == -1 ? 0 : Rows, Cols == -1 ? 0 : Cols) {}
|
||||
|
||||
matrix(Index r, Index c) requires(!IsCompileTimeSized)
|
||||
: parent(r, c)
|
||||
matrix(Index r, Index c)
|
||||
requires(!IsCompileTimeSized)
|
||||
: parent(r, c)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(r == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(c == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(r == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(c == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
}
|
||||
|
||||
matrix(Index n) requires(IsVectorAtCompileTime && (Rows != 1 || Cols != 1))
|
||||
: parent(Rows != -1 ? 1 : n, Cols != -1 ? 1 : n)
|
||||
{}
|
||||
matrix(Index n)
|
||||
requires(IsVectorAtCompileTime && (Rows != 1 || Cols != 1))
|
||||
: parent(Rows != -1 ? 1 : n, Cols != -1 ? 1 : n)
|
||||
{
|
||||
}
|
||||
|
||||
matrix(Scalar v) requires(Rows == 1 && Cols == 1) : parent(1,1,{v}) {}
|
||||
matrix(Scalar v)
|
||||
requires(Rows == 1 && Cols == 1)
|
||||
: parent(1, 1, {v})
|
||||
{
|
||||
}
|
||||
|
||||
matrix(Scalar v0, Scalar v1, auto... vs)
|
||||
requires((Rows == (2+sizeof...(vs)) && Cols == 1) || (Rows == 1 && Cols == (2+sizeof...(vs))))
|
||||
: parent(Rows,Cols,{v0,v1,static_cast<Scalar>(vs)...})
|
||||
{}
|
||||
requires((Rows == (2 + sizeof...(vs)) && Cols == 1) ||
|
||||
(Rows == 1 && Cols == (2 + sizeof...(vs))))
|
||||
: parent(Rows, Cols, {v0, v1, static_cast<Scalar>(vs)...})
|
||||
{
|
||||
}
|
||||
|
||||
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(Cols != -1)
|
||||
if constexpr (Rows != -1)
|
||||
assert(init.size() == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
{
|
||||
[[maybe_unused]] std::size_t c = 0;
|
||||
if(init.size()) c = init.begin()->size();
|
||||
assert(c == Cols && "Mismatched between dynamic and static column size");
|
||||
if (init.size()) c = init.begin()->size();
|
||||
assert(c == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
}
|
||||
}
|
||||
|
||||
matrix(std::initializer_list<Scalar> init)
|
||||
requires(IsVectorAtCompileTime) : parent(Rows, Cols, init)
|
||||
{}
|
||||
|
||||
matrix(concepts::entity auto const& e) : parent(e.rows(),e.cols())
|
||||
requires(IsVectorAtCompileTime)
|
||||
: parent(Rows, Cols, init)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(e.rows() == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(e.cols() == Cols && "Mismatched between dynamic and static col size");
|
||||
}
|
||||
|
||||
matrix(concepts::entity auto const& e) : parent(e.rows(), e.cols())
|
||||
{
|
||||
if constexpr (Rows != -1)
|
||||
assert(e.rows() == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(e.cols() == Cols &&
|
||||
"Mismatched between dynamic and static col size");
|
||||
for (rotgen::Index r = 0; r < e.rows(); ++r)
|
||||
for (rotgen::Index c = 0; c < e.cols(); ++c)
|
||||
(*this)(r, c) = e(r, c);
|
||||
for (rotgen::Index c = 0; c < e.cols(); ++c) (*this)(r, c) = e(r, c);
|
||||
}
|
||||
|
||||
matrix& operator=(concepts::entity auto const& e)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(e.rows() == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(e.cols() == Cols && "Mismatched between dynamic and static col size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(e.rows() == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(e.cols() == Cols &&
|
||||
"Mismatched between dynamic and static col size");
|
||||
resize(e.rows(), e.cols());
|
||||
|
||||
for (rotgen::Index r = 0; r < e.rows(); ++r)
|
||||
for (rotgen::Index c = 0; c < e.cols(); ++c)
|
||||
(*this)(r, c) = e(r, c);
|
||||
for (rotgen::Index c = 0; c < e.cols(); ++c) (*this)(r, c) = e(r, c);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
value_type& operator[](Index i) requires(IsVectorAtCompileTime)
|
||||
value_type& operator[](Index i)
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
return (*this)(i);
|
||||
}
|
||||
|
||||
value_type operator[](Index i) const requires(IsVectorAtCompileTime)
|
||||
value_type operator[](Index i) const
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
return (*this)(i);
|
||||
}
|
||||
|
||||
auto evaluate() const { return *this; }
|
||||
decltype(auto) noalias() const { return *this; }
|
||||
decltype(auto) noalias() { return *this; }
|
||||
auto evaluate() const { return *this; }
|
||||
|
||||
decltype(auto) noalias() const { return *this; }
|
||||
|
||||
decltype(auto) noalias() { return *this; }
|
||||
|
||||
void resize(int r, int c)
|
||||
{
|
||||
if constexpr(Rows == 1) assert(c == Cols && "Mismatched between dynamic and static col size");
|
||||
if constexpr(Cols == 1) assert(r == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr (Rows == 1)
|
||||
assert(c == Cols && "Mismatched between dynamic and static col size");
|
||||
if constexpr (Cols == 1)
|
||||
assert(r == Rows && "Mismatched between dynamic and static row size");
|
||||
parent::resize(r, c);
|
||||
}
|
||||
|
||||
void resize(int s) requires(IsVectorAtCompileTime)
|
||||
void resize(int s)
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
if constexpr(Rows == 1) parent::resize(1,s);
|
||||
else parent::resize(s,1);
|
||||
if constexpr (Rows == 1) parent::resize(1, s);
|
||||
else parent::resize(s, 1);
|
||||
}
|
||||
|
||||
void conservativeResize(int r, int c)
|
||||
{
|
||||
if constexpr(Rows == 1) assert(c == Cols && "Mismatched between dynamic and static col size");
|
||||
if constexpr(Cols == 1) assert(r == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr (Rows == 1)
|
||||
assert(c == Cols && "Mismatched between dynamic and static col size");
|
||||
if constexpr (Cols == 1)
|
||||
assert(r == Rows && "Mismatched between dynamic and static row size");
|
||||
parent::conservativeResize(r, c);
|
||||
}
|
||||
|
||||
void conservativeResize(int s) requires(IsVectorAtCompileTime)
|
||||
void conservativeResize(int s)
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
if constexpr(Rows == 1) parent::conservativeResize(1,s);
|
||||
else parent::conservativeResize(s,1);
|
||||
if constexpr (Rows == 1) parent::conservativeResize(1, s);
|
||||
else parent::conservativeResize(s, 1);
|
||||
}
|
||||
|
||||
matrix normalized() const requires(IsVectorAtCompileTime)
|
||||
matrix normalized() const
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
return matrix(base().normalized());
|
||||
}
|
||||
|
|
@ -151,28 +188,30 @@ namespace rotgen
|
|||
return transposed_type(base().transpose());
|
||||
}
|
||||
|
||||
matrix conjugate() const
|
||||
{
|
||||
return matrix(base().conjugate());
|
||||
}
|
||||
matrix conjugate() const { return matrix(base().conjugate()); }
|
||||
|
||||
transposed_type adjoint() const
|
||||
{
|
||||
return transposed_type(base().adjoint());
|
||||
}
|
||||
|
||||
void normalize() requires(IsVectorAtCompileTime)
|
||||
void normalize()
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
parent::normalize();
|
||||
}
|
||||
|
||||
void transposeInPlace() { parent::transposeInPlace(); }
|
||||
void adjointInPlace() { parent::adjointInPlace(); }
|
||||
|
||||
matrix cwiseAbs() const { return matrix(base().cwiseAbs()); }
|
||||
matrix cwiseAbs2() const { return matrix(base().cwiseAbs2()); }
|
||||
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()); }
|
||||
|
||||
matrix cwiseSqrt() const { return matrix(base().cwiseSqrt()); }
|
||||
|
||||
friend bool operator==(matrix const& lhs, matrix const& rhs)
|
||||
{
|
||||
|
|
@ -191,10 +230,7 @@ namespace rotgen
|
|||
return *this;
|
||||
}
|
||||
|
||||
matrix operator-() const
|
||||
{
|
||||
return matrix(base().operator-());
|
||||
}
|
||||
matrix operator-() const { return matrix(base().operator-()); }
|
||||
|
||||
matrix& operator*=(matrix const& rhs)
|
||||
{
|
||||
|
|
@ -215,12 +251,13 @@ namespace rotgen
|
|||
}
|
||||
|
||||
auto minCoeff() const { return parent::minCoeff(); }
|
||||
|
||||
auto maxCoeff() const { return parent::maxCoeff(); }
|
||||
|
||||
template<std::integral IndexType>
|
||||
auto minCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
Index r, c;
|
||||
auto result = parent::minCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
|
|
@ -230,70 +267,95 @@ namespace rotgen
|
|||
template<std::integral IndexType>
|
||||
auto maxCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
Index r, c;
|
||||
auto result = parent::maxCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
return result;
|
||||
}
|
||||
|
||||
static matrix Ones() requires (Rows != -1 && Cols != -1)
|
||||
static matrix Ones()
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Ones(Rows, Cols);
|
||||
}
|
||||
|
||||
static matrix Ones(int rows, int cols)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Ones(rows, cols);
|
||||
}
|
||||
|
||||
static matrix Zero() requires (Rows != -1 && Cols != -1)
|
||||
static matrix Zero()
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Zero(Rows, Cols);
|
||||
}
|
||||
|
||||
static matrix Zero(int rows, int cols)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Zero(rows, cols);
|
||||
}
|
||||
|
||||
static matrix Constant(Scalar value) requires (Rows != -1 && Cols != -1)
|
||||
static matrix Constant(Scalar value)
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Constant(Rows, Cols, static_cast<Scalar>(value));
|
||||
}
|
||||
|
||||
static matrix Constant(int rows, int cols, Scalar value)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Constant(rows, cols, static_cast<Scalar>(value));
|
||||
}
|
||||
|
||||
static matrix Random() requires (Rows != -1 && Cols != -1)
|
||||
static matrix Random()
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Random(Rows, Cols);
|
||||
}
|
||||
|
||||
static matrix Random(int rows, int cols)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Random(rows, cols);
|
||||
}
|
||||
|
||||
static matrix Identity() requires (Rows != -1 && Cols != -1)
|
||||
static matrix Identity()
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Identity(Rows, Cols);
|
||||
}
|
||||
|
||||
static matrix Identity(int rows, int cols)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Identity(rows, cols);
|
||||
}
|
||||
|
||||
|
|
@ -323,7 +385,8 @@ namespace rotgen
|
|||
|
||||
matrix& setConstant(Scalar value)
|
||||
{
|
||||
*this = parent::Constant(parent::rows(), parent::cols(), static_cast<Scalar>(value));
|
||||
*this = parent::Constant(parent::rows(), parent::cols(),
|
||||
static_cast<Scalar>(value));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -357,55 +420,65 @@ namespace rotgen
|
|||
return *this;
|
||||
}
|
||||
|
||||
template<int P>
|
||||
Scalar lpNorm() const
|
||||
template<int P> Scalar lpNorm() const
|
||||
{
|
||||
static_assert(P == 1 || P == 2 || P == Infinity);
|
||||
return parent::lp_norm(P);
|
||||
}
|
||||
|
||||
parent& base() { return static_cast<parent&>(*this); }
|
||||
parent const& base() const { return static_cast<parent const&>(*this);; }
|
||||
parent& base() { return static_cast<parent&>(*this); }
|
||||
|
||||
parent const& base() const
|
||||
{
|
||||
return static_cast<parent const&>(*this);
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
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, matrix<S,R,C,O,MR,MC> const& rhs)
|
||||
matrix<S, R, C, O, MR, MC> operator+(matrix<S, R, C, O, MR, MC> const& lhs,
|
||||
matrix<S, R, C, O, MR, MC> const& rhs)
|
||||
{
|
||||
matrix<S,R,C,O,MR,MC> that(lhs);
|
||||
matrix<S, R, C, O, MR, MC> that(lhs);
|
||||
return that += rhs;
|
||||
}
|
||||
|
||||
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, matrix<S,R,C,O,MR,MC> const& rhs)
|
||||
matrix<S, R, C, O, MR, MC> operator-(matrix<S, R, C, O, MR, MC> const& lhs,
|
||||
matrix<S, R, C, O, MR, MC> const& rhs)
|
||||
{
|
||||
matrix<S,R,C,O,MR,MC> that(lhs);
|
||||
matrix<S, R, C, O, MR, MC> that(lhs);
|
||||
return that -= rhs;
|
||||
}
|
||||
|
||||
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, matrix<S,R,C,O,MR,MC> const& rhs)
|
||||
matrix<S, R, C, O, MR, MC> operator*(matrix<S, R, C, O, MR, MC> const& lhs,
|
||||
matrix<S, R, C, O, MR, MC> const& rhs)
|
||||
{
|
||||
matrix<S,R,C,O,MR,MC> that(lhs);
|
||||
matrix<S, R, C, O, MR, MC> that(lhs);
|
||||
return that *= rhs;
|
||||
}
|
||||
|
||||
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> operator*(matrix<S, R, C, O, MR, MC> const& lhs,
|
||||
double rhs)
|
||||
{
|
||||
matrix<S,R,C,O,MR,MC> that(lhs);
|
||||
matrix<S, R, C, O, MR, MC> that(lhs);
|
||||
return that *= rhs;
|
||||
}
|
||||
|
||||
template<typename S, int R, int C, int O, int MR, int MC>
|
||||
matrix<S,R,C,O,MR,MC> operator*(double lhs, matrix<S,R,C,O,MR,MC> const& rhs)
|
||||
matrix<S, R, C, O, MR, MC> operator*(double lhs,
|
||||
matrix<S, R, C, O, MR, MC> const& rhs)
|
||||
{
|
||||
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> operator/(matrix<S, R, C, O, MR, MC> const& lhs,
|
||||
double rhs)
|
||||
{
|
||||
matrix<S,R,C,O,MR,MC> that(lhs);
|
||||
matrix<S, R, C, O, MR, MC> that(lhs);
|
||||
return that /= rhs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,49 +21,64 @@ namespace rotgen
|
|||
class matrix_impl32_row;
|
||||
class matrix_impl32_col;
|
||||
|
||||
#define SIZE 64
|
||||
#define TYPE double
|
||||
#define SIZE 64
|
||||
#define TYPE double
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#define TRANSCLASSNAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#include <rotgen/container/matrix/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSCLASSNAME
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _col)
|
||||
#define TRANSCLASSNAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _row)
|
||||
#include <rotgen/container/matrix/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSCLASSNAME
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#define TRANSCLASSNAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#include <rotgen/container/matrix/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSCLASSNAME
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _row)
|
||||
#define TRANSCLASSNAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _col)
|
||||
#include <rotgen/container/matrix/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSCLASSNAME
|
||||
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
|
||||
#define SIZE 32
|
||||
#define TYPE float
|
||||
#define SIZE 32
|
||||
#define TYPE float
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#define TRANSCLASSNAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#include <rotgen/container/matrix/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSCLASSNAME
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _col)
|
||||
#define TRANSCLASSNAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _row)
|
||||
#include <rotgen/container/matrix/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSCLASSNAME
|
||||
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_row)
|
||||
#define TRANSCLASSNAME ROTGEN_MATRIX_NAME(matrix_impl,SIZE,_col)
|
||||
#include <rotgen/container/matrix/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSCLASSNAME
|
||||
#define CLASSNAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _row)
|
||||
#define TRANSCLASSNAME ROTGEN_MATRIX_NAME(matrix_impl, SIZE, _col)
|
||||
#include <rotgen/container/matrix/dynamic/model.hpp>
|
||||
#undef CLASSNAME
|
||||
#undef TRANSCLASSNAME
|
||||
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
#undef SIZE
|
||||
#undef TYPE
|
||||
|
||||
template<typename Scalar,int Options> struct find_matrix_impl;
|
||||
template<typename Scalar, int Options> struct find_matrix_impl;
|
||||
|
||||
template<> struct find_matrix_impl<float , ColMajor> { using type = matrix_impl32_col; };
|
||||
template<> struct find_matrix_impl<float , RowMajor> { using type = matrix_impl32_row; };
|
||||
template<> struct find_matrix_impl<double, ColMajor> { using type = matrix_impl64_col; };
|
||||
template<> struct find_matrix_impl<double, RowMajor> { using type = matrix_impl64_row; };
|
||||
template<> struct find_matrix_impl<float, ColMajor>
|
||||
{
|
||||
using type = matrix_impl32_col;
|
||||
};
|
||||
|
||||
template<typename Scalar,int Options>
|
||||
using find_matrix = typename find_matrix_impl<Scalar,(Options & 1)>::type;
|
||||
template<> struct find_matrix_impl<float, RowMajor>
|
||||
{
|
||||
using type = matrix_impl32_row;
|
||||
};
|
||||
|
||||
template<> struct find_matrix_impl<double, ColMajor>
|
||||
{
|
||||
using type = matrix_impl64_col;
|
||||
};
|
||||
|
||||
template<> struct find_matrix_impl<double, RowMajor>
|
||||
{
|
||||
using type = matrix_impl64_row;
|
||||
};
|
||||
|
||||
template<typename Scalar, int Options>
|
||||
using find_matrix = typename find_matrix_impl<Scalar, (Options & 1)>::type;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,12 @@
|
|||
//==================================================================================================
|
||||
class ROTGEN_EXPORT CLASSNAME
|
||||
{
|
||||
public:
|
||||
public:
|
||||
CLASSNAME();
|
||||
CLASSNAME(std::size_t rows, std::size_t cols);
|
||||
CLASSNAME(std::size_t rows, std::size_t cols,std::initializer_list<TYPE> init);
|
||||
CLASSNAME(std::size_t rows,
|
||||
std::size_t cols,
|
||||
std::initializer_list<TYPE> init);
|
||||
|
||||
CLASSNAME(std::initializer_list<std::initializer_list<TYPE>> init);
|
||||
|
||||
|
|
@ -35,53 +37,57 @@ class ROTGEN_EXPORT CLASSNAME
|
|||
void resize(std::size_t new_rows, std::size_t new_cols);
|
||||
void conservativeResize(std::size_t new_rows, std::size_t new_cols);
|
||||
|
||||
CLASSNAME normalized() const;
|
||||
CLASSNAME transpose() const;
|
||||
CLASSNAME conjugate() const;
|
||||
CLASSNAME adjoint() const;
|
||||
CLASSNAME normalized() const;
|
||||
CLASSNAME transpose() const;
|
||||
CLASSNAME conjugate() const;
|
||||
CLASSNAME adjoint() const;
|
||||
|
||||
CLASSNAME cwiseAbs() const;
|
||||
CLASSNAME cwiseAbs2() const;
|
||||
CLASSNAME cwiseAbs() const;
|
||||
CLASSNAME cwiseAbs2() const;
|
||||
CLASSNAME cwiseInverse() const;
|
||||
CLASSNAME cwiseSqrt() const;
|
||||
CLASSNAME cwiseSqrt() const;
|
||||
|
||||
void normalize();
|
||||
void transposeInPlace();
|
||||
void adjointInPlace();
|
||||
|
||||
TYPE sum() const;
|
||||
TYPE prod() const;
|
||||
TYPE mean() const;
|
||||
TYPE trace() const;
|
||||
TYPE sum() const;
|
||||
TYPE prod() const;
|
||||
TYPE mean() const;
|
||||
TYPE trace() const;
|
||||
TYPE maxCoeff() const;
|
||||
TYPE minCoeff() const;
|
||||
TYPE maxCoeff(Index* row, Index* col) const;
|
||||
TYPE minCoeff(Index* row, Index* col) const;
|
||||
|
||||
TYPE squaredNorm() const;
|
||||
TYPE norm() const;
|
||||
TYPE squaredNorm() const;
|
||||
TYPE norm() const;
|
||||
TYPE lp_norm(int p) const;
|
||||
|
||||
TYPE& operator()(std::size_t i, std::size_t j);
|
||||
TYPE& operator()(std::size_t i, std::size_t j);
|
||||
TYPE const& operator()(std::size_t i, std::size_t j) const;
|
||||
|
||||
TYPE& operator()(std::size_t index);
|
||||
TYPE& operator()(std::size_t index);
|
||||
TYPE const& operator()(std::size_t index) const;
|
||||
|
||||
CLASSNAME& operator+=(CLASSNAME const& rhs);
|
||||
CLASSNAME& operator-=(CLASSNAME const& rhs);
|
||||
CLASSNAME operator-() const;
|
||||
CLASSNAME& operator*=(CLASSNAME const& rhs);
|
||||
CLASSNAME& operator*=(TYPE d);
|
||||
CLASSNAME& operator/=(TYPE d);
|
||||
CLASSNAME& operator*=(TYPE d);
|
||||
CLASSNAME& operator/=(TYPE d);
|
||||
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&,CLASSNAME const&);
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&, format<CLASSNAME> const&);
|
||||
friend ROTGEN_EXPORT bool operator==(CLASSNAME const& lhs, CLASSNAME const& rhs);
|
||||
friend ROTGEN_EXPORT bool operator!=(CLASSNAME const& lhs, CLASSNAME const& rhs);
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&,
|
||||
CLASSNAME const&);
|
||||
friend ROTGEN_EXPORT std::ostream& operator<<(std::ostream&,
|
||||
format<CLASSNAME> const&);
|
||||
friend ROTGEN_EXPORT bool operator==(CLASSNAME const& lhs,
|
||||
CLASSNAME const& rhs);
|
||||
friend ROTGEN_EXPORT bool operator!=(CLASSNAME const& lhs,
|
||||
CLASSNAME const& rhs);
|
||||
|
||||
const TYPE* data() const;
|
||||
TYPE* data();
|
||||
TYPE* data();
|
||||
|
||||
static CLASSNAME Zero(std::size_t rows, std::size_t cols);
|
||||
static CLASSNAME Ones(std::size_t rows, std::size_t cols);
|
||||
|
|
@ -89,11 +95,12 @@ class ROTGEN_EXPORT CLASSNAME
|
|||
static CLASSNAME Random(std::size_t rows, std::size_t cols);
|
||||
static CLASSNAME Identity(std::size_t rows, std::size_t cols);
|
||||
|
||||
private:
|
||||
private:
|
||||
struct payload;
|
||||
std::unique_ptr<payload> storage_;
|
||||
|
||||
public:
|
||||
std::unique_ptr<payload>& storage() { return storage_; }
|
||||
public:
|
||||
std::unique_ptr<payload>& storage() { return storage_; }
|
||||
|
||||
std::unique_ptr<payload> const& storage() const { return storage_; }
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,114 +15,139 @@ namespace rotgen
|
|||
{
|
||||
namespace detail
|
||||
{
|
||||
template<typename Scalar, int Rows, int Cols, int Opts, int MaxRows, int MaxCols>
|
||||
using storage_type = std::conditional_t < storage_status<Rows,Cols,MaxRows,MaxCols>
|
||||
, Eigen::Matrix<Scalar, Rows, Cols, Opts, MaxRows, MaxCols>
|
||||
, Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Opts>
|
||||
>;
|
||||
template<typename Scalar,
|
||||
int Rows,
|
||||
int Cols,
|
||||
int Opts,
|
||||
int MaxRows,
|
||||
int MaxCols>
|
||||
using storage_type = std::conditional_t<
|
||||
storage_status<Rows, Cols, MaxRows, MaxCols>,
|
||||
Eigen::Matrix<Scalar, Rows, Cols, Opts, MaxRows, MaxCols>,
|
||||
Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Opts>>;
|
||||
}
|
||||
|
||||
template< typename Scalar
|
||||
, int Rows = Dynamic , int Cols = Dynamic
|
||||
, int Opts = detail::force_order<Rows,Cols>
|
||||
, int MaxRows = Rows, int MaxCols = Cols
|
||||
>
|
||||
class matrix : private detail::storage_type<Scalar, Rows, Cols, Opts, MaxRows, MaxCols>
|
||||
template<typename Scalar,
|
||||
int Rows = Dynamic,
|
||||
int Cols = Dynamic,
|
||||
int Opts = detail::force_order<Rows, Cols>,
|
||||
int MaxRows = Rows,
|
||||
int MaxCols = Cols>
|
||||
class matrix
|
||||
: private detail::storage_type<Scalar, Rows, Cols, Opts, MaxRows, MaxCols>
|
||||
{
|
||||
public:
|
||||
using rotgen_tag = void;
|
||||
using parent = detail::storage_type<Scalar, Rows, Cols, Opts, MaxRows, MaxCols>;
|
||||
using value_type = Scalar;
|
||||
using Index = typename parent::Index;
|
||||
public:
|
||||
using rotgen_tag = void;
|
||||
using parent =
|
||||
detail::storage_type<Scalar, Rows, Cols, Opts, MaxRows, MaxCols>;
|
||||
using value_type = Scalar;
|
||||
using Index = typename parent::Index;
|
||||
|
||||
static constexpr auto storage_order = Opts & 1;
|
||||
using concrete_type = matrix;
|
||||
using concrete_dynamic_type = matrix<value_type>;
|
||||
|
||||
static constexpr int RowsAtCompileTime = Rows;
|
||||
static constexpr int ColsAtCompileTime = Cols;
|
||||
static constexpr int MaxRowsAtCompileTime = MaxRows;
|
||||
static constexpr int MaxColsAtCompileTime = MaxCols;
|
||||
static constexpr bool IsCompileTimeSized = Rows != -1 && Cols != -1;
|
||||
static constexpr bool IsVectorAtCompileTime = (RowsAtCompileTime == 1) || (ColsAtCompileTime == 1);
|
||||
static constexpr int Options = parent::Options;
|
||||
static constexpr bool IsRowMajor = parent::IsRowMajor;
|
||||
static constexpr int RowsAtCompileTime = Rows;
|
||||
static constexpr int ColsAtCompileTime = Cols;
|
||||
static constexpr int MaxRowsAtCompileTime = MaxRows;
|
||||
static constexpr int MaxColsAtCompileTime = MaxCols;
|
||||
static constexpr bool IsCompileTimeSized = Rows != -1 && Cols != -1;
|
||||
static constexpr bool IsVectorAtCompileTime =
|
||||
(RowsAtCompileTime == 1) || (ColsAtCompileTime == 1);
|
||||
static constexpr int Options = parent::Options;
|
||||
static constexpr bool IsRowMajor = parent::IsRowMajor;
|
||||
|
||||
template<typename ET>
|
||||
using as_concrete_type = detail::as_concrete_t<ET, matrix>;
|
||||
|
||||
static constexpr bool is_immutable = false;
|
||||
static constexpr bool is_defined_static = Rows!=-1 && Cols!=-1;
|
||||
static constexpr bool has_static_storage = storage_status<Rows,Cols,MaxRows,MaxCols>;
|
||||
static constexpr bool is_immutable = false;
|
||||
static constexpr bool is_defined_static = Rows != -1 && Cols != -1;
|
||||
static constexpr bool has_static_storage =
|
||||
storage_status<Rows, Cols, MaxRows, MaxCols>;
|
||||
|
||||
public:
|
||||
|
||||
matrix() requires(has_static_storage) {}
|
||||
matrix() requires(!has_static_storage) : parent(Rows > 0 ? Rows : 0, Cols > 0 ? Cols : 0){}
|
||||
matrix(Index r, Index c) requires(!IsCompileTimeSized) : parent(r, c) {}
|
||||
|
||||
matrix(const matrix& other) = default;
|
||||
matrix(matrix&& other) = default;
|
||||
matrix& operator=(const matrix&) = default;
|
||||
matrix& operator=(matrix&&) = default;
|
||||
|
||||
matrix(std::initializer_list<std::initializer_list<Scalar>> init) : parent(init)
|
||||
{}
|
||||
|
||||
matrix(Index n) requires(IsVectorAtCompileTime && (Rows != 1 || Cols != 1))
|
||||
: parent(n)
|
||||
{}
|
||||
|
||||
matrix(Scalar v) requires(Rows == 1 && Cols == 1) : parent
|
||||
( [&]()
|
||||
{
|
||||
if constexpr(has_static_storage) return parent(v);
|
||||
else return parent{1,1};
|
||||
}()
|
||||
)
|
||||
public:
|
||||
matrix()
|
||||
requires(has_static_storage)
|
||||
{
|
||||
if constexpr(!has_static_storage) (*this)(0) = v;
|
||||
}
|
||||
|
||||
matrix()
|
||||
requires(!has_static_storage)
|
||||
: parent(Rows > 0 ? Rows : 0, Cols > 0 ? Cols : 0)
|
||||
{
|
||||
}
|
||||
|
||||
matrix(Index r, Index c)
|
||||
requires(!IsCompileTimeSized)
|
||||
: parent(r, c)
|
||||
{
|
||||
}
|
||||
|
||||
matrix(matrix const& other) = default;
|
||||
matrix(matrix&& other) = default;
|
||||
matrix& operator=(matrix const&) = default;
|
||||
matrix& operator=(matrix&&) = default;
|
||||
|
||||
matrix(std::initializer_list<std::initializer_list<Scalar>> init)
|
||||
: parent(init)
|
||||
{
|
||||
}
|
||||
|
||||
matrix(Index n)
|
||||
requires(IsVectorAtCompileTime && (Rows != 1 || Cols != 1))
|
||||
: parent(n)
|
||||
{
|
||||
}
|
||||
|
||||
matrix(Scalar v)
|
||||
requires(Rows == 1 && Cols == 1)
|
||||
: parent([&]() {
|
||||
if constexpr (has_static_storage) return parent(v);
|
||||
else return parent{1, 1};
|
||||
}())
|
||||
{
|
||||
if constexpr (!has_static_storage) (*this)(0) = v;
|
||||
}
|
||||
|
||||
explicit matrix(std::initializer_list<Scalar> init)
|
||||
requires(IsVectorAtCompileTime)
|
||||
: parent( [&]()
|
||||
{
|
||||
if constexpr(has_static_storage) return parent{};
|
||||
else return parent{Rows,Cols};
|
||||
}()
|
||||
)
|
||||
: parent([&]() {
|
||||
if constexpr (has_static_storage) return parent{};
|
||||
else return parent{Rows, Cols};
|
||||
}())
|
||||
{
|
||||
auto first = init.begin();
|
||||
for(rotgen::Index i=0; i < parent::size(); i++)
|
||||
(*this)(i) = first[i];
|
||||
for (rotgen::Index i = 0; i < parent::size(); i++) (*this)(i) = first[i];
|
||||
}
|
||||
|
||||
matrix(Scalar v0, Scalar v1, auto... vs)
|
||||
requires((Rows == (2+sizeof...(vs)) && Cols == 1) || (Rows == 1 && Cols == (2+sizeof...(vs))))
|
||||
: matrix({v0,v1,static_cast<Scalar>(vs)...})
|
||||
{}
|
||||
requires((Rows == (2 + sizeof...(vs)) && Cols == 1) ||
|
||||
(Rows == 1 && Cols == (2 + sizeof...(vs))))
|
||||
: matrix({v0, v1, static_cast<Scalar>(vs)...})
|
||||
{
|
||||
}
|
||||
|
||||
matrix(concepts::entity auto const& other) : parent(other.base())
|
||||
{}
|
||||
matrix(concepts::entity auto const& other) : parent(other.base()) {}
|
||||
|
||||
template<typename OtherDerived>
|
||||
matrix(const Eigen::MatrixBase<OtherDerived>& other) : parent(other)
|
||||
{}
|
||||
matrix(Eigen::MatrixBase<OtherDerived> const& other) : parent(other)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename OtherDerived>
|
||||
matrix(const Eigen::EigenBase<OtherDerived>& other) : parent(other)
|
||||
{}
|
||||
matrix(Eigen::EigenBase<OtherDerived> const& other) : parent(other)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename OtherDerived>
|
||||
matrix& operator=(const Eigen::MatrixBase<OtherDerived>& other)
|
||||
matrix& operator=(Eigen::MatrixBase<OtherDerived> const& other)
|
||||
{
|
||||
parent::operator=(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename OtherDerived>
|
||||
matrix& operator=(const Eigen::EigenBase<OtherDerived>& other)
|
||||
matrix& operator=(Eigen::EigenBase<OtherDerived> const& other)
|
||||
{
|
||||
parent::operator=(other);
|
||||
return *this;
|
||||
|
|
@ -134,8 +159,9 @@ namespace rotgen
|
|||
return *this;
|
||||
}
|
||||
|
||||
parent& base() { return static_cast<parent&>(*this); }
|
||||
parent const& base() const { return static_cast<parent const&>(*this); }
|
||||
parent& base() { return static_cast<parent&>(*this); }
|
||||
|
||||
parent const& base() const { return static_cast<parent const&>(*this); }
|
||||
|
||||
auto evaluate() const
|
||||
{
|
||||
|
|
@ -145,19 +171,20 @@ namespace rotgen
|
|||
|
||||
decltype(auto) noalias() const
|
||||
{
|
||||
if constexpr(use_expression_templates) return base().noalias();
|
||||
else return *this;
|
||||
if constexpr (use_expression_templates) return base().noalias();
|
||||
else return *this;
|
||||
}
|
||||
|
||||
decltype(auto) noalias()
|
||||
{
|
||||
if constexpr(use_expression_templates) return base().noalias();
|
||||
else return *this;
|
||||
if constexpr (use_expression_templates) return base().noalias();
|
||||
else return *this;
|
||||
}
|
||||
|
||||
auto normalized() const requires(IsVectorAtCompileTime)
|
||||
auto normalized() const
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
if constexpr(use_expression_templates) return base().normalized();
|
||||
if constexpr (use_expression_templates) return base().normalized();
|
||||
else
|
||||
{
|
||||
auto res = base().normalized();
|
||||
|
|
@ -167,7 +194,7 @@ namespace rotgen
|
|||
|
||||
auto transpose() const
|
||||
{
|
||||
if constexpr(use_expression_templates) return base().transpose();
|
||||
if constexpr (use_expression_templates) return base().transpose();
|
||||
else
|
||||
{
|
||||
auto res = base().transpose();
|
||||
|
|
@ -187,163 +214,205 @@ namespace rotgen
|
|||
return as_concrete_type<decltype(res)>(res);
|
||||
}
|
||||
|
||||
void normalize() requires(IsVectorAtCompileTime)
|
||||
void normalize()
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
parent::normalize();
|
||||
}
|
||||
|
||||
void transposeInPlace() { parent::transposeInPlace(); }
|
||||
void adjointInPlace() { parent::adjointInPlace(); }
|
||||
|
||||
void adjointInPlace() { parent::adjointInPlace(); }
|
||||
|
||||
auto cwiseAbs() const
|
||||
{
|
||||
if constexpr(!use_expression_templates) return matrix{parent::cwiseAbs()};
|
||||
else return base().cwiseAbs();
|
||||
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();
|
||||
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();
|
||||
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();
|
||||
if constexpr (!use_expression_templates)
|
||||
return matrix{parent::cwiseSqrt()};
|
||||
else return base().cwiseSqrt();
|
||||
}
|
||||
|
||||
void resize(int s) requires(IsVectorAtCompileTime)
|
||||
void resize(int s)
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
if constexpr(Rows == 1) assert(s == Cols && "Mismatched between dynamic and static col size");
|
||||
if constexpr(Cols == 1) assert(s == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr (Rows == 1)
|
||||
assert(s == Cols && "Mismatched between dynamic and static col size");
|
||||
if constexpr (Cols == 1)
|
||||
assert(s == Rows && "Mismatched between dynamic and static row size");
|
||||
parent::resize(s);
|
||||
}
|
||||
|
||||
void resize(int r, int c)
|
||||
{
|
||||
if constexpr(Rows == 1) assert(c == Cols && "Mismatched between dynamic and static col size");
|
||||
if constexpr(Cols == 1) assert(r == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr (Rows == 1)
|
||||
assert(c == Cols && "Mismatched between dynamic and static col size");
|
||||
if constexpr (Cols == 1)
|
||||
assert(r == Rows && "Mismatched between dynamic and static row size");
|
||||
parent::resize(r, c);
|
||||
}
|
||||
|
||||
void conservativeResize(int s) requires(IsVectorAtCompileTime)
|
||||
void conservativeResize(int s)
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
if constexpr(Rows == 1) assert(s == Cols && "Mismatched between dynamic and static col size");
|
||||
if constexpr(Cols == 1) assert(s == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr (Rows == 1)
|
||||
assert(s == Cols && "Mismatched between dynamic and static col size");
|
||||
if constexpr (Cols == 1)
|
||||
assert(s == Rows && "Mismatched between dynamic and static row size");
|
||||
parent::conservativeResize(s);
|
||||
}
|
||||
|
||||
void conservativeResize(int r, int c)
|
||||
{
|
||||
if constexpr(Rows == 1) assert(c == Cols && "Mismatched between dynamic and static col size");
|
||||
if constexpr(Cols == 1) assert(r == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr (Rows == 1)
|
||||
assert(c == Cols && "Mismatched between dynamic and static col size");
|
||||
if constexpr (Cols == 1)
|
||||
assert(r == Rows && "Mismatched between dynamic and static row size");
|
||||
parent::conservativeResize(r, c);
|
||||
}
|
||||
|
||||
static matrix Constant(Scalar value) requires (Rows != -1 && Cols != -1)
|
||||
static matrix Constant(Scalar value)
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Constant(Rows, Cols, static_cast<Scalar>(value));
|
||||
}
|
||||
|
||||
static matrix Constant(int rows, int cols, Scalar value)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Constant(rows, cols, static_cast<Scalar>(value));
|
||||
}
|
||||
|
||||
static matrix Identity() requires (Rows != -1 && Cols != -1)
|
||||
static matrix Identity()
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Identity(Rows, Cols);
|
||||
}
|
||||
|
||||
static matrix Identity(int rows, int cols)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Identity(rows, cols);
|
||||
}
|
||||
|
||||
static matrix Ones() requires (Rows != -1 && Cols != -1)
|
||||
static matrix Ones()
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Ones(Rows, Cols);
|
||||
}
|
||||
|
||||
static matrix Ones(int rows, int cols)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Ones(rows, cols);
|
||||
}
|
||||
|
||||
static matrix Zero() requires (Rows != -1 && Cols != -1)
|
||||
static matrix Zero()
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Zero(Rows, Cols);
|
||||
}
|
||||
|
||||
static matrix Zero(int rows, int cols)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Zero(rows, cols);
|
||||
}
|
||||
|
||||
static matrix Random() requires (Rows != -1 && Cols != -1)
|
||||
static matrix Random()
|
||||
requires(Rows != -1 && Cols != -1)
|
||||
{
|
||||
return parent::Random(Rows, Cols);
|
||||
}
|
||||
|
||||
static matrix Random(int rows, int cols)
|
||||
{
|
||||
if constexpr(Rows != -1) assert(rows == Rows && "Mismatched between dynamic and static row size");
|
||||
if constexpr(Cols != -1) assert(cols == Cols && "Mismatched between dynamic and static column size");
|
||||
if constexpr (Rows != -1)
|
||||
assert(rows == Rows &&
|
||||
"Mismatched between dynamic and static row size");
|
||||
if constexpr (Cols != -1)
|
||||
assert(cols == Cols &&
|
||||
"Mismatched between dynamic and static column size");
|
||||
return parent::Random(rows, cols);
|
||||
}
|
||||
|
||||
template<int P>
|
||||
value_type lpNorm() const
|
||||
template<int P> value_type lpNorm() const
|
||||
{
|
||||
static_assert(P == 1 || P == 2 || P == Infinity);
|
||||
return parent::template lpNorm<P>();
|
||||
}
|
||||
|
||||
value_type& operator[](Index i) requires(IsVectorAtCompileTime)
|
||||
value_type& operator[](Index i)
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
return (*this)(i);
|
||||
}
|
||||
|
||||
value_type operator[](Index i) const requires(IsVectorAtCompileTime)
|
||||
value_type operator[](Index i) const
|
||||
requires(IsVectorAtCompileTime)
|
||||
{
|
||||
return (*this)(i);
|
||||
}
|
||||
|
||||
using parent::operator();
|
||||
using parent::rows;
|
||||
using parent::cols;
|
||||
using parent::size;
|
||||
using parent::prod;
|
||||
using parent::mean;
|
||||
using parent::trace;
|
||||
using parent::squaredNorm;
|
||||
using parent::norm;
|
||||
using parent::sum;
|
||||
using parent::data;
|
||||
|
||||
using parent::mean;
|
||||
using parent::norm;
|
||||
using parent::prod;
|
||||
using parent::rows;
|
||||
using parent::size;
|
||||
using parent::squaredNorm;
|
||||
using parent::sum;
|
||||
using parent::trace;
|
||||
|
||||
auto minCoeff() const { return parent::minCoeff(); }
|
||||
|
||||
auto maxCoeff() const { return parent::maxCoeff(); }
|
||||
|
||||
template<std::integral IndexType>
|
||||
auto minCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
Index r, c;
|
||||
auto result = parent::minCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
|
|
@ -353,7 +422,7 @@ namespace rotgen
|
|||
template<std::integral IndexType>
|
||||
auto maxCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
Index r, c;
|
||||
auto result = parent::maxCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
|
|
@ -362,7 +431,7 @@ namespace rotgen
|
|||
|
||||
matrix& setOnes()
|
||||
{
|
||||
*this = parent::Ones(rows(),cols());
|
||||
*this = parent::Ones(rows(), cols());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -374,7 +443,7 @@ namespace rotgen
|
|||
|
||||
matrix& setZero()
|
||||
{
|
||||
*this = parent::Zero(rows(),cols());
|
||||
*this = parent::Zero(rows(), cols());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -386,7 +455,7 @@ namespace rotgen
|
|||
|
||||
matrix& setConstant(Scalar value)
|
||||
{
|
||||
*this = parent::Constant(rows(),cols(), static_cast<Scalar>(value));
|
||||
*this = parent::Constant(rows(), cols(), static_cast<Scalar>(value));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -398,7 +467,7 @@ namespace rotgen
|
|||
|
||||
matrix& setRandom()
|
||||
{
|
||||
*this = parent::Random(rows(),cols());
|
||||
*this = parent::Random(rows(), cols());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -410,7 +479,7 @@ namespace rotgen
|
|||
|
||||
matrix& setIdentity()
|
||||
{
|
||||
*this = parent::Identity(rows(),cols());
|
||||
*this = parent::Identity(rows(), cols());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -432,10 +501,7 @@ namespace rotgen
|
|||
return *this;
|
||||
}
|
||||
|
||||
matrix operator-() const
|
||||
{
|
||||
return matrix(base()(*this).operator-());
|
||||
}
|
||||
matrix operator-() const { return matrix(base()(*this).operator-()); }
|
||||
|
||||
matrix& operator*=(matrix const& rhs)
|
||||
{
|
||||
|
|
@ -455,4 +521,4 @@ namespace rotgen
|
|||
return *this;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@
|
|||
//==================================================================================================
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(ROTGEN_FORCE_DYNAMIC)
|
||||
#include <Eigen/Dense>
|
||||
|
|
@ -20,88 +20,113 @@ namespace rotgen
|
|||
template<typename T, int Options, typename Stride>
|
||||
class ref : private map<T, Options, Stride>
|
||||
{
|
||||
public:
|
||||
using parent = map<T, Options, Stride>;
|
||||
using value_type = typename T::value_type;
|
||||
using rotgen_tag = void;
|
||||
using rotgen_ref_tag = void;
|
||||
public:
|
||||
using parent = map<T, Options, Stride>;
|
||||
using value_type = typename T::value_type;
|
||||
using rotgen_tag = void;
|
||||
using rotgen_ref_tag = void;
|
||||
|
||||
static constexpr int storage_order = T::storage_order;
|
||||
static constexpr int RowsAtCompileTime = T::RowsAtCompileTime;
|
||||
static constexpr int ColsAtCompileTime = T::ColsAtCompileTime;
|
||||
static constexpr int storage_order = T::storage_order;
|
||||
static constexpr int RowsAtCompileTime = T::RowsAtCompileTime;
|
||||
static constexpr int ColsAtCompileTime = T::ColsAtCompileTime;
|
||||
static constexpr bool IsVectorAtCompileTime = T::IsVectorAtCompileTime;
|
||||
static constexpr bool is_immutable = T::is_immutable;
|
||||
static constexpr bool is_immutable = T::is_immutable;
|
||||
|
||||
using parent::evaluate;
|
||||
using parent::noalias;
|
||||
using parent::operator();
|
||||
using parent::operator[];
|
||||
using parent::rows;
|
||||
using parent::cols;
|
||||
using parent::size;
|
||||
using parent::data;
|
||||
using parent::sum;
|
||||
using parent::prod;
|
||||
using parent::mean;
|
||||
using parent::trace;
|
||||
using parent::transpose;
|
||||
using parent::cwiseAbs;
|
||||
using parent::cwiseAbs2;
|
||||
using parent::cwiseInverse;
|
||||
using parent::cwiseSqrt;
|
||||
using parent::data;
|
||||
using parent::lpNorm;
|
||||
using parent::maxCoeff;
|
||||
using parent::mean;
|
||||
using parent::minCoeff;
|
||||
using parent::norm;
|
||||
using parent::normalize;
|
||||
using parent::prod;
|
||||
using parent::rows;
|
||||
using parent::size;
|
||||
using parent::squaredNorm;
|
||||
using parent::lpNorm;
|
||||
using parent::sum;
|
||||
using parent::trace;
|
||||
using parent::transpose;
|
||||
using parent::operator+=;
|
||||
using parent::operator-=;
|
||||
using parent::operator*=;
|
||||
using parent::operator/=;
|
||||
using parent::Zero;
|
||||
using parent::Constant;
|
||||
using parent::Random;
|
||||
using parent::Identity;
|
||||
using parent::setZero;
|
||||
using parent::setConstant;
|
||||
using parent::setRandom;
|
||||
using parent::setIdentity;
|
||||
using parent::outerStride;
|
||||
using parent::innerStride;
|
||||
using parent::outerStride;
|
||||
using parent::Random;
|
||||
using parent::setConstant;
|
||||
using parent::setIdentity;
|
||||
using parent::setRandom;
|
||||
using parent::setZero;
|
||||
using parent::Zero;
|
||||
|
||||
using parent::operator=;
|
||||
|
||||
using stride_type = typename parent::stride_type;
|
||||
|
||||
parent const& base() const { return static_cast<parent const&>(*this); }
|
||||
parent& base() { return static_cast<parent&>(*this); }
|
||||
|
||||
parent& base() { return static_cast<parent&>(*this); }
|
||||
|
||||
template<std::same_as<value_type> S, int R, int C, int O, int MR, int MC>
|
||||
ref(matrix<S, R, C, O, MR, MC>& m)
|
||||
: parent(m.data(), m.rows(), m.cols(), strides(m))
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Ref, int R, int C, bool I>
|
||||
requires(std::same_as<value_type, typename Ref::value_type> && (Ref::storage_order & 1) == storage_order)
|
||||
ref(block<Ref,R,C,I>&& b) : parent(b.data(), b.rows(), b.cols(), stride_type{b.outerStride(),b.innerStride()})
|
||||
{}
|
||||
requires(std::same_as<value_type, typename Ref::value_type> &&
|
||||
(Ref::storage_order & 1) == storage_order)
|
||||
ref(block<Ref, R, C, I>&& b)
|
||||
: parent(b.data(),
|
||||
b.rows(),
|
||||
b.cols(),
|
||||
stride_type{b.outerStride(), b.innerStride()})
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Ref, int R, int C, bool I>
|
||||
requires(std::same_as<value_type, typename Ref::value_type> && (Ref::storage_order & 1) == storage_order)
|
||||
ref(block<Ref,R,C,I>& b) : parent(b.data(), b.rows(), b.cols(), stride_type{b.outerStride(),b.innerStride()})
|
||||
{}
|
||||
requires(std::same_as<value_type, typename Ref::value_type> &&
|
||||
(Ref::storage_order & 1) == storage_order)
|
||||
ref(block<Ref, R, C, I>& b)
|
||||
: parent(b.data(),
|
||||
b.rows(),
|
||||
b.cols(),
|
||||
stride_type{b.outerStride(), b.innerStride()})
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Ref, int O, typename S>
|
||||
requires(std::same_as<value_type, typename Ref::value_type> && (Ref::storage_order & 1) == storage_order)
|
||||
ref(map<Ref,O,S>& b) : parent(b.data(), b.rows(), b.cols(), stride_type{b.outerStride(),b.innerStride()})
|
||||
{}
|
||||
requires(std::same_as<value_type, typename Ref::value_type> &&
|
||||
(Ref::storage_order & 1) == storage_order)
|
||||
ref(map<Ref, O, S>& b)
|
||||
: parent(b.data(),
|
||||
b.rows(),
|
||||
b.cols(),
|
||||
stride_type{b.outerStride(), b.innerStride()})
|
||||
{
|
||||
}
|
||||
|
||||
template<typename TT, int OO, typename SS>
|
||||
ref ( ref<TT,OO,SS>& b )
|
||||
requires(std::same_as<value_type, typename TT::value_type> && (TT::storage_order & 1) == storage_order)
|
||||
: parent(b.data(), b.rows(), b.cols(), stride_type{b.outerStride(),b.innerStride()})
|
||||
{}
|
||||
ref(ref<TT, OO, SS>& b)
|
||||
requires(std::same_as<value_type, typename TT::value_type> &&
|
||||
(TT::storage_order & 1) == storage_order)
|
||||
: parent(b.data(),
|
||||
b.rows(),
|
||||
b.cols(),
|
||||
stride_type{b.outerStride(), b.innerStride()})
|
||||
{
|
||||
}
|
||||
|
||||
ref(parent& m) : parent(m.data(), m.rows(), m.cols()) {}
|
||||
|
||||
|
|
@ -112,59 +137,59 @@ namespace rotgen
|
|||
|
||||
friend std::ostream& operator<<(std::ostream& os, format<ref> const& r)
|
||||
{
|
||||
return os << format{r.matrix_.base(),r.format_};
|
||||
return os << format{r.matrix_.base(), r.format_};
|
||||
}
|
||||
};
|
||||
|
||||
// Specialization for const matrix type
|
||||
template<typename T, int Options, typename Stride>
|
||||
class ref<const T, Options,Stride> : private map<const T, Options,Stride>
|
||||
class ref<T const, Options, Stride> : private map<T const, Options, Stride>
|
||||
{
|
||||
public:
|
||||
using parent = map<const T, Options,Stride>;
|
||||
using value_type = typename T::value_type;
|
||||
using rotgen_tag = void;
|
||||
using rotgen_ref_tag = void;
|
||||
public:
|
||||
using parent = map<T const, Options, Stride>;
|
||||
using value_type = typename T::value_type;
|
||||
using rotgen_tag = void;
|
||||
using rotgen_ref_tag = void;
|
||||
|
||||
static constexpr int storage_order = T::storage_order;
|
||||
static constexpr int RowsAtCompileTime = T::RowsAtCompileTime;
|
||||
static constexpr int ColsAtCompileTime = T::ColsAtCompileTime;
|
||||
static constexpr int storage_order = T::storage_order;
|
||||
static constexpr int RowsAtCompileTime = T::RowsAtCompileTime;
|
||||
static constexpr int ColsAtCompileTime = T::ColsAtCompileTime;
|
||||
static constexpr bool IsVectorAtCompileTime = T::IsVectorAtCompileTime;
|
||||
static constexpr bool is_immutable = T::is_immutable;
|
||||
static constexpr bool is_immutable = T::is_immutable;
|
||||
|
||||
using parent::evaluate;
|
||||
using parent::noalias;
|
||||
using parent::operator();
|
||||
using parent::operator[];
|
||||
using parent::rows;
|
||||
using parent::cols;
|
||||
using parent::size;
|
||||
using parent::data;
|
||||
using parent::sum;
|
||||
using parent::prod;
|
||||
using parent::mean;
|
||||
using parent::trace;
|
||||
using parent::transpose;
|
||||
using parent::cwiseAbs;
|
||||
using parent::cwiseAbs2;
|
||||
using parent::cwiseInverse;
|
||||
using parent::cwiseSqrt;
|
||||
using parent::data;
|
||||
using parent::lpNorm;
|
||||
using parent::maxCoeff;
|
||||
using parent::mean;
|
||||
using parent::minCoeff;
|
||||
using parent::norm;
|
||||
using parent::normalize;
|
||||
using parent::prod;
|
||||
using parent::rows;
|
||||
using parent::size;
|
||||
using parent::squaredNorm;
|
||||
using parent::lpNorm;
|
||||
using parent::sum;
|
||||
using parent::trace;
|
||||
using parent::transpose;
|
||||
using parent::operator+=;
|
||||
using parent::operator-=;
|
||||
using parent::operator*=;
|
||||
using parent::operator/=;
|
||||
using parent::Zero;
|
||||
using parent::Constant;
|
||||
using parent::Random;
|
||||
using parent::Identity;
|
||||
using parent::outerStride;
|
||||
using parent::innerStride;
|
||||
using parent::outerStride;
|
||||
using parent::Random;
|
||||
using parent::Zero;
|
||||
|
||||
using parent::operator=;
|
||||
|
||||
|
|
@ -176,25 +201,41 @@ namespace rotgen
|
|||
template<std::same_as<value_type> S, int R, int C, int O, int MR, int MC>
|
||||
ref(matrix<S, R, C, O, MR, MC> const& m)
|
||||
: parent(m.data(), m.rows(), m.cols(), strides(m))
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Ref, int R, int C, bool I>
|
||||
ref ( block<Ref,R,C,I> const& b )
|
||||
requires(std::same_as<value_type, typename Ref::value_type> && (Ref::storage_order & 1) == storage_order)
|
||||
: parent(b.data(), b.rows(), b.cols(), stride_type{b.outerStride(),b.innerStride()})
|
||||
{}
|
||||
ref(block<Ref, R, C, I> const& b)
|
||||
requires(std::same_as<value_type, typename Ref::value_type> &&
|
||||
(Ref::storage_order & 1) == storage_order)
|
||||
: parent(b.data(),
|
||||
b.rows(),
|
||||
b.cols(),
|
||||
stride_type{b.outerStride(), b.innerStride()})
|
||||
{
|
||||
}
|
||||
|
||||
template<typename Ref, int O, typename S>
|
||||
ref ( map<Ref,O,S> const& b )
|
||||
requires(std::same_as<value_type, typename Ref::value_type> && (Ref::storage_order & 1) == storage_order)
|
||||
: parent(b.data(), b.rows(), b.cols(), stride_type{b.outerStride(),b.innerStride()})
|
||||
{}
|
||||
ref(map<Ref, O, S> const& b)
|
||||
requires(std::same_as<value_type, typename Ref::value_type> &&
|
||||
(Ref::storage_order & 1) == storage_order)
|
||||
: parent(b.data(),
|
||||
b.rows(),
|
||||
b.cols(),
|
||||
stride_type{b.outerStride(), b.innerStride()})
|
||||
{
|
||||
}
|
||||
|
||||
template<typename TT, int OO, typename SS>
|
||||
ref ( ref<TT,OO,SS> const& b )
|
||||
requires(std::same_as<value_type, typename TT::value_type> && (TT::storage_order & 1) == storage_order)
|
||||
: parent(b.data(), b.rows(), b.cols(), stride_type{b.outerStride(),b.innerStride()})
|
||||
{}
|
||||
ref(ref<TT, OO, SS> const& b)
|
||||
requires(std::same_as<value_type, typename TT::value_type> &&
|
||||
(TT::storage_order & 1) == storage_order)
|
||||
: parent(b.data(),
|
||||
b.rows(),
|
||||
b.cols(),
|
||||
stride_type{b.outerStride(), b.innerStride()})
|
||||
{
|
||||
}
|
||||
|
||||
ref(parent const& m) : parent(m.data(), m.rows(), m.cols()) {}
|
||||
|
||||
|
|
@ -205,7 +246,7 @@ namespace rotgen
|
|||
|
||||
friend std::ostream& operator<<(std::ostream& os, format<ref> const& r)
|
||||
{
|
||||
return os << format{r.matrix_.base(),r.format_};
|
||||
return os << format{r.matrix_.base(), r.format_};
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -213,166 +254,186 @@ namespace rotgen
|
|||
ref(matrix<S, R, C, O, MR, MC>&) -> ref<matrix<S>>;
|
||||
|
||||
template<typename Ref, int R, int C, bool I>
|
||||
ref(block<Ref,R,C,I>& b) -> ref<Ref>;
|
||||
ref(block<Ref, R, C, I>& b) -> ref<Ref>;
|
||||
|
||||
template<typename S, int R, int C, int O, int MR, int MC>
|
||||
ref(matrix<S, R, C, O, MR, MC> const&) -> ref<matrix<S> const>;
|
||||
|
||||
template<typename Ref, int R, int C, bool I>
|
||||
ref(block<Ref,R,C,I> const& b) -> ref<Ref const>;
|
||||
ref(block<Ref, R, C, I> const& b) -> ref<Ref const>;
|
||||
|
||||
template<typename A, int O, typename S, typename B, int P, typename T>
|
||||
bool operator==(ref<A,O,S> lhs, ref<B,P,T> rhs)
|
||||
bool operator==(ref<A, O, S> lhs, ref<B, P, T> rhs)
|
||||
{
|
||||
return lhs.base() == rhs.base();
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S, typename B, int P, typename T>
|
||||
bool operator!=(ref<A,O,S> lhs, ref<B,P,T> rhs)
|
||||
bool operator!=(ref<A, O, S> lhs, ref<B, P, T> rhs)
|
||||
{
|
||||
return lhs.base() != rhs.base();
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S, typename B, int P, typename T>
|
||||
auto operator+(ref<A,O,S> lhs, ref<B,P,T> rhs) -> decltype(lhs.base() + rhs.base())
|
||||
auto operator+(ref<A, O, S> lhs, ref<B, P, T> rhs)
|
||||
-> decltype(lhs.base() + rhs.base())
|
||||
{
|
||||
return lhs.base() + rhs.base();
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S, typename B, int P, typename T>
|
||||
auto operator+=(ref<A,O,S> lhs, ref<B,P,T> rhs) -> decltype(lhs.base() += rhs.base())
|
||||
auto operator+=(ref<A, O, S> lhs, ref<B, P, T> rhs)
|
||||
-> decltype(lhs.base() += rhs.base())
|
||||
{
|
||||
return lhs.base() += rhs.base();
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S, typename B, int P, typename T>
|
||||
auto operator-(ref<A,O,S> lhs, ref<B,P,T> rhs)
|
||||
auto operator-(ref<A, O, S> lhs, ref<B, P, T> rhs)
|
||||
{
|
||||
return lhs.base() - rhs.base();
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S, typename B, int P, typename T>
|
||||
auto operator-=(ref<A,O,S> lhs, ref<B,P,T> rhs) -> decltype(lhs.base() -= rhs.base())
|
||||
auto operator-=(ref<A, O, S> lhs, ref<B, P, T> rhs)
|
||||
-> decltype(lhs.base() -= rhs.base())
|
||||
{
|
||||
return lhs.base() -= rhs.base();
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S, typename B, int P, typename T>
|
||||
auto operator*(ref<A,O,S> lhs, ref<B,P,T> rhs)
|
||||
auto operator*(ref<A, O, S> lhs, ref<B, P, T> rhs)
|
||||
{
|
||||
return lhs.base() * rhs.base();
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S, typename B, int P, typename T>
|
||||
auto operator*=(ref<A,O,S> lhs, ref<B,P,T> rhs) -> decltype(lhs.base() *= rhs.base())
|
||||
auto operator*=(ref<A, O, S> lhs, ref<B, P, T> rhs)
|
||||
-> decltype(lhs.base() *= rhs.base())
|
||||
{
|
||||
return lhs.base() *= rhs.base();
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S>
|
||||
auto operator*(ref<A,O,S> lhs, std::convertible_to<typename A::value_type> auto s)
|
||||
auto operator*(ref<A, O, S> lhs,
|
||||
std::convertible_to<typename A::value_type> auto s)
|
||||
{
|
||||
return lhs.base() * s;
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S>
|
||||
auto operator*(std::convertible_to<typename A::value_type> auto s, ref<A,O,S> rhs)
|
||||
auto operator*(std::convertible_to<typename A::value_type> auto s,
|
||||
ref<A, O, S> rhs)
|
||||
{
|
||||
return s * rhs.base();
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S>
|
||||
auto operator/(ref<A,O,S> lhs, std::convertible_to<typename A::value_type> auto s)
|
||||
auto operator/(ref<A, O, S> lhs,
|
||||
std::convertible_to<typename A::value_type> auto s)
|
||||
{
|
||||
return lhs.base() / s;
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S, typename B, int P, typename T>
|
||||
auto dot(ref<A,O,S> lhs, ref<B,P,T> rhs)
|
||||
auto dot(ref<A, O, S> lhs, ref<B, P, T> rhs)
|
||||
{
|
||||
return lhs.base().dot(rhs.base());
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S, typename B, int P, typename T>
|
||||
auto min(ref<A,O,S> lhs, ref<B,P,T> rhs) -> decltype(lhs.base().cwiseMin(rhs.base()))
|
||||
auto min(ref<A, O, S> lhs, ref<B, P, T> rhs)
|
||||
-> decltype(lhs.base().cwiseMin(rhs.base()))
|
||||
{
|
||||
return lhs.base().cwiseMin(rhs.base());
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S>
|
||||
auto min(ref<A,O,S> lhs, std::convertible_to<typename A::value_type> auto s) -> decltype(lhs.base().cwiseMin(s))
|
||||
auto min(ref<A, O, S> lhs, std::convertible_to<typename A::value_type> auto s)
|
||||
-> decltype(lhs.base().cwiseMin(s))
|
||||
{
|
||||
return lhs.base().cwiseMin(s);
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S>
|
||||
auto min(std::convertible_to<typename A::value_type> auto s,ref<A,O,S> rhs) -> decltype(rhs.base().cwiseMin(s))
|
||||
auto min(std::convertible_to<typename A::value_type> auto s, ref<A, O, S> rhs)
|
||||
-> decltype(rhs.base().cwiseMin(s))
|
||||
{
|
||||
return rhs.base().cwiseMin(s);
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S, typename B, int P, typename T>
|
||||
auto max(ref<A,O,S> lhs, ref<B,P,T> rhs) -> decltype(lhs.base().cwiseMax(rhs.base()))
|
||||
auto max(ref<A, O, S> lhs, ref<B, P, T> rhs)
|
||||
-> decltype(lhs.base().cwiseMax(rhs.base()))
|
||||
{
|
||||
return lhs.base().cwiseMax(rhs.base());
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S>
|
||||
auto max(ref<A,O,S> lhs, std::convertible_to<typename A::value_type> auto s) -> decltype(lhs.base().cwiseMax(s))
|
||||
auto max(ref<A, O, S> lhs, std::convertible_to<typename A::value_type> auto s)
|
||||
-> decltype(lhs.base().cwiseMax(s))
|
||||
{
|
||||
return lhs.base().cwiseMax(s);
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S>
|
||||
auto max(std::convertible_to<typename A::value_type> auto s,ref<A,O,S> rhs) -> decltype(rhs.base().cwiseMax(s))
|
||||
auto max(std::convertible_to<typename A::value_type> auto s, ref<A, O, S> rhs)
|
||||
-> decltype(rhs.base().cwiseMax(s))
|
||||
{
|
||||
return rhs.base().cwiseMax(s);
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S, typename B, int P, typename T>
|
||||
auto mul(ref<A,O,S> lhs, ref<B,P,T> rhs) -> decltype(lhs.base().cwiseProduct(rhs.base()))
|
||||
auto mul(ref<A, O, S> lhs, ref<B, P, T> rhs)
|
||||
-> decltype(lhs.base().cwiseProduct(rhs.base()))
|
||||
{
|
||||
return lhs.base().cwiseProduct(rhs.base());
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S>
|
||||
auto mul(ref<A,O,S> lhs, std::convertible_to<typename A::value_type> auto s) -> decltype(lhs * s)
|
||||
auto mul(ref<A, O, S> lhs, std::convertible_to<typename A::value_type> auto s)
|
||||
-> decltype(lhs * s)
|
||||
{
|
||||
return lhs * s;
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S>
|
||||
auto mul(std::convertible_to<typename A::value_type> auto s,ref<A,O,S> rhs) -> decltype(s * rhs)
|
||||
auto mul(std::convertible_to<typename A::value_type> auto s, ref<A, O, S> rhs)
|
||||
-> decltype(s * rhs)
|
||||
{
|
||||
return s * rhs;
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S, typename B, int P, typename T>
|
||||
auto div(ref<A,O,S> lhs, ref<B,P,T> rhs) -> decltype(lhs.base().cwiseQuotient(rhs.base()))
|
||||
auto div(ref<A, O, S> lhs, ref<B, P, T> rhs)
|
||||
-> decltype(lhs.base().cwiseQuotient(rhs.base()))
|
||||
{
|
||||
return lhs.base().cwiseQuotient(rhs.base());
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S>
|
||||
auto div(ref<A,O,S> lhs, std::convertible_to<typename A::value_type> auto s) -> decltype(lhs / s)
|
||||
auto div(ref<A, O, S> lhs, std::convertible_to<typename A::value_type> auto s)
|
||||
-> decltype(lhs / s)
|
||||
{
|
||||
return lhs / s;
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S>
|
||||
auto inverse(ref<A,O,S> lhs) -> decltype(lhs.base().inverse())
|
||||
auto inverse(ref<A, O, S> lhs) -> decltype(lhs.base().inverse())
|
||||
{
|
||||
return lhs.base().inverse();
|
||||
}
|
||||
|
||||
template<typename A, int O, typename S, typename B, int P, typename T>
|
||||
auto cross(ref<A,O,S> lhs, ref<B,P,T> rhs) -> decltype(lhs.base().cross(rhs.base()))
|
||||
auto cross(ref<A, O, S> lhs, ref<B, P, T> rhs)
|
||||
-> decltype(lhs.base().cross(rhs.base()))
|
||||
{
|
||||
return lhs.base().cross(rhs.base());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// Convert entity/eigen types to a proper ref so we can write less function overloads
|
||||
// Convert entity/eigen types to a proper ref so we can write less function
|
||||
// overloads
|
||||
template<typename T> struct generalize;
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -382,42 +443,41 @@ namespace rotgen
|
|||
using type = std::remove_cvref_t<T>;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
using generalize_t = typename generalize<T>::type;
|
||||
template<typename T> using generalize_t = typename generalize<T>::type;
|
||||
|
||||
template<concepts::entity T> struct generalize<T>
|
||||
{
|
||||
static constexpr bool is_const = std::is_const_v<T>;
|
||||
using base = matrix<typename T::value_type,T::RowsAtCompileTime,T::ColsAtCompileTime,T::storage_order>;
|
||||
using type = std::conditional_t<is_const,ref<base const>, ref<base>>;
|
||||
using base = matrix<typename T::value_type,
|
||||
T::RowsAtCompileTime,
|
||||
T::ColsAtCompileTime,
|
||||
T::storage_order>;
|
||||
using type = std::conditional_t<is_const, ref<base const>, ref<base>>;
|
||||
};
|
||||
|
||||
template<typename T, int O, typename S>
|
||||
struct generalize<ref<T,O,S>>
|
||||
template<typename T, int O, typename S> struct generalize<ref<T, O, S>>
|
||||
{
|
||||
using type = ref<T,O,S>;
|
||||
using type = ref<T, O, S>;
|
||||
};
|
||||
|
||||
template<typename T, int O, typename S>
|
||||
struct generalize<ref<T,O,S> const>
|
||||
template<typename T, int O, typename S> struct generalize<ref<T, O, S> const>
|
||||
{
|
||||
using type = ref<T,O,S>;
|
||||
using type = ref<T, O, S>;
|
||||
};
|
||||
|
||||
template<concepts::entity T>
|
||||
typename T::parent& base_of(T& a)
|
||||
template<concepts::entity T> typename T::parent& base_of(T& a)
|
||||
{
|
||||
return a.base();
|
||||
}
|
||||
|
||||
template<concepts::entity T>
|
||||
typename T::parent const& base_of(T const& a)
|
||||
template<concepts::entity T> typename T::parent const& base_of(T const& a)
|
||||
{
|
||||
return a.base();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T base_of(T a) requires(std::is_arithmetic_v<T>)
|
||||
T base_of(T a)
|
||||
requires(std::is_arithmetic_v<T>)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
|
@ -427,18 +487,19 @@ namespace rotgen
|
|||
{
|
||||
static constexpr bool is_const = std::is_const_v<T>;
|
||||
using concrete_type = decltype(std::declval<T>().eval());
|
||||
using base = matrix<typename T::Scalar,T::RowsAtCompileTime,T::ColsAtCompileTime,concrete_type::Options&1>;
|
||||
using type = std::conditional_t<is_const,ref<base const>, ref<base>>;
|
||||
using base = matrix<typename T::Scalar,
|
||||
T::RowsAtCompileTime,
|
||||
T::ColsAtCompileTime,
|
||||
concrete_type::Options & 1>;
|
||||
using type = std::conditional_t<is_const, ref<base const>, ref<base>>;
|
||||
};
|
||||
|
||||
template<concepts::eigen_compatible T>
|
||||
auto const& base_of(T const& a)
|
||||
template<concepts::eigen_compatible T> auto const& base_of(T const& a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
template<concepts::eigen_compatible T>
|
||||
auto& base_of(T& a)
|
||||
template<concepts::eigen_compatible T> auto& base_of(T& a)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,65 +16,66 @@
|
|||
namespace rotgen
|
||||
{
|
||||
#if !defined(ROTGEN_FORCE_DYNAMIC)
|
||||
using stride = Eigen::Stride<-1,-1>;
|
||||
using stride = Eigen::Stride<-1, -1>;
|
||||
#else
|
||||
struct stride
|
||||
{
|
||||
static constexpr bool is_dynamic = true;
|
||||
|
||||
stride() : outer_(-1), inner_(1) {}
|
||||
stride(Index s, Index i) : outer_(s), inner_(i) {}
|
||||
|
||||
stride(Index s, Index i) : outer_(s), inner_(i) {}
|
||||
|
||||
Index inner() const { return inner_; }
|
||||
|
||||
Index outer() const { return outer_; }
|
||||
|
||||
private:
|
||||
private:
|
||||
Index outer_;
|
||||
Index inner_;
|
||||
};
|
||||
#endif
|
||||
|
||||
template<Index Value= Dynamic>
|
||||
struct inner_stride : stride
|
||||
template<Index Value = Dynamic> struct inner_stride : stride
|
||||
{
|
||||
static constexpr bool is_dynamic = Value == Dynamic;
|
||||
inner_stride() : stride(-1,Value) {}
|
||||
|
||||
inner_stride() : stride(-1, Value) {}
|
||||
|
||||
inner_stride(Index v) : stride(0, v) {}
|
||||
};
|
||||
|
||||
template<Index Value = Dynamic>
|
||||
struct outer_stride : stride
|
||||
template<Index Value = Dynamic> struct outer_stride : stride
|
||||
{
|
||||
static constexpr bool is_dynamic = Value == Dynamic;
|
||||
outer_stride() : stride(Value,0) {}
|
||||
outer_stride(Index v) : stride(v,0) {}
|
||||
|
||||
outer_stride() : stride(Value, 0) {}
|
||||
|
||||
outer_stride(Index v) : stride(v, 0) {}
|
||||
};
|
||||
|
||||
inner_stride(Index) -> inner_stride<Dynamic>;
|
||||
outer_stride(Index) -> outer_stride<Dynamic>;
|
||||
|
||||
template<int Order>
|
||||
stride strides(Index r, Index c)
|
||||
template<int Order> stride strides(Index r, Index c)
|
||||
{
|
||||
if constexpr (Order == RowMajor) return {c,1};
|
||||
else return {r,1};
|
||||
if constexpr (Order == RowMajor) return {c, 1};
|
||||
else return {r, 1};
|
||||
}
|
||||
|
||||
template<int Order>
|
||||
stride strides(stride const& original,Index, Index)
|
||||
template<int Order> stride strides(stride const& original, Index, Index)
|
||||
{
|
||||
return original;
|
||||
}
|
||||
|
||||
template<int Order, Index N>
|
||||
stride strides(outer_stride<N> const& original,Index r, Index c)
|
||||
stride strides(outer_stride<N> const& original, Index r, Index c)
|
||||
{
|
||||
if constexpr(N==0) return stride{ Order==ColMajor ? r : c, 1};
|
||||
else return {original.outer(),1};
|
||||
if constexpr (N == 0) return stride{Order == ColMajor ? r : c, 1};
|
||||
else return {original.outer(), 1};
|
||||
}
|
||||
|
||||
template<concepts::entity E>
|
||||
auto strides(const E& e)
|
||||
template<concepts::entity E> auto strides(E const& e)
|
||||
{
|
||||
return strides<E::storage_order>(e.rows(), e.cols());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,33 +8,32 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef ROTGEN_STATIC_DEFINE
|
||||
# define ROTGEN_EXPORT
|
||||
# define ROTGEN_NO_EXPORT
|
||||
#define ROTGEN_EXPORT
|
||||
#define ROTGEN_NO_EXPORT
|
||||
#else
|
||||
# ifndef ROTGEN_EXPORT
|
||||
# ifdef rotgen_EXPORTS
|
||||
/* We are building this library */
|
||||
# define ROTGEN_EXPORT __attribute__((visibility("default")))
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define ROTGEN_EXPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
# endif
|
||||
#ifndef ROTGEN_EXPORT
|
||||
#ifdef rotgen_EXPORTS
|
||||
/* We are building this library */
|
||||
#define ROTGEN_EXPORT __attribute__((visibility("default")))
|
||||
#else
|
||||
/* We are using this library */
|
||||
#define ROTGEN_EXPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
# ifndef ROTGEN_NO_EXPORT
|
||||
# define ROTGEN_NO_EXPORT __attribute__((visibility("hidden")))
|
||||
# endif
|
||||
#ifndef ROTGEN_NO_EXPORT
|
||||
#define ROTGEN_NO_EXPORT __attribute__((visibility("hidden")))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ROTGEN_DEPRECATED
|
||||
# define ROTGEN_DEPRECATED __attribute__ ((__deprecated__))
|
||||
#define ROTGEN_DEPRECATED __attribute__((__deprecated__))
|
||||
#endif
|
||||
|
||||
#ifndef ROTGEN_DEPRECATED_EXPORT
|
||||
# define ROTGEN_DEPRECATED_EXPORT ROTGEN_EXPORT ROTGEN_DEPRECATED
|
||||
#define ROTGEN_DEPRECATED_EXPORT ROTGEN_EXPORT ROTGEN_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifndef ROTGEN_DEPRECATED_NO_EXPORT
|
||||
# define ROTGEN_DEPRECATED_NO_EXPORT ROTGEN_NO_EXPORT ROTGEN_DEPRECATED
|
||||
#define ROTGEN_DEPRECATED_NO_EXPORT ROTGEN_NO_EXPORT ROTGEN_DEPRECATED
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
//==================================================================================================
|
||||
#pragma once
|
||||
|
||||
#define ROTGEN_CAT(a, ...) ROTGEN_PRIMITIVE_CAT(a, __VA_ARGS__)
|
||||
#define ROTGEN_PRIMITIVE_CAT(a, ...) a ## __VA_ARGS__
|
||||
#define ROTGEN_MATRIX_NAME(BASE,ID,SUFFIX) ROTGEN_CAT(BASE,ROTGEN_CAT(ID,SUFFIX))
|
||||
#define ROTGEN_CAT(a, ...) ROTGEN_PRIMITIVE_CAT(a, __VA_ARGS__)
|
||||
#define ROTGEN_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
|
||||
#define ROTGEN_MATRIX_NAME(BASE, ID, SUFFIX) \
|
||||
ROTGEN_CAT(BASE, ROTGEN_CAT(ID, SUFFIX))
|
||||
|
|
|
|||
|
|
@ -9,50 +9,55 @@
|
|||
|
||||
namespace rotgen::detail
|
||||
{
|
||||
template< typename EigenType
|
||||
, template<typename,int,int,int,int,int> typename Wrapper
|
||||
>
|
||||
template<typename EigenType,
|
||||
template<typename, int, int, int, int, int> typename Wrapper>
|
||||
struct as_concrete
|
||||
{
|
||||
using type = Wrapper< typename EigenType::value_type
|
||||
, EigenType::RowsAtCompileTime, EigenType::ColsAtCompileTime
|
||||
, EigenType::Flags & 1
|
||||
, EigenType::MaxRowsAtCompileTime, EigenType::MaxColsAtCompileTime
|
||||
>;
|
||||
using type = Wrapper<typename EigenType::value_type,
|
||||
EigenType::RowsAtCompileTime,
|
||||
EigenType::ColsAtCompileTime,
|
||||
EigenType::Flags & 1,
|
||||
EigenType::MaxRowsAtCompileTime,
|
||||
EigenType::MaxColsAtCompileTime>;
|
||||
};
|
||||
|
||||
template<typename EigenType
|
||||
, template<typename,int,int,int,int,int> typename Wrapper
|
||||
>
|
||||
using as_concrete_t = typename as_concrete<std::remove_cvref_t<EigenType>,Wrapper>::type;
|
||||
template<typename EigenType,
|
||||
template<typename, int, int, int, int, int> typename Wrapper>
|
||||
using as_concrete_t =
|
||||
typename as_concrete<std::remove_cvref_t<EigenType>, Wrapper>::type;
|
||||
|
||||
template<typename M, typename N>
|
||||
inline constexpr bool has_same_vector_size = []()
|
||||
{
|
||||
inline constexpr bool has_same_vector_size = []() {
|
||||
// No vector = noo size
|
||||
if(!(M::IsVectorAtCompileTime && N::IsVectorAtCompileTime)) return false;
|
||||
if (!(M::IsVectorAtCompileTime && N::IsVectorAtCompileTime)) return false;
|
||||
// Row vectors -> same Cols
|
||||
if(M::RowsAtCompileTime == 1 && N::RowsAtCompileTime == 1) return M::ColsAtCompileTime == N::ColsAtCompileTime;
|
||||
if (M::RowsAtCompileTime == 1 && N::RowsAtCompileTime == 1)
|
||||
return M::ColsAtCompileTime == N::ColsAtCompileTime;
|
||||
// Col vectors -> same Rows
|
||||
if(M::ColsAtCompileTime == 1 && N::ColsAtCompileTime == 1) return M::RowsAtCompileTime == N::RowsAtCompileTime;
|
||||
if (M::ColsAtCompileTime == 1 && N::ColsAtCompileTime == 1)
|
||||
return M::RowsAtCompileTime == N::RowsAtCompileTime;
|
||||
// Mixing 1xN with Mx1
|
||||
return false;
|
||||
}();
|
||||
|
||||
template<typename T>
|
||||
using propagate_const = std::conditional_t<T::is_immutable || std::is_const_v<T>, std::add_const_t<T>, T>;
|
||||
using propagate_const =
|
||||
std::conditional_t<T::is_immutable || std::is_const_v<T>,
|
||||
std::add_const_t<T>,
|
||||
T>;
|
||||
|
||||
template<auto M, auto N>
|
||||
inline constexpr auto select_static = (M==rotgen::Dynamic || N==rotgen::Dynamic) ? rotgen::Dynamic : M;
|
||||
inline constexpr auto select_static =
|
||||
(M == rotgen::Dynamic || N == rotgen::Dynamic) ? rotgen::Dynamic : M;
|
||||
|
||||
template< typename M1, typename M2
|
||||
, template<typename,int,int,int,int,int> typename Wrapper
|
||||
>
|
||||
using composite_type = Wrapper< typename M1::value_type
|
||||
, select_static<M1::RowsAtCompileTime,M2::RowsAtCompileTime>
|
||||
, select_static<M1::ColsAtCompileTime,M2::ColsAtCompileTime>
|
||||
, M1::storage_order
|
||||
, select_static<M1::MaxRowsAtCompileTime,M2::MaxRowsAtCompileTime>
|
||||
, select_static<M1::MaxColsAtCompileTime,M2::MaxColsAtCompileTime>
|
||||
>;
|
||||
}
|
||||
template<typename M1,
|
||||
typename M2,
|
||||
template<typename, int, int, int, int, int> typename Wrapper>
|
||||
using composite_type =
|
||||
Wrapper<typename M1::value_type,
|
||||
select_static<M1::RowsAtCompileTime, M2::RowsAtCompileTime>,
|
||||
select_static<M1::ColsAtCompileTime, M2::ColsAtCompileTime>,
|
||||
M1::storage_order,
|
||||
select_static<M1::MaxRowsAtCompileTime, M2::MaxRowsAtCompileTime>,
|
||||
select_static<M1::MaxColsAtCompileTime, M2::MaxColsAtCompileTime>>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,180 +21,264 @@ namespace rotgen
|
|||
//==================================================================================================
|
||||
struct matrix_impl64_col::payload
|
||||
{
|
||||
using data_type = Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic,Eigen::ColMajor>;
|
||||
using data_type =
|
||||
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>;
|
||||
|
||||
data_type data;
|
||||
payload(std::size_t r=0, std::size_t c=0) : data(r, c) {}
|
||||
payload(std::initializer_list<std::initializer_list<double>> init) : data(init) {}
|
||||
|
||||
payload(std::size_t r = 0, std::size_t c = 0) : data(r, c) {}
|
||||
|
||||
payload(std::initializer_list<std::initializer_list<double>> init)
|
||||
: data(init)
|
||||
{
|
||||
}
|
||||
|
||||
payload(data_type&& matrix) : data(std::move(matrix)) {}
|
||||
|
||||
void assign(Eigen::Block<data_type> ref) { data = ref; }
|
||||
|
||||
void assign(data_type const& mat) { data = mat; }
|
||||
|
||||
void assign(data_type&& mat) { data = std::move(mat); }
|
||||
};
|
||||
|
||||
struct matrix_impl64_row::payload
|
||||
{
|
||||
using data_type = Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic,Eigen::RowMajor>;
|
||||
using data_type =
|
||||
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
|
||||
|
||||
data_type data;
|
||||
payload(std::size_t r=0, std::size_t c=0) : data(r, c) {}
|
||||
payload(std::initializer_list<std::initializer_list<double>> init) : data(init) {}
|
||||
|
||||
payload(std::size_t r = 0, std::size_t c = 0) : data(r, c) {}
|
||||
|
||||
payload(std::initializer_list<std::initializer_list<double>> init)
|
||||
: data(init)
|
||||
{
|
||||
}
|
||||
|
||||
payload(data_type&& matrix) : data(std::move(matrix)) {}
|
||||
|
||||
void assign(Eigen::Block<data_type> ref) { data = ref; }
|
||||
|
||||
void assign(data_type const& mat) { data = mat; }
|
||||
|
||||
void assign(data_type&& mat) { data = std::move(mat); }
|
||||
};
|
||||
|
||||
struct matrix_impl32_col::payload
|
||||
{
|
||||
using data_type = Eigen::Matrix<float,Eigen::Dynamic,Eigen::Dynamic,Eigen::ColMajor>;
|
||||
using data_type =
|
||||
Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>;
|
||||
|
||||
data_type data;
|
||||
payload(std::size_t r=0, std::size_t c=0) : data(r, c) {}
|
||||
payload(std::initializer_list<std::initializer_list<float>> init) : data(init) {}
|
||||
|
||||
payload(std::size_t r = 0, std::size_t c = 0) : data(r, c) {}
|
||||
|
||||
payload(std::initializer_list<std::initializer_list<float>> init)
|
||||
: data(init)
|
||||
{
|
||||
}
|
||||
|
||||
payload(data_type&& matrix) : data(std::move(matrix)) {}
|
||||
|
||||
void assign(Eigen::Block<data_type> ref) { data = ref; }
|
||||
|
||||
void assign(data_type const& mat) { data = mat; }
|
||||
|
||||
void assign(data_type&& mat) { data = std::move(mat); }
|
||||
};
|
||||
|
||||
struct matrix_impl32_row::payload
|
||||
{
|
||||
using data_type = Eigen::Matrix<float,Eigen::Dynamic,Eigen::Dynamic,Eigen::RowMajor>;
|
||||
using data_type =
|
||||
Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
|
||||
|
||||
data_type data;
|
||||
payload(std::size_t r=0, std::size_t c=0) : data(r, c) {}
|
||||
payload(std::initializer_list<std::initializer_list<float>> init) : data(init) {}
|
||||
|
||||
payload(std::size_t r = 0, std::size_t c = 0) : data(r, c) {}
|
||||
|
||||
payload(std::initializer_list<std::initializer_list<float>> init)
|
||||
: data(init)
|
||||
{
|
||||
}
|
||||
|
||||
payload(data_type&& matrix) : data(std::move(matrix)) {}
|
||||
|
||||
void assign(Eigen::Block<data_type> ref) { data = ref; }
|
||||
|
||||
void assign(data_type const& mat) { data = mat; }
|
||||
|
||||
void assign(data_type&& mat) { data = std::move(mat); }
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
// Internal payload - Required for cross-referencing from mixed order on map operators
|
||||
// Internal payload - Required for cross-referencing from mixed order on map
|
||||
// operators
|
||||
//==================================================================================================
|
||||
struct map_const_impl32_col::payload
|
||||
{
|
||||
using stride_type = Eigen::Stride<Eigen::Dynamic,Eigen::Dynamic>;
|
||||
using base_type = Eigen::Matrix<float,Eigen::Dynamic,Eigen::Dynamic,Eigen::ColMajor>;
|
||||
using data_type = Eigen::Map<base_type const,Eigen::Unaligned,stride_type>;
|
||||
using stride_type = Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>;
|
||||
using base_type =
|
||||
Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>;
|
||||
using data_type =
|
||||
Eigen::Map<base_type const, Eigen::Unaligned, stride_type>;
|
||||
|
||||
data_type data;
|
||||
|
||||
payload (data_type const& o) : data(o) {}
|
||||
payload (float const* ptr, Index r, Index c) : data(ptr,r,c) {}
|
||||
payload (float const* ptr, Index r, Index c, stride_type s) : data(ptr,r,c,s) {}
|
||||
payload(data_type const& o) : data(o) {}
|
||||
|
||||
payload(float const* ptr, Index r, Index c) : data(ptr, r, c) {}
|
||||
|
||||
payload(float const* ptr, Index r, Index c, stride_type s)
|
||||
: data(ptr, r, c, s)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct map_const_impl32_row::payload
|
||||
{
|
||||
using stride_type = Eigen::Stride<Eigen::Dynamic,Eigen::Dynamic>;
|
||||
using base_type = Eigen::Matrix<float,Eigen::Dynamic,Eigen::Dynamic,Eigen::RowMajor>;
|
||||
using data_type = Eigen::Map<base_type const,Eigen::Unaligned,stride_type>;
|
||||
using stride_type = Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>;
|
||||
using base_type =
|
||||
Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
|
||||
using data_type =
|
||||
Eigen::Map<base_type const, Eigen::Unaligned, stride_type>;
|
||||
|
||||
data_type data;
|
||||
|
||||
payload (data_type const& o) : data(o) {}
|
||||
payload (float const* ptr, Index r, Index c) : data(ptr,r,c) {}
|
||||
payload (float const* ptr, Index r, Index c, stride_type s) : data(ptr,r,c,s) {}
|
||||
payload(data_type const& o) : data(o) {}
|
||||
|
||||
payload(float const* ptr, Index r, Index c) : data(ptr, r, c) {}
|
||||
|
||||
payload(float const* ptr, Index r, Index c, stride_type s)
|
||||
: data(ptr, r, c, s)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct map_impl32_col::payload
|
||||
{
|
||||
using stride_type = Eigen::Stride<Eigen::Dynamic,Eigen::Dynamic>;
|
||||
using base_type = Eigen::Matrix<float,Eigen::Dynamic,Eigen::Dynamic,Eigen::ColMajor>;
|
||||
using data_type = Eigen::Map<base_type,Eigen::Unaligned,stride_type>;
|
||||
using stride_type = Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>;
|
||||
using base_type =
|
||||
Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>;
|
||||
using data_type = Eigen::Map<base_type, Eigen::Unaligned, stride_type>;
|
||||
|
||||
data_type data;
|
||||
|
||||
payload (data_type const& o) : data(o) {}
|
||||
payload (float* ptr, Index r, Index c) : data(ptr,r,c) {}
|
||||
payload (float* ptr, Index r, Index c, stride_type s) : data(ptr,r,c,s) {}
|
||||
payload(data_type const& o) : data(o) {}
|
||||
|
||||
payload(float* ptr, Index r, Index c) : data(ptr, r, c) {}
|
||||
|
||||
payload(float* ptr, Index r, Index c, stride_type s) : data(ptr, r, c, s) {}
|
||||
};
|
||||
|
||||
struct map_impl32_row::payload
|
||||
{
|
||||
using stride_type = Eigen::Stride<Eigen::Dynamic,Eigen::Dynamic>;
|
||||
using base_type = Eigen::Matrix<float,Eigen::Dynamic,Eigen::Dynamic,Eigen::RowMajor>;
|
||||
using data_type = Eigen::Map<base_type,Eigen::Unaligned,stride_type>;
|
||||
using stride_type = Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>;
|
||||
using base_type =
|
||||
Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
|
||||
using data_type = Eigen::Map<base_type, Eigen::Unaligned, stride_type>;
|
||||
|
||||
data_type data;
|
||||
|
||||
payload (data_type const& o) : data(o) {}
|
||||
payload (float* ptr, Index r, Index c) : data(ptr,r,c) {}
|
||||
payload (float* ptr, Index r, Index c, stride_type s) : data(ptr,r,c,s) {}
|
||||
};
|
||||
payload(data_type const& o) : data(o) {}
|
||||
|
||||
payload(float* ptr, Index r, Index c) : data(ptr, r, c) {}
|
||||
|
||||
payload(float* ptr, Index r, Index c, stride_type s) : data(ptr, r, c, s) {}
|
||||
};
|
||||
|
||||
struct map_const_impl64_col::payload
|
||||
{
|
||||
using stride_type = Eigen::Stride<Eigen::Dynamic,Eigen::Dynamic>;
|
||||
using base_type = Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic,Eigen::ColMajor>;
|
||||
using data_type = Eigen::Map<base_type const,Eigen::Unaligned,stride_type>;
|
||||
using stride_type = Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>;
|
||||
using base_type =
|
||||
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>;
|
||||
using data_type =
|
||||
Eigen::Map<base_type const, Eigen::Unaligned, stride_type>;
|
||||
|
||||
data_type data;
|
||||
|
||||
payload (data_type const& o) : data(o) {}
|
||||
payload (double const* ptr, Index r, Index c) : data(ptr,r,c) {}
|
||||
payload (double const* ptr, Index r, Index c, stride_type s) : data(ptr,r,c,s) {}
|
||||
payload(data_type const& o) : data(o) {}
|
||||
|
||||
payload(double const* ptr, Index r, Index c) : data(ptr, r, c) {}
|
||||
|
||||
payload(double const* ptr, Index r, Index c, stride_type s)
|
||||
: data(ptr, r, c, s)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct map_const_impl64_row::payload
|
||||
{
|
||||
using stride_type = Eigen::Stride<Eigen::Dynamic,Eigen::Dynamic>;
|
||||
using base_type = Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic,Eigen::RowMajor>;
|
||||
using data_type = Eigen::Map<base_type const,Eigen::Unaligned,stride_type>;
|
||||
using stride_type = Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>;
|
||||
using base_type =
|
||||
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
|
||||
using data_type =
|
||||
Eigen::Map<base_type const, Eigen::Unaligned, stride_type>;
|
||||
|
||||
data_type data;
|
||||
|
||||
payload (data_type const& o) : data(o) {}
|
||||
payload (double const* ptr, Index r, Index c) : data(ptr,r,c) {}
|
||||
payload (double const* ptr, Index r, Index c, stride_type s) : data(ptr,r,c,s) {}
|
||||
payload(data_type const& o) : data(o) {}
|
||||
|
||||
payload(double const* ptr, Index r, Index c) : data(ptr, r, c) {}
|
||||
|
||||
payload(double const* ptr, Index r, Index c, stride_type s)
|
||||
: data(ptr, r, c, s)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct map_impl64_col::payload
|
||||
{
|
||||
using stride_type = Eigen::Stride<Eigen::Dynamic,Eigen::Dynamic>;
|
||||
using base_type = Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic,Eigen::ColMajor>;
|
||||
using data_type = Eigen::Map<base_type,Eigen::Unaligned,stride_type>;
|
||||
using stride_type = Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>;
|
||||
using base_type =
|
||||
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>;
|
||||
using data_type = Eigen::Map<base_type, Eigen::Unaligned, stride_type>;
|
||||
|
||||
data_type data;
|
||||
|
||||
payload (data_type const& o) : data(o) {}
|
||||
payload (double* ptr, Index r, Index c) : data(ptr,r,c) {}
|
||||
payload (double* ptr, Index r, Index c, stride_type s) : data(ptr,r,c,s) {}
|
||||
payload(data_type const& o) : data(o) {}
|
||||
|
||||
payload(double* ptr, Index r, Index c) : data(ptr, r, c) {}
|
||||
|
||||
payload(double* ptr, Index r, Index c, stride_type s) : data(ptr, r, c, s)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct map_impl64_row::payload
|
||||
{
|
||||
using stride_type = Eigen::Stride<Eigen::Dynamic,Eigen::Dynamic>;
|
||||
using base_type = Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic,Eigen::RowMajor>;
|
||||
using data_type = Eigen::Map<base_type,Eigen::Unaligned,stride_type>;
|
||||
using stride_type = Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic>;
|
||||
using base_type =
|
||||
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
|
||||
using data_type = Eigen::Map<base_type, Eigen::Unaligned, stride_type>;
|
||||
|
||||
data_type data;
|
||||
|
||||
payload (data_type const& o) : data(o) {}
|
||||
payload (double* ptr, Index r, Index c) : data(ptr,r,c) {}
|
||||
payload (double* ptr, Index r, Index c, stride_type s) : data(ptr,r,c,s) {}
|
||||
payload(data_type const& o) : data(o) {}
|
||||
|
||||
payload(double* ptr, Index r, Index c) : data(ptr, r, c) {}
|
||||
|
||||
payload(double* ptr, Index r, Index c, stride_type s) : data(ptr, r, c, s)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
struct ioformat::payload
|
||||
struct ioformat::payload
|
||||
{
|
||||
Eigen::IOFormat instance;
|
||||
|
||||
payload ( int p, int f
|
||||
, std::string const& cs, std::string const& rsp
|
||||
, std::string const& rp, std::string const& rs
|
||||
, std::string const& mp, std::string const& ms
|
||||
, char fill
|
||||
)
|
||||
: instance(p,f,cs,rsp,rp,rs,mp,ms,fill)
|
||||
{}
|
||||
payload(int p,
|
||||
int f,
|
||||
std::string const& cs,
|
||||
std::string const& rsp,
|
||||
std::string const& rp,
|
||||
std::string const& rs,
|
||||
std::string const& mp,
|
||||
std::string const& ms,
|
||||
char fill)
|
||||
: instance(p, f, cs, rsp, rp, rs, mp, ms, fill)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -11,4 +11,4 @@
|
|||
#include <rotgen/format/dynamic.hpp>
|
||||
#else
|
||||
#include <rotgen/format/fixed.hpp>
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -15,36 +15,36 @@ namespace rotgen
|
|||
{
|
||||
class ROTGEN_EXPORT ioformat
|
||||
{
|
||||
private:
|
||||
private:
|
||||
struct payload;
|
||||
std::unique_ptr<payload> storage_;
|
||||
|
||||
public:
|
||||
ioformat( int precision, int flags = 0
|
||||
, std::string const& coeffSeparator = " "
|
||||
, std::string const& rowSeparator = "\n"
|
||||
, std::string const& rowPrefix = "", std::string const& rowSuffix = ""
|
||||
, std::string const& matPrefix = "", std::string const& matSuffix = ""
|
||||
, char fill = ' '
|
||||
);
|
||||
|
||||
public:
|
||||
ioformat(int precision,
|
||||
int flags = 0,
|
||||
std::string const& coeffSeparator = " ",
|
||||
std::string const& rowSeparator = "\n",
|
||||
std::string const& rowPrefix = "",
|
||||
std::string const& rowSuffix = "",
|
||||
std::string const& matPrefix = "",
|
||||
std::string const& matSuffix = "",
|
||||
char fill = ' ');
|
||||
|
||||
~ioformat();
|
||||
|
||||
std::unique_ptr<payload> const& storage() const { return storage_; }
|
||||
};
|
||||
|
||||
template <typename M>
|
||||
struct format
|
||||
template<typename M> struct format
|
||||
{
|
||||
format(const M& m, const ioformat& f) : matrix_(m), format_(f) {}
|
||||
format(M const& m, ioformat const& f) : matrix_(m), format_(f) {}
|
||||
|
||||
M const& matrix_;
|
||||
ioformat const& format_;
|
||||
M const& matrix_;
|
||||
ioformat const& format_;
|
||||
};
|
||||
|
||||
template <typename M>
|
||||
std::ostream& operator<<(std::ostream& os, const format<M>& f)
|
||||
template<typename M>
|
||||
std::ostream& operator<<(std::ostream& os, format<M> const& f)
|
||||
{
|
||||
return os << format{f.matrix_.base(), f.format_};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,19 +17,19 @@ namespace rotgen
|
|||
{
|
||||
using ioformat = Eigen::IOFormat;
|
||||
|
||||
template <typename M>
|
||||
struct format
|
||||
template<typename M> struct format
|
||||
{
|
||||
format(const M& m, const ioformat& f) : matrix_(m), format_(f) {}
|
||||
format(M const& m, ioformat const& f) : matrix_(m), format_(f) {}
|
||||
|
||||
M const& matrix_;
|
||||
ioformat const& format_;
|
||||
M const& matrix_;
|
||||
ioformat const& format_;
|
||||
};
|
||||
|
||||
template <typename M>
|
||||
std::ostream& operator<<(std::ostream& os, const format<M>& f)
|
||||
template<typename M>
|
||||
std::ostream& operator<<(std::ostream& os, format<M> const& f)
|
||||
{
|
||||
if constexpr(concepts::eigen_compatible<M>) return os << f.matrix_.format(f.format_);
|
||||
else return os << f.matrix_.base().format(f.format_);
|
||||
if constexpr (concepts::eigen_compatible<M>)
|
||||
return os << f.matrix_.format(f.format_);
|
||||
else return os << f.matrix_.base().format(f.format_);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@
|
|||
#include <rotgen/functions/extract.hpp>
|
||||
#include <rotgen/functions/functions.hpp>
|
||||
#include <rotgen/functions/operators.hpp>
|
||||
#include <rotgen/functions/reshaper.hpp>
|
||||
#include <rotgen/functions/reshaper.hpp>
|
||||
|
|
|
|||
|
|
@ -13,10 +13,11 @@ namespace rotgen
|
|||
namespace detail
|
||||
{
|
||||
template<concepts::entity Entity>
|
||||
void validate_extract ( [[maybe_unused]] Entity& e
|
||||
, [[maybe_unused]] Index i0, [[maybe_unused]] Index j0
|
||||
, [[maybe_unused]] Index ni, [[maybe_unused]] Index nj
|
||||
)
|
||||
void validate_extract([[maybe_unused]] Entity& e,
|
||||
[[maybe_unused]] Index i0,
|
||||
[[maybe_unused]] Index j0,
|
||||
[[maybe_unused]] Index ni,
|
||||
[[maybe_unused]] Index nj)
|
||||
{
|
||||
assert(i0 >= 0 && "block extraction uses negative row index.");
|
||||
assert(j0 >= 0 && "block extraction uses negative col index.");
|
||||
|
|
@ -24,37 +25,36 @@ namespace rotgen
|
|||
assert(j0 + nj <= e.cols() && "block extraction cols is out of range.");
|
||||
}
|
||||
}
|
||||
|
||||
//======================== EXTRACT ========================
|
||||
template<concepts::entity Entity>
|
||||
auto extract(Entity& e, Index i0, Index j0, Index ni, Index nj)
|
||||
{
|
||||
detail::validate_extract(e,i0,j0,ni,nj);
|
||||
if constexpr(concepts::reference<Entity>)
|
||||
detail::validate_extract(e, i0, j0, ni, nj);
|
||||
if constexpr (concepts::reference<Entity>)
|
||||
return extract(e.base(), i0, j0, ni, nj);
|
||||
else
|
||||
return block<detail::propagate_const<Entity>>(e, i0, j0, ni, nj);
|
||||
else return block<detail::propagate_const<Entity>>(e, i0, j0, ni, nj);
|
||||
}
|
||||
|
||||
template<Index NI, Index NJ, concepts::entity Entity>
|
||||
requires(NI!=-1 && NJ!=-1)
|
||||
requires(NI != -1 && NJ != -1)
|
||||
auto extract(Entity& e, Index i0, Index j0)
|
||||
{
|
||||
detail::validate_extract(e,i0,j0,NI,NJ);
|
||||
if constexpr(concepts::reference<Entity>)
|
||||
return extract<NI,NJ>(e.base(), i0, j0);
|
||||
else
|
||||
return block<detail::propagate_const<Entity> ,NI,NJ>(e, i0, j0);
|
||||
detail::validate_extract(e, i0, j0, NI, NJ);
|
||||
if constexpr (concepts::reference<Entity>)
|
||||
return extract<NI, NJ>(e.base(), i0, j0);
|
||||
else return block<detail::propagate_const<Entity>, NI, NJ>(e, i0, j0);
|
||||
}
|
||||
|
||||
template<Index NI, Index NJ, concepts::entity Entity>
|
||||
requires((NI!=-1) != (NJ!=-1))
|
||||
requires((NI != -1) != (NJ != -1))
|
||||
auto extract(Entity& e, Index i0, Index j0, Index ni, Index nj)
|
||||
{
|
||||
detail::validate_extract(e,i0,j0,ni,nj);
|
||||
if constexpr(concepts::reference<Entity>)
|
||||
return extract<NI,NJ>(e.base(), i0, j0, ni, nj);
|
||||
detail::validate_extract(e, i0, j0, ni, nj);
|
||||
if constexpr (concepts::reference<Entity>)
|
||||
return extract<NI, NJ>(e.base(), i0, j0, ni, nj);
|
||||
else
|
||||
return block<detail::propagate_const<Entity>,NI,NJ>(e, i0, j0, ni, nj);
|
||||
return block<detail::propagate_const<Entity>, NI, NJ>(e, i0, j0, ni, nj);
|
||||
}
|
||||
|
||||
//======================== TOP LEFT CORNER ========================
|
||||
|
|
@ -67,7 +67,7 @@ namespace rotgen
|
|||
template<Index NI, Index NJ, concepts::entity Entity>
|
||||
auto topLeftCorner(Entity& e)
|
||||
{
|
||||
return extract<NI,NJ>(e, 0, 0);
|
||||
return extract<NI, NJ>(e, 0, 0);
|
||||
}
|
||||
|
||||
//======================== TOP RIGHT CORNER ========================
|
||||
|
|
@ -80,7 +80,7 @@ namespace rotgen
|
|||
template<Index NI, Index NJ, concepts::entity Entity>
|
||||
auto topRightCorner(Entity& e)
|
||||
{
|
||||
return extract<NI,NJ>(e, 0, e.cols()-NJ);
|
||||
return extract<NI, NJ>(e, 0, e.cols() - NJ);
|
||||
}
|
||||
|
||||
//======================== BOTTOM LEFT CORNER ========================
|
||||
|
|
@ -93,7 +93,7 @@ namespace rotgen
|
|||
template<Index NI, Index NJ, concepts::entity Entity>
|
||||
auto bottomLeftCorner(Entity& e)
|
||||
{
|
||||
return extract<NI,NJ>(e, e.rows()-NI, 0);
|
||||
return extract<NI, NJ>(e, e.rows() - NI, 0);
|
||||
}
|
||||
|
||||
//======================== BOTTOM RIGHT CORNER ========================
|
||||
|
|
@ -106,20 +106,18 @@ namespace rotgen
|
|||
template<Index NI, Index NJ, concepts::entity Entity>
|
||||
auto bottomRightCorner(Entity& e)
|
||||
{
|
||||
return extract<NI,NJ>(e, e.rows()-NI, e.cols()-NJ);
|
||||
return extract<NI, NJ>(e, e.rows() - NI, e.cols() - NJ);
|
||||
}
|
||||
|
||||
//======================== TOP ROWS ========================
|
||||
template<concepts::entity Entity>
|
||||
auto topRows(Entity& e, Index ni)
|
||||
template<concepts::entity Entity> auto topRows(Entity& e, Index ni)
|
||||
{
|
||||
return extract(e, 0, 0, ni, e.cols());
|
||||
}
|
||||
|
||||
template<Index NI, concepts::entity Entity>
|
||||
auto topRows(Entity& e)
|
||||
template<Index NI, concepts::entity Entity> auto topRows(Entity& e)
|
||||
{
|
||||
return extract<NI,-1>(e, 0, 0, NI,e.cols());
|
||||
return extract<NI, -1>(e, 0, 0, NI, e.cols());
|
||||
}
|
||||
|
||||
//======================== MIDDLE ROWS ========================
|
||||
|
|
@ -132,33 +130,29 @@ namespace rotgen
|
|||
template<Index NI, concepts::entity Entity>
|
||||
auto middleRows(Entity& e, Index i0)
|
||||
{
|
||||
return extract<NI,-1>(e, i0, 0,NI,e.cols());
|
||||
return extract<NI, -1>(e, i0, 0, NI, e.cols());
|
||||
}
|
||||
|
||||
//======================== BOTTOM ROWS ========================
|
||||
template<concepts::entity Entity>
|
||||
auto bottomRows(Entity& e, Index ni)
|
||||
template<concepts::entity Entity> auto bottomRows(Entity& e, Index ni)
|
||||
{
|
||||
return extract(e, e.rows() - ni, 0, ni, e.cols());
|
||||
}
|
||||
|
||||
template<Index NI, concepts::entity Entity>
|
||||
auto bottomRows(Entity& e)
|
||||
template<Index NI, concepts::entity Entity> auto bottomRows(Entity& e)
|
||||
{
|
||||
return extract<NI,-1>(e, e.rows()-NI, 0,NI,e.cols());
|
||||
return extract<NI, -1>(e, e.rows() - NI, 0, NI, e.cols());
|
||||
}
|
||||
|
||||
//======================== LEFT COLS ========================
|
||||
template<concepts::entity Entity>
|
||||
auto leftCols(Entity& e, Index nj)
|
||||
template<concepts::entity Entity> auto leftCols(Entity& e, Index nj)
|
||||
{
|
||||
return extract(e, 0, 0, e.rows(), nj);
|
||||
}
|
||||
|
||||
template<Index NJ, concepts::entity Entity>
|
||||
auto leftCols(Entity& e)
|
||||
template<Index NJ, concepts::entity Entity> auto leftCols(Entity& e)
|
||||
{
|
||||
return extract<-1,NJ>(e, 0, 0,e.rows(),NJ);
|
||||
return extract<-1, NJ>(e, 0, 0, e.rows(), NJ);
|
||||
}
|
||||
|
||||
//======================== MIDDLE COLS ========================
|
||||
|
|
@ -171,81 +165,90 @@ namespace rotgen
|
|||
template<Index NJ, concepts::entity Entity>
|
||||
auto middleCols(Entity& e, Index j0)
|
||||
{
|
||||
return extract<-1,NJ>(e, 0, j0,e.rows(),NJ);
|
||||
return extract<-1, NJ>(e, 0, j0, e.rows(), NJ);
|
||||
}
|
||||
|
||||
//======================== RIGHT COLS ========================
|
||||
template<concepts::entity Entity>
|
||||
auto rightCols(Entity& e, Index nj)
|
||||
template<concepts::entity Entity> auto rightCols(Entity& e, Index nj)
|
||||
{
|
||||
return extract(e, 0, e.cols() - nj, e.rows(), nj);
|
||||
}
|
||||
|
||||
template<Index NJ, concepts::entity Entity>
|
||||
auto rightCols(Entity& e)
|
||||
template<Index NJ, concepts::entity Entity> auto rightCols(Entity& e)
|
||||
{
|
||||
return extract<-1,NJ>(e, 0, e.cols()-NJ,e.rows(),NJ);
|
||||
return extract<-1, NJ>(e, 0, e.cols() - NJ, e.rows(), NJ);
|
||||
}
|
||||
|
||||
//======================== ROW ========================
|
||||
template<concepts::entity Entity>
|
||||
auto row(Entity& e, Index i0)
|
||||
template<concepts::entity Entity> auto row(Entity& e, Index i0)
|
||||
{
|
||||
return extract<1,-1>(e, i0, 0, 1, e.cols());
|
||||
return extract<1, -1>(e, i0, 0, 1, e.cols());
|
||||
}
|
||||
|
||||
//======================== COL ========================
|
||||
template<concepts::entity Entity>
|
||||
auto col(Entity& e, Index j0)
|
||||
template<concepts::entity Entity> auto col(Entity& e, Index j0)
|
||||
{
|
||||
return extract<-1,1>(e, 0, j0, e.rows(), 1);
|
||||
return extract<-1, 1>(e, 0, j0, e.rows(), 1);
|
||||
}
|
||||
|
||||
//======================== VECTOR HEAD ========================
|
||||
template<concepts::entity Entity>
|
||||
auto head(Entity& e, Index n)
|
||||
requires(Entity::RowsAtCompileTime==1 || Entity::ColsAtCompileTime==1)
|
||||
requires(Entity::RowsAtCompileTime == 1 || Entity::ColsAtCompileTime == 1)
|
||||
{
|
||||
if constexpr(Entity::RowsAtCompileTime==1) return extract<1,Dynamic>(e,0,0,1,n);
|
||||
else if constexpr(Entity::ColsAtCompileTime==1) return extract<Dynamic,1>(e,0,0,n,1);
|
||||
if constexpr (Entity::RowsAtCompileTime == 1)
|
||||
return extract<1, Dynamic>(e, 0, 0, 1, n);
|
||||
else if constexpr (Entity::ColsAtCompileTime == 1)
|
||||
return extract<Dynamic, 1>(e, 0, 0, n, 1);
|
||||
}
|
||||
|
||||
template<Index N, concepts::entity Entity>
|
||||
auto head(Entity& e) requires(Entity::RowsAtCompileTime==1 || Entity::ColsAtCompileTime==1)
|
||||
auto head(Entity& e)
|
||||
requires(Entity::RowsAtCompileTime == 1 || Entity::ColsAtCompileTime == 1)
|
||||
{
|
||||
if constexpr(Entity::RowsAtCompileTime==1) return extract<1,N>(e,0,0);
|
||||
else if constexpr(Entity::ColsAtCompileTime==1) return extract<N,1>(e,0,0);
|
||||
if constexpr (Entity::RowsAtCompileTime == 1) return extract<1, N>(e, 0, 0);
|
||||
else if constexpr (Entity::ColsAtCompileTime == 1)
|
||||
return extract<N, 1>(e, 0, 0);
|
||||
}
|
||||
|
||||
//======================== VECTOR TAIL ========================
|
||||
template<concepts::entity Entity>
|
||||
auto tail(Entity& e, Index n)
|
||||
requires(Entity::RowsAtCompileTime==1 || Entity::ColsAtCompileTime==1)
|
||||
requires(Entity::RowsAtCompileTime == 1 || Entity::ColsAtCompileTime == 1)
|
||||
{
|
||||
if constexpr(Entity::RowsAtCompileTime==1) return extract<1,Dynamic>(e,0,e.cols()-n,1,n);
|
||||
else if constexpr(Entity::ColsAtCompileTime==1) return extract<Dynamic,1>(e,e.rows()-n,0,n,1);
|
||||
if constexpr (Entity::RowsAtCompileTime == 1)
|
||||
return extract<1, Dynamic>(e, 0, e.cols() - n, 1, n);
|
||||
else if constexpr (Entity::ColsAtCompileTime == 1)
|
||||
return extract<Dynamic, 1>(e, e.rows() - n, 0, n, 1);
|
||||
}
|
||||
|
||||
template<Index N, concepts::entity Entity>
|
||||
auto tail(Entity& e) requires(Entity::RowsAtCompileTime==1 || Entity::ColsAtCompileTime==1)
|
||||
auto tail(Entity& e)
|
||||
requires(Entity::RowsAtCompileTime == 1 || Entity::ColsAtCompileTime == 1)
|
||||
{
|
||||
if constexpr(Entity::RowsAtCompileTime==1) return extract<1,N>(e,0,e.cols()-N);
|
||||
else if constexpr(Entity::ColsAtCompileTime==1) return extract<N,1>(e,e.rows()-N,0);
|
||||
if constexpr (Entity::RowsAtCompileTime == 1)
|
||||
return extract<1, N>(e, 0, e.cols() - N);
|
||||
else if constexpr (Entity::ColsAtCompileTime == 1)
|
||||
return extract<N, 1>(e, e.rows() - N, 0);
|
||||
}
|
||||
|
||||
//======================== VECTOR SEGMENT ========================
|
||||
template<concepts::entity Entity>
|
||||
auto segment(Entity& e, Index s, Index n)
|
||||
requires(Entity::RowsAtCompileTime==1 || Entity::ColsAtCompileTime==1)
|
||||
requires(Entity::RowsAtCompileTime == 1 || Entity::ColsAtCompileTime == 1)
|
||||
{
|
||||
if constexpr(Entity::RowsAtCompileTime==1) return extract<1,Dynamic>(e,0,s,1,n);
|
||||
else if constexpr(Entity::ColsAtCompileTime==1) return extract<Dynamic,1>(e,s,0,n,1);
|
||||
if constexpr (Entity::RowsAtCompileTime == 1)
|
||||
return extract<1, Dynamic>(e, 0, s, 1, n);
|
||||
else if constexpr (Entity::ColsAtCompileTime == 1)
|
||||
return extract<Dynamic, 1>(e, s, 0, n, 1);
|
||||
}
|
||||
|
||||
template<Index N, concepts::entity Entity>
|
||||
auto segment(Entity& e, Index s) requires(Entity::RowsAtCompileTime==1 || Entity::ColsAtCompileTime==1)
|
||||
auto segment(Entity& e, Index s)
|
||||
requires(Entity::RowsAtCompileTime == 1 || Entity::ColsAtCompileTime == 1)
|
||||
{
|
||||
if constexpr(Entity::RowsAtCompileTime==1) return extract<1,N>(e,0,s);
|
||||
else if constexpr(Entity::ColsAtCompileTime==1) return extract<N,1>(e,s,0);
|
||||
if constexpr (Entity::RowsAtCompileTime == 1) return extract<1, N>(e, 0, s);
|
||||
else if constexpr (Entity::ColsAtCompileTime == 1)
|
||||
return extract<N, 1>(e, s, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,19 +14,44 @@ namespace rotgen
|
|||
//-----------------------------------------------------------------------------------------------
|
||||
// Infos & Shape
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
std::size_t rows(auto const& m) requires(requires{ m.rows(); }){ return m.rows(); }
|
||||
std::size_t cols(auto const& m) requires(requires{ m.cols(); }){ return m.cols(); }
|
||||
std::size_t size(auto const& m) requires(requires{ m.size(); }){ return m.size(); }
|
||||
std::size_t rows(auto const& m)
|
||||
requires(requires { m.rows(); })
|
||||
{
|
||||
return m.rows();
|
||||
}
|
||||
|
||||
void resize(auto& a, int s) requires requires{a.resize(s);} { a.resize(s); }
|
||||
void resize(auto& a, int r, int c) requires requires{a.resize(r,c);} { a.resize(r,c); }
|
||||
std::size_t cols(auto const& m)
|
||||
requires(requires { m.cols(); })
|
||||
{
|
||||
return m.cols();
|
||||
}
|
||||
|
||||
void conservativeResize(auto& a, int s) requires requires{a.conservativeResize(s);}
|
||||
std::size_t size(auto const& m)
|
||||
requires(requires { m.size(); })
|
||||
{
|
||||
return m.size();
|
||||
}
|
||||
|
||||
void resize(auto& a, int s)
|
||||
requires requires { a.resize(s); }
|
||||
{
|
||||
a.resize(s);
|
||||
}
|
||||
|
||||
void resize(auto& a, int r, int c)
|
||||
requires requires { a.resize(r, c); }
|
||||
{
|
||||
a.resize(r, c);
|
||||
}
|
||||
|
||||
void conservativeResize(auto& a, int s)
|
||||
requires requires { a.conservativeResize(s); }
|
||||
{
|
||||
a.conservativeResize(s);
|
||||
}
|
||||
|
||||
void conservativeResize(auto& a, int r, int c) requires requires{a.conservativeResize(r,c);}
|
||||
void conservativeResize(auto& a, int r, int c)
|
||||
requires requires { a.conservativeResize(r, c); }
|
||||
{
|
||||
a.conservativeResize(r, c);
|
||||
}
|
||||
|
|
@ -34,70 +59,129 @@ namespace rotgen
|
|||
//-----------------------------------------------------------------------------------------------
|
||||
// Global operations
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
decltype(auto) normalized (auto const& m) requires(requires{ m.normalized(); }) { return m.normalized(); }
|
||||
decltype(auto) transpose (auto const& m) requires(requires{ m.transpose(); }) { return m.transpose(); }
|
||||
decltype(auto) conjugate (auto const& m) requires(requires{ m.conjugate(); }) { return m.conjugate(); }
|
||||
decltype(auto) adjoint (auto const& m) requires(requires{ m.adjoint(); }) { return m.adjoint(); }
|
||||
decltype(auto) normalized(auto const& m)
|
||||
requires(requires { m.normalized(); })
|
||||
{
|
||||
return m.normalized();
|
||||
}
|
||||
|
||||
void normalize(auto& a) requires(requires{ a.normalize(); }) { a.normalize(); }
|
||||
void transposeInPlace(auto& a) requires(requires{ a.transposeInPlace(); }) { a.transposeInPlace(); }
|
||||
void adjointInPlace(auto& a) requires(requires{ a.adjointInPlace(); }) { a.adjointInPlace(); }
|
||||
decltype(auto) transpose(auto const& m)
|
||||
requires(requires { m.transpose(); })
|
||||
{
|
||||
return m.transpose();
|
||||
}
|
||||
|
||||
decltype(auto) conjugate(auto const& m)
|
||||
requires(requires { m.conjugate(); })
|
||||
{
|
||||
return m.conjugate();
|
||||
}
|
||||
|
||||
decltype(auto) adjoint(auto const& m)
|
||||
requires(requires { m.adjoint(); })
|
||||
{
|
||||
return m.adjoint();
|
||||
}
|
||||
|
||||
void normalize(auto& a)
|
||||
requires(requires { a.normalize(); })
|
||||
{
|
||||
a.normalize();
|
||||
}
|
||||
|
||||
void transposeInPlace(auto& a)
|
||||
requires(requires { a.transposeInPlace(); })
|
||||
{
|
||||
a.transposeInPlace();
|
||||
}
|
||||
|
||||
void adjointInPlace(auto& a)
|
||||
requires(requires { a.adjointInPlace(); })
|
||||
{
|
||||
a.adjointInPlace();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
// Component-wise functions
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
auto abs (auto const& arg) requires(requires{arg.cwiseAbs();} ) { return arg.cwiseAbs(); }
|
||||
auto abs2(auto const& arg) requires(requires{arg.cwiseAbs2();} ) { return arg.cwiseAbs2(); }
|
||||
auto rec (auto const& arg) requires(requires{arg.cwiseInverse();}) { return arg.cwiseInverse(); }
|
||||
auto sqrt(auto const& arg) requires(requires{arg.cwiseSqrt();} ) { return arg.cwiseSqrt(); }
|
||||
auto abs(auto const& arg)
|
||||
requires(requires { arg.cwiseAbs(); })
|
||||
{
|
||||
return arg.cwiseAbs();
|
||||
}
|
||||
|
||||
auto abs2(auto const& arg)
|
||||
requires(requires { arg.cwiseAbs2(); })
|
||||
{
|
||||
return arg.cwiseAbs2();
|
||||
}
|
||||
|
||||
auto rec(auto const& arg)
|
||||
requires(requires { arg.cwiseInverse(); })
|
||||
{
|
||||
return arg.cwiseInverse();
|
||||
}
|
||||
|
||||
auto sqrt(auto const& arg)
|
||||
requires(requires { arg.cwiseSqrt(); })
|
||||
{
|
||||
return arg.cwiseSqrt();
|
||||
}
|
||||
|
||||
template<concepts::entity A, concepts::entity B>
|
||||
auto min(A const& a, B const& b)
|
||||
{
|
||||
if constexpr(!use_expression_templates) return min(generalize_t<A const>(a), generalize_t<B const>(b));
|
||||
else return base_of(a).cwiseMin(base_of(b));
|
||||
if constexpr (!use_expression_templates)
|
||||
return min(generalize_t<A const>(a), generalize_t<B const>(b));
|
||||
else return base_of(a).cwiseMin(base_of(b));
|
||||
}
|
||||
|
||||
template<concepts::entity A>
|
||||
auto min(A const& a, std::convertible_to<typename A::value_type> auto b)
|
||||
{
|
||||
if constexpr(!use_expression_templates) return min(generalize_t<A const>(a), b);
|
||||
else return base_of(a).cwiseMin(b);
|
||||
if constexpr (!use_expression_templates)
|
||||
return min(generalize_t<A const>(a), b);
|
||||
else return base_of(a).cwiseMin(b);
|
||||
}
|
||||
|
||||
template<concepts::entity B>
|
||||
auto min(std::convertible_to<typename B::value_type> auto a, B const& b)
|
||||
{
|
||||
if constexpr(!use_expression_templates) return min(a,generalize_t<B const>(b));
|
||||
else return base_of(b).cwiseMin(a);
|
||||
if constexpr (!use_expression_templates)
|
||||
return min(a, generalize_t<B const>(b));
|
||||
else return base_of(b).cwiseMin(a);
|
||||
}
|
||||
|
||||
template<concepts::entity A, concepts::entity B>
|
||||
auto max(A const& a, B const& b)
|
||||
{
|
||||
if constexpr(!use_expression_templates) return max(generalize_t<A const>(a), generalize_t<B const>(b));
|
||||
else return base_of(a).cwiseMax(base_of(b));
|
||||
if constexpr (!use_expression_templates)
|
||||
return max(generalize_t<A const>(a), generalize_t<B const>(b));
|
||||
else return base_of(a).cwiseMax(base_of(b));
|
||||
}
|
||||
|
||||
template<concepts::entity A>
|
||||
auto max(A const& a, std::convertible_to<typename A::value_type> auto b)
|
||||
{
|
||||
if constexpr(!use_expression_templates) return max(generalize_t<A const>(a), b);
|
||||
else return base_of(a).cwiseMax(b);
|
||||
if constexpr (!use_expression_templates)
|
||||
return max(generalize_t<A const>(a), b);
|
||||
else return base_of(a).cwiseMax(b);
|
||||
}
|
||||
|
||||
template<concepts::entity B>
|
||||
auto max(std::convertible_to<typename B::value_type> auto a, B const& b)
|
||||
{
|
||||
if constexpr(!use_expression_templates) return max(a, generalize_t<B const>(b));
|
||||
else return base_of(b).cwiseMax(a);
|
||||
if constexpr (!use_expression_templates)
|
||||
return max(a, generalize_t<B const>(b));
|
||||
else return base_of(b).cwiseMax(a);
|
||||
}
|
||||
|
||||
template<concepts::entity A, concepts::entity B>
|
||||
auto mul(A const& a, B const& b)
|
||||
{
|
||||
if constexpr(!use_expression_templates) return mul(generalize_t<A const>(a), generalize_t<B const>(b));
|
||||
else return base_of(a).cwiseProduct(base_of(b));
|
||||
if constexpr (!use_expression_templates)
|
||||
return mul(generalize_t<A const>(a), generalize_t<B const>(b));
|
||||
else return base_of(a).cwiseProduct(base_of(b));
|
||||
}
|
||||
|
||||
template<concepts::entity A>
|
||||
|
|
@ -115,8 +199,9 @@ namespace rotgen
|
|||
template<concepts::entity A, concepts::entity B>
|
||||
auto div(A const& a, B const& b)
|
||||
{
|
||||
if constexpr(!use_expression_templates) return div(generalize_t<A const>(a), generalize_t<B const>(b));
|
||||
else return base_of(a).array() / base_of(b).array();
|
||||
if constexpr (!use_expression_templates)
|
||||
return div(generalize_t<A const>(a), generalize_t<B const>(b));
|
||||
else return base_of(a).array() / base_of(b).array();
|
||||
}
|
||||
|
||||
template<concepts::entity A>
|
||||
|
|
@ -125,47 +210,86 @@ namespace rotgen
|
|||
return a / b;
|
||||
}
|
||||
|
||||
template<concepts::entity A>
|
||||
auto square(A const& a)
|
||||
template<concepts::entity A> auto square(A const& a)
|
||||
{
|
||||
return mul(a,a);
|
||||
return mul(a, a);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
// Reductions
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
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(); }
|
||||
auto sum(auto const& arg) requires requires{ arg.sum(); } { return arg.sum(); }
|
||||
auto prod(concepts::entity auto const& arg) { return arg.prod(); }
|
||||
auto mean(concepts::entity auto const& arg) { return arg.mean(); }
|
||||
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();
|
||||
}
|
||||
|
||||
auto sum(auto const& arg)
|
||||
requires requires { arg.sum(); }
|
||||
{
|
||||
return arg.sum();
|
||||
}
|
||||
|
||||
auto prod(concepts::entity auto const& arg)
|
||||
{
|
||||
return arg.prod();
|
||||
}
|
||||
|
||||
auto mean(concepts::entity auto const& arg)
|
||||
{
|
||||
return arg.mean();
|
||||
}
|
||||
|
||||
template<concepts::entity A, concepts::entity B>
|
||||
auto dot(A const& a, B const& b)
|
||||
requires(detail::has_same_vector_size<A,B> && std::same_as<typename A::value_type, typename B::value_type>)
|
||||
requires(detail::has_same_vector_size<A, B> &&
|
||||
std::same_as<typename A::value_type, typename B::value_type>)
|
||||
{
|
||||
if constexpr(!use_expression_templates) return dot(generalize_t<A const>(a), generalize_t<B const>(b));
|
||||
else return base_of(a).dot(base_of(b));
|
||||
if constexpr (!use_expression_templates)
|
||||
return dot(generalize_t<A const>(a), generalize_t<B const>(b));
|
||||
else return base_of(a).dot(base_of(b));
|
||||
}
|
||||
|
||||
auto maxCoeff(auto const& arg) requires( requires{ arg.maxCoeff(); } ) { return arg.maxCoeff(); }
|
||||
auto minCoeff(auto const& arg) requires( requires{ arg.minCoeff(); } ) { return arg.minCoeff(); }
|
||||
auto maxCoeff(auto const& arg)
|
||||
requires(requires { arg.maxCoeff(); })
|
||||
{
|
||||
return arg.maxCoeff();
|
||||
}
|
||||
|
||||
auto minCoeff(auto const& arg)
|
||||
requires(requires { arg.minCoeff(); })
|
||||
{
|
||||
return arg.minCoeff();
|
||||
}
|
||||
|
||||
template<std::integral IndexType>
|
||||
auto maxCoeff(concepts::entity auto const& arg, IndexType* row, IndexType* col)
|
||||
auto maxCoeff(concepts::entity auto const& arg,
|
||||
IndexType* row,
|
||||
IndexType* col)
|
||||
{
|
||||
return arg.maxCoeff(row, col);
|
||||
}
|
||||
|
||||
template<std::integral IndexType>
|
||||
auto minCoeff(concepts::entity auto const& arg, IndexType* row, IndexType* col)
|
||||
auto minCoeff(concepts::entity auto const& arg,
|
||||
IndexType* row,
|
||||
IndexType* col)
|
||||
{
|
||||
return arg.minCoeff(row, col);
|
||||
}
|
||||
|
||||
template<int P, typename T>
|
||||
auto lpNorm(T const& arg) requires( requires{arg.template lpNorm<P>();} )
|
||||
auto lpNorm(T const& arg)
|
||||
requires(requires { arg.template lpNorm<P>(); })
|
||||
{
|
||||
static_assert(P == 1 || P == 2 || P == Infinity);
|
||||
return arg.template lpNorm<P>();
|
||||
|
|
@ -175,19 +299,22 @@ namespace rotgen
|
|||
// Expression handling
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
decltype(auto) noalias(T&& t) requires( requires{std::forward<T>(t).noalias();} )
|
||||
decltype(auto) noalias(T&& t)
|
||||
requires(requires { std::forward<T>(t).noalias(); })
|
||||
{
|
||||
return std::forward<T>(t).noalias();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto evaluate(T&& t) requires( requires{std::forward<T>(t).evaluate();} )
|
||||
auto evaluate(T&& t)
|
||||
requires(requires { std::forward<T>(t).evaluate(); })
|
||||
{
|
||||
return std::forward<T>(t).evaluate();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto evaluate(T&& t) requires( requires{std::forward<T>(t).eval();} )
|
||||
auto evaluate(T&& t)
|
||||
requires(requires { std::forward<T>(t).eval(); })
|
||||
{
|
||||
return std::forward<T>(t).eval();
|
||||
}
|
||||
|
|
@ -196,142 +323,168 @@ namespace rotgen
|
|||
// Generators
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
auto setZero(T&& t) requires( requires{std::forward<T>(t).setZero();} )
|
||||
auto setZero(T&& t)
|
||||
requires(requires { std::forward<T>(t).setZero(); })
|
||||
{
|
||||
return std::forward<T>(t).setZero();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setZero() requires( requires{T::Zero();} )
|
||||
auto setZero()
|
||||
requires(requires { T::Zero(); })
|
||||
{
|
||||
return T::Zero();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setZero(std::integral auto n) requires( requires{T::Zero(n);} )
|
||||
auto setZero(std::integral auto n)
|
||||
requires(requires { T::Zero(n); })
|
||||
{
|
||||
return T::Zero(n);
|
||||
return T::Zero(n);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setZero(std::integral auto r,std::integral auto c) requires( requires{T::Zero(r,c);} )
|
||||
auto setZero(std::integral auto r, std::integral auto c)
|
||||
requires(requires { T::Zero(r, c); })
|
||||
{
|
||||
return T::Zero(r,c);
|
||||
return T::Zero(r, c);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setOnes(T&& t) requires( requires{std::forward<T>(t).setOnes();} )
|
||||
auto setOnes(T&& t)
|
||||
requires(requires { std::forward<T>(t).setOnes(); })
|
||||
{
|
||||
return std::forward<T>(t).setOnes();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setOnes() requires( requires{T::Ones();} )
|
||||
auto setOnes()
|
||||
requires(requires { T::Ones(); })
|
||||
{
|
||||
return T::Ones();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setOnes(std::integral auto n) requires( requires{T::Ones(n);} )
|
||||
auto setOnes(std::integral auto n)
|
||||
requires(requires { T::Ones(n); })
|
||||
{
|
||||
return T::Ones(n);
|
||||
return T::Ones(n);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setOnes(std::integral auto r,std::integral auto c) requires( requires{T::Ones(r,c);} )
|
||||
auto setOnes(std::integral auto r, std::integral auto c)
|
||||
requires(requires { T::Ones(r, c); })
|
||||
{
|
||||
return T::Ones(r,c);
|
||||
return T::Ones(r, c);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setIdentity(T&& t) requires( requires{std::forward<T>(t).setIdentity();} )
|
||||
auto setIdentity(T&& t)
|
||||
requires(requires { std::forward<T>(t).setIdentity(); })
|
||||
{
|
||||
return std::forward<T>(t).setIdentity();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setIdentity() requires( requires{T::Identity();} )
|
||||
auto setIdentity()
|
||||
requires(requires { T::Identity(); })
|
||||
{
|
||||
return T::Identity();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setIdentity(std::integral auto n) requires( requires{T::Identity(n);} )
|
||||
auto setIdentity(std::integral auto n)
|
||||
requires(requires { T::Identity(n); })
|
||||
{
|
||||
return T::Identity(n);
|
||||
return T::Identity(n);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setIdentity(std::integral auto r,std::integral auto c) requires( requires{T::Identity(r,c);} )
|
||||
auto setIdentity(std::integral auto r, std::integral auto c)
|
||||
requires(requires { T::Identity(r, c); })
|
||||
{
|
||||
return T::Identity(r,c);
|
||||
return T::Identity(r, c);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setRandom(T&& t) requires( requires{std::forward<T>(t).setRandom();} )
|
||||
auto setRandom(T&& t)
|
||||
requires(requires { std::forward<T>(t).setRandom(); })
|
||||
{
|
||||
return std::forward<T>(t).setRandom();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setRandom() requires( requires{T::Random();} )
|
||||
auto setRandom()
|
||||
requires(requires { T::Random(); })
|
||||
{
|
||||
return T::Random();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setRandom(std::integral auto n) requires( requires{T::Random(n);} )
|
||||
auto setRandom(std::integral auto n)
|
||||
requires(requires { T::Random(n); })
|
||||
{
|
||||
return T::Random(n);
|
||||
return T::Random(n);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setRandom(std::integral auto r,std::integral auto c) requires( requires{T::Random(r,c);} )
|
||||
auto setRandom(std::integral auto r, std::integral auto c)
|
||||
requires(requires { T::Random(r, c); })
|
||||
{
|
||||
return T::Random(r,c);
|
||||
return T::Random(r, c);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setConstant(T&& t, auto v) requires( requires{std::forward<T>(t).setConstant(v);} )
|
||||
auto setConstant(T&& t, auto v)
|
||||
requires(requires { std::forward<T>(t).setConstant(v); })
|
||||
{
|
||||
return std::forward<T>(t).setConstant(v);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setConstant(auto v) requires( requires{T::Constant(v);} )
|
||||
auto setConstant(auto v)
|
||||
requires(requires { T::Constant(v); })
|
||||
{
|
||||
return T::Constant(v);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setConstant(std::integral auto n, auto v) requires( requires{T::Constant(n,v);} )
|
||||
auto setConstant(std::integral auto n, auto v)
|
||||
requires(requires { T::Constant(n, v); })
|
||||
{
|
||||
return T::Constant(n,v);
|
||||
return T::Constant(n, v);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
auto setConstant(std::integral auto r,std::integral auto c, auto v) requires( requires{T::Constant(r,c,v);} )
|
||||
auto setConstant(std::integral auto r, std::integral auto c, auto v)
|
||||
requires(requires { T::Constant(r, c, v); })
|
||||
{
|
||||
return T::Constant(r,c,v);
|
||||
return T::Constant(r, c, v);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
// Others
|
||||
// TODO: Adapt other functions ot behave as inverse and limit code in non-ref/non-map containers
|
||||
// TODO: Adapt other functions ot behave as inverse and limit code in
|
||||
// non-ref/non-map containers
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
template<typename A> auto inverse(A const& a)
|
||||
{
|
||||
if constexpr(!use_expression_templates) return inverse(generalize_t<A const>(a));
|
||||
else if constexpr(requires{typename A::rotgen_tag;}) return base_of(a).inverse();
|
||||
else return a.inverse();
|
||||
if constexpr (!use_expression_templates)
|
||||
return inverse(generalize_t<A const>(a));
|
||||
else if constexpr (requires { typename A::rotgen_tag; })
|
||||
return base_of(a).inverse();
|
||||
else return a.inverse();
|
||||
}
|
||||
|
||||
template<concepts::vectorND<3> L, concepts::vectorND<3> R> auto cross(L const& l, R const& r)
|
||||
template<concepts::vectorND<3> L, concepts::vectorND<3> R>
|
||||
auto cross(L const& l, R const& r)
|
||||
{
|
||||
if constexpr(!use_expression_templates)
|
||||
return cross(generalize_t<R const>(l),generalize_t<R const>(r));
|
||||
else if constexpr(requires{typename L::rotgen_tag;} || requires{typename R::rotgen_tag;} )
|
||||
if constexpr (!use_expression_templates)
|
||||
return cross(generalize_t<R const>(l), generalize_t<R const>(r));
|
||||
else if constexpr (
|
||||
requires { typename L::rotgen_tag; } ||
|
||||
requires { typename R::rotgen_tag; })
|
||||
return base_of(l).cross(base_of(r));
|
||||
else return l.cross(r);
|
||||
else return l.cross(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,50 +23,58 @@ namespace rotgen
|
|||
constexpr bool operator==(A const& a, B const& b) noexcept
|
||||
requires(concepts::entity<A> || concepts::entity<B>)
|
||||
{
|
||||
static_assert ( std::same_as<typename A::value_type,typename B::value_type>
|
||||
, "[ROTGEN] Incompatible type in operator=="
|
||||
);
|
||||
if constexpr(!use_expression_templates) return generalize_t<A const>(a) == generalize_t<B const>(b);
|
||||
else return base_of(a) == base_of(b);
|
||||
static_assert(std::same_as<typename A::value_type, typename B::value_type>,
|
||||
"[ROTGEN] Incompatible type in operator==");
|
||||
if constexpr (!use_expression_templates)
|
||||
return generalize_t<A const>(a) == generalize_t<B const>(b);
|
||||
else return base_of(a) == base_of(b);
|
||||
}
|
||||
|
||||
template<typename A, typename B>
|
||||
constexpr bool operator!=(A const& a, B const& b) noexcept
|
||||
requires(concepts::entity<A> || concepts::entity<B>)
|
||||
{
|
||||
static_assert ( std::same_as<typename A::value_type,typename B::value_type>
|
||||
, "[ROTGEN] Incompatible type in operator!="
|
||||
);
|
||||
if constexpr(!use_expression_templates) return generalize_t<A const>(a) != generalize_t<B const>(b);
|
||||
else return base_of(a) != base_of(b);
|
||||
static_assert(std::same_as<typename A::value_type, typename B::value_type>,
|
||||
"[ROTGEN] Incompatible type in operator!=");
|
||||
if constexpr (!use_expression_templates)
|
||||
return generalize_t<A const>(a) != generalize_t<B const>(b);
|
||||
else return base_of(a) != base_of(b);
|
||||
}
|
||||
|
||||
template<typename A, typename B>
|
||||
auto operator+(A const& a, B const& b) requires(concepts::entity<A> || concepts::entity<B>)
|
||||
auto operator+(A const& a, B const& b)
|
||||
requires(concepts::entity<A> || concepts::entity<B>)
|
||||
{
|
||||
if constexpr(!use_expression_templates) return generalize_t<A const>(a) + generalize_t<B const>(b);
|
||||
else return base_of(a) + base_of(b);
|
||||
if constexpr (!use_expression_templates)
|
||||
return generalize_t<A const>(a) + generalize_t<B const>(b);
|
||||
else return base_of(a) + base_of(b);
|
||||
}
|
||||
|
||||
template<typename A, typename B>
|
||||
auto operator-(A const& a, B const& b) requires(concepts::entity<A> || concepts::entity<B>)
|
||||
auto operator-(A const& a, B const& b)
|
||||
requires(concepts::entity<A> || concepts::entity<B>)
|
||||
{
|
||||
if constexpr(!use_expression_templates) return generalize_t<A const>(a) - generalize_t<B const>(b);
|
||||
else return base_of(a) - base_of(b);
|
||||
if constexpr (!use_expression_templates)
|
||||
return generalize_t<A const>(a) - generalize_t<B const>(b);
|
||||
else return base_of(a) - base_of(b);
|
||||
}
|
||||
|
||||
template<typename A, typename B>
|
||||
auto operator*(A const& a, B const& b) requires(concepts::entity<A> || concepts::entity<B>)
|
||||
auto operator*(A const& a, B const& b)
|
||||
requires(concepts::entity<A> || concepts::entity<B>)
|
||||
{
|
||||
if constexpr(!use_expression_templates) return generalize_t<A const>(a) * generalize_t<B const>(b);
|
||||
else return base_of(a) * base_of(b);
|
||||
if constexpr (!use_expression_templates)
|
||||
return generalize_t<A const>(a) * generalize_t<B const>(b);
|
||||
else return base_of(a) * base_of(b);
|
||||
}
|
||||
|
||||
template<typename A, typename B>
|
||||
auto operator/(A const& a, B const& b) requires(concepts::entity<A> && std::is_arithmetic_v<B>)
|
||||
auto operator/(A const& a, B const& b)
|
||||
requires(concepts::entity<A> && std::is_arithmetic_v<B>)
|
||||
{
|
||||
if constexpr(!use_expression_templates) return generalize_t<A const>(a) / b;
|
||||
else return base_of(a) / b;
|
||||
if constexpr (!use_expression_templates)
|
||||
return generalize_t<A const>(a) / b;
|
||||
else return base_of(a) / b;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
|
@ -75,23 +83,26 @@ namespace rotgen
|
|||
auto operator+=(A& a, B const& b)
|
||||
requires(concepts::entity<A> || concepts::entity<B>)
|
||||
{
|
||||
if constexpr(!use_expression_templates) return generalize_t<A>(a) += generalize_t<B const>(b);
|
||||
else return base_of(a) += base_of(b);
|
||||
if constexpr (!use_expression_templates)
|
||||
return generalize_t<A>(a) += generalize_t<B const>(b);
|
||||
else return base_of(a) += base_of(b);
|
||||
}
|
||||
|
||||
template<typename A, typename B>
|
||||
auto operator-=(A& a, B const& b)
|
||||
requires(concepts::entity<A> || concepts::entity<B>)
|
||||
{
|
||||
if constexpr(!use_expression_templates) return generalize_t<A>(a) -= generalize_t<B const>(b);
|
||||
else return base_of(a) -= base_of(b);
|
||||
if constexpr (!use_expression_templates)
|
||||
return generalize_t<A>(a) -= generalize_t<B const>(b);
|
||||
else return base_of(a) -= base_of(b);
|
||||
}
|
||||
|
||||
template<typename A, typename B>
|
||||
auto operator*=(A& a, B const& b)
|
||||
requires(concepts::entity<A> || concepts::entity<B>)
|
||||
{
|
||||
if constexpr(!use_expression_templates) return generalize_t<A>(a) *= generalize_t<B const>(b);
|
||||
else return base_of(a) *= base_of(b);
|
||||
if constexpr (!use_expression_templates)
|
||||
return generalize_t<A>(a) *= generalize_t<B const>(b);
|
||||
else return base_of(a) *= base_of(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,64 +16,62 @@ namespace rotgen
|
|||
|
||||
concrete_type sum() const
|
||||
{
|
||||
concrete_type res(target_.rows(),1);
|
||||
apply([&](auto r, auto i){ res(i) = r.sum(); });
|
||||
concrete_type res(target_.rows(), 1);
|
||||
apply([&](auto r, auto i) { res(i) = r.sum(); });
|
||||
return res;
|
||||
}
|
||||
|
||||
concrete_type mean() const
|
||||
{
|
||||
concrete_type res(target_.rows(),1);
|
||||
apply([&](auto r, auto i){ res(i) = r.mean(); });
|
||||
concrete_type res(target_.rows(), 1);
|
||||
apply([&](auto r, auto i) { res(i) = r.mean(); });
|
||||
return res;
|
||||
}
|
||||
|
||||
concrete_type prod() const
|
||||
concrete_type prod() const
|
||||
{
|
||||
concrete_type res(target_.rows(),1);
|
||||
apply([&](auto r, auto i){ res(i) = r.prod(); });
|
||||
concrete_type res(target_.rows(), 1);
|
||||
apply([&](auto r, auto i) { res(i) = r.prod(); });
|
||||
return res;
|
||||
}
|
||||
|
||||
concrete_type maxCoeff() const
|
||||
{
|
||||
concrete_type res(target_.rows(),1);
|
||||
apply([&](auto r, auto i){ res(i) = r.maxCoeff(); });
|
||||
concrete_type res(target_.rows(), 1);
|
||||
apply([&](auto r, auto i) { res(i) = r.maxCoeff(); });
|
||||
return res;
|
||||
}
|
||||
|
||||
concrete_type minCoeff() const
|
||||
{
|
||||
concrete_type res(target_.rows(),1);
|
||||
apply([&](auto r, auto i){ res(i) = r.minCoeff(); });
|
||||
concrete_type res(target_.rows(), 1);
|
||||
apply([&](auto r, auto i) { res(i) = r.minCoeff(); });
|
||||
return res;
|
||||
}
|
||||
|
||||
concrete_type squaredNorm() const
|
||||
concrete_type squaredNorm() const
|
||||
{
|
||||
concrete_type res(target_.rows(),1);
|
||||
apply([&](auto r, auto i){ res(i) = r.squaredNorm(); });
|
||||
concrete_type res(target_.rows(), 1);
|
||||
apply([&](auto r, auto i) { res(i) = r.squaredNorm(); });
|
||||
return res;
|
||||
}
|
||||
|
||||
concrete_type norm() const
|
||||
{
|
||||
concrete_type res(target_.rows(),1);
|
||||
apply([&](auto r, auto i){ res(i) = r.norm(); });
|
||||
concrete_type res(target_.rows(), 1);
|
||||
apply([&](auto r, auto i) { res(i) = r.norm(); });
|
||||
return res;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
template<typename Func> void apply(Func f)
|
||||
{
|
||||
for(Index i = 0; i < target_.rows(); ++i)
|
||||
f(row(target_,i), i);
|
||||
for (Index i = 0; i < target_.rows(); ++i) f(row(target_, i), i);
|
||||
}
|
||||
|
||||
template<typename Func> void apply(Func f) const
|
||||
{
|
||||
for(Index i = 0; i < target_.rows(); ++i)
|
||||
f(row(target_,i), i);
|
||||
for (Index i = 0; i < target_.rows(); ++i) f(row(target_, i), i);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -85,75 +83,73 @@ namespace rotgen
|
|||
concrete_type sum() const
|
||||
{
|
||||
concrete_type res(1, target_.cols());
|
||||
apply([&](auto r, auto i){ res(i) = r.sum(); });
|
||||
apply([&](auto r, auto i) { res(i) = r.sum(); });
|
||||
return res;
|
||||
}
|
||||
|
||||
concrete_type mean() const
|
||||
{
|
||||
concrete_type res(1, target_.cols());
|
||||
apply([&](auto r, auto i){ res(i) = r.mean(); });
|
||||
apply([&](auto r, auto i) { res(i) = r.mean(); });
|
||||
return res;
|
||||
}
|
||||
|
||||
concrete_type prod() const
|
||||
concrete_type prod() const
|
||||
{
|
||||
concrete_type res(1, target_.cols());
|
||||
apply([&](auto r, auto i){ res(i) = r.prod(); });
|
||||
apply([&](auto r, auto i) { res(i) = r.prod(); });
|
||||
return res;
|
||||
}
|
||||
|
||||
concrete_type maxCoeff() const
|
||||
{
|
||||
concrete_type res(1, target_.cols());
|
||||
apply([&](auto r, auto i){ res(i) = r.maxCoeff(); });
|
||||
apply([&](auto r, auto i) { res(i) = r.maxCoeff(); });
|
||||
return res;
|
||||
}
|
||||
|
||||
concrete_type minCoeff() const
|
||||
{
|
||||
concrete_type res(1, target_.cols());
|
||||
apply([&](auto r, auto i){ res(i) = r.minCoeff(); });
|
||||
apply([&](auto r, auto i) { res(i) = r.minCoeff(); });
|
||||
return res;
|
||||
}
|
||||
|
||||
concrete_type squaredNorm() const
|
||||
concrete_type squaredNorm() const
|
||||
{
|
||||
concrete_type res(1, target_.cols());
|
||||
apply([&](auto r, auto i){ res(i) = r.squaredNorm(); });
|
||||
apply([&](auto r, auto i) { res(i) = r.squaredNorm(); });
|
||||
return res;
|
||||
}
|
||||
|
||||
concrete_type norm() const
|
||||
{
|
||||
concrete_type res(1, target_.cols());
|
||||
apply([&](auto r, auto i){ res(i) = r.norm(); });
|
||||
apply([&](auto r, auto i) { res(i) = r.norm(); });
|
||||
return res;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
template<typename Func> void apply(Func f)
|
||||
{
|
||||
for(Index i = 0; i < target_.cols(); ++i)
|
||||
f(col(target_,i), i);
|
||||
for (Index i = 0; i < target_.cols(); ++i) f(col(target_, i), i);
|
||||
}
|
||||
|
||||
template<typename Func> void apply(Func f) const
|
||||
{
|
||||
for(Index i = 0; i < target_.cols(); ++i)
|
||||
f(col(target_,i), i);
|
||||
for (Index i = 0; i < target_.cols(); ++i) f(col(target_, i), i);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T> auto rowwise(T&& t)
|
||||
{
|
||||
if constexpr(use_expression_templates) return t.base().rowwise();
|
||||
else return rowwise_adaptor<T>{t};
|
||||
if constexpr (use_expression_templates) return t.base().rowwise();
|
||||
else return rowwise_adaptor<T>{t};
|
||||
}
|
||||
|
||||
template<typename T> auto colwise(T&& t)
|
||||
{
|
||||
if constexpr(use_expression_templates) return t.base().colwise();
|
||||
else return colwise_adaptor<T>{t};
|
||||
if constexpr (use_expression_templates) return t.base().colwise();
|
||||
else return colwise_adaptor<T>{t};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,11 @@
|
|||
//==================================================================================================
|
||||
#pragma once
|
||||
|
||||
//clang-format off
|
||||
#include <rotgen/config.hpp>
|
||||
#include <rotgen/format.hpp>
|
||||
#include <rotgen/container.hpp>
|
||||
#include <rotgen/alias.hpp>
|
||||
#include <rotgen/algebra.hpp>
|
||||
#include <rotgen/functions.hpp>
|
||||
//clang-format on
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue