C# Complex Matrix math library

I’ve been doing some work with converting Matlab scripts to be run on our software at work. Over the years I’ve spent a lot of time working with C#, and despite being a linux-opensource-freeasinbeer junkie, I rather like the language. Alas, I digress. So I originally took the source files from The Code Project: CSML. I have modified the libraries to use the List instead of ArrayList class. In testing, this has a tremendous speed boost. Named lists are also much faster in allocation than an ArrayList of objects.
In addition, I have also added some more functions. Most importantly, I’ve changed it so that operations on matrices don’t affect the original matrix. I’m sure there’s a logical explanation for this (possibly efficiency), however it was more Matlab-like to have matrix operations returning a freshly allocated chunk of memory with the completed calculations.
I’ve also added a function that can filter Complex data specified by the coefficients of a transfer function. It is identical in the Matlab ‘filter’ function.

Here is the library. I imply no guarantees or warranties of any kind to its validity. Through experimentation, I have found that this is faster than the CSML library simply from these few modifications.

Hope someone finds this useful.
Fekete András

Liked it? Take a second to support me on Patreon!

Leave a Reply