Community
cancel
Showing results for 
Search instead for 
Did you mean: 
58 Views

Inverting a fully populated, low dimension square matirx

Dear All,

Could someone kindly give me an example for C++ which uses MKL library for calculating the inverse of a square matrix. I would like to extend that to find the inverse of a square matrix which is fully populated and low dimensions (at most 2020).

Thanks,
Ahmad
0 Kudos
2 Replies
58 Views

I have found the example at http://stackoverflow.com/questions/3519959/computing-the-inverse-of-a-matrix-using-lapack-in-c. However, the function dgetrf and dgetri are not fast. I compared the speed for calculating the inverse of 1010 fully populated matrix with MATLAB and there was order of magnitude difference. Is there a faster function than dgetri?

Thanks.
styc
Beginner
58 Views

How fast do you want it to be? By my measurement DGETRF + DGETRI takes just 1.8ms:

$ cat test.f90
program test

    double precision a(10, 10), work(10)
    integer ipiv(10), info
    integer t1, t2, r

    call random_number(a)

    call system_clock(count=t1)
    call dgetrf(10, 10, a, 10, ipiv, info)
    call dgetri(10, a, 10, ipiv, work, 10, info)
    call system_clock(count=t2, count_rate=r)
    print *, (t2 - t1) / sngl

end program
$ ifort test.f90 -otest -mkl=sequential
$ time ./test
 1.8000000E-03
$
Reply