Looking a little at Kmath, how am I supposed to us...
# mathematics
h
Looking a little at Kmath, how am I supposed to use the
LinearSpace
like
EjmlLinearSpaceFSCC
. More exactly the extension-functions like
Matrix<Float>.toEjml()
I've tried to use the
with (EjmlLinearSpaceFSCC) { code... }
syntax but it doesn't work. Not sure how else I'd get those to work?
a
This extension is mostly for inner use. It is used under the hood for converting external matrices to EJML. basically
with (EjmlLinearSpaceFSCC) { code... }
should work. Could you explain what is the problem?
h
I'm currently doing a very simple example (which I have the code for in Ejml, but wanted to try Kmath as it seems interesting). This is the current code failing:
This is just a sample. In the
transform
I really need sparsity as the output is very sparse tI don't really need the sparsity right now, but the output of
a
Let me try it, I have not tried it since @Iaroslav Postovalov introduced codegen.
h
@altavir my bad... I had
<T>
😆
a
Ah, OK. Then it should not work. Basically, you do not need to call
toEjml
because it is converted automatically under the hood. Just do the operations you need
h
That's good to know! 🙂 If I wish to find all distinct values in a `Matrix`I must either use
rows
or
elements
where both has
PerformancePitfall
Is there another recommended way to fetch elements? Simply a for-loop?
a
The rows does for-loop. So it should be OK for you. But it is in general depends on implementation. Elements is more time-consuming since it creates an index-element pair on each step. So it is not a good idea to use it in performance-critical code. The warning does not necessary mean that it is slow, it means that you should probably check it.
1
h
Yes, the code made that clear (awesome!) - that's why I wanted to validate 😄 Thank you!