0

I'm using armadillo's eigs_gen to find the smallest algebraic eigenvalue of a sparse matrix, but eigs_gen can not give an answer. I test the eigs_gen for eye matrix 6*6, it also can not give the answer. The code is:

#include <iostream>
#include <armadillo>
using namespace arma;
using namespace std;
int main(int argc, char** argv)
{
    cout << "Armadillo version: " << arma_version::as_string() << endl;
    sp_mat A = speye<sp_mat>(6, 6);
    A.print("A:");

    cx_vec eigval;
    cx_mat eigvec;

    eigs_gen(eigval, eigvec, A, 1, "sm", 1);  // find 1 eigenvalues/eigenvectors
    eigval.print("eigval:");
    return 0;
}   

The answer is:

Armadillo version: 6.100.0 (Midnight Blue)
A:
[matrix size: 6x6; n_nonzero: 6; density: 16.67%]

     (0, 0)         1.0000
     (1, 1)         1.0000
     (2, 2)         1.0000
     (3, 3)         1.0000
     (4, 4)         1.0000
     (5, 5)         1.0000

*** Error in `./test': double free or corruption (out): 0x00007fff38dd6910 ***
Aborted (core dumped)

However, an correct answer could be achieved, when the eye matrix is 5*5.
The code is:

#include <iostream>
#include <armadillo>
using namespace arma;
using namespace std;
int main(int argc, char** argv)
{
    cout << "Armadillo version: " << arma_version::as_string() << endl;
    sp_mat A = speye<sp_mat>(5, 5);
    A.print("A:");

    cx_vec eigval;
    cx_mat eigvec;

    eigs_gen(eigval, eigvec, A, 1, "sm", 1);  // find 1 eigenvalues/eigenvectors
    eigval.print("eigval:");
    return 0;
}  

the answer is:

Armadillo version: 6.100.0 (Midnight Blue)
A:
[matrix size: 5x5; n_nonzero: 5; density: 20.00%]

     (0, 0)         1.0000
     (1, 1)         1.0000
     (2, 2)         1.0000
     (3, 3)         1.000
     (4, 4)         1.0000

eigval:
    (+1.000e+00,+0.000e+00)

My compile command is:

g++ test.cpp -o test -O2 -I/usr/local/include/armadillo -L/usr/local/lib -DARMA_DONT_USE_WRAPPER -larpack -llapack -lblas -lf2c -lgfortran

I'm working on ubuntu 14.04LTS.

Hen Xue
  • 1
  • 2
  • works fine for me. what does valgrind say? – hbrerkere Oct 26 '15 at 02:21
  • @hbrerkere hi, valgrind says that there is something wrong with the functions of 'arpack' package. The functions is pow_di, dlamc2_, dlamch_ and so on. I guess that maybe something woring with my 'arpack'. Could you tell me why this happened? thanks. What valgrind said is below: ==7735== Conditional jump or move depends on uninitialised value(s) ==7735== at 0x43366B: pow_di ... ==7735== by 0x408A9E: void arma::arpack::naupd(int*, char*, int*, char*, int*, double*, double*, int*, double*, int*, int*, int*, double*, double*, int*, double*, int*) (arpack_wrapper.hpp:33). – Hen Xue Oct 29 '15 at 03:12

1 Answers1

0

I have find the solution to this problem. The reason is that libopenblas, liblapack, libarpack were compiled by myself and all were Packaged as a static library. When they were used together, this problem was happened. The solution is that install these packages through commands listed below. sudo apt-get install libopenblas-dev sudo apt-get install liblapack-dev sudo apt-get install libarpack2-dev

Hen Xue
  • 1
  • 2