33namespace nda::linalg {
70 template <blas_lapack::BlasArray<2> A, blas_lapack::BlasArrayFor<A, 1> TAU>
73 auto const [m, n] = a.shape();
74 auto const min_mn = std::min(m, n);
75 auto const k = (complete ? m : min_mn);
80 Q(range::all, range(min_mn)) = a(range::all, range(min_mn));
87 if (info != 0) NDA_RUNTIME_ERROR <<
"Error in nda::linalg::get_qr_matrices: orgqr/ungqr returned a non-zero value: info = " << info;
90 for (
int i = 0; i < min_mn; ++i) R(range(i + 1), i) = a(range(i + 1), i);
91 for (
int i = min_mn; i < n; ++i) R(range::all, i) = a(range::all, i);
93 return std::make_tuple(Q, R);
128 template <blas_lapack::BlasArray<2> A>
131 auto const [m, n] = a.shape();
139 if (info != 0) NDA_RUNTIME_ERROR <<
"Error in nda::linalg::qr_in_place: geqp3 returned a non-zero value: info = " << info;
147 return std::make_tuple(jpvt, Q, R);
168 auto qr(A
const &a,
bool complete =
false) {
173 auto [sigma, Q, R] =
qr_in_place(a_copy, complete);
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.
static basic_array zeros(std::array< Int, Rank > const &shape)
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 geqp3 routine.
auto zeros(std::array< Int, Rank > const &shape)
Make an array of the given shape on the given address space and zero-initialize it.
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_qr_matrices(A const &a, TAU const &tau, bool complete=false)
Get the and matrices from the output of nda::lapack::geqp3 or nda::lapack::geqrf.
auto qr_in_place(A &&a, bool complete=false)
Compute the QR factorization of a matrix in place.
auto qr(A const &a, bool complete=false)
Compute the QR factorization of a matrix.
int ungqr(A &&a, TAU &&tau, W &&work=vector_value_t< A >{})
Interface to the LAPACK/cuSOLVER ungqr routine.
int geqp3(A &&a, JPVT &&jpvt, TAU &&tau, W1 &&work=vector_value_t< A >{}, W2 &&rwork=vector_fp_t< A >{})
Interface to the LAPACK geqp3 routine.
int orgqr(A &&a, TAU &&tau, W &&work=vector_value_t< A >{})
Interface to the LAPACK/cuSOLVER orgqr 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_complex_v
Constexpr variable that is true if type T is a std::complex type.
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.
Provides a generic interface to the LAPACK/cuSOLVER orgqr routine.
Includes the itertools header and provides some additional utilities.
Contiguous layout policy with C-order (row-major order).
Contiguous layout policy with Fortran-order (column-major order).
Provides type traits for the nda library.
Provides a generic interface to the LAPACK/cuSOLVER ungqr routine.