I am having trouble with a C program that uses the function dsysv
from LAPACK. Everything compiles and works without any errors, my only problem is, that the routine doesn't chance any of the arrays it is supposed to.
The code (only hardcode for test purposes):
#include <iostream>
using namespace std;
extern "C" {
extern int dsysv_( char*, int* , int* , double* ,int*,int*, double*,int*, double* ,int* ,int *);
}
int main() {
int n=3;
int nrhs=1;
int lda= 3;
int ldb=3;
int ipiv[3]={0,0,0};
double a[3*3] = {
1,2,3,
0,4,5,
0,0,6
};
double b[3]={1,2,3};
int info=42;
int lwork=-1;
double work[1]={0};
char uplo='U';
dsysv_(&uplo, &n, &nrhs, a, &lda, ipiv, b, &ldb, work, &lwork, &info);
cout<<"info: "<<info<<endl;
for(int i=0; i<3; i++){
cout<<b[i]<<" ";
}
cout <<endl<<"and A: "<<endl;
for(int i=0; i<9; i++){
cout<<a[i]<<" ";
}
return 1;
}
which returns:
info: 0
1 2 3
and A:
1 2 3 0 4 5 0 0 6
Although the function is supposed to overwrite a
and b
.
I think I miss something really obvious here, which I am not aware of since I just started working with LAPACK and would appreciate any help with it.