module numbers.direct_blas_lapack

Short summary

module cpyquickhelper.numbers.direct_blas_lapack

Direct calls to libraries BLAS and LAPACK.

source on GitHub

Functions

function

truncated documentation

cblas_daxpy

Calls axpy on double cblas_daxpy.

cblas_daxpy_void

Calls axpy on double cblas_daxpy. x

cblas_ddot

Computes a dot product with cblas_ddot.

cblas_saxpy

Calls axpy on float cblas_saxpy.

cblas_saxpy_void

Calls axpy on double cblas_daxpy.

cblas_sdot

Computes a dot product with cblas_sdot.

dgelss

Finds X in the problem AX=B by minimizing \norm{AX - B}^2. Uses function dgels. …

Documentation

@file @brief Direct calls to libraries BLAS and LAPACK.

cpyquickhelper.numbers.direct_blas_lapack.cblas_daxpy()

Calls axpy on double cblas_daxpy.

cpyquickhelper.numbers.direct_blas_lapack.cblas_daxpy_void()

Calls axpy on double cblas_daxpy. x and y are pointer on contiguous arrays of the same size.

cpyquickhelper.numbers.direct_blas_lapack.cblas_ddot()

Computes a dot product with cblas_ddot.

cpyquickhelper.numbers.direct_blas_lapack.cblas_saxpy()

Calls axpy on float cblas_saxpy.

cpyquickhelper.numbers.direct_blas_lapack.cblas_saxpy_void()

Calls axpy on double cblas_daxpy.

cpyquickhelper.numbers.direct_blas_lapack.cblas_sdot()

Computes a dot product with cblas_sdot.

cpyquickhelper.numbers.direct_blas_lapack.dgelss()

Finds X in the problem AX=B by minimizing \norm{AX - B}^2. Uses function dgels.

Parameters:
  • A – matrix with 2 dimensions

  • B – matrix with 2 dimensions

  • prec – precision

Returns:

integer (INFO)

INFO is:

  • = 0: successful exit

  • < 0: if INFO = -i, the i-th argument had an illegal value

  • > 0: if INFO = i, the i-th diagonal element of the triangular factor of A is zero, so that A does not have full rank; the least squares solution could not be computed.

Note

::1 indicates A, B, C must be contiguous arrays. Arrays A, B are modified by the function. B contains the solution.

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.]]