Hi. this is my code:
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
extern void dgesdd_ ( char *JOBZ, int *M, int *N, double *A, int *LDA,double *S, double *U, int *LDU, double
*VT, int *LDVT, double *WORK,int *LWORK, int *IWORK, int *INFO );
int main()
{
char JOBU;
int k,h,i,j,l,v,b;
int M = 10;
int N = 3;
int LWORK;
int INFO;
double a[M][N];
double s[N];
double work[56046];
int iwork[M*N];
double uu[M][N];
double vt[N][N];
FILE *fp;
fp = fopen("vector1.txt","r");
for ( k = 0; k < M; k++){
for(h = 0; h < N; h++){
fscanf(fp,"%lf",&a[k][h]);
printf("a[%d][%d] = %lf\t",k,h,a[k][h]);
}
printf("\n");
}
fclose(fp);
LWORK = 56046;
JOBU = 'A';
dgesdd_( &JOBU, &M, &N, a, &M, s, uu, &M, vt, &N, work, &LWORK, iwork, &INFO);
for(i = 0; i<M; i = i +1){
for(j = 0; j<N; j = j +1){
printf("uu[%d][%d] = %lf\t",i,j,uu[i][j]);
}
printf("\n");
}
printf("\n");
for(l = 0; l<N; l = l +1){
printf("s[%d] = %lf\n",l,s[l]);
}
printf("\n");
for(v = 0; v<N; v = v +1){
for(b = 0; b<N; b = b +1){
printf("vt[%d] = %lf\t",v,vt[v][b]);
}
printf("\n");
}
printf("\n INFO=%d\n", INFO );
return 0;
}
I'm having the problem that when I load a file with a matrix 10x3 and I print the uu matrix, I got a segmentation fault in the second line. Also if I modify it for a large matrix, I got the uu meatrix with a columns of all 1, se s vector are all 0, and the vt are all 0.
Thank you very much for any help

