ARPACK

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

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

Description

ARPACK (Arnoldi Package) is a mathematical library containing a set of functions for solving eigenvalue problems involving very large matrices. This library allows you to calculate only certain eigenvalues and their corresponding eigenvectors. It's particularly useful for extremely large, sparse matrices, such as arise frequently from finite difference approximations to partial differential equations. The functions are based on a variant of the Arnoldi process called the implicitly restarted Lanczos method.

The library ARPACK was originally written in Fortran 77, nevertheless there is a C++ interface called ARPACK++. In its basic mode, ARPACK is serial (a certain amount of multithreading is possible via BLAS), however there is a parallel version based on MPI: PARPARCK. It can operate across several nodes. This library offers a parallel form of all the basic functions of ARPACK.

A user guide is available online at Rice University. The library is built on LAPACK and BLAS and it's therefore possible to use optimized versions of these libraries to accelerate the calculations. In order to get some additional functionality with ARPACK++, it's useful to first install SuperLU and UMFPACK.

Examples

Here is a small example of the use of ARPACK in Fortran where we calculate the two first eigenvalues and corresponding eigenvectors of a 3x3 matrix.


File : ex_arpack.f90
!****************************************************************
!*********    MATRIX TRANSPORT MODULE                     *********
!****************************************************************
MODULE GENERAL
REAL(KIND=8) :: MATRICE(3,3)
END MODULE GENERAL
!****************************************************************
 
 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 
!****************************************************************
!***************      MAIN PROGRAM                ******************
!****************************************************************
PROGRAM EX_ARPACK
 
 
!--------------------------------
! VARIABLE DECLARATION
!--------------------------------
USE GENERAL
IMPLICIT NONE
INTEGER :: IDO=0, N=3, NEV=2, NCV=3, LDV=3
INTEGER :: IPARAM(11)=0, LWORKL, INFO=0
INTEGER :: IPNTR(11)=0, PURSUE=1
INTEGER :: LDZ=3
LOGICAL :: SELECTION(3)
REAL(KIND=8) :: TOL=0D0, RESID(3), V(3,3)
REAL(KIND=8) :: WORKD(9), WORKL(81)
REAL(KIND=8) :: Z(3,2), D(2), SIGMA
!---------------------------------
 
 
!---------------------------------
!ENTER THE MATRIX VALUES
!---------------------------------
MATRICE=0D0
MATRICE(1,1)=2D0
MATRICE(1,3)=1D0
MATRICE(2,2)=1D0
MATRICE(3,1)=1D0
MATRICE(3,3)=2D0
!----------------------------------
 
 
!----------------------------------
! CALCULATE THE EIGENVALUES AND EIGENVECTORS 
!----------------------------------
IPARAM(1)=1  
IPARAM(3)=25
IPARAM(7)=1
LWORKL=9+72
DO WHILE (PURSUE==1) 
   CALL DSAUPD(IDO,'I',N,'SM',NEV,TOL,RESID,NCV,V, &
       & LDV, IPARAM, IPNTR, WORKD, WORKL, LWORKL, INFO)
   IF (IDO==1 .OR. IDO==-1) THEN
     CALL MAT_VEC(WORKD(IPNTR(1)),WORKD(IPNTR(2)))
   ELSE IF (IDO==99) THEN
     PURSUE=0
   END IF
END DO
!------------------------------------
 
 
!------------------------------------
!POST PROCESSING WITH DSEUPD
!------------------------------------
CALL DSEUPD(.TRUE.,'A',SELECTION,D,Z,LDZ,SIGMA, &
     & 'I', N, 'SM', NEV, TOL, RESID, NCV, V, &
     & LDV, IPARAM, IPNTR, WORKD, WORKL, LWORKL, INFO)
!------------------------------------
!****************************************************************
 
 
!****************************************************************
!**************        DISPLAY THE RESULTS            ************
!****************************************************************
PRINT*, '#1 : '
PRINT*, '    EIGENVALUE  -> ', D(1)
PRINT*, '    EIGENVECTOR -> ', Z(:,1)
PRINT*, '#2 : '
PRINT*, '    EIGENVALUE -> ', D(2)
PRINT*, '    EIGENVECTOR -> ', Z(:,2)
!****************************************************************
 
 
!****************************************************************
!******************      END OF THE PROGRAM      *****************
!****************************************************************
END PROGRAM EX_ARPACK
!****************************************************************
 
 
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
!****************************************************************
!*******    MATRIX-VECTOR MULTIPLICATION       ************
!****************************************************************
!CALCULATION OF {Y}=[A]*{X}
SUBROUTINE MAT_VEC(X,Y)
!--------------------------------------------
 
!--------------------------------------------
! VARIABLE DECLARATION 
!--------------------------------------------
USE GENERAL
IMPLICIT NONE
INTEGER :: I, J
REAL(KIND=8) :: X(3), Y(3)
!--------------------------------------------
 
!--------------------------------------------
! MATRIX-VECTOR MULTIPLICATION 
!--------------------------------------------
Y=0D0
DO I=1,3
   DO J=1,3
     Y(I)=Y(I)+MATRICE(I,J)*X(J)
   END DO
END DO
!--------------------------------------------
 
!--------------------------------------------
! END OF THE SUBROUTINE 
!--------------------------------------------
END SUBROUTINE
!--------------------------------------------
!****************************************************************


This example can be easily compiled. For example, if you use LAPACK and BLAS from the Math Kernel Library, the compilation can be done with the Intel Fortran compiler this way:

[nom@serveur $] 
ifort ex_arpack.f90 -larpack -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm


Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Ressources de Calcul Québec
Outils
Partager