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[128]; 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[4], ret_X[4*4], ret_res[4]; 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[i]); } 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[i]); } 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)