Community
cancel
Showing results for
Did you mean:
Highlighted
Beginner
112 Views

## segment error on mkl_sparse_?_ev when the matrix has degenerate eigenvalues

Hi everyone,

I am trying to calculate eigenvalues of some real symmetric sparse matrices. What I notice is that the program crashes occasionally. I found a minimum working example:

```#include <stdio.h>
#include <mkl.h>
#include <mkl_spblas.h>
#include <mkl_solvers_ee.h>

int main()
{
int i;
MKL_INT pm;
mkl_sparse_ee_init(pm);
// feastinit(pm);  // Using FEAST is fine
char ls_which = 'L';
sparse_matrix_t mat_handle;

double vals[] = {3, 1, 1, 5, 1, 5, 5};
MKL_INT cols[] = {0, 1, 3, 1, 2, 2, 3};
MKL_INT rows[] =  {0, 3, 5, 6, 7};

double vals2[] = {3, 1, 1, 1, 5, 5, 5};
MKL_INT cols2[] = {0, 1, 2, 3, 1, 2, 3};
MKL_INT rows2[] =  {0, 4, 5, 6, 7};

MKL_INT ret_k;
double ret_E, ret_X[4*4], ret_res;
struct matrix_descr descs = {.type = SPARSE_MATRIX_TYPE_SYMMETRIC,
.mode = SPARSE_FILL_MODE_UPPER,
.diag = SPARSE_DIAG_NON_UNIT
};
int csize = 4;
sparse_status_t spflag = mkl_sparse_d_create_csr(&mat_handle, SPARSE_INDEX_BASE_ZERO, csize, csize,
rows, rows+1, cols, vals);
printf("create_csr return: %d\n", (int)spflag );
spflag = mkl_sparse_d_ev(&ls_which, pm, mat_handle, descs, csize, &ret_k, ret_E, ret_X, ret_res);
printf("sparse_ev return: %d\n", (int)spflag );
for(i=0; i<4; ++i)
{
printf("%f ", ret_E);
}
printf("\n");
spflag = mkl_sparse_d_create_csr(&mat_handle, SPARSE_INDEX_BASE_ZERO, csize, csize,
rows2, rows2+1, cols2, vals2);
printf("create_csr return: %d\n", (int)spflag );
spflag = mkl_sparse_d_ev(&ls_which, pm, mat_handle, descs, csize, &ret_k, ret_E, ret_X, ret_res); // *Crash* here
printf("sparse_ev return: %d\n", (int)spflag );
for(i=0; i<4; ++i)
{
printf("%f ", ret_E);
}

printf("\n");
}
```

The first matrix is

[3, 1, 0, 1;
1, 5, 1, 0;
0, 1, 5, 0;
1, 0, 0, 5

The second matrix is

[3, 1, 1, 1;
1, 5, 0, 0;
1, 0, 5, 0;
1, 0, 0, 5

which has two degenerated eigenvalue 5. I am wondering what happens.

Also attach the simple Makefile:

```INTEL_ROOT = /opt/intel/compilers_and_libraries/mac
MKLROOT = \$(INTEL_ROOT)/mkl
FLAGS =   -L\${MKLROOT}/lib -Wl,-rpath,\${MKLROOT}/lib -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl
mkl_test: test.c
icc -o mkl_test test.c -I\$(MKLROOT)/include \$(FLAGS) ```
2 Replies
Highlighted
Beginner
112 Views

Did you solve this problem? if not, why don't you try to change the type to General matrix?

I am now suffering from symmetric diagonalization using mkl_sparse_d_ev function. In my case, if I use the general format (even though the matrix is still symmetric), the function works perfectly.

Highlighted
Novice
105 Views

I have a positive semi-definite matrix with two zero-eigenvalues. I'm trying to find its smallest, non-zero eigenvalue. I seem to be having the same trouble when I use SPARSE_MATRIX_TYPE_SYMMETRIC. This is the backtrace:

``````#0  0x00007ffff591c0e7 in mkl_sparse_d_transpose_matrix_i4 () from /opt/intel/mkl/lib/intel64/libmkl_intel_thread.so
#1  0x00007ffff597eda2 in mkl_sparse_d_transposeMatrix_i4 () from /opt/intel/mkl/lib/intel64/libmkl_intel_thread.so