This project has moved and is read-only. For the latest updates, please go here.

Inefficient Matrix Smoothing - Why?

Jun 23, 2011 at 4:48 PM
Edited Jun 23, 2011 at 4:49 PM

Hi

I'm building a complex 3x3 covariance matrix 48000 times a second which I need to smooth using a first order IIR filter (Y[n] = tau*X[n] + (1-tau)Y[n-1]). Initially I just did this directly using the Matrix way as such:

mArrayOld = mArray* tau1 + mArrayOld* tau2; // note: complex32 tau1, tau2; 

But that seems very inefficient because my compute (Dell E6500) cannot process the data fast enough (CPU load goes to from ~10% to ~100%)

Then I tried to do the smoothing for every matrix entry (only the unique ones for the Symmetric Matrix) as such:

mArrayOld[0, 0] = mArray[0, 0] * tau1 + mArrayOld[0, 0] * tau2;
mArrayOld[1, 0] = mArray[1, 0] * tau1 + mArrayOld[1, 0] * tau2;
mArrayOld[1, 1] = mArray[1, 1] * tau1 + mArrayOld[1, 1] * tau2;
mArrayOld[2, 0] = mArray[2, 0] * tau1 + mArrayOld[2, 0] * tau2;
mArrayOld[2, 1] = mArray[2, 1] * tau1 + mArrayOld[2, 1] * tau2;
mArrayOld[2, 2] = mArray[2, 2] * tau1 + mArrayOld[2, 2] * tau2;

And that only costs about 1-2%

Can you please share why there is such a great difference between the two approaches?

Cheers

Jun 23, 2011 at 5:24 PM

Hi,

We had an issue with scaling small arrays that has since been fixed. Please grab the most recent source and try again. Does the newer version make much of a difference?

Thanks,
Marcus 

Jun 23, 2011 at 5:44 PM
Edited Jun 23, 2011 at 5:55 PM

You might also want to try a library that is geared towards small matrices (4x4 or smaller). Have you taken a look at the Microsoft XNA?

update: Nevermind about XNA. It seem to only support floats.

Jun 23, 2011 at 6:19 PM
Edited Jun 23, 2011 at 6:20 PM

Hi

Thanks for the support!

I grabbed the tip of MathNet and didn't find any improvement.

Cheers

 

Jun 23, 2011 at 6:23 PM
Edited Jun 23, 2011 at 6:24 PM

Does adding

MathNet.Numerics.Control.DisableParallelization = true;

make any difference?

Jun 23, 2011 at 6:28 PM

Hi

Yes, now the CPU load looks as low as with the other approach!

Thanks, this is great! :)

Cheers

 

Jun 23, 2011 at 6:30 PM

And my Matrix inversion step is now very cheap too!

thanks :)

Jun 23, 2011 at 6:32 PM

This is good to know. I'll have to make a few more changes.

Thanks!
Marcus