Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Bigarray from string #8519
I'd like to file a feature request about adding a new function that takes:
Let me just talk about the use case I've had and why I would like that.
none of these libraries permit to select the kind and dimensions of your data.
Maybe it would be more clear if I say that I want a function that takes a Bytes.t instead of string: I'm not interested into the character array in itself, but as a representation of underlying data.
The memcpy package makes it fairly easy to write such a function:
open Bigarray let bacopy : type a b. bytes -> (a, b) kind -> int array -> (a, b, c_layout) Genarray.t = fun src k dims -> let dst = Genarray.create k c_layout dims in Memcpy.(memcpy_from_bytes (bigarray Ctypes.genarray dims k)) ~src ~dst ~dst_off:0; dst
There's currently no support for Fortran-layout arrays, but it wouldn't be hard to add.