32namespace nda::lapack {
68 template <BlasArray<2> A, BlasArrayRealFor<A, 1> S, BlasArrayFor<A, 2> U, BlasArrayFor<A, 2> VH, BlasArrayFor<A, 1> W1 = vector_value_t<A>,
69 BlasArrayRealFor<A, 1> W2 = vector_fp_t<A>>
75 auto [m, n] = a.shape();
76 auto const k = std::min(m, n);
83 EXPECTS(a.indexmap().min_stride() == 1);
84 EXPECTS(s.indexmap().min_stride() == 1);
85 EXPECTS(u.indexmap().min_stride() == 1);
86 EXPECTS(vh.indexmap().min_stride() == 1);
89 auto u_data = u.data();
90 auto vh_data = vh.data();
100 if constexpr (run_on_device) { EXPECTS(m >= n); }
105 if constexpr (run_on_device) {
106 tmp_lwork = device::gesvd_buffer_size(m, n, a.data());
108 f77::gesvd(
'A',
'A', m, n, a.data(),
get_ld(a), s.data(), u_data, u_ld, vh_data, vh_ld, &tmp_lwork, -1, rwork.data(), info);
110 int lwork =
static_cast<int>(std::ceil(std::real(tmp_lwork)));
116 if constexpr (run_on_device) {
117 device::gesvd(
'A',
'A', m, n, a.data(),
get_ld(a), s.data(), u_data, u_ld, vh_data, vh_ld, work.data(), lwork, rwork.data(), info);
119 f77::gesvd(
'A',
'A', m, n, a.data(),
get_ld(a), s.data(), u_data, u_ld, vh_data, vh_ld, work.data(), lwork, rwork.data(), info);
Provides definitions and type traits involving the different memory address spaces supported by nda.
Provides the generic class for arrays.
void swap(nda::basic_array_view< V1, R1, LP1, A1, AP1, OP1 > &a, nda::basic_array_view< V2, R2, LP2, A2, AP2, OP2 > &b)=delete
std::swap is deleted for nda::basic_array_view.
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 GPU and non-GPU specific functionality.
void resize_or_check_if_view(A &a, std::array< long, A::rank > const &sha)
Resize a given regular array to the given shape or check if a given view as the correct shape.
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.
int get_ld(A const &a)
Get the leading dimension of an nda::MemoryArray with rank 1 or 2 for BLAS/LAPACK calls.
static constexpr bool has_C_layout
Constexpr variable that is true if all given nda::Array types have nda::C_layout.
void resize_or_check_work_buffer(A &a, long min_size)
Resize or check the size of a 1D array/view.
vector< get_value_t< A >, heap< mem::get_addr_space< A > > > vector_value_t
Alias for an nda::vector with the same value type and address space as the given type.
vector< get_fp_t< A >, heap< mem::get_addr_space< A > > > vector_fp_t
Alias for an nda::vector with the same address space as the given type and its value type determined ...
int gesvd(A &&a, S &&s, U &&u, VH &&vh, W1 &&work=vector_value_t< A >{}, W2 &&rwork=vector_fp_t< A >{})
Interface to the LAPACK/cuSOLVER gesvd routine.
static constexpr bool have_device_compatible_addr_space
Constexpr variable that is true if all given types have an address space compatible with Device.
Provides a C++ interface for various LAPACK routines.
Provides definitions of various layout policies.
Macros used in the nda library.
Defines various memory handling policies.
Provides type traits for the nda library.