34#ifndef NDA_HAVE_DEVICE
43namespace nda::lapack {
73 template <MemoryMatrix A, MemoryVector S, MemoryMatrix U, MemoryMatrix VT>
75 int gesvd(A &&a, S &&s, U &&u, VT &&vt) {
76 static_assert(has_F_layout<A> and has_F_layout<U> and has_F_layout<VT>,
"Error in nda::lapack::gesvd: C order not supported");
78 auto dm = std::min(a.extent(0), a.extent(1));
79 if (s.size() < dm) s.resize(dm);
82 EXPECTS(a.indexmap().min_stride() == 1);
83 EXPECTS(s.indexmap().min_stride() == 1);
84 EXPECTS(u.indexmap().min_stride() == 1);
85 EXPECTS(vt.indexmap().min_stride() == 1);
88 auto gesvd_call = []<
typename... Ts>(Ts &&...args) {
90#if defined(NDA_HAVE_DEVICE)
91 lapack::device::gesvd(std::forward<Ts>(args)...);
96 lapack::f77::gesvd(std::forward<Ts>(args)...);
102 value_type bufferSize_T{};
105 gesvd_call(
'A',
'A', a.extent(0), a.extent(1), a.data(), get_ld(a), s.data(), u.data(), get_ld(u), vt.data(), get_ld(vt), &bufferSize_T, -1,
107 int bufferSize =
static_cast<int>(std::ceil(std::real(bufferSize_T)));
111 gesvd_call(
'A',
'A', a.extent(0), a.extent(1), a.data(), get_ld(a), s.data(), u.data(), get_ld(u), vt.data(), get_ld(vt), work.
data(), bufferSize,
114 if (info) NDA_RUNTIME_ERROR <<
"Error in nda::lapack::gesvd: info = " << info;
Provides definitions and type traits involving the different memory address spaces supported by nda.
A generic multi-dimensional array.
ValueType const * data() const noexcept
Get a pointer to the actual data (in general this is not the beginning of the memory block for a view...
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.
Provides a custom runtime error class and macros to assert conditions and throw exceptions.
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.
int gesvd(A &&a, S &&s, U &&u, VT &&vt)
Interface to the LAPACK gesvd routine.
static constexpr bool have_compatible_addr_space
Constexpr variable that is true if all given types have compatible address spaces.
static constexpr bool have_device_compatible_addr_space
Constexpr variable that is true if all given types have an address space compatible with Device.
void compile_error_no_gpu()
Trigger a compilation error in case GPU specific functionality is used without configuring the projec...
constexpr bool is_blas_lapack_v
Alias for nda::is_double_or_complex_v.
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.