Deprecated: please see new documentation site.


LAPACK is a free package of linear algebra subroutines written in Fortran that can be used to solve:

  • Systems of Linear equations
  • Linear least squares problems
  • Eigenvalue problems
  • Singular value problems
  • Associated Computations
    • Matrix factorizations (LU, Cholesky, QR, SVD, Schur, generalized Schur)
    • Reordering of the Schur factorizations
    • Estimating condition numbers
    • ...

LAPACK can be used for the following types of matrices:

  • Dense and band (not general sparse matrices)
  • Real and complex
  • Single and double precision


We have version 3.1.1 installed on the LONI clusters (version 3.2 on Eric). A general LAPACK library has been installed to /usr/lib/liblapack.a. Users of LAPACK are not required to add lapack to their software environment. However, if you would still like to, here are the instructions: Add lapack to your path via

 $ softenv | grep lapack

More information on the software environment can be found here. The libraries are stored in /usr/local/packages/lapack-3.1.1-<compiler>

Get information about a routine

LAPACK routines have information stored within the MAN pages. To get more information on a given routine, execute:

$ man <routine name>

For example:

$ man dgesvd

Use LAPACK in Fortran Programs

Call LAPACK routines as you would built-in Fortran functions:

call dgesv(n, nrhs, A, LDA, IPIV, B, LDB, info)

Compile with the lapack library

$ fc files.f -llapack
Show Example Fortran Program

Use LAPACK in C Programs

The LAPACK routines must be declared with extern, the name must be in lowercase, and followed by an '_':

extern void dgetrf_(int*, int*, double*, int*, int*, int*);

Be sure when calling the LAPACK routing to pass arguements by reference. Also, in C matrices are stored in row major order, however in Fortran matrices are stored in column major order, so be sure to transpose your matrices!

Compile your program via

$ cc files.c -llapack

Note: if you want to use your own compiled lapack library, you might want to use the following libraries: -L$LAPACK -llapack -lblas -L/home/compilers/Intel/intel_fc91/lib -lifcore

Show Example Program

Use LAPACK in C++ Programs

The same rules for C apply to C++ programs, except that routines must be declared with extern "C"

extern "C" void dgetrf_(int*, int*, double*, int*, int*, int*);

Compile your program via

$ CC files.C -llapack 
Show Example Program

Additional Resources

  • ScaLAPACK - Scalable LAPACK: A parallel implementation of LAPACK designed for distributed-memory message-passing computers.
  • Intel MKL - Intel's Math Kernel Library: Supports multithreaded LAPACK as well as Scalapack, FFT, ... libraries
  • LAPACK Users Guide

Users may direct questions to

Powered by MediaWiki