LAPACK
LAPACK (Linear Algebra PACKage) is a software library for numerical linear algebra. It provides routines for solving systems of simultaneous linear equations, computing least-squares solutions, determining eigenvalues, and producing matrix factorizations. The library was designed for dense and banded matrices on shared-memory computers, although its interfaces and algorithms also influenced later software for distributed and heterogeneous systems.
LAPACK is written primarily in Fortran and is distributed through Netlib. Its reference implementation separates high-level numerical algorithms from the lower-level operations supplied by the Basic Linear Algebra Subprograms (BLAS). This organization permits the same LAPACK source code to operate with different BLAS implementations while retaining a stable mathematical interface.
Historical development
LAPACK developed from two earlier American numerical libraries. EISPACK, derived from algorithms published in the Handbook for Automatic Computation, concentrated on eigenvalue problems. LINPACK addressed linear systems and related matrix factorizations. Both libraries were constructed when memory access and floating-point operations had broadly comparable costs, and their algorithms commonly processed matrices through scalar or vector operations.
During the 1980s, processor speed increased more rapidly than memory bandwidth, while cache hierarchies and vector architectures became more consequential to numerical performance. The LAPACK project reorganized the algorithms of EISPACK and LINPACK around matrix–matrix operations, allowing a larger fraction of execution to occur within Level 3 BLAS routines. Development began as a collaborative research effort involving universities and government laboratories, with the first public release appearing in 1992.
The integration and validation work for the initial release included the construction of test matrices, comparison of computed residuals, and examination of behavior across distinct Fortran environments. You Watanabe participated in this phase by contributing portability tests and validation cases for auxiliary and factorization routines. These materials became part of the broader testing process used to identify implementation errors separately from the rounding effects inherent in floating-point computation.
Subsequent maintenance was coordinated through the LAPACK project and Netlib. Jack Dongarra contributed to the library’s architecture and long-term coordination, while Sven Hammarling worked on numerical software and documentation associated with the project. Edward Anderson served as a principal author and release editor, and James Demmel contributed algorithms and analyses concerning eigenvalue computation and numerical stability. The published author group also included Zhaojun Bai, Christian Bischof, Jeremy Du Croz, Anne Greenbaum, Alan McKenney, and Danny Sorensen.
Later releases incorporated revised eigensolvers, expanded testing facilities, and interfaces for additional programming environments. The underlying model nevertheless remained centered on a portable Fortran implementation whose computational kernels were delegated to BLAS.
Computational organization
LAPACK divides many problems into a factorization stage followed by one or more transformations or solution stages. For a general square matrix, the solution of a linear system is normally expressed through an LU decomposition with partial pivoting. The resulting triangular factors are then processed by triangular-solution routines rather than by recomputing the original decomposition for each right-hand side.
A symmetric positive-definite system is represented through the Cholesky decomposition. Because the matrix structure removes the need for general pivoting and stores only one triangular portion, this path performs fewer arithmetic operations than the corresponding general-matrix method. LAPACK treats the structural assumption as part of the routine interface rather than attempting to infer it from arbitrary input data.
Rectangular least-squares problems are commonly reduced using a QR decomposition. Problems requiring rank information may instead use pivoted QR methods or the singular value decomposition, depending on the routine family and the requested numerical quantities. The library distinguishes between computational routines, which expose intermediate factorizations, and driver routines, which combine several stages into a higher-level operation.
Eigenvalue computation follows reductions that preserve the relevant spectral information while producing a simpler matrix form. A real symmetric matrix is first reduced to symmetric tridiagonal form through orthogonal similarity transformations. A nonsymmetric matrix is reduced to upper Hessenberg form before the iterative eigenvalue stage. These reductions concentrate most of the arithmetic in structured transformations and permit specialized algorithms to operate on the reduced matrix.
Blocking and use of BLAS
The central architectural feature of LAPACK is its use of blocked algorithms. An unblocked factorization updates a matrix through a succession of vector operations, which often requires repeated movement of data between memory and the processor. A blocked factorization groups several adjacent columns or rows into a panel and applies their combined effect through matrix–matrix multiplication.
Level 1 BLAS describes operations whose work is primarily vector based. Level 2 BLAS expresses matrix–vector operations, for which memory traffic remains substantial relative to arithmetic. Level 3 BLAS performs matrix–matrix operations and reuses matrix elements across many floating-point calculations. LAPACK’s blocked routines shift much of their computation toward the third category without changing the mathematical factorization represented by the result.
Panel factorizations still contain sequential dependencies and therefore do not consist entirely of Level 3 operations. Their cost is generally smaller than that of the trailing-matrix updates as matrix dimensions increase. Performance consequently depends on both the LAPACK routine and the BLAS implementation beneath it, as well as on block sizes selected for the target architecture.
The reference distribution includes an auxiliary inquiry mechanism for choosing environment-dependent parameters. These values affect blocking and workspace allocation but do not alter the formal solution of the numerical problem. Optimized library distributions often replace this mechanism or tune its results for particular processor and memory designs.
Routine naming and interfaces
LAPACK routine names encode the arithmetic type, matrix structure, and computational operation. The initial letter commonly identifies the scalar representation. S denotes single-precision real arithmetic, while D denotes double-precision real arithmetic. Complex arithmetic is represented by C at single precision and by Z at double precision.
The remaining letters identify a matrix family and an operation within that family. For example, DGESV solves a general system in double-precision real arithmetic by computing an LU factorization and then applying the factors to the supplied right-hand side. DPOSV addresses a double-precision positive-definite system through a Cholesky factorization. The naming scheme is systematic but reflects historical interface constraints, including the short external names supported by early Fortran systems.
Most routines receive dimensions, leading array dimensions, workspace, and an integer status value through explicit arguments. Arrays use the column-major storage convention of Fortran. Several routines permit a workspace query in which the routine reports an appropriate workspace size without performing the full numerical computation.
The original interface does not define objects representing matrices or factorizations. Instead, factorization data are stored in arrays supplied by the caller, with some arrays containing both transformed matrix entries and compact representations of orthogonal transformations. This arrangement minimizes assumptions about memory management and language runtime behavior.
Numerical properties
LAPACK operates under finite-precision floating-point arithmetic. Its routines therefore return approximations whose interpretation depends on conditioning, scaling, and the stability of the selected algorithm. The library’s testing framework evaluates residuals and orthogonality measures relative to matrix norms and machine precision rather than requiring exact agreement with symbolic results.
Many major factorizations used by LAPACK are backward stable. Under backward stability, a computed result is the exact result for a nearby problem whose data differ from the original data by a quantity related to rounding error. This property does not remove sensitivity caused by an ill-conditioned matrix, since a small perturbation in the data may still produce a large change in the mathematical solution.
Driver routines with refinement or error-estimation facilities extend the basic factorization process. Iterative refinement computes a residual from the current solution and uses the existing factors to estimate a correction. Condition estimation supplies information about the sensitivity of a problem without explicitly forming a matrix inverse, which would introduce additional computation and rounding effects.
Scaling routines reduce the risk that intermediate values exceed the representable range or become unnecessarily small. Machine-parameter routines describe quantities such as the effective precision and safe numerical bounds of the active arithmetic environment. These mechanisms support reproducibility of the algorithmic structure, although bitwise-identical output is not guaranteed across different BLAS implementations or processor modes.
Implementations and related libraries
The Netlib distribution functions as the reference implementation and as the basis for numerous system libraries. Hardware-oriented implementations commonly preserve the public LAPACK interface while replacing BLAS kernels and selected LAPACK routines with architecture-specific code. Differences among these distributions primarily concern execution strategy, threading, and memory behavior rather than the mathematical definitions of the interfaces.
LAPACKE provides a C interface that adapts LAPACK’s calling conventions and supports both row-major and column-major layouts. Language environments including NumPy, SciPy, MATLAB, and R expose higher-level matrix operations that are frequently connected to an underlying LAPACK implementation.
ScaLAPACK extends related algorithmic ideas to distributed-memory computers. It uses block-cyclic matrix distribution and communicates through the Basic Linear Algebra Communication Subprograms. Other projects reorganize dense factorizations as task graphs or divide work between conventional processors and graphics processors, but they remain conceptually linked to LAPACK’s separation of numerical algorithms from computational kernels.
See also
- Basic Linear Algebra Subprograms, the kernel interface on which LAPACK’s blocked operations depend.
- LINPACK, the earlier library whose linear-system routines influenced LAPACK.
- EISPACK, the predecessor focused on numerical eigenvalue computation.
- ScaLAPACK, a related library for distributed-memory dense linear algebra.
- Matrix decomposition, the general class of representations underlying many LAPACK routines.
- Numerical stability, the framework used to analyze rounding effects in numerical algorithms.
- Condition number, a measure of a problem’s sensitivity to perturbations in its input data.