Git Product home page Git Product logo

arpackpp's Introduction

arpackpp (ARPACK++)

Introduction

Arpackpp is a C++ interface to the ARPACK Fortran package, which implements the implicit restarted Arnoldi method for iteratively solving large-scale sparse eigenvalue problems.

Arpackpp is a collection of classes (C++ headers and examples) that offers C++ programmers an interface to ARPACK. Furthermore, it interfaces with LAPACK, SuperLU, Cholmod and UMFPACK to incorporate efficient matrix solvers. Arpackpp preserves the full capability, performance, accuracy and low memory requirements of the ARPACK Fortran package, but takes advantage of the C++ object-oriented programming environment.

This GitHub project is designed to provide a common maintained version of arpackpp. It is derived from the original package (ARPACK++ Version 1.2. by Gomes and Sorensen), which has not been actively maintained for many years. Several updates have been included in this version (some of them were previously hosted as patches at http://reuter.mit.edu/software/arpackpatch/ ). This GitHub repository is designed to collect fixes and updates (e.g. to more recent or future releases of the involved libraries). Please consider contributing (see todo list below).

Features:

Features of original ARPACK++ package:

  • Friendly interface that hides the complicated reverse communication interface of the Fortran Arpack package from the user.
  • Easy interface using matrices and vectors via the Standard Template Library (STL).
  • Provides an interface between ARPACK and solvers in SuperLU, LAPACK, UMFPACK and CHOLMOD to solve eigenvalue problems (specifically shift invert methods).
  • Use of templates for optimal performance.

Additional features of this GitHub arpackpp package:

  • CMake support for building the examples
  • Examples build on Mac OSX using CLang
  • Install scripts for getting and building the dependencies of examples
  • Support for SuperLU versions 5.0 and up
  • Added initial support for CHOLMOD (for symmetric real problems)
  • Updated UMFPACK sym integration with SuiteSparse
  • Fixed ARPACK++1.2 to run with g++ 4.4.6 and SuperLU 4.3 (patch see here: http://reuter.mit.edu/software/arpackpatch/ )

TODO

  • CMake: get rid of globbing and specify individual files, also add some testing
  • UMFPACK complex examples do not build (need update like sym)
  • CHOLMOD complex examples not included (implement similar to real sym)
  • Update documentation (install) to cover more scenarios (APT, Homebrew)

Files

Files included in the main directory:

  1. README.md

    This file.

  2. INSTALL.md

    Compile and install notes.

  3. Makefile.inc (historic)

    An include file used to compile arpackpp examples. You must change some directories and machine-dependent directives contained into this file prior to compiling the examples. See the description of the "makefiles" directory below.

  4. CmakeLists.txt

    A Cmake file to compile arpackpp examples.

  5. install-*.sh

    Shell scripts to download and install dependencies into a local ./external directory. Some dependencies can also be installed via a package-manager on your system. See INSTALL.md for details.

Arpackpp subdirectories:

  1. makefiles (historic)

    This directory contains example Makefile.inc include files for some platforms. Choose one and copy it onto the arpackpp/Makefile.inc file.

  2. include

    The directory that contains arpackpp library, i.e., all header files that define arpackpp class templates.

  3. examples

    The directory where all arpackpp examples can be found. These examples are intended to illustrate how to use and compile arpackpp classes and are divided according to the type of problem being solved and also the kind of information that the user is supposed to supply. Look at the examples/README file for further information.

    Note: additional header files are contained in examples/matrices and examples/matprod that are needed to build examples or your own code!

  4. doc

    The directory that contains a the arpackpp user's manual and some instructions on how to install the libraries required by arpackpp.

Dependencies

For efficient sparse matrix operations, any of these:

Detailed description of dependencies:

  1. ARPACK (Fortran):

    Arpackpp is a C++ interface to ARPACK Fortran code, so the original ARPACK library must be installed prior to using the C++ version. A maintained package (arpack new generation) can be obtained via the following GitHub repository (see also install-arpack-ng.sh):

    https://github.com/opencollab/arpack-ng

  2. BLAS and LAPACK (Fortran versions):

    Some arpackpp examples require routines from BLAS and LAPACK, so these libraries need to be installed before compiling the examples.

    It is recommended that vendor-optimized versions of BLAS and LAPACK are installed using a package manager. To install from source, a good choice is OpenBLAS or FlexiBLAS. Follow their install instructions on

    https://github.com/xianyi/OpenBLAS

    or

    https://github.com/mpimd-csc/flexiblas

  3. SuperLU:

    Some ARPACK++ classes call SuperLU library functions to solve eigenvalue problems that require complex or real (non)symmetric matrix decompositions. Thus, SuperLU must also be installed if you intend to use one of these classes. SuperLU is via the following GitHub repository webpage (see also install-superlu.sh):

    https://github.com/xiaoyeli/superlu

  4. UMFPACK, CHOLMOD:

    The UMFPACK package can also be used to solve eigenvalue problems that require real or complex (non)symmetric/non-Hermitian matrix decompositions.

    The CHOLMOD package is performing a Cholesky decomposition and some of the symmetric problems can now interface with it.

    Both UMFPACK and CHOLMOD are part of the SuiteSparse package which is available via the following GitHub repository (see also install-suitesparse.sh):

    https://github.com/DrTimothyAldenDavis/SuiteSparse

Documentation

Arpackpp user's manual is available in the doc directory. It contains all information needed to declare and solve eigenvalue problems using arpack++ classes and functions. Arpackpp computational modes and data types are also described in the manual. Instructions on how to install the above mentioned libraries are given in the INSTALL.md file. Moreover, README files were include in many arpackpp directories to give additional information about arpackpp files and examples.

Using arpackpp:

As a collection of class templates, arpackpp need not to be compiled. Because templates are defined in header (.h) files, no object (.o) or library (.a) files have to be build, except those corresponding to other libraries required by arpackpp (see Dependencies above). Arpackpp header files are included in the "include" directory and can be moved to another directory if desired. An option in the form

-I$(ARPACKPP_INC) \
-I$(ARPACKPP_INC)/../examples/matrices \
-I$(ARPACKPP_INC)/../examples/matprod

should be added to the command line when compiling programs that use arpackpp. Here, ARPACKPP_INC is the name of the directory that contains all arpackpp header files. Note, depending on what type of problem you want so solve, you need to also include the example matrices and/or matprod directories (see examples). You can also use cmake (see below) with make install to install all headers to your system into a single directory.

Compiling and running arpackpp examples:

Arpackpp supports cmake for the compilation of the examples. To build all examples, including the ones that depend on SuperLU, do

$ cmake -B build -D ENABLE_SUPERLU=ON
$ cmake --build build

For this to work all dependencies need to be installed (either on the system or in the external subdirectory). See INSTALL.md for details. Regular Makefiles (in-source build) are also still supported.

Acknowledgements

ARPACK++ authors:

  • Francisco M. Gomes (chico AT ime.unicamp.br)
  • Danny Sorensen (LASTNAME AT caam.rice.edu)

arpackpp (2.0.0 and above) authors:

  • Martin Reuter (LASTNAME AT mit.edu)

arpackpp's People

Contributors

jgraydus avatar jschueller avatar m-reuter avatar pierre-dejoue avatar wo80 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arpackpp's Issues

Generalised eigenvalue problem with shift-inverse mode using UMFPACK

Hello

Thank you for keeping the repository up - I profit a lot from the code available here.

When trying to solve generalized eigenvalue problem with shift-inverse mode I saw that the example using UMFPACK:

/arpackpp/examples/umfpack/nonsym/unsymgsc.cc

does not compile. In fact it is commented out in the CMakeLists.txt. However the coresponding SuperLU file:

/arpackpp/examples/superlu/nonsym/lnsymgsc.cc

is compiled and the example works. Is the umfpack not meant to be used for this kind of problem or was is just not implemented yet?

Yours
Artur

Duplicate symbols when linking two objects including arsnsym.h

Hello,
When linking two different objects both including some arpackpp headers, I get symbol duplicate errors (see below). It seems that some global variables or members are declared in these headers without the "extern" keyword. This is problematic when the user is designing a library on top of arpackpp with implementations in different files than the headers. Or am I getting confused somewhere?

`g++ -undefined dynamic_lookup -o spectrum.out spectrum.o ../cfg/readConfig.o -L/Users/atantet/PhD/dev/lib/ -lgsl -lconfig++ -lergopack

duplicate symbol ArpackError::Set(ArpackError::ErrorCode, std::basic_string<char, std::char_traits, std::allocator > const&) in:
spectrum.o
/Users/atantet/PhD/dev/lib//libergopack.a(transferSpectrum.o)

duplicate symbol ArpackError::code in:
spectrum.o
/Users/atantet/PhD/dev/lib//libergopack.a(transferSpectrum.o)

duplicate symbol MemoryOverflow() in:
spectrum.o
/Users/atantet/PhD/dev/lib//libergopack.a(transferSpectrum.o)

duplicate symbol debug in:
spectrum.o
/Users/atantet/PhD/dev/lib//libergopack.a(transferSpectrum.o)

ld: 4 duplicate symbols for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [spectrum.out] Error 1
`

Installing with dynamic gfortran library

It looks like arpackpp has not been terribly active recently but I am wondering if you would be able to address a small issue we have encountered trying to install arpackpp on our compute cluster at the University of Chicago.

We use Scientific Linux 7. I have all the dependencies installed. However, the cmake step fails because it is unable to find a static gfortran library; on our system, we only have dynamic gfortran libraries installed:

$ ls -1 /lib64/libgfortran*
/lib64/libgfortran.so.1
/lib64/libgfortran.so.1.0.0
/lib64/libgfortran.so.3
/lib64/libgfortran.so.3.0.0

Indeed, there is a note in the CMakeLists.txt file that the static gfortran library is preferred. Is it possible to revise the cmake procedure to check for availability of libgfortran.so as well? Or is there a reason why this is discouraged? I think some Linux setups by default will not have the static libraries installed, and this will make it more difficult to install arpackpp on these systems.

Question about the arpackpp

Dear Doctor Martin Reuter,

I am guobiao Yao and following your github for a period of time. Because I am doing my research on line feature matching by using the libraries of arpackpp. So I need install the arpackpp in my computer with Window10 64bit. So is it feasible if I want intall the arpackpp in my compuer?
Thanks for your help.
Looking forward to your reply.
Guobiao Yao in OSU PCVLAB

Posible memory leak?

Hi
When I compute eigenvalues with ARluSymGenEig a few times, the memory required is only increase.

In this program
I call that function with diferent values of hsim_val, ms_val, mv_val. (the irow is equal in these 3 matrix)
I call it 10 times, and the required memory in every call increase the total memory required ( and when the matrix is big, requires 1.5 GB in each call)

void eigen(int n, int nz, std::vector<double> &exp_val, std::vector<double> &evec){
  ARumSymMatrix<double> A(n, nz, hsim_val, irow, pcol, 'U');
  ARumSymMatrix<double> B(n, nz, ms_val, irow, pcol, 'U');
  ARumSymMatrix<double> C(n, nz, mv_val, irow, pcol, 'U');
  ARluSymGenEig<double> dprob('C', NEV, A, B, -10, "SA");

  dprob.FindEigenvectors();
  evec.resize(NEV);
  double *Ax = new double[n * NEV];
  for (int i=0; i<NEV; i++) {
    evec[i] = dprob.Eigenvalue(i);
    C.MultMv(dprob.RawEigenvector(i), &Ax[n * i]);
  }
  double *Rx = new double[NEV];
  for(int i=0 ; i<NEV ; i++){
      Rx[i] = 0;
      for(int o=0 ; o<n ; o++){
        Rx[i] +=  dprob.RawEigenvector(i)[o] * Ax[o + n * i];
      }
  }

  delete[] Ax;
  exp_val.resize(NEV);
  for(int i=0 ; i<NEV ; i++){
    exp_val[i] = Rx[i];
  }
  delete[] Rx;
}

Error with multiple threads

Hello,
When i tried to solve several eigen value problems in prallel, i met an error:

Arpack error in Aupp.
-> Maximum number of iterations taken.

Basically, i used "for" loop with openMP for parallelizing in multiple threads. I can't find any description about whether arpackpp is thread-safe or not.

All the best

superlu 5.0 should set $BLAS

"install-superlu.sh" says that if $BLAS is not equal to "SYSTEM", then it will resort to locally installed openblas. For people who have done apt-get install libopenblas-dev, maybe it is better to make it clear:
$export BLAS=SYSTEM && ./install-superlu.sh

Wrong eigenvalues with UMFpack

Hi,

I am using arpackpp to solve a generalized eigenvalue for symmetric sparse matrices. However, I noticed I get negative eigenvalues for a symmetric positive semi-definite matrix. When I replace the call with SuperLU instead of UMFpack then I get correct values. Any one noticed this problem?

I don't mind using SuperLU but I am calling my program within MPI. And I get memory mapping error and segfault when I use SuperLU within MPI. (I am using the serial SuperLU version as provided in the library. I just need to call it within in my MPI program which uses MPI just to divide the data into pieces. I am not using SuperLU-dist). If I don't use MPI, SuperLU works fine.

The UMFPack works within my MPI program without any segfault but gives negative eigenvalues.

I would greatly appreciate any help.

Thanks,
Manu

Plans to make a release?

The last release was in 2015. Then there were many commits in 2019.

Maybe it makes sense to make a release?

Access Violation exception

I was kind of surprised, while debugging a (somewhat random) access violation exception with Visual Studio, to see the following code in arlnsmat.h, FactorAsI:

SuperMatrix AsI;
 
// ...
 
irowi = new int[nnz+this->n];
pcoli = new int[this->n+1];
asi   = new ARTYPE[nnz+this->n];
 
// ...
 
Create_CompCol_Matrix(&AsI, this->n,  this->n, nnz, asi, irowi, pcoli, SLU_NC, SLU_GE);
 
// ...
 
Destroy_CompCol_Matrix(&AsI);

The SuperLU function Destroy_CompCol_Matrix will call free, which is probably causing the exception, see https://isocpp.org/wiki/faq/freestore-mgmt#mixing-malloc-and-delete.

I think, the best way to solve this, would be to add malloc for the different datatypes to superluc.h.

I haven't looked, but there might be other places with similar issues.

compiling on windows

Hi,

Is there any way to compile arpackpp into a Windows DLL? My goal is to P/Invoke this in C#.

Cheers,
Raphael

Error while using ARNonSymStdEig

Hi I'm Leonardo,

I'm writing a project using arpack++ to find the eigenvector and eigenvalue of an Laplacian matrix.

https://en.wikipedia.org/wiki/Laplacian_matrix

I standardized the matrix in order to have a symmetric matrix (L_sym) and use it in the ARmStrong class.
And everything works.

Then, for different reason, I had to take the same matrix and written it in the form of a real non symmetric matrix (L_rw). In this case I used the ARSymStdEig class. And on the same input the program, on several runs, give me as result right and wrong in a randomly way.

My first reaction was to think that my program was poorly written and then I went to see how the example nsymreg works. And I noticed that changing the number of the request eigenvalue or the tolerance or the mcv the result change. i.e. the order of the eigenvalue are wrong or they are completely different.

I really don't know what to do.

ps: sorry for my english

Is it possible to use `gemv` from BLAS directly on `ARdsNonSymMatrix`?

Hi, I wonder if it's possible to perform this operation:

w = alpha * matrix * v;

where matrix is of type ARdsNonSymMatrix, v and w are vectors, and alpha is a double?

There is matrix.MultMv, which does exactly that but without alpha multiplication. There's also a gemv function (it is used internally in matrix.MultMv) which could do that but the problem is A member is protected in the ARdsNonSymMatrix class.

Thank you!

Integer overflow

Hello,

i recently found a problem in the arpackpp library when trying to compute eigenvalues of very large matrices. This is caused by an integer overflow in the Prepare function in the arrseig.h header when memory gets allocated by V=new ARTYPE[n*ncv+1] because n*ncv exceeds the maximum integer value (for example for n=4000000 and ncv=601).
It is sufficient to change the datatype of n, ncv, etc from int unsigned long in the arrseig.h header or might there occur further problems in other header files or in the Fortran routines?

Also sometimes the calculations get stuck at some iteration when choosing the dimensions such that the integer overflow problem does not occur. Might this also be caused by a bug of the library or might it be caused by the algorithm used?

It would be nice if somebody could help me out with these problems.

Best regards
IdontKehr

How to use `ARSymStdEig` in the shift-invert mode?

The problem I'm solving is a truncated SVD, so following an example in the documentation, I'm using ARSymStdEig with ARdsNonSymMatrix in the following way:

    typedef ARdsNonSymMatrix<double, double> ArMatrix;
    ArMatrix ar_matrix(n_rows, n_cols, raw_matrix);

    ARSymStdEig<double, ArMatrix>
      right_eigen_solver(n_cols, n_sing, &ar_matrix, &ArMatrix::MultMtMv);

The issue with this is that my singular values are clustered around 1.0, the first few are actually exactly 1.0, and then they decay very slowly, so I was thinking of using the shift-invert mode to speed up the convergence. Documentation says in that case the method you provide in the constructor should return (A - sigma * I)^(-1) * v instead of A*v, but there is no ready-made method for that in ARdsNonSymMatrix.

Should I inherit from ARdsNonSymMatrix and write my own method that solves a linear system (A - sigma * I) * x = v within itself? What are the arguments, and how do I know the value of sigma?

Thanks!

Wrong method signatures

I think some of the method signatures for calling the SuperLU routines are wrong. Please take a look at my commit: wo80@2635daa

I'll create a pull request, if you confirm.

Valgrind Error from ARrcStdEig::FindEigenvalues

Hello,
When calling ARrcStdEig::FindEigenvalues, Valgrind complains about Conditional jump or move depends on uninitialised value(s) This is caused by HowMny not being initialized prior to the Fortran call.
Even though the value should not be referenced when only eigenvalues are computed, in dseupd.f it is checked before recv,

320 | if ( (howmny .ne. 'A' .and.
     &           howmny .ne. 'P' .and.
     &           howmny .ne. 'S'.and. rvec )
     &                                         ierr = -15

The simplest solution would probably be to either give HowMny a default value, or set it to some value before calling Eupp()

Error when compile with gcc 5.4

Hello

After successfully configuring with cmake ../,
The following errors occur during the compilation step

/usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.a(write.o): In function write_float': (.text.write_float+0xb2): undefined reference tosignbitq'
/usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.a(write.o): In function write_float': (.text.write_float+0xbf): undefined reference tofiniteq'
/usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.a(write.o): In function write_float': (.text.write_float+0x133): undefined reference toquadmath_snprintf'
/usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.a(write.o): In function write_float': (.text.write_float+0x254): undefined reference tofiniteq'
/usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.a(write.o): In function write_float': (.text.write_float+0xaff): undefined reference toisnanq'
/usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.a(write.o): In function write_float': (.text.write_float+0xb83): undefined reference toquadmath_snprintf'
/usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.a(write.o): In function write_float': (.text.write_float+0xf7d): undefined reference toquadmath_snprintf'
/usr/lib/gcc/x86_64-linux-gnu/5/libgfortran.a(write.o): In function write_float': (.text.write_float+0x10d8): undefined reference toquadmath_snprintf'

I'm using ubuntu 16.04 with gcc 5.4.
I think the -lquadmath should be added to the link flags.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.