Speed up math code in C# by writing a C dll?

Posted by Projectile Fish on Stack Overflow See other posts from Stack Overflow or by Projectile Fish
Published on 2010-05-25T01:47:11Z Indexed on 2010/05/25 1:51 UTC
Read the original article Hit count: 254

Filed under:
|
|
|

I have a very large nested for loop in which some multiplications and additions are performed on floating point numbers.

for (int i = 0; i < length1; i++)
{
    s = GetS(i);
    c = GetC(i);

    for(int j = 0; j < length2; j++)
    {
        double oldU = u[j];
        u[j] = c * oldU + s * omega[i][j];
        omega[i][j] = c * omega[i][j] - s * oldU;
    }
}

This loop is taking up the majority of my processing time and is a bottleneck.

Would I be likely to see any speed improvements if I rewrite this loop in C and interface to it from C#?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET