Python wrappers
Public Python APIs implemented by this engine symbol.Solve the linear least-squares problem .
Shape
- Input
a:(..., m, n). - Input
b:(..., m, k)or(..., m). - Output:
(n, k)or(n,).
Parameters
aTensorImplPtrCoefficient matrix of shape
(..., m, n) with leading batch dims. Must be at least 2-D and have a floating-point dtype.bTensorImplPtrRight-hand side of shape
(..., m, k) (multiple RHS) or (..., m) (single RHS). Must share dtype with a.Returns
std::vector<TensorImplPtr>A one-element vector {solution} where solution has shape (n, k) when nrhs > 1 and (n,) when nrhs == 1. The vector wrapping anticipates a future expansion to {solution, residuals, rank, singular_values} matching the NumPy/reference-framework signature.
Raises
:runtime_errorIf either input is null or has a non-floating-point dtype.
Notes
The current backend uses *gels (QR driver), which assumes is
full rank. Rank-deficient inputs may produce silently inaccurate
solutions until *gelsd / *gelsy drivers are exposed.
Examples
>>> // Solve A x = b in the least-squares sense (tall A, single RHS):
>>> auto x_impl = lstsq_op(a_impl, b_impl)[0];