This bugzilla service is closed. All entries have been migrated to
Bug 116 - SparseModule and MPFR C++.
Summary: SparseModule and MPFR C++.
Alias: None
Product: Eigen
Classification: Unclassified
Component: Sparse (show other bugs)
Version: 3.0
Hardware: x86 - 32-bit All
: Normal major
Assignee: Nobody
Depends on:
Reported: 2010-11-18 07:40 UTC by bertrand.cannelle
Modified: 2019-12-04 09:59 UTC (History)
1 user (show)

MPFR C++ without dlmalloc (30.52 KB, application/octet-stream)
2010-11-30 08:39 UTC, Pavel
no flags Details

Description bertrand.cannelle 2010-11-18 07:40:46 UTC
I have tried to use the SparseModule with MPFR C++, but I have an error that I cannot understand. I don't know whether the problem comes from Eigen or from MPFR C++.

My code runs correctly when the numerical type of the matrix is double but does not work when the type is mpreal in Sparse Module.
Can you give me some hint about this error ?

Thank you for your answer.


To reproduce my bug, you can use this code


#include <Eigen/MPRealSupport>

#include "mpreal.h"

#include <Eigen/Core>

#include <Eigen/LU>

#include <Eigen/Dense>

#include <Eigen/Sparse>

 #include <Eigen/SparseExtra>

using namespace mpfr;

using namespace std;

template<class U>

void Test(Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> A ,Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> B){

    Eigen::Matrix<U,Eigen::Dynamic,Eigen::Dynamic> T_A_;

    Eigen::Matrix<U,Eigen::Dynamic,Eigen::Dynamic> T_B_;

    T_A_.resize(A.rows (),A.cols()); 

    T_B_.resize(B.rows (),B.cols()); 

    for(unsigned int r=0;r<A.rows ();r=r+1)

        for(unsigned int c=0;c<A.cols();c=c+1)


    for(unsigned int r=0;r<B.rows ();r=r+1)

        for(unsigned int c=0;c<B.cols();c=c+1)


    Eigen::Matrix<U,Eigen::Dynamic,Eigen::Dynamic> T_X_;


    Eigen::LDLT< Eigen::Matrix<U,Eigen::Dynamic,Eigen::Dynamic> > ldlt(T_A_);



    std::cout << "relative error: " << (T_A_*T_X_ - T_B_).norm() / T_B_.norm() << std::endl;    



    Eigen::DynamicSparseMatrix<U> T_A ;

    Eigen::Matrix<U,Eigen::Dynamic,Eigen::Dynamic> T_B(B.rows (),B.cols()) ;

    T_A.resize(A.rows (),A.cols());

    for(unsigned int i=0;i<100;i=i+1){

        for(unsigned int j=0;j<100;j=j+1)




   Eigen::Matrix<U,Eigen::Dynamic,Eigen::Dynamic> T_X=T_B;

    Eigen::SparseLDLT< Eigen::SparseMatrix<U,Eigen::Upper|Eigen::SelfAdjoint> > llt(T_A);

    if (llt.succeeded()){






    std::cout << "relative error: " << (T_A*T_X - T_B).norm() / T_B.norm() << std::endl;    


int main(int argc,char**argv)


    Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> A = Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic>::Random(100,100);

    Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> B = Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic>::Random(100,1);







relative error: 18.1509
relative error: 22.196
relative error: 18.1509
Comment 1 bertrand.cannelle 2010-11-18 07:57:57 UTC
On the page of MPFR++

I have seen this post, so maybe it can help you to find my bug ?

Posted September 18, 2009 at 1:36 pm | Permalink


What do you mean “seems to work”? Sure, Eigen compiles fine with MPFR C++, but at least for me it crashes when the ~Matrix() destructor is called.

Pavel, unless you can point me to some working example of Eigen with MPFR C++, then I think it is false advertising to put Eigen in your “Software using MPFR C++”. If it really does work, I would appreciate a pointer to some more information.


      Pavel Holoborodko
      Posted July 21, 2010 at 11:22 am | Permalink

      As for July 15, 2010, Eigen developers have fixed these bug.
Comment 2 bertrand.cannelle 2010-11-19 07:48:29 UTC
gdb backtrace:

Starting program: 
relative error: 18.1509
relative error: 22.196
relative error: 18.1509

Program received signal SIGABRT, Aborted.
0xb7fe2430 in __kernel_vsyscall ()
(gdb) bt
#0  0xb7fe2430 in __kernel_vsyscall ()
#1  0xb7d09651 in *__GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2  0xb7d0ca82 in *__GI_abort () at abort.c:92
#3  0x080fa60f in dlfree (mem=0x82353d8) at ./mpfrc++/dlmalloc.c:4828
#4  0x080fc6dd in mpfr::mpreal::mpreal_free (ptr=0x82353d8, size=542003396) at ./mpfrc++/mpreal.cpp:486
#5  0xb7f7d8a8 in mpfr_clear () from /usr/lib/
#6  0x080fb055 in ~mpreal (this=0x8164fc4, __in_chrg=<value optimised out>) at ./mpfrc++/mpreal.cpp:187
#7  0x080d5c7f in Eigen::CompressedStorage<mpfr::mpreal, int>::reallocate (this=0x8163388, size=14)
    at /usr/local/include/eigen3/Eigen/src/Sparse/CompressedStorage.h:224
#8  0x080d04db in Eigen::CompressedStorage<mpfr::mpreal, int>::resize (this=0x8163388, size=7, reserveSizeFactor=1)
    at /usr/local/include/eigen3/Eigen/src/Sparse/CompressedStorage.h:99
#9  0x080cc46e in Eigen::CompressedStorage<mpfr::mpreal, int>::atWithInsertion (this=0x8163388, key=6, defaultValue=...)
    at /usr/local/include/eigen3/Eigen/src/Sparse/CompressedStorage.h:185
#10 0x080ca36f in Eigen::DynamicSparseMatrix<mpfr::mpreal, 0, int>::coeffRef (this=0xbffff120, row=6, col=0)
    at /usr/local/include/eigen3/Eigen/src/Sparse/DynamicSparseMatrix.h:117
#11 0x080c8cae in Test<mpfr::mpreal> (A=..., B=...) at ./mpreal_eigen_test.cpp:41
#12 0x080c65ee in main (argc=1, argv=0xbffff364) at ./mpreal_eigen_test.cpp:64
Comment 3 Pavel 2010-11-30 08:39:31 UTC
Created attachment 42 [details]
MPFR C++ without dlmalloc
Comment 4 Pavel 2010-11-30 08:43:59 UTC
Try to use MPFR C++ without dlmalloc (see attached file for that version).

Bug reported by JamesHH on September 18, 2009 has been fixed.
Comment 5 bertrand.cannelle 2010-11-30 10:38:20 UTC
I have just tried your patch but I have always the same  problem.
The bug report by JamesHH concerned the plain matrix, but I use sparse matrix.

The code with  plain matrix and double works
The same code with  plain matrix and real works
The same code with  sparse matrix and double works
but the same code with sparse matrix and real doesn't

Whith your patch the back trace of gdb are :

#0  0xb7d498da in malloc_consolidate (av=<value optimised out>) at malloc.c:5144
#1  0xb7d4bafd in _int_malloc (av=<value optimised out>, bytes=<value optimised out>) at malloc.c:4372
#2  0xb7d4df9c in *__GI___libc_malloc (bytes=2020) at malloc.c:3660
#3  0xb7f3bc07 in operator new(unsigned int) () from /usr/lib/
#4  0xb7f3bd3d in operator new[](unsigned int) () from /usr/lib/
#5  0x080d5559 in Eigen::CompressedStorage<mpfr::mpreal, int>::reallocate (this=0x8225708, size=126)
    at /usr/local/include/eigen3/Eigen/src/Sparse/CompressedStorage.h:217
#6  0x080cfedb in Eigen::CompressedStorage<mpfr::mpreal, int>::resize (this=0x8225708, size=63, reserveSizeFactor=1)

    at /usr/local/include/eigen3/Eigen/src/Sparse/CompressedStorage.h:99
#7  0x080cbe6e in Eigen::CompressedStorage<mpfr::mpreal, int>::atWithInsertion (this=0x8225708, key=62, defaultValue=...)

    at /usr/local/include/eigen3/Eigen/src/Sparse/CompressedStorage.h:185
#8  0x080c9d6f in Eigen::DynamicSparseMatrix<mpfr::mpreal, 0, int>::coeffRef (this=0xbffff110, row=62, col=0)

    at /usr/local/include/eigen3/Eigen/src/Sparse/DynamicSparseMatrix.h:117
#9  0x080c86ae in Test<mpfr::mpreal> (A=..., B=...) at /home/bcannelle/Programmation/Developpements/Temporaire/eigenmpfr_patch/mpreal_eigen_test.cpp:41
#10 0x080c5fee in main (argc=1, argv=0xbffff354) at /home/bcannelle/Programmation/Developpements/Temporaire/eigenmpfr_patch/mpreal_eigen_test.cpp:64
Comment 6 bertrand.cannelle 2011-08-26 11:07:14 UTC
This bug has been resolved but I do not know when.
The code available in the branch on August 26 that the code works
Thanks for all

Comment 7 Nobody 2019-12-04 09:59:59 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance:

Note You need to log in before you can comment on or make changes to this bug.