module Array2:Two-dimensional arrays. Thesig
..end
Array2
structure provides operations
similar to those of Bigarray.Genarray
, but specialized to the
case of two-dimensional arrays.type('a, 'b, 'c)
t =('a, 'b, 'c) Bigarray.Array2.t
'a
, representation kind 'b
, and memory layout 'c
.val create : ('a, 'b) BatBigarray.kind ->
'c BatBigarray.layout -> int -> int -> ('a, 'b, 'c) t
Array2.create kind layout dim1 dim2
returns a new bigarray of
two dimension, whose size is dim1
in the first dimension
and dim2
in the second dimension. kind
and layout
determine the array element kind and the array layout
as described for Bigarray.Genarray.create
.val dim1 : ('a, 'b, 'c) t -> int
val dim2 : ('a, 'b, 'c) t -> int
val kind : ('a, 'b, 'c) t -> ('a, 'b) BatBigarray.kind
val layout : ('a, 'b, 'c) t -> 'c BatBigarray.layout
val get : ('a, 'b, 'c) t -> int -> int -> 'a
Array2.get a x y
, also written a.{x,y}
,
returns the element of a
at coordinates (x
, y
).
x
and y
must be within the bounds
of a
, as described for Bigarray.Genarray.get
;
otherwise, Invalid_arg
is raised.val set : ('a, 'b, 'c) t -> int -> int -> 'a -> unit
Array2.set a x y v
, or alternatively a.{x,y} <- v
,
stores the value v
at coordinates (x
, y
) in a
.
x
and y
must be within the bounds of a
,
as described for Bigarray.Genarray.set
;
otherwise, Invalid_arg
is raised.val sub_left : ('a, 'b, BatBigarray.c_layout) t ->
int -> int -> ('a, 'b, BatBigarray.c_layout) t
Bigarray.Genarray.sub_left
for more details.
Array2.sub_left
applies only to arrays with C layout.val sub_right : ('a, 'b, BatBigarray.fortran_layout) t ->
int -> int -> ('a, 'b, BatBigarray.fortran_layout) t
Bigarray.Genarray.sub_right
for more details.
Array2.sub_right
applies only to arrays with Fortran layout.val slice_left : ('a, 'b, BatBigarray.c_layout) t ->
int -> ('a, 'b, BatBigarray.c_layout) BatBigarray.Array1.t
Bigarray.Genarray.slice_left
for more details.
Array2.slice_left
applies only to arrays with C layout.val slice_right : ('a, 'b, BatBigarray.fortran_layout) t ->
int -> ('a, 'b, BatBigarray.fortran_layout) BatBigarray.Array1.t
Bigarray.Genarray.slice_right
for more details. Array2.slice_right
applies only to arrays
with Fortran layout.val blit : ('a, 'b, 'c) t ->
('a, 'b, 'c) t -> unit
Bigarray.Genarray.blit
for more details.val fill : ('a, 'b, 'c) t -> 'a -> unit
Bigarray.Genarray.fill
for more details.val of_array : ('a, 'b) BatBigarray.kind ->
'c BatBigarray.layout -> 'a array array -> ('a, 'b, 'c) t
val map_file : Unix.file_descr ->
?pos:int64 ->
('a, 'b) BatBigarray.kind ->
'c BatBigarray.layout ->
bool -> int -> int -> ('a, 'b, 'c) t
Bigarray.Genarray.map_file
for more details.val enum : ('a, 'b, 'c) t -> 'a BatEnum.t
enum e
returns an enumeration on the elements of e
.
The order of enumeration is unspecified.val map : ('a -> 'b) ->
('b, 'c) Bigarray.kind ->
('a, 'd, 'e) t -> ('b, 'c, 'e) t
Array2.map f a
applies function f
to all the elements of a
,
and builds a Bigarray.Array2.t
with the results returned by f
.val mapij : (int -> int -> 'a -> 'b) ->
('b, 'c) Bigarray.kind ->
('a, 'd, 'e) t -> ('b, 'c, 'e) t
Bigarray.Array2.map
, but the
function is applied to the index of the element as the first two
arguments, and the element itself as the third argument.val to_array : ('a, 'b, 'c) t -> 'a array array
In case of doubt, don't use them.
val unsafe_get : ('a, 'b, 'c) t -> int -> int -> 'a
Bigarray.Array2.get
, but bounds checking is not always
performed.val unsafe_set : ('a, 'b, 'c) t -> int -> int -> 'a -> unit
Bigarray.Array2.set
, but bounds checking is not always
performed.