37namespace nda::lapack {
74 template <MemoryMatrix A, MemoryArray B, MemoryVector S>
76 int gelss(A &&a, B &&b, S &&s,
double rcond,
int &rank) {
77 static_assert(has_F_layout<A> and has_F_layout<B>,
"Error in nda::lapack::gelss: C order not supported");
80 auto dm = std::min(a.extent(0), a.extent(1));
81 if (s.size() < dm) s.resize(dm);
84 EXPECTS(a.indexmap().min_stride() == 1);
85 EXPECTS(b.indexmap().min_stride() == 1);
86 EXPECTS(s.indexmap().min_stride() == 1);
90 value_type bufferSize_T{};
93 int nrhs = 1, ldb = b.size();
98 f77::gelss(a.extent(0), a.extent(1), nrhs, a.data(), get_ld(a), b.data(), ldb, s.data(), rcond, rank, &bufferSize_T, -1, rwork.data(), info);
99 int bufferSize =
static_cast<int>(std::ceil(std::real(bufferSize_T)));
103 f77::gelss(a.extent(0), a.extent(1), nrhs, a.data(), get_ld(a), b.data(), ldb, s.data(), rcond, rank, work.
data(), bufferSize, rwork.data(),
106 if (info) NDA_RUNTIME_ERROR <<
"Error in nda::lapack::gelss: info = " << info;
Provides definitions and type traits involving the different memory address spaces supported by nda.
Provides the generic class for arrays.
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...
Check if a given type is a memory matrix, i.e. an nda::MemoryArrayOfRank<2>.
Check if a given type is a memory vector, i.e. an nda::MemoryArrayOfRank<1>.
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.
basic_array< ValueType, Rank, Layout, 'A', ContainerPolicy > array
Alias template of an nda::basic_array with an 'A' 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.
int gelss(A &&a, B &&b, S &&s, double rcond, int &rank)
Interface to the LAPACK gelss routine.
static constexpr bool on_host
Constexpr variable that is true if all given types have a Host address space.
constexpr bool is_blas_lapack_v
Alias for nda::is_double_or_complex_v.
Provides a C++ interface for various LAPACK routines.
Macros used in the nda library.
Provides type traits for the nda library.