sparse vs full matrix with same # elements


michielm
03-01-2010, 01:54 PM
Hi,
I have a sparse diagonally banded matrix of e.g. 28 filled elements and 72 empty ones. I want to solve the system and I have two options:

1. use conjugant gradient mathod to solve the sparse banded matrix directly

2. translate the sparse matrix to a full matrix of 28 filled elements and solve that one (seems not possible, but in my particular case it is!)

does anyone know which one will be faster? Or can someone give me a hint on how much slower, solution of a sparse 28-72 matrix is as compared to a full 28 matrix?!

Thanks in advance!

MPD78
03-01-2010, 02:31 PM
Hello,

...sparse diagonally banded matrix...

Just thinking about the problem, it would seem that simply solving the sparse matrix would be faster. Hence, the purpose of a sparse solver.

To quote from the Numerical Recipes 3rd Edition chapter 2 section 2.7;

"... it is wasteful to use general methods of linear algebra on such problems because most of O(N^3) arithmetic operations devoted to solving the set of equations or inverting the matrix involve zero operands."

does anyone know which one will be faster?

I would have to bet the sparse solver will be faster.

Why don't you test the two methods yourself?

Thanks
Matt

michielm
03-03-2010, 06:55 AM
thanks for the comments. I think testing it myself is probably the best option!

MPD78
03-03-2010, 02:54 PM
Your welcome. Let us know what your results are.

Thanks
Matt

michielm
03-08-2010, 05:13 AM
I have tested both and up to a sparse matrix of 5000x5000 I could not find much difference (it depended more on background processes of my pc). Above that, I got into trouble with virtual memory due to the large memory allocation for the sparse matrix. That is why I've posted another question: Here (http://www.nr.com/forum/showthread.php?p=4359#post4359)