i'm desperatly trying to compute the pseudo inverse of an M x N matrix A in CLAPACK. I compared my results with the Matlab function
- Code: Select all
pinv(A)
My program works for square matrices, but as soon as M is different than N the results differ :cry:
Do you know if there is a routine to explicitly compute the pseudo inverse in CLAPACK ? I used sgelss_, dgelss_, or preferably sgelsd, dgelsd_ following this example :
http://icl.cs.utk.edu/lapack-forum/viewtopic.php?p=497&
that is, solving min_x ||AX - B|| with B the identity matrix of size N...and X that would be the pseudo inverse....Unfortunably it doesn't work when M > N or M < N.
I used 1d arrays for A and B, eg :
- Code: Select all
real * A = (real*)malloc(sizeof(real)*N*M); //matrix A of size MxN
real * B = (real*)malloc(sizeof(real)*N*N); //matrix B = Id of size NxN
I also tryed the true arrays version :
- Code: Select all
real A[M][N];
real B[N][N];
or the double pointers one :
- Code: Select all
real ** A = (real**)malloc(sizeof(real*)*M);
for (i=0;i<M;i++)
A[i] = (real*)malloc(sizeof(real)*N);
and every time i get different results .......but not once the good results...
...I can't figure it out :( :( :(
any comments madly appreciated
thanks in advance,
cheers :wink:

