42namespace nda::linalg {
61 template <
typename LP = F_layout, MemoryMatrix A>
67 auto const [m, n] = a.shape();
68 auto const k = std::min(m, n);
69 auto L = output_t::zeros(m, k);
70 auto U = output_t::zeros(k, n);
71 for (
int i = 0; i < k; ++i) {
73 L(range(i + 1, m), i) = a(range(i + 1, m), i);
74 U(range(i + 1), i) = a(range(i + 1), i);
78 for (
int i = k; i < n; ++i) U(range::all, i) = a(range::all, i);
80 return std::make_tuple(L, U);
110 template <
typename LP = F_layout, MemoryMatrix A>
121 NDA_RUNTIME_ERROR <<
"Error in nda::lu_in_place: getrf failed with invalid argument (info = " << info <<
")";
122 }
else if (info > 0 and not allow_singular) {
123 NDA_RUNTIME_ERROR <<
"Error in nda::lu_in_place: Matrix is singular, U(" << info <<
"," << info <<
") is exactly zero";
130 return std::make_tuple(sigma, L, U);
148 auto lu(A
const &a,
bool allow_singular =
false) {
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 various convenient aliases and helper functions for nda::basic_array and nda::basic_array_vi...
Provides a custom runtime error class and macros to assert conditions and throw exceptions.
Provides a generic interface to the LAPACK getrf routine.
basic_array< ValueType, 1, C_layout, 'V', ContainerPolicy > vector
Alias template of an nda::basic_array with rank 1 and a 'V' algebra.
basic_array< ValueType, 2, Layout, 'M', ContainerPolicy > matrix
Alias template of an nda::basic_array with rank 2 and an 'M' algebra.
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.
static constexpr bool has_F_layout
Constexpr variable that is true if the given nda::Array type has nda::F_layout.
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 definitions of various layout policies.
Provides utility functions for the nda::linalg namespace.
Macros used in the nda library.
Includes the itertools header and provides some additional utilities.
Contiguous layout policy with Fortran-order (column-major order).
Provides type traits for the nda library.