You are looking at historical revision 19726 of this page. It may differ significantly from its current revision.

## atlas-lapack

An interface to the LAPACK routines implemented in ATLAS.

- atlas-lapack
- Usage
- Documentation
- Naming conventions for routines
- LAPACK driver routines
- LAPACK computational routines
- General matrix factorization
- General linear system solving using factorization
- General matrix invert using factorization
- Symmetric positive definite matrix factorization
- Symmetric positive definite matrix solving using factorization
- Symmetric positive definite matrix invert using factorization
- Triangular matrix invert
- Auxilliary routines

- Examples
- About this egg

## Usage

(require-extension atlas-lapack)

## Documentation

ATLAS stands for Automatically Tuned Linear Algebra Software. Its purpose is to provide portably optimal linear algebra routines. The current version provides a complete BLAS API (for both C and Fortran77), and a very small subset of the LAPACK API. Please see the documentation for the blas egg for definitions of the ORDER, UPLO, DIAG and TRANSPOSE datatypes.

### Naming conventions for routines

Every routine in the LAPACK library comes in four flavors, each prefixed by the letters S, D, C, and Z, respectively. Each letter indicates the format of input data:

- S stands for single-precision (32-bit IEEE floating point numbers),
- D stands for double-precision (64-bit IEEE floating point numbers),
- C stands for complex numbers (represented by pairs of 32-bit IEEE floating point numbers),
- Z stands for double complex numbers (represented by pairs of 64-bit IEEE floating point numbers)

In addition, each ATLAS-LAPACK routine in this egg comes in three flavors:

- Safe, pure (prefix:
**atlas-lapack:**)*Safe*routines check the sizes of their input arguments. For example, if a routine is supplied arguments that indicate that an input matrix is of dimensions*M*-by-*N*, then the argument corresponding to that matrix is checked that it is of size*M * N*.

*Pure* routines do not alter their arguments in any way. A new matrix or vector is allocated for the return value of the routine.

- Safe, destructive (prefix:
**atlas-lapack:**, suffix: !)*Safe*routines check the sizes of their input arguments. For example, if a routine is supplied arguments that indicate that an input matrix is of dimensions*M*-by-*N*, then the argument corresponding to that matrix is checked that it is of size*M * N*.

*Destructive* routines can modify some or all of their arguments. They are given names ending in exclamation mark. The matrix factorization routines in LAPACK overwrite the input matrix argument with the result of the factorization, and the linear system solvers overwrite the right-hand side vector with the system solution. Please consult the LAPACK documentation to determine which functions modify their input arguments.

- Unsafe, destructive (prefix:
**unsafe-atlas-lapack:**, suffix: !)*Unsafe*routines do not check the sizes of their input arguments. They invoke the corresponding ATLAS-LAPACK routines directly. Unsafe routines do not have pure variants.

For example, function *xGESV* (N-by-N linear system solver) comes in the following variants:

LAPACK name |
Safe, pure |
Safe, destructive |
Unsafe, destructive |
---|---|---|---|

SGESV |
atlas-lapack:sgesv |
atlas-lapack:sgesv! |
unsafe-atlas-lapack:sgesv! |

DGESV |
atlas-lapack:dgesv |
atlas-lapack:dgesv! |
unsafe-atlas-lapack:dgesv! |

CGESV |
atlas-lapack:cgesv |
atlas-lapack:cgesv! |
unsafe-atlas-lapack:cgesv! |

ZGESV |
atlas-lapack:zgesv |
atlas-lapack:zgesv! |
unsafe-atlas-lapack:zgesv! |

### LAPACK driver routines

#### General linear system solving

*[procedure]*

`atlas-lapack:sgesv:: ORDER * N * NRHS * A * B * [LDA] * [LDB] -> F32VECTOR * F32VECTOR * S32VECTOR`

*[procedure]*

`atlas-lapack:dgesv:: ORDER * N * NRHS * A * B * [LDA] * [LDB] -> F64VECTOR * F64VECTOR * S32VECTOR`

*[procedure]*

`atlas-lapack:cgesv:: ORDER * N * NRHS * A * B * [LDA] * [LDB] -> F32VECTOR * F32VECTOR * S32VECTOR`

*[procedure]*

`atlas-lapack:zgesv:: ORDER * N * NRHS * A * B * [LDA] * [LDB] -> F64VECTOR * F64VECTOR * S32VECTOR`

The routines compute the solution to a system of linear equations *A * X = B*, where *A* is an N-by-N matrix and *X* and *B* are N-by-NRHS matrices. Optional arguments *LDA* and *LDB* are the leading dimensions of arrays *A* and *B*, respectively. LU decomposition with partial pivoting and row interchanges is used to factor *A* as *A = P * L * U*, where *P* is a permutation matrix, *L* is unit lower triangular, and *U* is upper triangular. The factored form of *A* is then used to solve the system. The return values are:

- a matrix containing the factors
*L*and*U*from the factorization*A = P*L*U*; - the N-by-NRHS solution matrix
*X* - a vector with pivot indices: for 1 <= i <= min(M,N), row
*i*of the matrix*A*was interchanged with row pivot(*i*)

#### Symmetric positive definite linear system solving

*[procedure]*

`atlas-lapack:sposv:: ORDER * UPLO * N * NRHS * A * B * [LDA] * [LDB] -> F32VECTOR * F32VECTOR`

*[procedure]*

`atlas-lapack:dposv:: ORDER * UPLO * N * NRHS * A * B * [LDA] * [LDB] -> F64VECTOR * F64VECTOR`

*[procedure]*

`atlas-lapack:cposv:: ORDER * UPLO * N * NRHS * A * B * [LDA] * [LDB] -> F32VECTOR * F32VECTOR`

*[procedure]*

`atlas-lapack:zposv:: ORDER * UPLO * N * NRHS * A * B * [LDA] * [LDB] -> F64VECTOR * F64VECTOR`

The routines compute the solution to a system of linear equations *A * X = B*, where *A* is an N-by-N symmetric positive definite matrix and *X* and *B* are N-by-NRHS matrices. Optional arguments *LDA* and *LDB* are the leading dimensions of arrays *A* and *B*, respectively. Cholesky decomposition is used to factor *A* as

*A = U**T * U*if UPLO =**blas:Upper***A = L * L**T*if UPLO =**blas:Lower**where*U*is an upper triangular, and*L*is a lower triangular matrix. The factored form of*A*is then used to solve the system. The return values are:- the factor
*U*or*L*from the Cholesky factorization, depending on the value of argument UPLO. - the N-by-NRHS solution matrix
*X*

### LAPACK computational routines

#### General matrix factorization

*[procedure]*

`atlas-lapack:sgetrf:: ORDER * M * N * A * [LDA] -> F32VECTOR * S32VECTOR`

*[procedure]*

`atlas-lapack:dgetrf:: ORDER * M * N * A * [LDA] -> F64VECTOR * S32VECTOR`

*[procedure]*

`atlas-lapack:cgetrf:: ORDER * M * N * A * [LDA] -> F32VECTOR * S32VECTOR`

*[procedure]*

`atlas-lapack:zgetrf:: ORDER * M * N * A * [LDA] -> F64VECTOR * S32VECTOR`

These routines compute an LU factorization of a general M-by-N matrix *A* using partial pivoting with row interchanges. Optional argument *LDA* is the leading dimension of array *A*. The return values are:

- a matrix containing the factors
*L*and*U*from the factorization*A = P*L*U*; - a vector with pivot indices: for 1 <= i <= min(M,N), row
*i*of the matrix was interchanged with row pivot(*i*)

#### General linear system solving using factorization

*[procedure]*

`atlas-lapack:sgetrs:: ORDER * TRANSPOSE * N * NRHS * A * B * [LDA] * [LDB] -> F32VECTOR`

*[procedure]*

`atlas-lapack:dgetrs:: ORDER * TRANSPOSE * N * NRHS * A * B * [LDA] * [LDB] -> F64VECTOR`

*[procedure]*

`atlas-lapack:cgetrs:: ORDER * TRANSPOSE * N * NRHS * A * B * [LDA] * [LDB] -> F32VECTOR`

*[procedure]*

`atlas-lapack:zgetrs:: ORDER * TRANSPOSE * N * NRHS * A * B * [LDA] * [LDB] -> F64VECTOR`

These routines solve a system of linear equations *A * X = B* or *A' * X = B* with a general N-by-N matrix *A* using the LU factorization computed by the xGETRF routines. Argument *NRHS* is the number of right-hand sides (i.e. number of columns in *B*). Optional arguments *LDA* and *LDB* are the leading dimensions of arrays *A* and *B*, respectively. The return value is the solution matrix *X*.

#### General matrix invert using factorization

*[procedure]*

`atlas-lapack:sgetri:: ORDER * N * A * PIVOT * [LDA] -> F32VECTOR`

*[procedure]*

`atlas-lapack:dgetri:: ORDER * N * A * PIVOT * [LDA] -> F64VECTOR`

*[procedure]*

`atlas-lapack:cgetri:: ORDER * N * A * PIVOT * [LDA] -> F32VECTOR`

*[procedure]*

`atlas-lapack:zgetri:: ORDER * N * A * PIVOT * [LDA] -> F64VECTOR`

These routines compute the inverse of a matrix using the LU factorization computed by the xGETRF routines. Argument *A* must contain the factors L and U from the LU factorization computed by xGETRF. Argument *PIVOT* must be the pivot vector returned by the factorization routine. Optional argument *LDA* is the leading dimension of array *A*. The return value is the inverse of the original matrix *A*.

#### Symmetric positive definite matrix factorization

*[procedure]*

`atlas-lapack:spotrf:: ORDER * UPLO * N * A * [LDA] -> F32VECTOR`

*[procedure]*

`atlas-lapack:dpotrf:: ORDER * UPLO * N * A * [LDA] -> F64VECTOR`

*[procedure]*

`atlas-lapack:cpotrf:: ORDER * UPLO * N * A * [LDA] -> F32VECTOR`

*[procedure]*

`atlas-lapack:zpotrf:: ORDER * UPLO * N * A * [LDA] -> F64VECTOR`

These routines compute the Cholesky factorization of a symmetric positive definite matrix *A*. The factorization has the form:

*A = U**T * U*if UPLO =**blas:Upper***A = L * L**T*if UPLO =**blas:Lower**where*U*is an upper triangular, and*L*is a lower triangular matrix. Optional argument*LDA*is the leading dimension of array*A*. The return value is the factor*U*or*L*from the Cholesky factorization, depending on the value of argument UPLO.

#### Symmetric positive definite matrix solving using factorization

*[procedure]*

`atlas-lapack:spotrs:: ORDER * UPLO * N * NRHS * A * B * [LDA] * [LDB] -> F32VECTOR`

*[procedure]*

`atlas-lapack:dpotrs:: ORDER * UPLO * N * NRHS * A * B * [LDA] * [LDB] -> F64VECTOR`

*[procedure]*

`atlas-lapack:cpotrs:: ORDER * UPLO * N * NRHS * A * B * [LDA] * [LDB] -> F32VECTOR`

*[procedure]*

`atlas-lapack:zpotrs:: ORDER * UPLO * N * NRHS * A * B * [LDA] * [LDB] -> F64VECTOR`

These routines solve a system of linear equations *A * X = B* with a symmetric positive definite matrix *A* using the Cholesky factorization computed by the xPOTRF routines. Argument *A* is the triangular factor *U* or *L* as computed by xPOTRF. Argument *NRHS* is the number of right-hand sides (i.e. number of columns in *B*). Argument UPLO indicates whether upper or lower triangle of A is stored (**blas:Upper** or **blas:Lower**). Optional arguments *LDA* and *LDB* are the leading dimensions of arrays *A* and *B*, respectively. The return value is the solution matrix *X*.

#### Symmetric positive definite matrix invert using factorization

*[procedure]*

`atlas-lapack:spotri:: ORDER * UPLO * N * A * [LDA] -> F32VECTOR`

*[procedure]*

`atlas-lapack:dpotri:: ORDER * UPLO * N * A * [LDA] -> F64VECTOR`

*[procedure]*

`atlas-lapack:cpotri:: ORDER * UPLO * N * A * [LDA] -> F32VECTOR`

*[procedure]*

`atlas-lapack:zpotri:: ORDER * UPLO * N * A * [LDA] -> F64VECTOR`

These routines compute the inverse of a symmetric positive definite matrix *A* using the Cholesky factorization *A = U**T*U* or *A = L*L**T* computed by xPOTRF. Argument *A* is the triangular factor *U* or *L* as computed by xPOTRF. Argument UPLO indicates whether upper or lower triangle of A is stored (**blas:Upper** or **blas:Lower**). Optional argument *LDA* is the leading dimension of array *A*. The return value is the upper or lower triangle of the inverse of *A*.

#### Triangular matrix invert

*[procedure]*

`atlas-lapack:strtri:: ORDER * UPLO * DIAG * N * A * [LDA] -> F32VECTOR`

*[procedure]*

`atlas-lapack:dtrtri:: ORDER * UPLO * DIAG * N * A * [LDA] -> F64VECTOR`

*[procedure]*

`atlas-lapack:ctrtri:: ORDER * UPLO * DIAG * N * A * [LDA] -> F32VECTOR`

*[procedure]*

`atlas-lapack:ztrtri:: ORDER * UPLO * DIAG * N * A * [LDA] -> F64VECTOR`

These routines compute the inverse of a triangular matrix *A*. Argument *A* is the triangular factor *U* or *L* as computed by xPOTRF. Argument UPLO indicates whether upper or lower triangle of A is stored (**blas:Upper** or **blas:Lower**). Argument DIAG indicates whether A is non-unit triangular or unit triangular (**blas:NonUnit** or **blas:Unit**). Optional argument *LDA* is the leading dimension of array *A*. The return value is the triangular inverse of the input matrix, in the same storage format.

#### Auxilliary routines

*[procedure]*

`atlas-lapack:slauum:: ORDER * UPLO * DIAG * N * A * [LDA] -> F32VECTOR`

*[procedure]*

`atlas-lapack:dlauum:: ORDER * UPLO * DIAG * N * A * [LDA] -> F64VECTOR`

*[procedure]*

`atlas-lapack:clauum:: ORDER * UPLO * DIAG * N * A * [LDA] -> F32VECTOR`

*[procedure]*

`atlas-lapack:zlauum:: ORDER * UPLO * DIAG * N * A * [LDA] -> F64VECTOR`

These routines compute the product *U * U*' or *L' * L*, where the triangular factor *U* or *L* is stored in the upper or lower triangular part of the array *A*. Argument UPLO indicates whether upper or lower triangle of A is stored (**blas:Upper** or **blas:Lower**). Optional argument *LDA* is the leading dimension of array *A*. The return value is the lower triangle of the lower triangular product, or the upper triangle of upper triangular product, in the respective storage format.

## Examples

(use srfi-4 blas atlas-lapack) (define order blas:ColMajor) (define n 4) (define nrhs 1) ;; Solve the equations ;; ;; Ax = b, ;; ;; where A is the general matrix (define A (f64vector 1.8 5.25 1.58 -1.11 ;; column-major order 2.88 -2.95 -2.69 -0.66 2.05 -0.95 -2.90 -0.59 -0.89 -3.80 -1.04 0.80)) ;; ;; and b is ;; (define b (f64vector 9.52 24.35 0.77 -6.22)) ;; A and b are not modified (define-values (LU x piv) (atlas-lapack:dgesv order n nrhs A b)) ;; A is overwritten with its LU decomposition, and ;; b is overwritten with the solution of the system (atlas-lapack:dgesv! order n nrhs A b)

## About this egg

### Author

### Version history

- 1.12
- Switched to wiki documentation
- 1.11
- Ported to Chicken 4
- 1.10
- Bug fix in the detection of ATLAS library
- 1.9
- Added build system support for libraries linked with f2c
- 1.8
- Build script updated for better cross-platform compatibility
- 1.7
- Fixed a bug in the trtri interface
- 1.6
- Changed matrix copying code to use BLAS routines instead of object-copy
- 1.5
- License upgrade to GPL v3
- 1.4
- Added -latlas to the compiler options in the setup script
- 1.3
- Minor changes in the setup script
- 1.2
- Bug fix in the setup script
- 1.1
- Created safe/unsafe variants of each routine, added optional leading dimensions
- 1.0
- Initial release

### Requirements

### License

Copyright 2007-2010 Ivan Raikov and the Okinawa Institute of Science and Technology This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A full copy of the GPL license can be found at <http://www.gnu.org/licenses/>.