Go to the documentation of this file. 1 #ifndef EAGINE_MATH_MATRIX_CTR_HPP
9 #define EAGINE_MATH_MATRIX_CTR_HPP
11 #include "../nothing.hpp"
17 template <
template <
class>
class MC,
typename T,
int C,
int R,
bool RM,
bool V>
18 struct constructed_matrix<MC<matrix<T, C, R, RM, V>>>
20 is_matrix_constructor_v<MC<matrix<T, C, R, RM, V>>>,
21 matrix<T, C, R, RM, V>,
33 struct constructed_matrix<MC<matrix<T, C, R, RM, V>, I>>
35 is_matrix_constructor_v<MC<matrix<T, C, R, RM, V>, I>>,
36 matrix<T, C, R, RM, V>,
41 template <
bool RM,
typename MC>
43 is_matrix_constructor_v<MC> && is_row_major_v<constructed_matrix_t<MC>> == RM,
49 template <
bool RM,
typename MC>
50 static constexpr
auto construct_matrix(
const MC& c) noexcept -> std::enable_if_t<
51 is_matrix_constructor_v<MC> && is_row_major_v<constructed_matrix_t<MC>> != RM,
52 reordered_matrix_t<constructed_matrix_t<MC>>> {
53 return reorder_mat_ctr(c)();
64 typename = std::enable_if_t<
65 is_matrix_constructor_v<MC1> && is_matrix_constructor_v<MC2> &&
66 are_multiplicable<constructed_matrix_t<MC1>, constructed_matrix_t<MC2>>::value>>
67 static inline auto multiply(
const MC1& mc1,
const MC2& mc2) noexcept {
68 return multiply(construct_matrix<true>(mc1), construct_matrix<false>(mc2));
73 template <
typename MC>
75 static_assert(is_matrix_constructor_v<MC>);
79 template <
typename... P>
81 : MC(std::forward<P>(p)...) {}
85 return MC::operator()();
89 template <
typename MC>
90 struct is_matrix_constructor<convertible_matrix_constructor<MC>>
91 : is_matrix_constructor<MC> {};
93 template <
typename MC>
94 struct constructed_matrix<convertible_matrix_constructor<MC>>
95 : constructed_matrix<MC> {};
99 template <
typename MC>
100 struct is_known_matrix_type<math::convertible_matrix_constructor<MC>>
101 : is_known_matrix_type<math::constructed_matrix_t<MC>> {};
103 template <
typename MC>
104 struct canonical_compound_type<math::convertible_matrix_constructor<MC>>
105 : canonical_compound_type<math::constructed_matrix_t<MC>> {};
107 template <
typename MC>
108 struct compound_view_maker<math::convertible_matrix_constructor<MC>> {
109 struct _result_type {
110 using M = math::constructed_matrix_t<MC>;
111 using T =
typename M::element_type;
114 operator span<const T>() const noexcept {
115 compound_view_maker<M> cvm;
121 const math::convertible_matrix_constructor<MC>& mc)
const noexcept {
122 return _result_type{mc()};
126 template <
typename MC>
127 struct is_row_major<math::convertible_matrix_constructor<MC>>
128 : math::is_row_major<math::constructed_matrix_t<MC>> {};
132 #endif // EAGINE_MATH_MATRIX_CTR_HPP
Common code is placed in this namespace.
Definition: eagine.hpp:21
typename constructed_matrix< X >::type constructed_matrix_t
Trait returning the matrix type constructed by constructor type X.
Definition: matrix.hpp:496
convertible_matrix_constructor(P &&... p)
Forwards arguments to the basic matrix constructor.
Definition: matrix_ctr.hpp:80
Helper class used in matrix constructor implementation.
Definition: matrix_ctr.hpp:74
static constexpr auto construct_matrix(const MC &c) noexcept -> std::enable_if_t< is_matrix_constructor_v< MC > &&is_row_major_v< constructed_matrix_t< MC >>==RM, constructed_matrix_t< MC >>
Uses the specified matrix constructor c to construct a matrix.
Definition: matrix_ctr.hpp:42
static auto multiply(const matrix< T, K, M, RM1, V > &m1, const matrix< T, N, K, RM2, V > &m2) noexcept -> matrix< T, N, M, RM1, V >
Matrix multiplication function.
Definition: matrix.hpp:529