views:

479

answers:

1

I'm working on an experimental implementation of Goldenthal et.al's inextensible cloth algorithm in C#.

First I used Math.NET Iridium to assemble and solve the matrices, but quickly replaced this with dnAnalytics since the latter allows me to reuse matrices, almost eliminating further memory allocation, which is important for real-time performance (small cloths) or iterative solving in general.

The problem is that the solvers (of primary interest are LU and Bi-CG) in dnAnalytics still allocate matrices and vectors behind the scenes, instead of reusing past allocations.

=> Are there any sparse linear algebra libraries out there that reuse memory out-of-the-box, or will I have to rewrite the code myself?

+1  A: 

This advice may be superfluous, but when using dnAnalytics, make sure you use the Intel Math kernel library. As tempting as the idea of a pure-C# implementation sounds, I've found the performance difference to be staggering; Dense systems were solved about one hundred times faster.

Michiel Buddingh'
This speed difference is likely due to poor memory management by the programmer in the 'pure-C# implementation'.
Paul
Could be. The Intel Math Kernel library supposedly contains a fair amount of hand-optimised assembly code, which will, of course, outperform most managed code. In any case, the difference was far greater than the minor linear-factor speedup I had anticipated.
Michiel Buddingh'