type ('a, 'b, 'c) t
The type of two-dimensional Bigarrays whose elements have OCaml type
'a
, representation kind'b
, and memory layout'c
.
val create : ('a, 'b) kind -> 'c layout -> int -> int -> ('a, 'b, 'c) t
Array2.create kind layout dim1 dim2
returns a new Bigarray of two dimension, whose size isdim1
in the first dimension anddim2
in the second dimension.kind
andlayout
determine the array element kind and the array layout as described forBigarray.Genarray.create
.
val dim1 : ('a, 'b, 'c) t -> int
Return the first dimension of the given two-dimensional Bigarray.
val dim2 : ('a, 'b, 'c) t -> int
Return the second dimension of the given two-dimensional Bigarray.
val change_layout : ('a, 'b, 'c) t -> 'd layout -> ('a, 'b, 'd) t
Array2.change_layout a layout
returns a Bigarray with the specifiedlayout
, sharing the data witha
(and hence having the same dimensions asa
). No copying of elements is involved: the new array and the original array share the same storage space. The dimensions are reversed, such thatget v [| a; b |]
in C layout becomesget v [| b+1; a+1 |]
in Fortran layout.- since
- 4.06.0
val size_in_bytes : ('a, 'b, 'c) t -> int
size_in_bytes a
is the number of elements ina
multiplied bya
'skind_size_in_bytes
.- since
- 4.03.0
val get : ('a, 'b, 'c) t -> int -> int -> 'a
Array2.get a x y
, also writtena.{x,y}
, returns the element ofa
at coordinates (x
,y
).x
andy
must be within the bounds ofa
, as described forBigarray.Genarray.get
; otherwise,Invalid_argument
is raised.
val set : ('a, 'b, 'c) t -> int -> int -> 'a -> unit
Array2.set a x y v
, or alternativelya.{x,y} <- v
, stores the valuev
at coordinates (x
,y
) ina
.x
andy
must be within the bounds ofa
, as described forBigarray.Genarray.set
; otherwise,Invalid_argument
is raised.
val sub_left : ('a, 'b, c_layout) t -> int -> int -> ('a, 'b, c_layout) t
Extract a two-dimensional sub-array of the given two-dimensional Bigarray by restricting the first dimension. See
Bigarray.Genarray.sub_left
for more details.Array2.sub_left
applies only to arrays with C layout.
val sub_right : ('a, 'b, fortran_layout) t -> int -> int -> ('a, 'b, fortran_layout) t
Extract a two-dimensional sub-array of the given two-dimensional Bigarray by restricting the second dimension. See
Bigarray.Genarray.sub_right
for more details.Array2.sub_right
applies only to arrays with Fortran layout.
val slice_left : ('a, 'b, c_layout) t -> int -> ('a, 'b, c_layout) Array1.t
Extract a row (one-dimensional slice) of the given two-dimensional Bigarray. 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.
val slice_right : ('a, 'b, fortran_layout) t -> int -> ('a, 'b, fortran_layout) Array1.t
Extract a column (one-dimensional slice) of the given two-dimensional Bigarray. 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.
val blit : ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit
Copy the first Bigarray to the second Bigarray. See
Bigarray.Genarray.blit
for more details.
val fill : ('a, 'b, 'c) t -> 'a -> unit
Fill the given Bigarray with the given value. See
Bigarray.Genarray.fill
for more details.
val of_array : ('a, 'b) kind -> 'c layout -> 'a array array -> ('a, 'b, 'c) t
Build a two-dimensional Bigarray initialized from the given array of arrays.
val unsafe_get : ('a, 'b, 'c) t -> int -> int -> 'a
Like
Bigarray.Array2.get
, but bounds checking is not always performed.
val unsafe_set : ('a, 'b, 'c) t -> int -> int -> 'a -> unit
Like
Bigarray.Array2.set
, but bounds checking is not always performed.