module Array1: sig .. end
One-dimensional arrays. The
Array1
structure provides operations
similar to those of
Bigarray.Genarray
, but specialized to the case of one-dimensional arrays.
(The
Array2
and
Array3
structures below provide operations
specialized for two- and three-dimensional arrays.)
Statically knowing the number of dimensions of the array allows
faster operations, and more precise static type-checking.
type t('a, 'b, 'c);
The type of one-dimensional big arrays whose elements have
OCaml type 'a
, representation kind 'b
, and memory layout 'c
.
let create: (Bigarray.kind('a, 'b), Bigarray.layout('c), int) => t('a, 'b, 'c);
Array1.create kind layout dim
returns a new bigarray of
one dimension, whose size is dim
. kind
and layout
determine the array element kind and the array layout
as described for Genarray.create
.
let dim: t('a, 'b, 'c) => int;
Return the size (dimension) of the given one-dimensional
big array.
let kind: t('a, 'b, 'c) => Bigarray.kind('a, 'b);
Return the kind of the given big array.
let layout: t('a, 'b, 'c) => Bigarray.layout('c);
Return the layout of the given big array.
let get: (t('a, 'b, 'c), int) => 'a;
Array1.get a x
, or alternatively a.{x}
,
returns the element of a
at index x
.
x
must be greater or equal than 0
and strictly less than
Array1.dim a
if a
has C layout. If a
has Fortran layout,
x
must be greater or equal than 1
and less or equal than
Array1.dim a
. Otherwise, Invalid_argument
is raised.
let set: (t('a, 'b, 'c), int, 'a) => unit;
Array1.set a x v
, also written
a.{x} <- v
,
stores the value
v
at index
x
in
a
.
x
must be inside the bounds of
a
as described in
Bigarray.Array1.get
;
otherwise,
Invalid_argument
is raised.
let sub: (t('a, 'b, 'c), int, int) => t('a, 'b, 'c);
Extract a sub-array of the given one-dimensional big array.
See Genarray.sub_left
for more details.
let blit: (t('a, 'b, 'c), t('a, 'b, 'c)) => unit;
Copy the first big array to the second big array.
See Genarray.blit
for more details.
let fill: (t('a, 'b, 'c), 'a) => unit;
Fill the given big array with the given value.
See Genarray.fill
for more details.
let of_array:
(Bigarray.kind('a, 'b), Bigarray.layout('c), array('a)) => t('a, 'b, 'c);
Build a one-dimensional big array initialized from the
given array.
let map_file:
(
Unix.file_descr,
~pos: int64=?,
Bigarray.kind('a, 'b),
Bigarray.layout('c),
bool,
int
) =>
t('a, 'b, 'c);
let unsafe_get: (t('a, 'b, 'c), int) => 'a;
Like
Bigarray.Array1.get
, but bounds checking is not always performed.
Use with caution and only when the program logic guarantees that
the access is within bounds.
let unsafe_set: (t('a, 'b, 'c), int, 'a) => unit;
Like
Bigarray.Array1.set
, but bounds checking is not always performed.
Use with caution and only when the program logic guarantees that
the access is within bounds.