Skip to contents

Lstsq

Arguments

self

(Tensor) the matrix B

A

(Tensor) the m by n matrix A

Note

The case when \eqn{m < n} is not supported on the GPU.

lstsq(input, A, out=NULL) -> Tensor

Computes the solution to the least squares and least norm problems for a full rank matrix A of size (m×n) and a matrix B of size (m×k).

If mn, torch_lstsq() solves the least-squares problem:

minXAXB2. If m<n, torch_lstsq() solves the least-norm problem:

minXX2subject toAX=B. Returned tensor X has shape (max(m,n)×k). The first n rows of X contains the solution. If mn, the residual sum of squares for the solution in each column is given by the sum of squares of elements in the remaining mn rows of that column.