Question: Why dense matrix implementation is not a jagged array? #812
Replies: 4 comments
-
The predecessor of Math.NET Numerics, Iridium, did indeed use jagged arrays. The reason we switched to one-dimensional arrays is primarily that we can leverage native providers (MKL, OpenBlas, CUDA etc). It also provides more room for optimizations for most operations (except maybe multiplication), e.g. using the new managed SIMD support. For example, creating, copying or adding two matrices is much simpler. The storage abstraction does have some overhead, but this should not be significant in practice, at least as long as you do not use the indexers (since they do range checking and have to compute an offset). Maybe you can show the specific code that is slow, so we can have a look. Technically the storage abstraction would allow writing a dense provider using jagged arrays, but then you could not leverage the linear algebra provider infrastructure. |
Beta Was this translation helpful? Give feedback.
-
Hi, thanks. I'm trying to port facebook's fast text alghorithm to dot net. And thinking about possible use of math.net in it. Probably some ops could be described in terms of math.net but I don't know correct names. So I just used indexers. Actually all code in a single file. https://github.com/hodzanassredin/NFastText/blob/master/src/NFastText/Matrix.fs Update: |
Beta Was this translation helpful? Give feedback.
-
Do you know that you can probably extract the lost commits from git reflog? |
Beta Was this translation helpful? Give feedback.
-
I have a lot of extension methods to convert jagged arrays to MathnetNumerics and vica versa. also some jagged array basic extension methods like transpose, rowwise sums, colwise sums etc.. |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm trying to replace my own arrays based matix implementation in a roject by math.net densematrix. But after replace it 2 times slover than my jagged arrays implementation. As far as I understand jagged arrays is faster on dot net than multidimensional arrays and one dim arrays with multiplication.
Beta Was this translation helpful? Give feedback.
All reactions