31namespace nda::linalg {
53 template <
typename LP = F_layout, MemoryMatrix A>
59 auto const [m, n] = a.shape();
60 auto const k = std::min(m, n);
61 auto L = output_t::zeros(m, k);
62 auto U = output_t::zeros(k, n);
63 for (
int i = 0; i < k; ++i) {
65 L(range(i + 1, m), i) = a(range(i + 1, m), i);
66 U(range(i + 1), i) = a(range(i + 1), i);
70 for (
int i = k; i < n; ++i) U(range::all, i) = a(range::all, i);
72 return std::make_tuple(L, U);
105 template <
typename LP = F_layout, blas_lapack::BlasArray<2> A>
114 NDA_RUNTIME_ERROR <<
"Error in nda::linalg::lu_in_place: getrf failed with invalid argument (info = " << info <<
")";
115 }
else if (info > 0 and not allow_singular) {
116 NDA_RUNTIME_ERROR <<
"Error in nda::linalg::lu_in_place: Matrix is singular, U(" << info <<
"," << info <<
") is exactly zero";
123 return std::make_tuple(sigma, L, U);
145 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/cuSOLVER 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 all given nda::Array types have nda::F_layout.
auto get_lu_matrices(A const &a)
Get the and matrices from the output of nda::lapack::getrf.
auto lu_in_place(A &&a, bool allow_singular=false)
Compute the LU factorization of a matrix in place.
auto lu(A const &a, bool allow_singular=false)
Compute the LU factorization of a matrix.
int getrf(A &&a, IPIV &&ipiv, W &&work=vector_value_t< A >{})
Interface to the LAPACK/cuSOLVER getrf routine.
auto get_permutation_vector(Vector auto const &ipiv, int m)
Get the permutation vector from the pivot indices returned by nda::lapack::getrf or other LAPACK rou...
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
Constexpr variable that is true if type T is either of type 'float', double, std::complex<float>' or ...
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.