module Ba:sig
..end
WARNING. This interface is subject to change in the future.
This module has a few convenience functions for linear (1D) bigarrays.
The purpose of Gg.buffer
is to allow to specify a few more data
types than bigarrays are able to express and facilitate the
generic handling of linear bigarrays.
type ('a, 'b)
ba_scalar_type =
| |
Int8 : |
| |
Int16 : |
| |
Int32 : |
| |
Int64 : |
| |
UInt8 : |
| |
UInt16 : |
| |
UInt32 : |
| |
UInt64 : |
| |
Float16 : |
| |
Float32 : |
| |
Float64 : |
val ba_kind_of_ba_scalar_type : ('a, 'b) ba_scalar_type -> ('a, 'b) Bigarray.kind
ba_kind_of_ba_scalar_type st
is the bigarray kind corresponding
to st
.typescalar_type =
[ `Float16
| `Float32
| `Float64
| `Int16
| `Int32
| `Int64
| `Int8
| `UInt16
| `UInt32
| `UInt64
| `UInt8 ]
val scalar_type_of_ba_scalar_type : ('a, 'b) ba_scalar_type -> scalar_type
scalar_type_of_ba_scalar_type st
is the scalar type corresponding
to st
.val scalar_type_byte_count : scalar_type -> int
scalar_type_byte_count st
is the number of bytes used by a scalar
of type st
.val pp_scalar_type : Format.formatter -> scalar_type -> unit
pp_scalar_type ppf st
prints a textual representation of st
on ppf
.module Buffer:sig
..end
val create : ('a, 'b) ba_scalar_type -> int -> ('a, 'b) Gg.bigarray
create k count
is a bigarray of kind k
with count
scalars.val length : ('a, 'b) Gg.bigarray -> int
length ba
is the length of ba
.val sub : ('a, 'b) Gg.bigarray -> int -> int -> ('a, 'b) Gg.bigarray
sub ba i len
are the i
th to i
th + n
scalars of ba
as a bigarray. Note, this is not a copy.val blit : ('a, 'b) Gg.bigarray -> int -> ('a, 'b) Gg.bigarray -> int -> int -> unit
blit src si dst di len
copies len
scalar values starting at si
in src
to dst
starting at di
.val fill : ('a, 'b) Gg.bigarray -> 'a -> unit
fill ba v
sets each scalar value of ba
to v
.val of_array : ('a, 'b) ba_scalar_type -> 'a array -> ('a, 'b) Gg.bigarray
of_array st a
is a bigarray from array a
.val of_list : ('a, 'b) ba_scalar_type -> 'a list -> ('a, 'b) Gg.bigarray
of_list st l
is a bigarray from list l
.val of_bytes : ?be:bool -> ('a, 'b) ba_scalar_type -> string -> ('a, 'b) Gg.bigarray
of_bytes be s k
is a bigarray of kind k
from s
. if be
is true
data is assumed to be in big endian order (defaults to
false
).
TODO For now only Int8
and UInt8
are supported.
Raises Invalid_argument
if given an unsupported kind or if
the data length is not a multiple of the requested scalar type.
val pp : ?count:int ->
?stride:int ->
?first:int ->
?dim:int ->
pp_scalar:(Format.formatter -> 'a -> unit) ->
Format.formatter -> ('a, 'b) Gg.bigarray -> unit
pp count stride first dim pp_scalar ppf b
prints on ppf
,
count
groups of size dim
of scalars of b
, starting at first
using pp_scalar
, and striding stride
scalars to go from group
to group. If count
is unspecified prints as much as
possible. stride
defaults to dim
, first
defaults to 0
and
dim
to 1
.val get_v2 : (float, 'b) Gg.bigarray -> int -> Gg.v2
get_v2 b i
is the i
th to i+1
th scalars of b
as a vector.val get_v3 : (float, 'b) Gg.bigarray -> int -> Gg.v3
get_v3 b i
is the i
th to i+2
th scalars of b
as a vector.val get_v4 : (float, 'b) Gg.bigarray -> int -> Gg.v4
get_v4 b i
is the i
th to i+3
th scalars of b
as a vector.val get_2d : ('a, 'b) Gg.bigarray -> int -> 'a * 'a
get_v2 b i
is the i
th to i+1
th scalars of b
.val get_3d : ('a, 'b) Gg.bigarray -> int -> 'a * 'a * 'a
get_v3 b i
is the i
th to i+2
th scalars of b
.val get_4d : ('a, 'b) Gg.bigarray -> int -> 'a * 'a * 'a * 'a
get_v4 b i
is the i
th to i+3
th scalars of b
.val geti_2d : (int32, 'b) Gg.bigarray -> int -> int * int
get_v2 b i
is the i
th to i+1
th scalars of b
. The
integers are converted with Int32.to_int
.val geti_3d : (int32, 'b) Gg.bigarray -> int -> int * int * int
get_v3 b i
is the i
th to i+2
th scalars of b
. The
integers are converted with Int32.to_int
val set_v2 : (float, 'b) Gg.bigarray -> int -> Gg.v2 -> unit
set_v2 b i v
sets the i
th to i+1
th scalars of b
with
v
.val set_v3 : (float, 'b) Gg.bigarray -> int -> Gg.v3 -> unit
set_v3 b i v
sets the i
th to i+2
th scalars of b
with
v
.val set_v4 : (float, 'b) Gg.bigarray -> int -> Gg.v4 -> unit
set_v4 b i v
sets the i
th to i+3
th scalars of b
with
v
.val set_2d : ('a, 'b) Gg.bigarray -> int -> 'a -> 'a -> unit
set_2d b i s1 s2
sets the i
th to i+1
th scalar of b
to
s1
, s2
.val set_3d : ('a, 'b) Gg.bigarray -> int -> 'a -> 'a -> 'a -> unit
set_3d b i s1 s2 s3
sets the i
th to i+2
th scalar of b
to
s1
, s2
, s3
.val set_4d : ('a, 'b) Gg.bigarray -> int -> 'a -> 'a -> 'a -> 'a -> unit
set_4d b i s1 s2 s3 s4
sets the i
th to i+3
th scalar of b
to s1
, s2
, s3
, s4
.val seti_2d : (int32, 'b) Gg.bigarray -> int -> int -> int -> unit
set_2d b i s1 s2
sets the i
th to i+1
th scalar of b
to
s1
, s2
.val seti_3d : (int32, 'b) Gg.bigarray -> int -> int -> int -> int -> unit
set_3d b i s1 s2 s3
sets the i
th to i+2
th scalar of b
to
s1
, s2
, s3
.