12#include "detray/algebra/concepts.hpp"
13#include "detray/algebra/type_traits.hpp"
14#include "detray/definitions/detail/qualifiers.hpp"
19namespace detray::algebra::generic::matrix::determinant {
22template <concepts::square_matrix matrix_t>
37 template <index_type N>
41 template <index_type N>
47 template <
class input_matrix_type>
49 const input_matrix_type &m)
const {
50 using element_getter_t =
51 detray::traits::element_getter_t<input_matrix_type>;
53 constexpr element_getter_t elem{};
60 template <index_type N>
62 struct determinant_getter_helper<N> {
66 template <
class input_matrix_type>
68 const input_matrix_type &m)
const {
69 using scalar_t = detray::traits::value_t<input_matrix_type>;
70 using index_t = detray::traits::index_t<input_matrix_type>;
71 using element_getter_t =
72 detray::traits::element_getter_t<input_matrix_type>;
74 constexpr element_getter_t elem{};
79 input_matrix_type temp;
85 for (index_t col = 0; col < N; col++) {
102 template <
class input_matrix_type>
103 DETRAY_HOST_DEVICE
constexpr void get_cofactor(
const input_matrix_type &m,
104 input_matrix_type &temp,
107 using index_t = detray::traits::index_t<input_matrix_type>;
108 using element_getter_t =
109 detray::traits::element_getter_t<input_matrix_type>;
111 constexpr element_getter_t elem{};
117 for (index_t row = 0; row < N; row++) {
118 for (index_t col = 0; col < N; col++) {
121 if (row != p && col != q) {
122 elem(temp, i, j++) = elem(m, row, col);
constexpr scalar_type operator()(const input_matrix_type &m) const
Return the sole element of the one-element matrix.
Definition cofactor.hpp:48
constexpr void get_cofactor(const input_matrix_type &m, input_matrix_type &temp, index_type p, index_type q) const
Fill the temporary matrix with the minor excluding one row and column.
Definition cofactor.hpp:103
Helper that evaluates the determinant for a fixed matrix rank.
Definition cofactor.hpp:38
"Determinant getter", assuming a N X N matrix
Definition cofactor.hpp:23
constexpr scalar_type operator()(const matrix_t &m) const
Compute the determinant of a square matrix.
Definition cofactor.hpp:32
detray::traits::index_t< matrix_t > index_type
Index type used to traverse the matrix.
Definition cofactor.hpp:27
detray::traits::value_t< matrix_t > scalar_type
Scalar type of the determinant.
Definition cofactor.hpp:25