when i tried to implement the QR factorization example as described in the IBM Example: http://www.cepba.upc.edu/docs/ibm_doc/m ... sl368.html
i get another output for the Matrix R than they show on this page.
My code is:
- Code: Select all
double *A1,*work,*tau;
A1 = (double*)calloc(12,sizeof(double));
A1[0] = 0.0;
A1[1] = 2.0;
A1[2] = 2.0;
A1[3] = 0.0;
A1[4] = 2.0;
A1[5] = 2.0;
A1[6] = 2.0;
A1[7] = -1.0;
A1[8] = -1.0;
A1[9] = 1.0;
A1[10] = -1.0;
A1[11] = -1.0;
int m = 6;
int n = 2;
int lda = 6;
work = (double*)calloc(2,sizeof(double));
tau = (double*)calloc(2,sizeof(double));
int lwork = 2;
int info;
for(int i=0; i < 12; i++){
printf("%f \n",A1[i]);
}
printf("------------------------------------------------------------\n");
dgeqrf_(&m,&n,A1,&m,tau,work,&n,&info);
for(int i=0; i < 12; i++){
printf("%f \n",A1[i]);
}
printf("------------------------------------------------------------\n");
And my output is:
- Code: Select all
-4.0
0.5
0.5
0.0
0.5
0.5
2.0
2.236068
0.309017
-0.309017
0.309017
0.309017
Can anybody say where my problem is?