mathnet-numerics icon indicating copy to clipboard operation
mathnet-numerics copied to clipboard

SubMatrix() without copying, using the new Span/Memory?

Open qusma opened this issue 8 years ago • 5 comments

Title says it all really, it would be great to have a SubMatrix function that does not create a copy, for performance reasons.

qusma avatar Dec 18 '17 14:12 qusma

Bump

fryderykhuang avatar Nov 30 '18 11:11 fryderykhuang

Yes, that would be interesting.

Although we can optimize for the case where there are no modifications, we do need to find a way to ensure modifying one does not modify the other, in both directions.

cdrnet avatar Nov 30 '18 15:11 cdrnet

That would be awesome. I am using MathNet distributions and I copied the related source code into my project just to try Samples(double[] values) as Samples(Span<double> values). I used stackalloc for intermediate variables during operations.

Both garbage collection, memory usage and temporal performance are improved quite a lot. (Of course, it depends how heavily you use array allocating methods).

zgrkpnr avatar Dec 09 '18 18:12 zgrkpnr

The entire API should support Span<T>

aaronhudon avatar Mar 31 '21 00:03 aaronhudon

bump, any news about this?