44namespace nda::linalg {
75 template <MemoryMatrix A, MemoryVector TAU>
78 auto const [m, n] = a.shape();
79 auto const min_mn = std::min(m, n);
80 auto const k = (complete ? m : min_mn);
85 Q(range::all, range(min_mn)) = a(range::all, range(min_mn));
92 if (info != 0) NDA_RUNTIME_ERROR <<
"Error in nda::qr_in_place: orgqr/ungqr returned a non-zero value: info = " << info;
95 for (
int i = 0; i < min_mn; ++i) R(range(i + 1), i) = a(range(i + 1), i);
96 for (
int i = min_mn; i < n; ++i) R(range::all, i) = a(range::all, i);
98 return std::make_tuple(Q, R);
129 template <MemoryMatrix A>
132 auto const [m, n] = a.shape();
140 if (info != 0) NDA_RUNTIME_ERROR <<
"Error in nda::qr_in_place: geqp3 returned a non-zero value: info = " << info;
148 return std::make_tuple(jpvt, Q, R);
165 auto qr(A
const &a,
bool complete =
false) {
170 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.
constexpr bool have_same_value_type_v
Constexpr variable that is true if all types in As have the same value type as A0.
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 ungqr(A &&a, TAU &&tau)
Interface to the LAPACK ungqr routine.
int orgqr(A &&a, TAU &&tau)
Interface to the LAPACK orgqr routine.
int geqp3(A &&a, JPVT &&jpvt, TAU &&tau)
Interface to the LAPACK geqp3 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
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.
Provides a generic interface to the LAPACK 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 ungqr routine.