75 requires(have_same_value_type_v<A, B>
and mem::on_host<A, B, S>
and is_blas_lapack_v<get_value_t<A>>)
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");
78 static_assert(MemoryVector<B>
or MemoryMatrix<B>,
"Error in nda::lapack::gelss: B must be a vector or a matrix");
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);
89 using value_type = get_value_t<A>;
90 value_type bufferSize_T{};
91 auto rwork = array<
double, 1>(5 * dm);
93 int nrhs = 1, ldb = b.size();
94 if constexpr (MemoryMatrix<B>) {
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)));
102 array<value_type, 1> work(bufferSize);
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(),
int gelss(A &&a, B &&b, S &&s, double rcond, int &rank)
Interface to the LAPACK gelss routine.