|
My distro is Ubuntu 9.04, and processor Core 2 Quad Q9400. I have done it with dynamical memory, but segfault remains. Also, it's intresting, when I uncomment bzero call, the program finishes normally.
#include <stdio.h> #include <mkl_lapack.h> #include <unistd.h> #include <string.h>
int main(){ int n = 3; // 1 2 3 // 2 4 5 // 3 5 7 double MM[1000] = {1, 2, 3, 2, 4, 5, 3, 5, 7}; double *M = (double *) malloc( sizeof(double) * 1000); memcpy(M, MM, sizeof(double) * 9); //bzero(M, sizeof(double) * 1000); double a,b; int i,j; double accuracy = 1e-6; int m; double *eigVal = (double *) malloc( sizeof(double) * 1000); double *eigVect = (double *) malloc( sizeof(double) * 1000); int *isuppz = (int *) malloc( sizeof(int) * 1000); double *work = (double *) malloc( sizeof(double) * 1000); int *iwork = (int *) malloc( sizeof(int) * 1000); int many = 1000; int status = 0;
// First two work: a = -100; b = 100; dsyevr("V", "V", "L", &n, M, &n, &a, &b, &i, &j, &accuracy, &m, eigVal, eigVect, &n, isuppz, work, &many, iwork, &many, &status);
i = 1; j = 2; dsyevr("V", "I", "L", &n, M, &n, &a, &b, &i, &j, &accuracy, &m, eigVal, eigVect, &n, isuppz, work, &many, iwork, &many, &status);
// Second two make segfaults: i = 1; j = 3; dsyevr("V", "I", "L", &n, M, &n, &a, &b, &i, &j, &accuracy, &m, eigVal, eigVect, &n, isuppz, work, &many, iwork, &many, &status);
dsyevr("V", "A", "L", &n, M, &n, &a, &b, &i, &j, &accuracy, &m, eigVal, eigVect, &n, isuppz, work, &many, iwork, &many, &status);
int k; for(k = 0; k < n; k ++){ printf("%f ", eigVal[k]); } printf("\n");
return 0; }
|