23namespace nda::linalg {
52 auto const dim = m.shape()[0];
55 }
else if (dim == 2) {
56 return m(0, 0) * m(1, 1) - m(0, 1) * m(1, 0);
57 }
else if (dim == 3) {
58 return m(0, 0) * (m(1, 1) * m(2, 2) - m(1, 2) * m(2, 1))
59 - m(0, 1) * (m(1, 0) * m(2, 2) - m(1, 2) * m(2, 0))
60 + m(0, 2) * (m(1, 0) * m(2, 1) - m(1, 1) * m(2, 0));
65 if (info < 0) NDA_RUNTIME_ERROR <<
"Error in nda::linalg::det_in_place: getrf routine failed: info = " << info;
70 for (
int i = 0; i < dim; i++) {
73 if (ipiv(i) != i + 1) ++n_flips;
76 return ((n_flips % 2 == 1) ? -
det :
det);
95 auto det(M
const &m) {
Provides definitions and type traits involving the different memory address spaces supported by nda.
Provides the generic class for arrays.
Provides basic functions to create and manipulate arrays and views.
Provides concepts for the nda library.
Provides a custom runtime error class and macros to assert conditions and throw exceptions.
Provides a generic interface to the LAPACK getrf routine.
decltype(auto) make_regular(A &&a)
Make a given object regular.
bool is_matrix_square(A const &a, bool print_error=false)
Check if a given matrix is square, i.e. if the first dimension has the same extent as the second dime...
basic_array< ValueType, 1, C_layout, 'V', ContainerPolicy > vector
Alias template of an nda::basic_array with rank 1 and a 'V' algebra.
constexpr char get_algebra
Constexpr variable that specifies the algebra of a type.
std::decay_t< decltype(get_first_element(std::declval< A const >()))> get_value_t
Get the value type of an array/view or a scalar type.
#define CLEF_MAKE_FNT_LAZY(name)
Macro to make any function lazy, i.e. accept lazy arguments and return a function call expression nod...
auto det(A &&...__a)
Lazy version of nda::linalg::det.
int getrf(A &&a, IPIV &&ipiv)
Interface to the LAPACK getrf routine.
static constexpr bool have_host_compatible_addr_space
Constexpr variable that is true if all given types have an address space compatible with Host.
constexpr bool is_blas_lapack_v
Alias for nda::is_double_or_complex_v.
Provides functions to create and manipulate matrices, i.e. arrays/view with 'M' algebra.
Defines various memory handling policies.
Provides type traits for the nda library.