package batteries
Install
Dune Dependency
Authors
Maintainers
Sources
md5=ea26b5c72e6731e59d856626049cca4d
sha512=55975b62c26f6db77433a3ac31f97af609fc6789bb62ac38b267249c78fd44ff37fe81901f1cf560857b9493a6046dd37b0d1c0234c66bd59e52843aac3ce6cb
doc/batteries.unthreaded/BatBigarray/Array2/index.html
Module BatBigarray.Array2
Source
Two-dimensional arrays. The Array2
structure provides operations similar to those of Bigarray.Genarray
, but specialized to the case of two-dimensional arrays.
The type of two-dimensional big arrays whose elements have OCaml type 'a
, representation kind 'b
, and memory layout 'c
.
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
.
Return the first dimension of the given two-dimensional big array.
Return the second dimension of the given two-dimensional big array.
Array2.change_layout a layout
returns a bigarray with the specified layout
, sharing the data with a
(and hence having the same dimensions as a
). No copying of elements is involved: the new array and the original array share the same storage space. The dimensions are reversed, such that get v [| a; b |]
in C layout becomes get v [| b+1; a+1 |]
in Fortran layout.
size_in_bytes a
is the number of elements in a
multiplied by a
's kind_size_in_bytes
.
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
;
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
;
Extract a two-dimensional sub-array of the given two-dimensional big array by restricting the first dimension. See Bigarray.Genarray.sub_left
for more details. Array2.sub_left
applies only to arrays with C layout.
Extract a two-dimensional sub-array of the given two-dimensional big array by restricting the second dimension. See Bigarray.Genarray.sub_right
for more details. Array2.sub_right
applies only to arrays with Fortran layout.
Extract a row (one-dimensional slice) of the given two-dimensional big array. The integer parameter is the index of the row to extract. See Bigarray.Genarray.slice_left
for more details. Array2.slice_left
applies only to arrays with C layout.
Extract a column (one-dimensional slice) of the given two-dimensional big array. The integer parameter is the index of the column to extract. See Bigarray.Genarray.slice_right
for more details. Array2.slice_right
applies only to arrays with Fortran layout.
Copy the first big array to the second big array. See Bigarray.Genarray.blit
for more details.
Fill the given big array with the given value. See Bigarray.Genarray.fill
for more details.
Build a two-dimensional big array initialized from the given array of arrays.
val map_file :
Unix.file_descr ->
?pos:int64 ->
('a, 'b) kind ->
'c layout ->
bool ->
int ->
int ->
('a, 'b, 'c) t
Memory mapping of a file as a two-dimensional big array. See Bigarray.Genarray.map_file
for more details.
enum e
returns an enumeration on the elements of e
. The order of enumeration is unspecified.
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
Same as 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.
modify f a
changes each element x
in a
to f x
in-place.
Same as Bigarray.Array2.modify
, but the function is applied to the index of the element as the first two arguments, and the element itself as the third argument.
Build a two-dimensional array initialized from the given big array.
Unsafe operations
In case of doubt, don't use them.
Like Bigarray.Array2.get
, but bounds checking is not always performed.
Like Bigarray.Array2.set
, but bounds checking is not always performed.