22template <
typename T,
typename =
void>
23struct scalar_value_type
30struct scalar_value_type<T, std::void_t<typename T::value_type>>
32 typedef typename T::value_type value_type;
36using scalar_value_type_t =
typename scalar_value_type<T>::value_type;
145 std::size_t offset = 0, std::size_t n = 1)
147 for (std::size_t i = 0; i < perm.size(); ++i)
148 for (std::size_t b = 0; b < n; ++b)
149 std::swap(data[n * (offset + i) + b], data[n * (offset + perm[i]) + b]);
155 std::span<E> data, std::span<const int> emap,
158 for (std::size_t i = 0; i < perm.size(); ++i)
159 for (std::size_t b = 0; b < n; ++b)
160 std::swap(data[n * emap[i] + b], data[n * emap[perm[i]] + b]);
173 std::span<E> data, std::size_t offset = 0,
176 const std::size_t dim = perm.size();
177 const std::size_t data_size = (data.size() + (dim < n ? n - dim : 0)) / n;
178 for (std::size_t b = 0; b < n; ++b)
180 for (std::size_t i = 0; i < dim; ++i)
182 std::swap(data[data_size * b + offset + i],
183 data[data_size * b + offset + perm[i]]);
204template <std::
floating_po
int T>
205std::vector<std::size_t>
208 return math::transpose_lu<T>(A);
242template <
typename T,
typename E>
244 std::span<const std::size_t> v_size_t,
245 MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan<
246 const T, MDSPAN_IMPL_STANDARD_NAMESPACE::dextents<std::size_t, 2>>
248 std::span<E> data, std::size_t offset = 0, std::size_t n = 1)
250 using U =
typename impl::scalar_value_type_t<E>;
252 const std::size_t dim = v_size_t.size();
254 for (std::size_t b = 0; b < n; ++b)
256 for (std::size_t i = 0; i < dim; ++i)
258 for (std::size_t j = i + 1; j < dim; ++j)
260 data[n * (offset + i) + b]
261 +=
static_cast<U
>(M(i, j)) * data[n * (offset + j) + b];
264 for (std::size_t i = 1; i <= dim; ++i)
266 data[n * (offset + dim - i) + b] *=
static_cast<U
>(M(dim - i, dim - i));
267 for (std::size_t j = 0; j < dim - i; ++j)
269 data[n * (offset + dim - i) + b]
270 +=
static_cast<U
>(M(dim - i, j)) * data[n * (offset + j) + b];
284template <
typename T,
typename E>
286 std::span<const std::size_t> v_size_t,
287 MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan<
288 const T, MDSPAN_IMPL_STANDARD_NAMESPACE::dextents<std::size_t, 2>>
290 std::span<E> data, std::size_t offset = 0, std::size_t n = 1)
292 using U =
typename impl::scalar_value_type_t<E>;
294 const std::size_t dim = v_size_t.size();
295 const std::size_t data_size = (data.size() + (dim < n ? n - dim : 0)) / n;
297 for (std::size_t b = 0; b < n; ++b)
299 for (std::size_t i = 0; i < dim; ++i)
301 for (std::size_t j = i + 1; j < dim; ++j)
303 data[data_size * b + offset + i]
304 +=
static_cast<U
>(M(i, j)) * data[data_size * b + offset + j];
307 for (std::size_t i = 1; i <= dim; ++i)
309 data[data_size * b + offset + dim - i]
310 *=
static_cast<U
>(M(dim - i, dim - i));
311 for (std::size_t j = 0; j < dim - i; ++j)
313 data[data_size * b + offset + dim - i]
314 +=
static_cast<U
>(M(dim - i, j)) * data[data_size * b + offset + j];
Matrix and permutation pre-computation.
Definition: precompute.h:17
void apply_tranpose_matrix_right(std::span< const std::size_t > v_size_t, MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan< const T, MDSPAN_IMPL_STANDARD_NAMESPACE::dextents< std::size_t, 2 > > M, std::span< E > data, std::size_t offset=0, std::size_t n=1)
Apply a (precomputed) matrix to some transposed data.
Definition: precompute.h:285
std::vector< std::size_t > prepare_matrix(std::pair< std::vector< T >, std::array< std::size_t, 2 > > &A)
Prepare a square matrix.
Definition: precompute.h:206
void apply_permutation(std::span< const std::size_t > perm, std::span< E > data, std::size_t offset=0, std::size_t n=1)
Apply a (precomputed) permutation .
Definition: precompute.h:144
void apply_inv_permutation_right(std::span< const std::size_t > perm, std::span< E > data, std::size_t offset=0, std::size_t n=1)
Apply a (precomputed) permutation to some transposed data.
Definition: precompute.h:172
void prepare_permutation(std::span< std::size_t > perm)
Prepare a permutation.
Definition: precompute.cpp:10
void apply_permutation_mapped(std::span< const std::size_t > perm, std::span< E > data, std::span< const int > emap, std::size_t n=1)
Permutation of mapped data.
Definition: precompute.h:154
void apply_matrix(std::span< const std::size_t > v_size_t, MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan< const T, MDSPAN_IMPL_STANDARD_NAMESPACE::dextents< std::size_t, 2 > > M, std::span< E > data, std::size_t offset=0, std::size_t n=1)
Apply a (precomputed) matrix.
Definition: precompute.h:243