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

Eigen, SuperLU, UmfPack : failure compilation

Tags: None
(comma "," separated)
sandre
Registered Member
Posts
6
Karma
0
Hi !

I'm sorry if you already answered this question, but I spent a lot of time looking for a solution, and I have no more ideas (I'm not used to C++ and libraries).
I would like to decompose a matrix into LU form. I'm using Eigen 3.1.2 and LU decomposition worked fine with a small matrix. But of course with big data, it's too long. So to use sparse matrix and LU decomposition, I try to install one of the library supported by Eigen :
- first I tried to install SuperLU, but I failed to compile it properly. And I don't understand : is Matlab mandatory in order to compile SuperLU ?
- next I tried to use UmfPack. As libumfpack5.4.0 and even the whole suitesparse are available in Ubuntu 12.10, I installed it with :
apt-get install libsuitesparse-dev
Now I have (all libraries have rw-r--r-- permissions) :
    ...
    /usr/lib/libumfpack.so -> libumfpack.so.5.4.0
    /usr/lib/libumfpack.so.5.4.0
    /usr/lib/libumfpack.a
    ...
    /usr/lib/libamd.so -> libamd.so.2.2.0
    /usr/lib/libamd.so.2.2.0
    /usr/lib/libamd.a
    ...
    /usr/lib/libblas.so.3gf -> /etc/alternatives/libblas.so.3gf
    /usr/lib/libblas.so.3 -> /etc/alternatives/libblas.so.3
    /usr/lib/libblas.so -> /etc/alternatives/libblas.so
    /usr/lib/libblas.a -> /etc/alternatives/libblas.a
    ...
    /usr/lib/libblas/libblas.so.3.0
    /usr/lib/libblas/libblas.so.3 -> libblas.so.3.0
    /usr/lib/libblas/libblas.so -> libblas.so.3
    /usr/lib/libblas/libblas.a
    ...
    /etc/alternatives/libblas.so.3gf -> /usr/lib/libblas/libblas.so.3
    /etc/alternatives/libblas.so.3 -> /usr/lib/libblas/libblas.so.3
    /etc/alternatives/libblas.so -> /usr/lib/libblas/libblas.so
    /etc/alternatives/libblas.a -> /usr/lib/libblas/libblas.a

Next, I tried to compile test.cpp :

Code: Select all
#include <Eigen/Sparse>
#include <Eigen/UmfPackSupport>

int main(int argc, char **argv) {

   Eigen::VectorXf iVectorXf, iLUVectorXf;
   Eigen::MatrixXf iMatrixXf;

   //fill iVectorXf and iMatrixXf

   Eigen::SparseMatrix<float> iSparseMatrix;
   iSparseMatrix = iMatrixXf.sparseView();

   Eigen::UmfPackLU<Eigen::SparseMatrix<float> > iUmfPackLU(iSparseMatrix);
   iLUVectorXf = iUmfPackLU.solve(iVectorXf);

   return 0;
}
with the command :

g++ -L"/usr/lib" -lumfpack -lamd -lblas test.cpp
and I get :

WARNING!
In file included from test.cpp:2:0:
/usr/local/include/Eigen/UmfPackSupport:9:21: error 'umfpack.h': No such file or directory
compilation done.

I tested a lot of other things, but I have always the same error. Do you have any idea ? What have I forgotten ?

Thanks
Dee33
Registered Member
Posts
54
Karma
0
OS
You forgot to give the path to SuiteSparse headers. It should be
Code: Select all
g++ -I /path-to-umfpack.h -I /path-to-Eigen -lumfpack -lamd -llapack -lblas  test.cpp

But I think it's better to use a Cmake based project. There is a FindUmfpack.cmake in the cmake directory of Eigen.

Note that we have now a Sparse LU factorization module in the devel branch. It should work for your large test cases. It's based on the SuperLU package.
sandre
Registered Member
Posts
6
Karma
0
You're right ! I still have errors, but the previous error is gone :

Code: Select all
$ g++ -I /usr/include/suitesparse -I /usr/local/include/ -lumfpack -lamd -llapack -lblas test.cpp

WARNING!
In file included from /usr/local/include/Eigen/UmfPackSupport:32:0,
from test.cpp:2:
/usr/local/include/Eigen/src/UmfPackSupport/UmfPackSupport.h: In instantiation of ‘void Eigen::UmfPackLU<_MatrixType>::analyzePattern(const MatrixType&) [with _MatrixType = Eigen::SparseMatrix<float>; Eigen::UmfPackLU<_MatrixType>::MatrixType = Eigen::SparseMatrix<float>]’:
/usr/local/include/Eigen/src/UmfPackSupport/UmfPackSupport.h:197:7: required from ‘void Eigen::UmfPackLU<_MatrixType>::compute(const MatrixType&) [with _MatrixType = Eigen::SparseMatrix<float>; Eigen::UmfPackLU<_MatrixType>::MatrixType = Eigen::SparseMatrix<float>]’
/usr/local/include/Eigen/src/UmfPackSupport/UmfPackSupport.h:144:7: required from ‘Eigen::UmfPackLU<_MatrixType>::UmfPackLU(const MatrixType&) [with _MatrixType = Eigen::SparseMatrix<float>; Eigen::UmfPackLU<_MatrixType>::MatrixType = Eigen::SparseMatrix<float>]’
test.cpp:14:75: required from here
/usr/local/include/Eigen/src/UmfPackSupport/UmfPackSupport.h:243:7: erreur: no matching function for call to ‘umfpack_symbolic(Eigen::SparseMatrix<float>::Index, Eigen::SparseMatrix<float>::Index, const int*&, const int*&, const Scalar*&, void**, int, int)’
/usr/local/include/Eigen/src/UmfPackSupport/UmfPackSupport.h:243:7: note: candidates are:
...

As I prefer to use only one library, I tried SparseLU module from the devel branch, and it works perfectly with my small data set ! Thank you so much !
Though I still have error, but it seems to come from my big data :

WARNING!
THE MATRIX IS STRUCTURALLY SINGULAR ... ZERO COLUMN AT 238
BTVSP: /usr/local/include/Eigen/src/SparseLU/SparseLU.h:163: const Eigen::internal::solve_retval<Eigen::SparseLU<_MatrixType, _OrderingType>, Rhs> Eigen::SparseLU<_MatrixType, _OrderingType>::solve(const Eigen::MatrixBase<OtherDerived>&) const [with Rhs = Eigen::Matrix<float, -1, 1>; _MatrixType = Eigen::SparseMatrix<float>; _OrderingType = Eigen::COLAMDOrdering<int>]: Assertion `m_factorizationIsOk && "SparseLU is not initialized."' failed.
Abandon (core dumped)

I'll try to figure out what the problem is.
Dee33
Registered Member
Posts
54
Karma
0
OS
You define a matrix of float but Umfpack supports only double and complex double.

It's good to know that the sparse LU works for your problem.
If you have any strange behavior when using it, please send us your matrix in matrix market format.
Just use saveMarket() defined in unsupported/Eigen/src/SparseExtra/MarketIO.h
sandre
Registered Member
Posts
6
Karma
0
Thank you for the information about UmfPack, I understand better.

I saved my sparse matrix using saveMarket(), but (sorry if it's a stupid question) where do I send you the file ? Do you mean via the Eigen issue tracker (Bugzilla) ?
However I don't know if it will be interesting for you. I think there is a problem before the creation of this sparse matrix. The initial matrix file is probably not well-formatted (but it's the same format as the smaller), or the problem come from the computation I execute to fill the matrix. I'm still checking it.
Dee33
Registered Member
Posts
54
Karma
0
OS
Yes please check your code and if you think the problem come from Eigen, you can file a bug via the Issue tracker at http://eigen.tuxfamily.org/bz/
If you succeed to link with Umfpack, you can compare both results.
sandre
Registered Member
Posts
6
Karma
0
I found the problem, and it has nothing to do with Eigen. I used :
Code: Select all
abs()

instead of
Code: Select all
fabs()

So I had a zero where there shouldn't be...Some exceptions are missing in my code !

I'll try again with Umfpack and I'll keep you in touch if I have something interesting. Or most likely if I have errors :)

Thank you for your help.

This topic is solved.
sandre
Registered Member
Posts
6
Karma
0
Sorry to bother you again, but I still have error when compiling test.cpp with Umfpack. I replaced float by double, and I get :
WARNING!
/tmp/ccw5kmga.o: in fonction « Eigen::umfpack_free_numeric(void**, double) »:
test.cpp:(.text._ZN5Eigen20umfpack_free_numericEPPvd[_ZN5Eigen20umfpack_free_numericEPPvd]+0x19): undefined reference to « umfpack_di_free_numeric »
/tmp/ccw5kmga.o: in fonction « Eigen::umfpack_free_symbolic(void**, double) »:
test.cpp:(.text._ZN5Eigen21umfpack_free_symbolicEPPvd[_ZN5Eigen21umfpack_free_symbolicEPPvd]+0x19): undefined reference to « umfpack_di_free_symbolic »
/tmp/ccw5kmga.o: in fonction « Eigen::umfpack_symbolic(int, int, int const*, int const*, double const*, void**, double const*, double*) »:
test.cpp:(.text._ZN5Eigen16umfpack_symbolicEiiPKiS1_PKdPPvS3_Pd[_ZN5Eigen16umfpack_symbolicEiiPKiS1_PKdPPvS3_Pd]+0x48): undefined reference to « umfpack_di_symbolic »
/tmp/ccw5kmga.o: in « Eigen::umfpack_numeric(int const*, int const*, double const*, void*, void**, double const*, double*) »:
test.cpp:(.text._ZN5Eigen15umfpack_numericEPKiS1_PKdPvPS4_S3_Pd[_ZN5Eigen15umfpack_numericEPKiS1_PKdPvPS4_S3_Pd]+0x44): undefined reference to « umfpack_di_numeric »
/tmp/ccw5kmga.o: in « Eigen::umfpack_solve(int, int const*, int const*, double const*, double*, double const*, void*, double const*, double*) »:
test.cpp:(.text._ZN5Eigen13umfpack_solveEiPKiS1_PKdPdS3_PvS3_S4_[_ZN5Eigen13umfpack_solveEiPKiS1_PKdPdS3_PvS3_S4_]+0x53): undefined reference to « umfpack_di_solve »
collect2: error: ld returned 1 exit status

I checked if umfpack_di_free_numeric is available :
Code: Select all
$ ls /usr/include/suitesparse/

    amd.h
    amd_internal.h
    btf.h
    btf_internal.h
    camd.h
    camd_internal.h
    ccolamd.h
    cholmod_blas.h
    cholmod_check.h
    cholmod_cholesky.h
    cholmod_complexity.h
    cholmod_config.h
    cholmod_core.h
    cholmod.h
    cholmod_internal.h
    cholmod_io64.h
    cholmod_matrixops.h
    cholmod_modify.h
    cholmod_partition.h
    cholmod_supernodal.h
    cholmod_template.h
    colamd.h
    cs.h
    klu.h
    klu_internal.h
    klu_version.h
    ldl.h
    spqr.hpp
    SuiteSparseQR_C.h
    SuiteSparseQR_definitions.h
    SuiteSparseQR.hpp
    UFconfig.h
    umfpack_col_to_triplet.h
    umfpack_defaults.h
    umfpack_free_numeric.h
    umfpack_free_symbolic.h
    umfpack_get_determinant.h
    umfpack_get_lunz.h
    umfpack_get_numeric.h
    umfpack_get_symbolic.h
    umfpack_global.h
    umfpack.h
    umfpack_load_numeric.h
    umfpack_load_symbolic.h
    umfpack_numeric.h
    umfpack_qsymbolic.h
    umfpack_report_control.h
    umfpack_report_info.h
    umfpack_report_matrix.h
    umfpack_report_numeric.h
    umfpack_report_perm.h
    umfpack_report_status.h
    umfpack_report_symbolic.h
    umfpack_report_triplet.h
    umfpack_report_vector.h
    umfpack_save_numeric.h
    umfpack_save_symbolic.h
    umfpack_scale.h
    umfpack_solve.h
    umfpack_symbolic.h
    umfpack_tictoc.h
    umfpack_timer.h
    umfpack_transpose.h
    umfpack_triplet_to_col.h
    umfpack_wsolve.h
Code: Select all
$ grep umfpack_di_free_numeric umfpack_free_numeric.h

    void umfpack_di_free_numeric
    umfpack_di_free_numeric (&Numeric) ;

Have I missed something again ?
Dee33
Registered Member
Posts
54
Karma
0
OS
The list of libraries should go at the end of the command line
Code: Select all
g++ -I /usr/include/suitesparse -I /usr/local/include/  test.cpp  -lumfpack -lamd -llapack -lblas
sandre
Registered Member
Posts
6
Karma
0
Thanks ! It works.

If you're interested, I compared the execution time of LU facotrization between SparseLU module and UmfpackLU module.
With my data (matrices 40*40, more than 50% of zeros), SparseLU is almost as fast as UmfpackLU. But, when I use SparseLU with matrix of float, the execution time of the entire code (not only test.cpp) is a little faster compared to UmfpackLU.
As I don't need double for the moment, I'll keep using SparseLU module.
zoranb
Registered Member
Posts
1
Karma
0
I hope this is the right topic for this question..

I'm quite new with UMFPACK library and routines. In User guide it says that is quite easy to do basic matrix manipulations when we have matrices in triplet format, like adding or subtracting. But i can't see it...Help please :)
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
This forum is not about UMFPACK but about the Eigen library. Nevertheless, UMFPACK is a linear solver, and it does not offer matrix manipulation facilities. To this end you can use the Eigen library. Have a look at the sparse documentation: http://eigen.tuxfamily.org/dox/group__S ... apter.html


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], lockheed, Sogou [Bot], Yahoo [Bot]