I would grateful if you could help me to resolve the following issue. I have stumbled upon the wall and i can't really tell what is the problem here. I would like to use the LAPACK functions dgeqrf, dormqr and dtrtrs under c++ to solve the homogeneous system (15 times 15). But i tried to see if i can solve much simpler system for the first hand. What i am posting here is my simple usage of the dgeqrf.
#include "lapacke.h"
#include "lapacke_config.h"
#include "lapacke_mangling.h"
#include "lapacke_utils.h"
using namespace std;
int main()
{
int INFO=3;
double WORK[3];
int LWORK=3;
double TAU[3];
int LDA = 3;
int LDB = 3;
int N = 3;
double det;
double A[9] =
{
1, 1, 0,
0, 1, 0,
0, 1, 1
};
// end of declarations
LAPACK_dgeqrf(&N,&N,A,&LDA,TAU,WORK,&LWORK,&INFO);
for(int i=0;i<N*N;i++){
cout<<A[i]<<",";
}
cout<<endl;
if (INFO!=0){
return 0;
}
det=pow(-1,N-1);
for(int i=0;i<N;i++){
det = det * A[i*N+i];
}
cout<<det<<endl;
What i do not understand is why i am getting R-matrix which is not correct? The printout gives:
-1.41421,0.414214,0,-0.707107,0.707107,0,-0.707107,0.707107,1,
If i check it against the other online matrix calculators, it is wrong. I understand that upper triangle together with the diagonal should be my R-matrix. And what is more surprising i obtain the determinant which is correct (i checked it against more simple examples). R-matrix should be unique, right? If i want to solve the 15 times 15 problem, i should have this first step resolved...i hope someone could explain it to me. I would like to say upfront that i tried to use all three subroutines to solve the simple 3 times 3 system but it gave meaningless results. I hope that once i got this one right, i will understand the issue with dormqr and drtrs as well.
Cheers!