You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to do some very basic matrix operation using the default implementation (persistent vector)
of core.matrix 0.62.0 and I'd love to keep my rational elements as clojure.lang.Ratio as long as I can
during my matrix transformations.
I noticed that when I sum different diagonal matrices using rational elements they get coerced to clojure.lang.Double.
I tracked down the issue to clojure.core.matrix.impl.defaults:
Hi, yes this does look like unexpected behaviour. Arrays should preserve the type of elements as far as possible, although the extent to which they do this is somewhat up to the implementation.
Hello,
I'm trying to do some very basic matrix operation using the default implementation (persistent vector)
of core.matrix 0.62.0 and I'd love to keep my rational elements as clojure.lang.Ratio as long as I can
during my matrix transformations.
I noticed that when I sum different diagonal matrices using rational elements they get coerced to clojure.lang.Double.
I tracked down the issue to
clojure.core.matrix.impl.defaults
:Replacing
zs (vec (repeat dims 0.0))
withzs (vec (repeat dims 0))
in the let bindings makes it work as expected (for me).I didn't check if this breaks some test, but if you whish I can submit a pull request.
Here you can find a test case:
As you can see I also had to map over my range with math/abs in the let binding of my example because matrix/abs coerced too my items.
Thank you.
The text was updated successfully, but these errors were encountered: