7namespace least_squares_detail
12 using S =
typename Matrix::value_type;
14 auto zero = scalar_at_precision<S>(0,
p);
15 auto one = scalar_at_precision<S>(1,
p);
16 std::size_t m = a.extent(0), n = a.extent(1), nrhs = b.extent(1);
17 for (std::size_t k = 0; k < n; ++k)
18 for (std::size_t i = k + 1; i < m; ++i)
20 S f = a[k, k], g = a[i, k];
21 if (g == zero)
continue;
23 S phase = af == 0 ? one : f / af;
28 for (std::size_t j = k + 1; j < n; ++j)
30 S x = a[k, j], y = a[i, j];
31 a[k, j] =
c * x + s * y;
34 for (std::size_t j = 0; j < nrhs; ++j)
36 S x = b[k, j], y = b[i, j];
37 b[k, j] =
c * x + s * y;
45template <
class X,
class A,
class B,
class... P>
46 requires least_squares_detail::Operands<X, A, B> && least_squares_detail::PrecisionArgs<
typename A::value_type, P...>
55template <
class X,
class A,
class B,
class... P>
56 requires least_squares_detail::Operands<X, A, B> && least_squares_detail::PrecisionArgs<
typename A::value_type, P...>
62 x, a, b, residuals, info, options, least_squares_detail::working_precision<typename A::value_type>(precision...),
63 [](
auto& work,
auto& rhs,
Precision p) { least_squares_detail::givens(work, rhs, p); });
Exact arithmetic or an explicit binary working precision.
Definition core/precision.hpp:13
uni20::complex< T > conj(detail::standard_complex< T > x)
Returns the complex conjugate for complex-valued scalars.
Definition math.hpp:70
typename make_real< T >::type make_real_t
Alias for the underlying real-valued type of T.
Definition scalar_traits.hpp:168
void givens(Matrix &a, Matrix &b, Precision p)
Definition backends/cpu/least_squares.hpp:10
KernelAttempt run(X &x, A &a, B &b, std::span< make_real_t< typename A::value_type > > residuals, LeastSquaresInfo &info, LeastSquaresOptions< make_real_t< typename A::value_type > > const &options, Precision p, Factor factor)
Definition least_squares_common.hpp:92
Definition linalg/async.hpp:28
KernelAttempt try_kernel(BlasBackend, gemm_op const &, C &c, S const &alpha, A &a, B &b, S const &beta)
Pack logical host values and execute GEMM through value-preserving provider conversion.
Definition linalg/backends/blas/binary80.hpp:30
KernelAttempt
Result of one runtime kernel backend attempt.
Definition kernel_attempt.hpp:27
consteval auto kernel_accepts_types(BlasBackend, gemm_op const &, C &, S const &, A &, B &, S const &)
Accept host-readable native binary80 operands, including transforming accessors.
Definition linalg/backends/blas/binary80.hpp:19
constexpr KernelAcceptance< KernelTypeAcceptance::yes > kernel_types_yes
Report that a backend accepts every instance of the argument types.
Definition dispatch_error.hpp:40
constexpr detail::scalar_math::abs_fn abs
Absolute value or complex magnitude, preserving the selected scalar implementation.
Definition math.hpp:459
constexpr detail::scalar_math::hypot_fn hypot
Euclidean length with scalar-specific overflow and underflow handling.
Definition math.hpp:507
Definition data_table.cpp:8
Backend value for the reference host CPU dense linalg oracle.
Definition backend_selector.hpp:55
Completed numerical attempt; success does not certify rank or conditioning.
Definition least_squares_info.hpp:26
Full-rank QR rejection policy, independent of any physical convergence criterion.
Definition least_squares_info.hpp:37
Preserving full-column-rank least squares with fixed solution and diagnostic outputs.
Definition operation_tags.hpp:21