This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Problem when using umfpack with Eigen3

Tags: None
(comma "," separated)
maucejo
Registered Member
Posts
3
Karma
0
OS
Hi everybody,

I want to use the unsupported UmfPack support module to solve sparse problems as found in FEM. Howerver, after installing umfpack and its dependencies, I have the following error:

../unsupported/Eigen/src/SparseExtra/UmfPackSupport.h: In member function ‘bool Eigen::SparseLU<_MatrixType, Eigen::UmfPack>::solve(const Eigen::MatrixBase<OtherDerived>&, Eigen::MatrixBase<OtherDerived>*) const [with BDerived = Eigen::Matrix<double, -0x00000000000000001, 1, 0, -0x00000000000000001, 1>, XDerived = Eigen::Matrix<std::complex<double>, -0x00000000000000001, 1, 0, -0x00000000000000001, 1>, _MatrixType = Eigen::SparseMatrix<double, 0, int>]’:

../eigen/unsupported/Eigen/src/SparseExtra/UmfPackSupport.h:337: error: no matching function for call to ‘umfpack_solve(int, const int*, const int*, const double*, std::complex<double>*, double*, void* const&, int, int)’

../eigen/unsupported/Eigen/src/SparseExtra/UmfPackSupport.h:74: note: candidates are: int Eigen::umfpack_solve(int, const int*, const int*, const double*, double*, const double*, void*, const double*, double*)
../eigen/unsupported/Eigen/src/SparseExtra/UmfPackSupport.h:74: note: candidates are: int Eigen::umfpack_solve(int, const int*, const int*, const double*, double*, const double*, void*, const double*, double*)


I have any idea why this error arises.

Dou you have any idea and solution to solve problem.

Thank you for helping me.

Greetings

Maucejo
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
it seems you are trying to solve Ax=b with A and b double objects, and x a vector of complex...
maucejo
Registered Member
Posts
3
Karma
0
OS
You are right! However, when I correct this error, I obtained a new error message:

/tmp/ccJeqRQz.o: In function `Eigen::umfpack_free_numeric(void**, double)':
eigen.cc:(.text._ZN5Eigen20umfpack_free_numericEPPvd[Eigen::umfpack_free_numeric(void**, double)]+0x19): undefined reference to `umfpack_di_free_numeric'
/tmp/ccJeqRQz.o: In function `Eigen::umfpack_symbolic(int, int, int const*, int const*, double const*, void**, double const*, double*)':
eigen.cc:(.text._ZN5Eigen16umfpack_symbolicEiiPKiS1_PKdPPvS3_Pd[Eigen::umfpack_symbolic(int, int, int const*, int const*, double const*, void**, double const*, double*)]+0x3e): undefined reference to `umfpack_di_symbolic'
/tmp/ccJeqRQz.o: In function `Eigen::umfpack_numeric(int const*, int const*, double const*, void*, void**, double const*, double*)':
eigen.cc:(.text._ZN5Eigen15umfpack_numericEPKiS1_PKdPvPS4_S3_Pd[Eigen::umfpack_numeric(int const*, int const*, double const*, void*, void**, double const*, double*)]+0x37): undefined reference to `umfpack_di_numeric'
/tmp/ccJeqRQz.o: In function `Eigen::umfpack_free_symbolic(void**, double)':
eigen.cc:(.text._ZN5Eigen21umfpack_free_symbolicEPPvd[Eigen::umfpack_free_symbolic(void**, double)]+0x19): undefined reference to `umfpack_di_free_symbolic'
/tmp/ccJeqRQz.o: In function `Eigen::umfpack_solve(int, int const*, int const*, double const*, double*, double const*, void*, double const*, double*)':
eigen.cc:(.text._ZN5Eigen13umfpack_solveEiPKiS1_PKdPdS3_PvS3_S4_[Eigen::umfpack_solve(int, int const*, int const*, double const*, double*, double const*, void*, double const*, double*)]+0x45): undefined reference to `umfpack_di_solve'
collect2: ld returned 1 exit status


There is probably an error when linking umfpack to Eigen3, but I don't know where the problem is.

Here is the code I use:

Code: Select all
#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET

#include <iostream>
#include <Eigen/Dense>
#include <Eigen/Sparse>
#include <unsupported/Eigen/SparseExtra>
#include <unsupported/Eigen/UmfPackSupport>

using namespace Eigen;
using namespace std;

int main()
{
  SparseMatrix<double> A(10,10);
  A.reserve(18);

  A.insert(0,0) = 2.;
  A.insert(1,0) = 1.;
  A.insert(4,0) = 1.;
  A.insert(9,0) = -1.;
  A.insert(2,1) = 1.;
  A.insert(3,2) = 1.;
  A.insert(4,3) = 1.;
  A.insert(0,4) = -1.;
  A.insert(4,4) = 2.;
  A.insert(5,4) = 1.;
  A.insert(9,4) = 3.;
  A.insert(6,5) = 1.;
  A.insert(7,6) = 1.;
  A.insert(8,7) = 1.;
  A.insert(9,8) = 1.;
  A.insert(1,9) = 1.;
  A.insert(4,9) = -1.;
  A.insert(9,9) = 4.;

  VectorXd b(10);
  b << -6.,
        1.,
        2.,
        3.,
        8.,
        4.,
        5.,
        6.,
        7.,
       -7.,

  VectorXd x(3);
  x << VectorXd::Zero(3);

  SparseLU<SparseMatrix<double>,UmfPack> lu_of_A(A);
  if(!lu_of_A.succeeded())
  {
    // decomposition failed
    return -1;
  }
  if(!lu_of_A.solve(b,&x))
  {
    // solving failed
    return -1;
  }
  cout << x << endl;
}


Thank you

maucejo
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
you have to explicitly link your code against umfpack library. -lumfpack. Depending on how the umfpack lib has been generated you might also have to link against a blas library. For instance, you can compile Eigen's BLAS interface:

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release path_to_eigen3_source
cd blas
make

gives you a static (.a) and dynamic (.so) blas.
maucejo
Registered Member
Posts
3
Karma
0
OS
Thank you! Now it works fine!

Here is the instruction I used to compile my program. It had to link UMFPACK AMD and BLAS.

g++ -I path_to_my_program myprog.cc -lgfortran -L path_to_umfpack/UMFPACK/Lib -lumfpack -L path_to_AMD/AMD/Lib -lamd -L/path_to_blas -lblas -o myprog


I hope it will be useful for Eigen users ...


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], q.ignora, watchstar