For many computations, NMath uses the Intel® Math Kernel Library (MKL), which contains highly-optimized, extensively-threaded versions of the C and FORTRAN public domain computing packages known as the BLAS (Basic Linear Algebra Subroutines) and LAPACK (Linear Algebra PACKage). This gives NMath classes performance levels comparable to C,and often results in performance an order of magnitude faster than non-platform-optimized implementations.
In the example above, tests were performed on square matrices of varying sizes, and with varying numbers of repetitions. Each test was run 10 times and the average time was computed.(The machine used was a 2.8GHz Intel Core i7-930 quad core, with 8GB PC3 8500 DDR3 SDRAM, running 64-bit Microsoft Windows 7 Ultimate.)
NMath offers significantly higher performance than a straight C# implementation, especially for larger matrices. For example, the average time for multiplying 1000×1000 matrices using the C# matrix code averages over 43 times slower than NMath running single-threaded, and 30 times slower than NMath running multithreaded. The data also show the negligible overhead relative to straight C or C++ involved in invoking MKL from managed .NET code.
For more detailed timing data, and complete code samples, see our performance whitepaper.