Linear Systems Solver (for small Systems)
SolverNxN is designed to solve many small linear system in a vectorized way in order to improve time perfomaces. It is in practice a faster alternative to the matlab commands:
for k = 1:number_of_systems</span></span>
x=A\b;
end
The Matlab looping speed can visibly slow down this process so most of the time is spent in the for loop and not to solve the system. This is particulary true when A is a small matrix. In this case SolverNxN can be a useful tool.
The speed improvement is more visibile the greater number are the systems and the smaller is their dimension.
The algorithm works assembling all the small elementary systems into a sparse matrix so the \ command is called just one time.
VERY IMPORTANT:
Because of algorithm structure is very important that no system is singular. One singular system can ruin the whole solution. So use this routine only if you are sure all the systems are solvable.
Let’s say we want to solve Nsyst m x m linear systems.
The function call is:
x=SolverNxN(Amxn,b);
INPUTS:
- Amxn: is a matrix of dimensions [m ,(m x Nsyst)], so it is just an horizontal concatenation of the small elementary systems.
- b: is a [(m x Nsyst),1] vector formed by the vertical concatenation of the elematry system vectors.
OUTPUT:
- x: is a [(m x Nsyst),1] vector formed by the vertical concatenation of the elematry system solutions.
Here it is an example:
It is inlcuded a Test for speed comparison, here it is some results:
Program started We are going to solve 1000000 3x3 systems Looping took: 19.6869 s Solver NxN took: 3.1457 s
Residue is 0.0000 Solution is correct!
For question,suggestion,bugs report: giaccariluigi@msn.com
It is brand new so please report problems to my e-mail
Author: Giaccari Luigi
Created: 12/02/2009
Last Update: 12/02/2009
Download Now
| for i=1:number_of_systems | |
| x=A\b; | |
| end | |
Popularity: 5% [?]
Related Posts
Comments
3 Comments on Linear Systems Solver (for small Systems)
-
Expesmefs on
Wed, 19th Aug 2009 03:53
-
Arne Bøckmann on
Wed, 10th Mar 2010 09:38
Thank you, this was ingenious! I have been wanting something like this for long,
but lack the skills to code it myself. Both this and the GLTree implementation are perfect for Smoothed Particle Hydrodynamics. Btw, do you have a research paper or any theoretical description of your GLTree algorithm?
[Reply]
Tell me what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!
Include MATLAB code in your comment by doing the following:
<pre lang="MATLAB">
%insert code here
</pre>



















































Luigi Giaccari Reply:
March 10th, 2010 at 18:07
Thanks,
I am thinking about writing a doc for GLTree, we’ll see.
Luigi
[Reply]