Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solving linear systems of equations

I have a system of 6 equations that I need to solve over and over again in a program (with many different inputs of course). I am currently using the Cramer's rule method of solving the system and it works quite well (it seems that my processor really likes add and multiply operations, it gets solutions in 1 microsecond despite the explicit equations being over 2 pages in length). However the number of times i need to solve is huge and I'm looking for an even faster method.

The question is, is there an even faster or more efficient method for solving these equations or would something like CUDA be beneficial here?

like image 906
Faken Avatar asked Jul 24 '10 04:07

Faken


2 Answers

perhaps you could give http://arma.sourceforge.net/docs.html a try.

It provides premade solve function, http://arma.sourceforge.net/docs.html#solve. however it uses atlas/lapack backand, which is geared more towards larger functions.

You can also try multiplication by inverse, http://arma.sourceforge.net/docs.html#inv, which is compile time template and maybe faster for your purposes.

try this: x = inv(A)*b . Since A does not change, inversion is done only once. Then you are home free with simple matrix vector multiplications, which will be really fast

like image 153
Anycorn Avatar answered Sep 17 '22 22:09

Anycorn


Cramer's rule doesn't scale well. For little system of equations with two or three unknowns it's fine but if the system gets larger, other methods are more efficient, for example: LU decomposition + forward substitution + backward substitution.

like image 40
sellibitze Avatar answered Sep 17 '22 22:09

sellibitze