Multik 0.1 released with complex numbers, new line...
# mathematics
p
Multik 0.1 released with complex numbers, new linear algebra methods, improved performance and other features https://blog.jetbrains.com/kotlin/2021/10/multik-0-1-is-out/ Slack Conversation
👍 3
🎉 3
a
Looks nice. We can start connecting it to KMath tensor API. I found an inconsistency though. You try to follow numpy broadcasting rules. but
Copy code
a = numpy.array([[1, 2, 3],[1, 2, 3]])
b = numpy.array([1, 2, 3])
a + b
will work in numpy and won't work in multik. I am not a fan of implicit broadcasting (and do not like numpy ideology in general), but one needs to be clear about that. In KMath I insisted that broadcasting is not possible in default algebras.
p
What makes you think that we are trying to comply with the numpy broadcasting rules?
Copy code
a = numpy.array([[1, 2, 3],[1, 2, 3]])
b = numpy.array([1, 2, 3])
a + b
This code will not work for us even at the compilation stage, since the dimensions are different. We introduced
Dimension
right from the start for this kind of checks.
a
Broadcasting for single number obviously works. Therefor the question is how do you choose when to broadcast and when not to.
In my opinion, implicit broadcasting is one of the main problems in numpy. In Julia they do special broadcasting operation with
.
, but it solves the problem only for simple one-argument operations. When we started to think about how to apply specific broadcasting rules to specific cases, we came to the algebra-based model, we use now in KMath. We use different rules for different scopes.
p
Yes, ndarray operations with scalars are allowed. For several reasons: * these are quite frequent operations * no internal transformations occur for this * they are intuitive, unlike broadcasting two ndarrays * is a different object, not ndarray. That is, if we take and create ndarray with one elements, then the operation with another ndarray will be impossible due to different shapes. I agree that implicit broadcasting is a problem. Therefore, at the level of ndarrays, it is also impossible for us.
a
What about types? I can check myself but what will happen if we will try to add a compex number to a ndarray of doubles or vise versa?
OK, I did not expect this:
But it works for complex numbers
p
Same type required
a
I mean that you can add any number to a Complex. And even sum different complex types
p
Yes, it is possible for this to be consistent with the numeric operations in Kotlin.