• tested with: Ubuntu 8.04 (Hardy Heron) and Ubuntu 9.10 (Karmic Koala)


ARPACK is a well known collection of FORTRAN subroutines designed to compute a few eigenvalues and eigenvectors of large scale sparse matrices. ARPACK++ is a collection of classes that offers c++ programmers an interface to ARPACK. It preserves the full capability, performance, accuracy and low memory requirements of the FORTRAN package, but takes advantage of the c++ object-oriented programming environment.

While in theory ARPACK++ is in the Ubuntu and in the Debian ditribution, it is an old wrapper and encounters errors with more recent compiler; it must therefore be installed and fixed manually.



Prior to installing Arpack++, the following packages have to be installed:

  • gfortran

  • lapack2-dev

  • superlu3-dev

either via synaptic or via apt-get

apt-get install libarpack2-dev libsuperlu3-dev gfortran 

Source Code

download arpack++ 1.2 (beta version) at http://www.ime.unicamp.br/~chico/arpack++/ and the patch for arpac++ 1.2 at http://reuter.mit.edu/index.php/software/arpackpatch/ in the same directory

open with an editor the patch file arpack++1.2.patch.diff

gedit arpack++1.2.patch.diff

and change the (should be 9362th) line



+FORTRAN_LIBS = -lgfortran -lgfortranbegin -lnsl

then untar arpack++

tar -zxvf arpack++.tar.gz

and check that it is version 1.2 with the command

head -1 arpack++/README

that should return the string

ARPACK++ version 1.2. Feb 20, 2000.

now apply the patch

cp arpack++1.2.patch.diff arpack++/
cd arpack++
patch -p 1 < arpack++1.2.patch.diff

Compiling with ARPACK++

at this point arpack++ should be working: as it is only a c++ interface to arpack, there are no libraries but only header files to be included into your c++ code; therefore you need to compile with

-I $whereisarpack/arpack++/include

where you should substitute to $whereisarpack the place where arpack++.tar.gz has been untarred

A brief tutorial is contained in the directory $whereisarpack/arpack++/doc; anyhow, besides including the arpack++ headers, you need also to link with the required numerical libraries (arpack,superlu,lapack,blas....); to do so it is useful to look at the codes contained in $whereisarpack/arpack++/examples/superlu/sym

ARPACK++ examples

To check what you need to compile, let's examine the the examples in $whereisarpack/arpack++/examples directory; in particular for finding the eigenvalues of a symmetric matrix using superlu, go to into the proper subdirectory and compile:

cd $whereisarpack/arpack++/examples/superlu/sym

Notice that executable lsymreg is the only working example that does not core-dump;

Ignore the warnings (mostly deprecated conversion from string constant to 'char*') and pay attention to thecompilation lines

g++ -g -Dlinux -I../../../include -I -Wall -ansi -pedantic-errors -I../../../examples/matrices/sym -I../../../include -c lsymreg.cc

g++ -g -Dlinux -I../../../include -I -Wall -ansi -pedantic-errors -I../../../examples/matrices/sym -o lsymreg lsymreg.o /usr/lib/libsuperlu.a  -larpack -llapack -lblas -lgfortran -lgfortranbegin -lnsl 

while the -I../../../examples/matrices/sym include is needed as the program refers to some matrix classes defined in $whereisarpack/arpack++/examples/matrices/sym needed by lsymreg, the other include


and linking

/usr/lib/libsuperlu.a  -larpack -llapack -lblas -lgfortran -lgfortranbegin -lnsl

are the ones needed for general compilation (with superlu libraries); therefore the full options needed are

-I $whereisarpack/arpack++/include -lsuperlu -larpack -llapack -lblas -lgfortran -lgfortranbegin -lnsl

As a final check try to compile by ourself lsymreg.cc:

g++ lsymreg.cc -o my_lsymreg -I $whereisarpack/arpack++/examples/matrices/sym -I $whereisarpack/arpack++/include -lsuperlu -larpack -llapack -lblas -lgfortran -lgfortranbegin -lnsl

(remember to substitute to $whereisarpack the directory where ARPACK++ is) and check that the executable my_lsymreg exists and works


CategoryInstallation CategoryScience

Arpack++ (last edited 2009-11-27 17:25:31 by chianchiere)