Examples¶

  1. Use lapack function dgelss

Use lapack function dgelss

C minimizes the problem \norm{AX - B}^2.

<<<

import numpy
from scipy.linalg.lapack import dgelss as scipy_dgelss
from cpyquickhelper.numbers.direct_blas_lapack import dgelss

A = numpy.array([[10., 1.], [12., 1.], [13., 1]])
B = numpy.array([[20., 22., 23.]]).T
v, x, s, rank, work, info = scipy_dgelss(A, B)
print(x[:2])

A = A.T.copy()
info = dgelss(A, B)
assert info == 0
print(B[:2])

>>>

    [[ 1.]
     [10.]]
    [[ 1.]
     [10.]]

(original entry : docstring of cpyquickhelper.numbers.direct_blas_lapack.dgelss, line 24)