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
Let's say I open a repl and execute the following code.
#require "owl" ;;
open Owl.Dense.Matrix.D ;;
let n = 5 in get_slice [ [] ; [ 1 ; n - 1 ] ] (eye n) ;;
Then I will get a typing error on n-1 :
Error: This expression has type int but an expression was expected of type
('a, 'b) Owl_dense_matrix_generic.t =
('a, 'b, Bigarray.c_layout) Bigarray.Genarray.t
The reason is that Owl.Dense.Matrix.D redefines the - operator to work with matrices.
Although this is expected behavior, I wonder whether this is the right choice for the library. As the example shows even when doing linear algebra the integer binary operators may still be used. Of course I could simply use Stdlib.(-) n 1 or define an other symbol for integer operations but I would not call that a great user experience.
I must say it seems like something quite obvious so I wonder if I missed something in the documentation or even whether that's a deliberate choice.
The text was updated successfully, but these errors were encountered:
moduleM=Owl.Dense.Matrix.Dlet n =5;;
let slice =M.get_slice [ []; n-1 ] (M.eye n);;
let zero =M.(eye n - eye n)
?
It might be more ergonomic if Owl used decorated binary operators like -# or some such. I don't know if this has been discussed? In any case it seems a pretty breaking change at this point.
I am not aware of a discussion around this, but I understand the pain. Fwiw, I stumbled upon the same at the beginning and ended up doing what you do in your last comment (and sometime also rely on Stdlib. to recover integer operators).
Let's say I open a repl and execute the following code.
Then I will get a typing error on
n-1
:The reason is that
Owl.Dense.Matrix.D
redefines the-
operator to work with matrices.Although this is expected behavior, I wonder whether this is the right choice for the library. As the example shows even when doing linear algebra the integer binary operators may still be used. Of course I could simply use
Stdlib.(-) n 1
or define an other symbol for integer operations but I would not call that a great user experience.I must say it seems like something quite obvious so I wonder if I missed something in the documentation or even whether that's a deliberate choice.
The text was updated successfully, but these errors were encountered: