ATOMS : Linear Algebra details

# Linear Algebra

A collection of algorithms for linear algebra
Details
Version
0.2
A more recent valid version exists: 0.4.1
Author
Michael Baudin
Owner Organization
DIGITEO
Maintainers
Michael BAUDIN
Antoine ELIAS
Category
Dependencies
Creation Date
September 14, 2011
Source created on
Scilab 5.3.x
Binaries available on
Scilab 5.3.x:
Linux 32-bit Windows 32-bit Windows 64-bit macOS Linux 64-bit
Install command
`--> atomsInstall("linalg")`
Report a bug
Description
```            The goal of this toolbox is to provide a collection of
algorithms for linear algebra.

These algorithms are most of the time already provided by Scilab, but
are available here for comparison purpose.

The linalg_pow function is much faster than Scilab's pow,
when the exponent is large.
The algorithm used here is based on binary exponentiation, and
requires only log2(p) iterations, compared to p iterations for the
naive pow.
For example, for p=99999, it was found that linalg_pow requires 0.003
seconds for a 5-by-5 matrix, while Scilab requires 2.7 seconds.

The linalg_zhbev function provides the same feature as Lapack's
ZHBEV, that is, computes the eigenvalues of a complex hermitian band matrix.
The other method in Scilab to compute eigenvalues of sparse matrices
is to use Arnoldi's iterations.
This does not make use of the Hermitian structure of some matrices.

The solution of A*X=B in Scilab is based on the backslash operator.
The backslash operator is switching from Gaussian Elimination (with
pivoting) to Linear Least Squares when the condition number of
the matrix is larger than roughly 10^8.
This switch is annoying for matrices which condition number are
between 10^8 and 10^16, where the Gaussian Elimination can
produce a more accurate result than Least Squares.
The linalg_gesv function provided in this module is a direct
interface to the Gaussian Elimination from Lapack.
In some cases, this function can produce significantly more accurate
solution than backslash.

Features :
-------

* linalg_chol — Computes the Cholesky decomposition.
* linalg_condeig — Computes the condition number of the eigenvalues of a
matrix.
* linalg_expm — Computes the exponential of a matrix.
* linalg_factorlu — Computes the LU decomposition without pivoting.
* linalg_factorlupivot — Computes the LU decomposition with pivoting.
* linalg_gaussnaive — Solves a linear equation by Gauss method and no
pivoting.
* linalg_gausspivotal — Computes the solution of a linear equation with Gauss
and row pivoting.
* linalg_gausspivotalnaive — Computes the solution of a linear equation with
Gauss and row pivoting.
* linalg_hbandL — Converts a complex hermitian band matrix into its compact
form.
* linalg_pow — Computes A^p
* linalg_powfast — Computes A^p
* linalg_rayleighiteration — Computes approximated a pair of eigenvalue and
eigenvector.
* linalg_solvelu — Computes the solution of a linear equation, given its LU
decomposition.

BLAS/LAPACK
* linalg_dgemm — Computes D = Alpha*A*B+ Beta*C for a real matrix.
* linalg_dgesv — Solves A*X = B for real equations.
* linalg_dsyev — Computes the eigenvalues of a symmetric real matrix.
* linalg_gemm — Computes D = Alpha*A*B+ Beta*C for a real or complex matrix.
* linalg_gesv — Computes the real or complex solution X of A*X=B.
* linalg_zgemm — Computes D = Alpha*A*B+ Beta*C for a complex matrix.
* linalg_zgesv — Solves A*X = B for complex equations.
* linalg_zhbev — Computes the eigenvalues of a complex hermitian band
matrix.
```
Files (6)
[117.72 kB]
Source code archive
```
```
[128.32 kB]
Linux 32-bit binary for Scilab 5.3.x
```Linux 32-bit
Automatically generated by the ATOMS compilation chain

```
[225.77 kB]
Windows 32-bit binary for Scilab 5.3.x
```Windows 32-bit
Automatically generated by the ATOMS compilation chain

```
[228.66 kB]
Windows 64-bit binary for Scilab 5.3.x
```Windows 64-bit
Automatically generated by the ATOMS compilation chain

```
[122.60 kB]
macOS binary for Scilab 5.3.x
```MacOSX version
Automatically generated by the ATOMS compilation chain

```
[127.25 kB]
Linux 64-bit binary for Scilab 5.3.x
```Linux 64-bit
Automatically generated by the ATOMS compilation chain

```
News (0)
Comment from Allan CORNET -- September 14, 2011, 05:08:52 PM
`Please notice that on Windows this module uses MKL librarie`
Comment -- September 23, 2011, 10:59:30 AM
```linalg v0.2 correctly packaged on Scilab 5.3.2 on Linux 32 bits.

-->atomsSystemUpdate()
-->atomsInstall("linalg")
ans  =
!linalg  0.2-1  allusers  SCI/contrib/linalg/0.2-1  I  !
!                                                      !
!apifun  0.2-2  allusers  SCI/contrib/apifun/0.2-2  A  !
!                                                      !
!assert  1.3-1  allusers  SCI/contrib/assert/1.3-1  A  !

After restart, most tests pass:

-->atomsTest("linalg")
TMPDIR = /tmp/SCI_TMP_3346_BMAyvJ

001/020 - [SCI/contrib/linalg/0.2-1] chol.......................passed
002/020 - [SCI/contrib/linalg/0.2-1] dgemm......................passed
003/020 - [SCI/contrib/linalg/0.2-1] dgesv......................passed
004/020 - [SCI/contrib/linalg/0.2-1] dsyev......................passed
005/020 - [SCI/contrib/linalg/0.2-1] expm.......................passed
006/020 - [SCI/contrib/linalg/0.2-1] factorlu...................failed  : dia and ref
are not equal
007/020 - [SCI/contrib/linalg/0.2-1] factorlupivot..............passed
008/020 - [SCI/contrib/linalg/0.2-1] gaussnaive.................passed
009/020 - [SCI/contrib/linalg/0.2-1] gausspivotal...............passed
010/020 - [SCI/contrib/linalg/0.2-1] gausspivotalnaive..........passed
011/020 - [SCI/contrib/linalg/0.2-1] gemm.......................passed
012/020 - [SCI/contrib/linalg/0.2-1] gesv.......................failed  : premature end

of the test script
013/020 - [SCI/contrib/linalg/0.2-1] hbandL.....................passed
014/020 - [SCI/contrib/linalg/0.2-1] pow........................passed
015/020 - [SCI/contrib/linalg/0.2-1] powfast....................passed
016/020 - [SCI/contrib/linalg/0.2-1] rayleighiteration..........passed
017/020 - [SCI/contrib/linalg/0.2-1] solvelu....................passed
018/020 - [SCI/contrib/linalg/0.2-1] zgemm......................passed
019/020 - [SCI/contrib/linalg/0.2-1] zgesv......................failed  : premature end

of the test script
020/020 - [SCI/contrib/linalg/0.2-1] zhbev......................passed

The factorlu bug is minor and will be fixed in the next release.

The bug in gesv and zgesv is more interesting and has been reported:

http://forge.scilab.org/index.php/p/linalg/issues/530/
```
Comment -- September 23, 2011, 11:00:02 AM
```Here is the changelog for the v0.2.

linalg (v0.2)
* Used apifun to check input arguments.
* Provide optional verbose option for linalg_factorlu.
* Provide optional verbose option for linalg_solvelu.
* Provide optional verbose option for linalg_factorlupivot.
* Provide optional verbose option for linalg_gaussnaive.
* Provide optional verbose option for linalg_rayleighiteration.
* Fixed problems in linalg_rayleighiteration caused by the switch
to linear least squares in backslash.
The algorithm had problems when it came closer to
the exact result, because an intermediate matrix
becomes more and more ill-conditionned.
In this case, Scilab switches the backslash operator
from Gaussian elimination to least squares, which
makes the algorithms going nuts.
Hence, we cannot use this algorithm with a relative
tolerance which is too small.
We now use linalg_gesv and the problem is gone away.
* Reduced the default relative tolerance in linalg_rayleighiteration
to %eps.
```