LAPACK

De Wiki de Calcul Québec
Aller à : Navigation, rechercher
Cette page est une traduction de la page LAPACK et la traduction est complétée à 100 % et à jour.

Autres langues :anglais 100% • ‎français 100%

Sommaire

Description

LAPACK (Linear Algebra Package) is a mathematical library consisting of a collection of functions for the solution of systems of linear equations, least squares problems, eigenvalue/eigenvector calculations and singular value decompositions. There are also routines for the computation of several common matrix decompositions: LU, QR, SVD, Cholesky, Schur and generalized Schur. The methods in LAPACK work with dense and banded matrices whose elements are either real or complex. The base library is written in Fortran 77 but there are also versions for Fortran 90 (LAPACK90), Fortran 95 (LAPACK95), C (CLAPACK) and C++ (Lapack++).

The reference implementation of LAPACK is available at Netlib and the methods are written in such a way as to make use of the BLAS library. The library's speed can be greatly enhanced by using an optimized BLAS, such as the one included in the MKL. Nevertheless, various third parties offer their own LAPACK implementation so as to maximize the library's performance while also preserving the compatibility and precision of an individual LAPACK version.

Available Implementations

Intel Math Kernel Library (MKL)

The Math Kernel Library contains a complete and optimized version of LAPACK.

Example

Here is an example computing the eigenvalues of a matrix using Lapack. The example is written in Fortran 90.

File : ex_lapack.f90
!PROGRAM EXAMPLE TO SOLVE A SYSTEM
!OF LINEAR EQUATIONS USING LAPACK
!CHRISTIAN LANGLOIS, CCS, SEPTEMBER 2003
PROGRAM LAPACK_SOL
!**********************************************************
 
 
!**********************************************************
!***********      VARIABLE DECLARATION           **********
!**********************************************************
IMPLICIT NONE
INTEGER :: N=3, NRHS=1, LDA=3, IPIV(3), LDB=3
INTEGER :: LWORK, INFO
REAL(KIND=8) :: RES
REAL(KIND=8),EXTERNAL :: DDOT
REAL(KIND=8) :: A(3,3), B(3,1)
REAL(KIND=8), ALLOCATABLE :: WORK(:)
!**********************************************************
 
 
!**********************************************************
!************       PROBLEM DATA             **************
!**********************************************************
A=0D0
A(1,1)=2D0
A(1,3)=1D0
A(2,2)=1D0
A(3,1)=1D0
A(3,3)=2D0
B(1,1)=1D0
B(2,1)=2D0
B(3,1)=3D0
!**********************************************************
 
 
!**********************************************************
!******    COMPUTE THE NECESSARY WORKSPACE         ********
!**********************************************************
ALLOCATE(WORK(5))
LWORK=-1
CALL DSYSV('U',N,NRHS,A,LDA,IPIV,B,LDB,WORK,LWORK,INFO)
LWORK=IDNINT(WORK(1))
DEALLOCATE(WORK)
!**********************************************************
 
 
!**********************************************************
!************      SOLVE THE SYSTEM           *************
!**********************************************************
ALLOCATE(WORK(LWORK))
CALL DSYSV('U',N,NRHS,A,LDA,IPIV,B,LDB,WORK,LWORK,INFO)
DEALLOCATE(WORK)
!**********************************************************
 
 
!**********************************************************
!**********       DISPLAY THE RESULTS           ***********
!**********************************************************
PRINT*, 'THE SYSTEM SOLUTION IS: ', B
!**********************************************************
RES = DDOT( N, A(1,:), 1, B(1,:), 1 )
PRINT*, 'Dot product = ', RES
 
 
!**********************************************************
!**************      END OF PROGRAM         ***************
!**********************************************************
END PROGRAM LAPACK_SOL
!**********************************************************


To compile the example using the Math Kernel Library, you will need a command similar to this one:

[nom@serveur $] mpif90 ex_lapack.f90 -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm


ATLAS

ATLAS only provides a partial implementation of LAPACK.

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Ressources de Calcul Québec
Outils
Partager