I am a new user of lapack, and I tried as a simple first step to invert a matrix. The functions seems to work correctly, but when I check the result with the result that matlab gives me, it doesn't match.

Here is what I tried :this is my initial matrix (the numbers are floats)

You don't give the details of your code so we can't tell exactlywhat you have done wrong, but the following C program printsthe solution as given by matlab. (For convenience, I'm transposingon both input and output.)

Thank you for your help, this also works for me.I think the problem is in the way I define A, since I define it as a float* and then read every value from a file. (I do this because that's what I will have to do later).Here is how I define A :

LapackCov is a home function that computes a covariance matrix and put it in the lapack format.This function returns values that match the ones I get with Matlab.

When I run my code and set breakpoints to track different values here is what I see :- before calling sgetrf, Kg has a "good" value : 0.21770304 float- before calling sgetri for the first time, Kg still has a "good" value : 4.1318846 float- before calling sgetri for the second time, Kg still has a "good" value : 4.1318846 float, nothing has changed, which is what we expected since we called sgetri for the first time with a lwork = -1.- after calling sgetri for the second time, Kg has a total nonsense value : 18053338. float

To me this looks like a memory error : some of my variables are getting overwritten, and I don't know how I can prevent this from happening !How can I allocate enough memory space for my computation so that none of my variables get corrupted ?

Seriously, Lapack is well tested on huge matrices. You don't post enough ofyour own code for a third party to detect the error it contains. This forumis primarily for discussing questions relating to Lapack itself. In general, wecannot diagnose bugs in programs that happen to call Lapack functions. Wemay be able to do so if you compose and post a minimal but complete testcase -- otherwise, your crystal ball is as good as ours!

Hello,This might be an old thread, but I have one idea and a question. The results of LAPACK and Mathcad may be different, because Mathcad uses double precision arithmetic and LAPACK uses single (eg. sgetrf like in this case) or double (dgetrf).And here is my question. My sample program works with dgetrf, but do not with sgetrf (compiler does not find it). Why is that? installation problem, link issues,... ? And how to use qgetrf (which I assume would be quadruple precision)? I use -llapack, -lblas in DevC++ compiler options. Sorry for slightly ot.