Does `multik` support sparse arrays?
# mathematics
h
Does
multik
support sparse arrays?
a
сс @Pavel Gorgulov
Right now it does not. I am not sure about plans about that. Do you plan to work on JVM or in multiplatform? I believe Commons-math supports sparse matrices. Not sure about arrays
And it would be nice if you could explain the use case for sparse arrays
h
JVM only for now. A sparse matrix fulfills the need :) Essentially I'm using it for sparse matrices where I sometimes extract it into arrays. But an array is really just a 1D-matrix so no worries How about kmath, does that support it?
a
Not yet, since there was no request for it. We can add it to commons-math or nd4j wrappers (nd4j also has sparse matrices) if you could formulate what do you need in terms of operations.
h
It's mainly for feature vectors (like bag-of-words) and one-hot-encodings where there's more 0:s than 1:s. Would be cool with int-matrices like multik support but float/double obviously works great too :)
a
So you need only vectors themselves? Do you need addition, subtraction, inversion etc?
h
In the library I also do addition, subtraction, SVD and much more. Would be nice to share library/data structure throughout everything
a
If you do not need operations, you can use https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/index.html for real-valued sparse vectors and https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/index.html for int-valued vectors. And we can add wrappers on top of it in kmath-commons.
👍 1
h
I'll investigate tomorrow thank you 😄
р
@Hampus Londögård torch has it: https://pytorch.org/docs/stable/sparse.html
🥳 1
so kmath has it then as well
I would advise to just simply write your calculation in python and torchscript it. You can then run that on the JVM.
h
Will check that too tomorrow! 🙂
р
I think if your calculation is just about manipulating tensors, then instead of using all those libraries with multidimensional arrays we have in Kotlin, I would just torchscript the whole calculation in python and then run that on the JVM side.
with time I am just going to open a bit more of the functionality around that in kmath