parent
3313e257c8
commit
ddf8816c5b
12 changed files with 165 additions and 46 deletions
|
|
@ -280,6 +280,12 @@ namespace rotgen
|
|||
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)
|
||||
{
|
||||
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()))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,9 +9,21 @@
|
|||
|
||||
namespace rotgen::detail
|
||||
{
|
||||
template<typename M, typename N>
|
||||
inline constexpr bool has_same_vector_size = []()
|
||||
{
|
||||
// No vector = noo size
|
||||
if(!(M::IsVectorAtCompileTime && N::IsVectorAtCompileTime)) return false;
|
||||
// Row vectors -> same Cols
|
||||
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;
|
||||
// Mixing 1xN with Mx1
|
||||
return false;
|
||||
}();
|
||||
|
||||
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>
|
||||
using composite_matrix_type = matrix< typename M1::value_type
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ namespace rotgen
|
|||
}
|
||||
|
||||
template<int P>
|
||||
double lpNorm() const
|
||||
value_type lpNorm() const
|
||||
{
|
||||
assert(P == 1 || P == 2 || P == Infinity);
|
||||
return parent::lpNorm(P);
|
||||
|
|
|
|||
|
|
@ -313,8 +313,14 @@ namespace rotgen
|
|||
return *this;
|
||||
}
|
||||
|
||||
template<typename R2, int O2, typename S2>
|
||||
value_type dot(map<R2,O2,S2> const& rhs) const
|
||||
{
|
||||
return base().dot(rhs.base());
|
||||
}
|
||||
|
||||
template<int P>
|
||||
double lpNorm() const
|
||||
value_type lpNorm() const
|
||||
{
|
||||
assert(P == 1 || P == 2 || P == Infinity);
|
||||
return parent::lpNorm(P);
|
||||
|
|
|
|||
|
|
@ -356,6 +356,12 @@ namespace rotgen
|
|||
return result;
|
||||
}
|
||||
|
||||
template<typename R2, int O2, typename S2>
|
||||
value_type dot(map<R2,O2,S2> const& rhs) const
|
||||
{
|
||||
return base().dot(rhs.base());
|
||||
}
|
||||
|
||||
template<int P> value_type lpNorm() const
|
||||
{
|
||||
static_assert(P == 1 || P == 2 || P == Infinity);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
//==================================================================================================
|
||||
#pragma once
|
||||
|
||||
#include <rotgen/detail/helpers.hpp>
|
||||
|
||||
namespace rotgen
|
||||
{
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
|
|
@ -142,6 +144,14 @@ namespace rotgen
|
|||
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>)
|
||||
{
|
||||
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(); }
|
||||
|
||||
|
|
|
|||
|
|
@ -63,8 +63,10 @@ class ROTGEN_EXPORT CLASSNAME
|
|||
TYPE trace() const;
|
||||
TYPE maxCoeff() const;
|
||||
TYPE minCoeff() const;
|
||||
TYPE maxCoeff(Index* row, Index* col) const;
|
||||
TYPE minCoeff(Index* row, Index* col) 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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue