Quantcast
Channel: Math.NET Numerics - Math.NET
Viewing all articles
Browse latest Browse all 224

Which is faster - SetSubMatrix vs interative copy of a column

$
0
0

Hello, just getting started with MatNET.Numerics. I am porting some Matlab code to C#.

I frequently need to copy a column of a Matrix to another Matrix (same number of rows). Making the code run fast is paramount. Is it faster to create a for loop, and copy each individual element, or should I be using SetSubMatrix()? E.g.:

for (int i = 0; i < matrixA.RowCount; ++i)
{
    matrixA.At(i, myNewCol, matrixB.At(i, myOldCol));
}

vs

matrixA.SetSubMatrix(0, myNewCol, matrixB.SubMatrix(0, matrixB.RowCount, myOldCol, 1));

Which is faster?

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 224

Trending Articles