Top Related Projects
SciPy library main repository
The fundamental package for scientific computing with Python.
OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.
BLAS-like Library Instantiation Software Framework
Microsoft Quantum Development Kit Samples
NumPy & SciPy for GPU
Quick Overview
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. LAPACK is written in Fortran 90 and is highly efficient, portable, and widely used in scientific computing.
Pros
- High performance and optimized routines for linear algebra operations
- Extensively tested and reliable, with a long history of use in scientific computing
- Portable across different hardware architectures and operating systems
- Serves as a foundation for many higher-level scientific computing libraries
Cons
- Steep learning curve due to its low-level nature and Fortran interface
- Documentation can be technical and challenging for beginners
- Requires careful memory management and array handling
- May require additional wrappers or interfaces for use in modern programming languages
Code Examples
- Solving a system of linear equations (AX=B):
PROGRAM example
IMPLICIT NONE
INTEGER, PARAMETER :: N = 3
REAL*8 A(N,N), B(N), IPIV(N)
INTEGER INFO
A = RESHAPE((/1.0, 2.0, 3.0, 2.0, 5.0, 3.0, 1.0, 0.0, 8.0/), (/N,N/))
B = (/1.0, 2.0, 3.0/)
CALL DGESV(N, 1, A, N, IPIV, B, N, INFO)
IF (INFO == 0) THEN
PRINT *, "Solution:", B
ELSE
PRINT *, "Error: DGESV failed"
END IF
END PROGRAM
- Computing eigenvalues of a symmetric matrix:
PROGRAM eigenvalues
IMPLICIT NONE
INTEGER, PARAMETER :: N = 3
REAL*8 A(N,N), W(N), WORK(3*N-1)
INTEGER INFO
A = RESHAPE((/1.0, 2.0, 3.0, 2.0, 5.0, 3.0, 3.0, 3.0, 6.0/), (/N,N/))
CALL DSYEV('N', 'U', N, A, N, W, WORK, 3*N-1, INFO)
IF (INFO == 0) THEN
PRINT *, "Eigenvalues:", W
ELSE
PRINT *, "Error: DSYEV failed"
END IF
END PROGRAM
- Singular Value Decomposition (SVD):
PROGRAM svd
IMPLICIT NONE
INTEGER, PARAMETER :: M = 4, N = 3
REAL*8 A(M,N), S(MIN(M,N)), U(M,M), VT(N,N), WORK(5*MAX(M,N))
INTEGER INFO
A = RESHAPE((/1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0/), (/M,N/))
CALL DGESVD('A', 'A', M, N, A, M, S, U, M, VT, N, WORK, 5*MAX(M,N), INFO)
IF (INFO == 0) THEN
PRINT *, "Singular values:", S
ELSE
PRINT *, "Error: DGESVD failed"
END IF
END PROGRAM
Getting Started
To use LAPACK, follow these steps:
- Install LAPACK on your system (e.g.,
sudo apt-get install liblapack-dev
on Ubuntu) - Include the LAPACK header in your Fortran code:
USE LAPACK95
Competitor Comparisons
SciPy library main repository
Pros of SciPy
- Broader scope: SciPy offers a wide range of scientific computing tools beyond linear algebra
- Higher-level interface: Provides a more user-friendly API for scientific computing tasks
- Python integration: Seamlessly integrates with other Python libraries and workflows
Cons of SciPy
- Performance overhead: May be slower for certain operations due to Python wrapper
- Less specialized: Not as focused on linear algebra as LAPACK, potentially lacking some advanced features
Code Comparison
LAPACK (Fortran):
CALL DGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO )
SciPy (Python):
from scipy import linalg
x = linalg.solve(a, b)
Summary
SciPy provides a more accessible and versatile scientific computing toolkit, while LAPACK offers specialized linear algebra routines with potentially better performance. SciPy is ideal for Python users seeking a comprehensive solution, whereas LAPACK is better suited for low-level, high-performance linear algebra operations.
The fundamental package for scientific computing with Python.
Pros of NumPy
- Higher-level Python interface, making it more accessible for data scientists and researchers
- Extensive array operations and mathematical functions beyond linear algebra
- Integrates well with other Python scientific computing libraries
Cons of NumPy
- May have slower performance for certain specialized linear algebra operations
- Larger package size and more dependencies compared to LAPACK
- Less fine-grained control over low-level linear algebra routines
Code Comparison
LAPACK (Fortran):
CALL DGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO )
NumPy (Python):
x = np.linalg.solve(a, b)
NumPy provides a more intuitive and concise interface for common linear algebra operations, while LAPACK offers more detailed control and potentially better performance for specialized tasks. NumPy is better suited for general-purpose scientific computing in Python, whereas LAPACK is ideal for low-level, high-performance linear algebra implementations.
OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.
Pros of OpenBLAS
- Optimized for performance on various CPU architectures
- Supports multi-threading for improved speed on multi-core systems
- Includes both BLAS and LAPACK functionality in a single library
Cons of OpenBLAS
- May have a larger memory footprint due to optimizations
- Can be more complex to build and configure for specific systems
- Might not always match LAPACK's reference implementation exactly
Code Comparison
LAPACK (Fortran):
SUBROUTINE DGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
DOUBLE PRECISION ALPHA,BETA
INTEGER K,LDA,LDB,LDC,M,N
CHARACTER TRANSA,TRANSB
DOUBLE PRECISION A(LDA,*),B(LDB,*),C(LDC,*)
OpenBLAS (C):
void cblas_dgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,
const enum CBLAS_TRANSPOSE TransB, const int M, const int N,
const int K, const double alpha, const double *A,
const int lda, const double *B, const int ldb,
const double beta, double *C, const int ldc);
Both examples show the function signature for matrix multiplication (DGEMM), illustrating the difference in language and parameter handling between LAPACK and OpenBLAS.
BLAS-like Library Instantiation Software Framework
Pros of BLIS
- Designed for modern CPU architectures, offering better performance on contemporary hardware
- More flexible and extensible framework, allowing easier customization and optimization
- Provides a cleaner, more modular codebase that's easier to maintain and contribute to
Cons of BLIS
- Smaller community and ecosystem compared to LAPACK
- Less comprehensive in terms of supported operations, focusing primarily on BLAS-like functionality
- May require more effort to integrate into existing systems that are built around LAPACK
Code Comparison
LAPACK (Fortran):
SUBROUTINE DGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
DOUBLE PRECISION ALPHA,BETA
INTEGER K,LDA,LDB,LDC,M,N
CHARACTER TRANSA,TRANSB
DOUBLE PRECISION A(LDA,*),B(LDB,*),C(LDC,*)
BLIS (C):
void bli_dgemm(
trans_t transa,
trans_t transb,
dim_t m,
dim_t n,
dim_t k,
double* alpha,
double* a, inc_t rsa, inc_t csa,
double* b, inc_t rsb, inc_t csb,
double* beta,
double* c, inc_t rsc, inc_t csc
)
Microsoft Quantum Development Kit Samples
Pros of Quantum
- Focuses on cutting-edge quantum computing, offering a framework for developing quantum algorithms
- Provides a high-level programming language (Q#) specifically designed for quantum computing
- Includes extensive documentation, tutorials, and samples for learning quantum programming
Cons of Quantum
- Less mature and established compared to LAPACK, which has been widely used for decades
- Limited practical applications currently due to the nascent state of quantum hardware
- Steeper learning curve for developers not familiar with quantum computing concepts
Code Comparison
LAPACK (Fortran):
SUBROUTINE DGETRF( M, N, A, LDA, IPIV, INFO )
INTEGER INFO, LDA, M, N
INTEGER IPIV( * )
DOUBLE PRECISION A( LDA, * )
Quantum (Q#):
operation ApplyQuantumFourierTransform(register : Qubit[]) : Unit is Adj + Ctl {
let nQubits = Length(register);
for (i in 0 .. nQubits - 1) {
H(register[i]);
// ... (additional operations)
}
}
The code snippets illustrate the difference in focus and syntax between the two projects. LAPACK deals with linear algebra operations on classical computers, while Quantum provides constructs for quantum algorithms.
NumPy & SciPy for GPU
Pros of CuPy
- GPU-accelerated computing for NumPy-like operations
- Seamless integration with existing NumPy code
- Supports various CUDA libraries and custom kernels
Cons of CuPy
- Limited to NVIDIA GPUs and requires CUDA installation
- May have compatibility issues with some NumPy functions
- Potential performance overhead for small datasets
Code Comparison
LAPACK (Fortran):
SUBROUTINE DGEMM(TRANSA,TRANSB,M,N,K,ALPHA,A,LDA,B,LDB,BETA,C,LDC)
DOUBLE PRECISION ALPHA,BETA
INTEGER K,LDA,LDB,LDC,M,N
CHARACTER TRANSA,TRANSB
DOUBLE PRECISION A(LDA,*),B(LDB,*),C(LDC,*)
CuPy (Python):
import cupy as cp
a = cp.array([[1, 2], [3, 4]])
b = cp.array([[5, 6], [7, 8]])
c = cp.dot(a, b)
Summary
LAPACK is a low-level linear algebra library written in Fortran, offering high performance for CPU-based computations. CuPy, on the other hand, provides a NumPy-like interface for GPU-accelerated computing, making it easier to leverage GPU power for numerical operations. While LAPACK is more versatile and widely supported, CuPy offers significant speed improvements for large-scale computations on compatible hardware.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
LAPACK
- VERSION 1.0 : February 29, 1992
- VERSION 1.0a : June 30, 1992
- VERSION 1.0b : October 31, 1992
- VERSION 1.1 : March 31, 1993
- VERSION 2.0 : September 30, 1994
- VERSION 3.0 : June 30, 1999
- VERSION 3.0 + update : October 31, 1999
- VERSION 3.0 + update : May 31, 2000
- VERSION 3.1 : November 2006
- VERSION 3.1.1 : February 2007
- VERSION 3.2 : November 2008
- VERSION 3.2.1 : April 2009
- VERSION 3.2.2 : June 2010
- VERSION 3.3.0 : November 2010
- VERSION 3.3.1 : April 2011
- VERSION 3.4.0 : November 2011
- VERSION 3.4.1 : April 2012
- VERSION 3.4.2 : September 2012
- VERSION 3.5.0 : November 2013
- VERSION 3.6.0 : November 2015
- VERSION 3.6.1 : June 2016
- VERSION 3.7.0 : December 2016
- VERSION 3.7.1 : June 2017
- VERSION 3.8.0 : November 2017
- VERSION 3.9.0 : November 2019
- VERSION 3.9.1 : April 2021
- VERSION 3.10.0 : June 2021
- VERSION 3.10.1 : April 2022
- VERSION 3.11.0 : November 2022
- VERSION 3.12.0 : November 2023
LAPACK is a library of Fortran subroutines for solving the most commonly occurring problems in numerical linear algebra.
LAPACK is a freely-available software package. It can be included in commercial software packages (and has been). We only ask that that proper credit be given to the authors, for example by citing the LAPACK Users' Guide. The license used for the software is the modified BSD license.
Like all software, it is copyrighted. It is not trademarked, but we do ask the following: if you modify the source for these routines we ask that you change the name of the routine and comment the changes made to the original.
We will gladly answer any questions regarding the software. If a modification is done, however, it is the responsibility of the person who modified the routine to provide support.
LAPACK is available from GitHub. LAPACK releases are also available on netlib.
The distribution contains (1) the Fortran source for LAPACK, and (2) its testing programs. It also contains (3) the Fortran reference implementation of the Basic Linear Algebra Subprograms (the Level 1, 2, and 3 BLAS) needed by LAPACK. However this code is intended for use only if there is no other implementation of the BLAS already available on your machine; the efficiency of LAPACK depends very much on the efficiency of the BLAS. It also contains (4) CBLAS, a C interface to the BLAS, and (5) LAPACKE, a C interface to LAPACK.
Installation
- LAPACK can be installed with
make
. The configuration must be set in themake.inc
file. Amake.inc.example
for a Linux machine running GNU compilers is given in the main directory. Some specificmake.inc
are also available in theINSTALL
directory. - LAPACK includes also the CMake build. You will need
to have CMake installed on your machine. CMake will allow an easy
installation on a Windows Machine. An example CMake build to install the
LAPACK library under
$HOME/.local/lapack/
is:mkdir build cd build cmake -DCMAKE_INSTALL_PREFIX=$HOME/.local/lapack .. cmake --build . -j --target install
- LAPACK can be built and installed using vcpkg dependency manager:
The lapack port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.git clone https://github.com/Microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh # ./bootstrap-vcpkg.bat for Windows ./vcpkg integrate install ./vcpkg install lapack
User Support
LAPACK has been thoroughly tested, on many different types of computers. The LAPACK project supports the package in the sense that reports of errors or poor performance will gain immediate attention from the developers. Such reports, descriptions of interesting applications, and other comments should be sent by email to the LAPACK team.
A list of known problems, bugs, and compiler errors for LAPACK is maintained on netlib. Please see as well the GitHub issue tracker.
For further information on LAPACK please read our FAQ and Users' Guide. A user forum and specific information for running LAPACK under Windows. is also available to help you with the LAPACK library.
Testing
LAPACK includes a thorough test suite. We recommend that, after compilation, you run the test suite.
For complete information on the LAPACK Testing please consult LAPACK Working Note 41 "Installation Guide for LAPACK".
LAPACKE
LAPACK now includes the LAPACKE package. LAPACKE is a Standard C language API for LAPACK that was born from a collaboration of the LAPACK and INTEL Math Kernel Library teams.
Top Related Projects
SciPy library main repository
The fundamental package for scientific computing with Python.
OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.
BLAS-like Library Instantiation Software Framework
Microsoft Quantum Development Kit Samples
NumPy & SciPy for GPU
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot