Large matrix inversion

Open discussion regarding features, bugs, issues, vendors, etc.

Large matrix inversion

Postby weichengcn » Tue Jul 11, 2006 10:03 pm

Hi, everyone,
I am currently using GSL BLAS LU decomposition for large matrix inversion but the speed is slow.

I am new to LAPACK, just wondering if it is faster to invert large matrix using LAPACK, if it is, could someone give me an example code please, my application is gsl_matrix based so.. the method has to be compatible with gsl_matrix data structure.

Thanks a lot

Posts: 2
Joined: Tue Jul 11, 2006 9:52 pm

Postby phymilton » Fri Aug 18, 2006 12:10 pm

Can you give us some quantitive numbers for your problem: what is the dimentison of your large matrix, and what is your expected speed and how much slower the lapack gives and anyother package you tested that gives faster calcualtion.

Based on the above information, we may find a solution.
Posts: 19
Joined: Mon Jan 24, 2005 11:41 pm
Location: Ames, IA

Postby weichengcn » Sat Aug 19, 2006 6:25 pm

Hi there,
I am inverting 200 by 200 matrix, currently i am using the Cholesky and LU decomposition in GSL library for the inversion and invert 350000 time plus other calculation, that takes about 2 hours. Wondering if it is faster to use LAPACK. Matlab is using LAPACK as far as i know, the same matlab code runs faster than my code.
Posts: 2
Joined: Tue Jul 11, 2006 9:52 pm

Postby Julie » Sun Aug 20, 2006 1:17 pm


I am not sure how much support related to GSL you will find on this forum.

It seems like you are using the default BLAS libraries provided by GSL. A good idea is to replace this default BLAS (in this case: the reference CBLAS) by an optimized BLAS library. Optimized means optimized for your machine.

If you are working with very small matrices (say <50x50) then using reference BLAS or optimized BLAS library is not a big deal. Since you are dealing with 200x200 matrices, you will see a difference in term of speed.
So: use an optimized BLAS library.

Matlab comes with a BLAS library optimized for your system. So no wonder: it is expected that Matlab is faster than your code using GSL and reference BLAS providing the inversion represents the most part of your run.

Yes, both Matlab and GSL are relying on LAPACK routines for LU decomposition and inversion.

Coding a third code that calls LAPACK routines directly is not really useful in your context.

Even the GSL code can be 'criticized'. I am not sure that the GSL code will be any faster than the Matlab one provided you are using the same BLAS library. There can be some advantages in term of memory management and other things. But if 'all' you need from us is matrix inversion, Matlab/Octave offer alternatives easier to use with low overhead.

You can find more on optimized BLAS library at:

Posts: 299
Joined: Wed Feb 23, 2005 12:32 am
Location: ICL, Denver. Colorado

Return to User Discussion

Who is online

Users browsing this forum: ftorrentoe and 4 guests