
Module Bigarray.Genarraymodule Genarray: type (
The type
Genarray.t is the type of big arrays with variable
numbers of dimensions. Any number of dimensions between 1 and 16
is supported.
The three type parameters to
(float, float32_elt, fortran_layout) Genarray.t
is the type of generic big arrays containing 32bit floats
in Fortran layout; reads and writes in this array use the
Caml type float .val create : Genarray.create kind layout dimensions returns a new big array
whose element kind is determined by the parameter kind (one of
float32 , float64 , int8_signed , etc) and whose layout is
determined by the parameter layout (one of c_layout or
fortran_layout ). The dimensions parameter is an array of
integers that indicate the size of the big array in each dimension.
The length of dimensions determines the number of dimensions
of the bigarray.
For instance,
Big arrays returned by
val num_dims :
Return the number of dimensions of the given big array.
val dims : Genarray.dims a returns all dimensions of the big array a ,
as an array of integers of length Genarray.num_dims a .val nth_dim : Genarray.nth_dim a n returns the n th dimension of the
big array a . The first dimension corresponds to n = 0 ;
the second dimension corresponds to n = 1 ; the last dimension,
to n = Genarray.num_dims a  1 .
Raise Invalid_arg if n is less than 0 or greater or equal than
Genarray.num_dims a .val kind :
Return the kind of the given big array.
val layout :
Return the layout of the given big array.
val get :
Read an element of a generic big array.
Genarray.get a [i1; ...; iN] returns the element of a
whose coordinates are i1 in the first dimension, i2 in
the second dimension, ..., iN in the N th dimension.
If
If val set :
Assign an element of a generic big array.
Genarray.set a [i1; ...; iN] v stores the value v in the
element of a whose coordinates are i1 in the first dimension,
i2 in the second dimension, ..., iN in the N th dimension.
The array
If val sub_left :
Extract a subarray of the given big array by restricting the
first (leftmost) dimension.
Genarray.sub_left a ofs len
returns a big array with the same number of dimensions as a ,
and the same dimensions as a , except the first dimension,
which corresponds to the interval [ofs ... ofs + len  1]
of the first dimension of a . No copying of elements is
involved: the subarray and the original array share the same
storage space. In other terms, the element at coordinates
[i1; ...; iN] of the subarray is identical to the
element at coordinates [i1+ofs; ...; iN] of the original
array a .
val sub_right :
Extract a subarray of the given big array by restricting the
last (rightmost) dimension.
Genarray.sub_right a ofs len
returns a big array with the same number of dimensions as a ,
and the same dimensions as a , except the last dimension,
which corresponds to the interval [ofs ... ofs + len  1]
of the last dimension of a . No copying of elements is
involved: the subarray and the original array share the same
storage space. In other terms, the element at coordinates
[i1; ...; iN] of the subarray is identical to the
element at coordinates [i1; ...; iN+ofs] of the original
array a .
val slice_left :
Extract a subarray of lower dimension from the given big array
by fixing one or several of the first (leftmost) coordinates.
Genarray.slice_left a [i1; ... ; iM] returns the ``slice''
of a obtained by setting the first M coordinates to
i1 , ..., iM . If a has N dimensions, the slice has
dimension N  M , and the element at coordinates
[j1; ...; j(NM)] in the slice is identical to the element
at coordinates [i1; ...; iM; j1; ...; j(NM)] in the original
array a . No copying of elements is involved: the slice and
the original array share the same storage space.
val slice_right :
Extract a subarray of lower dimension from the given big array
by fixing one or several of the last (rightmost) coordinates.
Genarray.slice_right a [i1; ... ; iM] returns the ``slice''
of a obtained by setting the last M coordinates to
i1 , ..., iM . If a has N dimensions, the slice has
dimension N  M , and the element at coordinates
[j1; ...; j(NM)] in the slice is identical to the element
at coordinates [j1; ...; j(NM); i1; ...; iM] in the original
array a . No copying of elements is involved: the slice and
the original array share the same storage space.
val blit :
Copy all elements of a big array in another big array.
Genarray.blit src dst copies all elements of src into
dst . Both arrays src and dst must have the same number of
dimensions and equal dimensions. Copying a subarray of src
to a subarray of dst can be achieved by applying Genarray.blit
to subarray or slices of src and dst .val fill :
Set all elements of a big array to a given value.
Genarray.fill a v stores the value v in all elements of
the big array a . Setting only some elements of a to v
can be achieved by applying Genarray.fill to a subarray
or a slice of a .val map_file :
Memory mapping of a file as a big array.
Genarray.map_file fd kind layout shared dims
returns a big array of kind kind , layout layout ,
and dimensions as specified in dims . The data contained in
this big array are the contents of the file referred to by
the file descriptor fd (as opened previously with
Unix.openfile , for example). If shared is true ,
all modifications performed on the array are reflected in
the file. This requires that fd be opened with write permissions.
If shared is false , modifications performed on the array
are done in memory only, using copyonwrite of the modified
pages; the underlying file is not affected.
To adjust automatically the dimensions of the big array to
the actual size of the file, the major dimension (that is,
the first dimension for an array with C layout, and the last
dimension for an array with Fortran layout) can be given as
If all dimensions of the big array are given, the file size is
matched against the size of the big array. If the file is larger
than the big array, only the initial portion of the file is
mapped to the big array. If the file is smaller than the big
array, the file is automatically grown to the size of the big array.
This requires write permissions on 