Page 1 of 2

Linear equation matrix solver

PostPosted: Fri Feb 21, 2014 8:00 pm
by KG_is_back
The name says it all. It solves linear matrices via Gaussian elimination. You input the number of equations N and the float array in form of [a,b,c,..,z,constant,a,b,...,z,constant,...] and output is solution for [a,b,...,z]. The Array must be of size N*(N+1) or will be resized to that size.
Known bugs:
-Precision is a little problem... sometimes x/x-y/y is not zero, So I had to round small numbers to zero in the algorithm.
-Only non-singular matrices can be solved. This is not really a bug, but a mathematic fact...

Please try it out and let me know what you think ;)

Re: Linear equation matrix solver

PostPosted: Sat Feb 22, 2014 1:48 am
by tester
Ehm, I have no idea what for I could use it (at least right now), but I think you are doing a great job by assembling these "little things". :mrgreen: When the proper time comes - they get needed.

Re: Linear equation matrix solver

PostPosted: Sat Feb 22, 2014 2:39 am
by KG_is_back
I personally was doing it for implementing FIR to IIR converter implementing least squares method.
You provide it with test tone before and after the filter you wanna copy (or dirac and the IR), the algorithm handles y(0) as function of x(0), x(1),... and y(1),y(2),... and least squares method approximates the A and B coefficients. That requires solving quite big matrices, so there was no way around.
Unfortunately so far I've made it to work only for first order filter... for some reason it fails solving the matrix of higher order filters including biquad.

Re: Linear equation matrix solver

PostPosted: Sat Feb 22, 2014 12:43 pm
by tester
Is the issue related to accuracy?
If it's a matter of accuracy, then transforming it to ruby should help.

Re: Linear equation matrix solver

PostPosted: Sat Feb 22, 2014 1:10 pm
by KG_is_back
tester wrote:Is the issue related to accuracy?
If it's a matter of accuracy, then transforming it to ruby should help.


I do not know... But Ruby double precision would improve the precision a lot - precision in digital formats is general problem of Gaussian elimination. It is often followed by different method to improve the precision.

Re: Linear equation matrix solver

PostPosted: Sun Feb 23, 2014 1:21 am
by KG_is_back
Found the bug... Now it's working properly, I updated the schematic in first post... Still, the precision is a little problem. If someone can make it in ruby it would be great - Gaussian elimination is not that hard to implement

Re: Linear equation matrix solver

PostPosted: Sun Feb 23, 2014 3:29 pm
by martinvicanek
Neat! The bugfixed schematic now solves a test case that the first version didn't. Unfortunately I can't help you with Ruby but for those who are familiar with the language it should be straightforward to port some available code (e.g. Gauss-Jordan elimination, chapter 2.1 p.36ff of Numerical Recipes in C).

Re: Linear equation matrix solver

PostPosted: Sun Feb 23, 2014 3:36 pm
by martinvicanek
KG_is_back wrote:FIR to IIR converter

:o I thought FIR filter design was harder than IIR filter design? Or are you after reverb modelling?

Re: Linear equation matrix solver

PostPosted: Sun Feb 23, 2014 4:36 pm
by KG_is_back
martinvicanek wrote:
KG_is_back wrote:FIR to IIR converter

:o I thought FIR filter design was harder than IIR filter design? Or are you after reverb modelling?


Possibly... I what to create a plugin that would be able to approximate short FIR into IIR which is much more cpu friendly. (cab modeling etc.).

General equation of N-th order filter is: y(0)=x(0)*b0 + x(1)*b1 + ... x(n)*bn + (-a1)*y(1) + ... That is a linear equation with multiple variables (x,y - and their delayed versions). When you have a test tone (x) and tone passed through (y) least squares method can approximate the coefficients, so the effect on output match with original.
The equation can also be expand larger by c*htan(x) or d*(x^2) and other functions and now the system can approximate nonlinear devices too.

I already have a working prototype, but it is not ready to make public yet

Re: Linear equation matrix solver

PostPosted: Sun Feb 23, 2014 5:06 pm
by MegaHurtz
Havn't really heard of it before, but after a quick browse it seems to be a liniar transformation.
Which offcourse is not what it should be, right. So are you creating the non liniar version?

Edit: ^^ Yea :)
Begging for a convolution within a convolution.. Strange little paradox there, the way I see it after 5 mins is that the number of matreces also bound by a number of taps you use for it. Inproper defenition if infinite? But hey if its long its long I guess.