16 #include "Eigen/Dense"
27 template <
typename MatrixType>
29 MatrixType::ColsAtCompileTime>
31 constexpr
int rows = MatrixType::RowsAtCompileTime;
32 constexpr
int cols = MatrixType::ColsAtCompileTime;
34 static_assert(rows != -1 && cols != -1,
35 "bitsetToMatrix does not support dynamic matrices");
39 for (
size_t i = 0;
i < rows * cols;
i++) {
40 p[
i] = bs[rows * cols - 1 -
i];
51 template <
typename Derived>
53 using MatrixType = Eigen::PlainObjectBase<Derived>;
54 constexpr
size_t rows = MatrixType::RowsAtCompileTime;
55 constexpr
size_t cols = MatrixType::ColsAtCompileTime;
57 std::bitset<rows * cols> res;
60 for (
size_t i = 0;
i < rows * cols;
i++) {
61 res[rows * cols - 1 -
i] =
static_cast<bool>(
p[
i]);
77 template <
typename A,
typename B>
79 const A&
a,
const B&
b) {
82 constexpr
int M = A::RowsAtCompileTime;
83 constexpr
int N = A::ColsAtCompileTime;
84 constexpr
int P = B::ColsAtCompileTime;
88 static_assert(N == B::RowsAtCompileTime);
90 if constexpr (M <= 4 && N <= 4 && P <= 4) {
127 constexpr
int M1 = M / 2;
128 constexpr
int M2 = (M + 1) / 2;
129 constexpr
int N1 = N / 2;
130 constexpr
int N2 = (N + 1) / 2;
131 constexpr
int P1 = P / 2;
132 constexpr
int P2 = (P + 1) / 2;
139 r.template topLeftCorner<M1, P1>().noalias() =
140 a.template topLeftCorner<M1, N1>() *
141 b.template topLeftCorner<N1, P1>() +
142 a.template topRightCorner<M1, N2>() *
143 b.template bottomLeftCorner<N2, P1>();
146 r.template topRightCorner<M1, P2>().noalias() =
147 a.template topLeftCorner<M1, N1>() *
148 b.template topRightCorner<N1, P2>() +
149 a.template topRightCorner<M1, N2>() *
150 b.template bottomRightCorner<N2, P2>();
153 r.template bottomLeftCorner<M2, P1>().noalias() =
154 a.template bottomLeftCorner<M2, N1>() *
155 b.template topLeftCorner<N1, P1>() +
156 a.template bottomRightCorner<M2, N2>() *
157 b.template bottomLeftCorner<N2, P1>();
160 r.template bottomRightCorner<M2, P2>().noalias() =
161 a.template bottomLeftCorner<M2, N1>() *
162 b.template topRightCorner<N1, P2>() +
163 a.template bottomRightCorner<M2, N2>() *
164 b.template bottomRightCorner<N2, P2>();
187 template <
typename MatrixType,
typename ResultType = MatrixType>
190 bool invertible =
false;
192 m.computeInverseWithCheck(result, invertible);
204 template <
typename T>
208 constexpr
static double value = 500.0;
212 constexpr
static float value = 50.0;
221 template <
typename T>
224 constexpr
T minExponent = -maxExponent;
225 if (val < minExponent) {
229 if (val > maxExponent) {
230 return std::numeric_limits<T>::infinity();
233 return std::exp(val);