LAPACK explained

LAPACK (Netlib reference implementation)
Logo Size:120px
Programming Language:Fortran 90
Genre:Software library
License:BSD-new

LAPACK ("Linear Algebra Package") is a standard software library for numerical linear algebra. It provides routines for solving systems of linear equations and linear least squares, eigenvalue problems, and singular value decomposition. It also includes routines to implement the associated matrix factorizations such as LU, QR, Cholesky and Schur decomposition.[1] LAPACK was originally written in FORTRAN 77, but moved to Fortran 90 in version 3.2 (2008).[2] The routines handle both real and complex matrices in both single and double precision. LAPACK relies on an underlying BLAS implementation to provide efficient and portable computational building blocks for its routines.

LAPACK was designed as the successor to the linear equations and linear least-squares routines of LINPACK and the eigenvalue routines of EISPACK. LINPACK, written in the 1970s and 1980s, was designed to run on the then-modern vector computers with shared memory. LAPACK, in contrast, was designed to effectively exploit the caches on modern cache-based architectures and the instruction-level parallelism of modern superscalar processors, and thus can run orders of magnitude faster than LINPACK on such machines, given a well-tuned BLAS implementation. LAPACK has also been extended to run on distributed memory systems in later packages such as ScaLAPACK and PLAPACK.[3]

Netlib LAPACK is licensed under a three-clause BSD style license, a permissive free software license with few restrictions.[4]

Naming scheme

Subroutines in LAPACK have a naming convention which makes the identifiers very compact. This was necessary as the first Fortran standards only supported identifiers up to six characters long, so the names had to be shortened to fit into this limit.

A LAPACK subroutine name is in the form pmmaaa, where:

For example, the subroutine to solve a linear system with a general (non-structured) matrix using real double-precision arithmetic is called DGESV.

Matrix types in the LAPACK naming scheme
NameDescription
BDbidiagonal matrix
DIdiagonal matrix
GBgeneral band matrix
GEgeneral matrix (i.e., unsymmetric, in some cases rectangular)
GGgeneral matrices, generalized problem (i.e., a pair of general matrices)
GTgeneral tridiagonal matrix
HB(complex) Hermitian band matrix
HE(complex) Hermitian matrix
HGupper Hessenberg matrix, generalized problem (i.e. a Hessenberg and a triangular matrix)
HP(complex) Hermitian, packed storage matrix
HSupper Hessenberg matrix
OP(real) orthogonal matrix, packed storage matrix
OR(real) orthogonal matrix
PBsymmetric matrix or Hermitian matrix positive definite band
POsymmetric matrix or Hermitian matrix positive definite
PPsymmetric matrix or Hermitian matrix positive definite, packed storage matrix
PTsymmetric matrix or Hermitian matrix positive definite tridiagonal matrix
SB(real) symmetric band matrix
SPsymmetric, packed storage matrix
ST(real) symmetric matrix tridiagonal matrix
SYsymmetric matrix
TBtriangular band matrix
TGtriangular matrices, generalized problem (i.e., a pair of triangular matrices)
TPtriangular, packed storage matrix
TRtriangular matrix (or in some cases quasi-triangular)
TZtrapezoidal matrix
UN(complex) unitary matrix
UP(complex) unitary, packed storage matrix

Use with other programming languages and libraries

Many programming environments today support the use of libraries with C binding, allowing LAPACK routines to be used directly so long as a few restrictions are observed. Additionally, many other software libraries and tools for scientific and numerical computing are built on top of LAPACK, such as R,[5] MATLAB,[6] and SciPy.[7]

Several alternative language bindings are also available:

Implementations

As with BLAS, LAPACK is sometimes forked or rewritten to provide better performance on specific systems. Some of the implementations are:

Accelerate: Apple's framework for macOS and iOS, which includes tuned versions of BLAS and LAPACK.[8] [9]
  • Netlib LAPACK: The official LAPACK.
  • Netlib ScaLAPACK: Scalable (multicore) LAPACK, built on top of PBLAS.
  • Intel MKL: Intel's Math routines for their x86 CPUs.
  • OpenBLAS: Open-source reimplementation of BLAS and LAPACK.
  • Gonum LAPACK: A partial native Go implementation.
  • Since LAPACK typically calls underlying BLAS routines to perform the bulk of its computations, simply linking to a better-tuned BLAS implementation can be enough to significantly improve performance. As a result, LAPACK is not reimplemented as often as BLAS is.

    Similar projects

    These projects provide a similar functionality to LAPACK, but with a main interface differing from that of LAPACK:

    Libflame: A dense linear algebra library. Has a LAPACK-compatible wrapper. Can be used with any BLAS, although BLIS is the preferred implementation.[10]
  • Eigen: A header library for linear algebra. Has a BLAS and a partial LAPACK implementation for compatibility.
  • MAGMA: Matrix Algebra on GPU and Multicore Architectures (MAGMA) project develops a dense linear algebra library similar to LAPACK but for heterogeneous and hybrid architectures including multicore systems accelerated with GPGPUs.
  • PLASMA: The Parallel Linear Algebra for Scalable Multi-core Architectures (PLASMA) project is a modern replacement of LAPACK for multi-core architectures. PLASMA is a software framework for development of asynchronous operations and features out of order scheduling with a runtime scheduler called QUARK that may be used for any code that expresses its dependencies with a directed acyclic graph.[11]
  • See also

    Notes and References

    1. Book: Anderson. E.. Bai. Z.. Bischof. C.. Blackford. S.. Demmel. J.. James Demmel. Dongarra. J.. Jack Dongarra. Du Croz. J.. Greenbaum. A.. Anne Greenbaum. Hammarling. S.. McKenney. A.. Sorensen. D.. LAPACK Users' Guide. Third. Society for Industrial and Applied Mathematics. 1999. Philadelphia, PA. 0-89871-447-8. 28 May 2022.
    2. Web site: LAPACK 3.2 Release Notes. 16 November 2008.
    3. Web site: 20 April 2017. 12 June 2007. PLAPACK: Parallel Linear Algebra Package. www.cs.utexas.edu. University of Texas at Austin.
    4. Web site: LICENSE.txt . Netlib . 28 May 2022.
    5. Web site: R: LAPACK Library . 2022-03-19 . stat.ethz.ch.
    6. Web site: LAPACK in MATLAB . Mathworks Help Center . 28 May 2022.
    7. Web site: Low-level LAPACK functions . SciPy v1.8.1 Manual . 28 May 2022.
    8. Web site: Guides and Sample Code. developer.apple.com. 2017-07-07.
    9. Web site: Guides and Sample Code. developer.apple.com. 2017-07-07.
    10. Web site: amd/libflame: High-performance object-based library for DLA computations . GitHub . AMD . 25 August 2020.
    11. Web site: ICL. icl.eecs.utk.edu. en. 2017-07-07.