To focus the search input from anywhere on the page, press the 'S' key.
in-package search v0.1.0
-
bigarray
-
dynlink
-
ocamlbytecomp
-
ocamlcommon
-
ocamlmiddleend
-
ocamloptcomp
-
odoc_info
-
raw_spacetime_lib
-
-
stdlib
-
str
-
threads
-
unix
Library
Module
Module type
Parameter
Class
Class type
include module type of struct include Bigarray end
Element kinds
Bigarrays can contain elements of the following kinds:
- IEEE single precision (32 bits) floating-point numbers (
Bigarray.float32_elt
), - IEEE double precision (64 bits) floating-point numbers (
Bigarray.float64_elt
), - IEEE single precision (2 * 32 bits) floating-point complex numbers (
Bigarray.complex32_elt
), - IEEE double precision (2 * 64 bits) floating-point complex numbers (
Bigarray.complex64_elt
), - 8-bit integers (signed or unsigned) (
Bigarray.int8_signed_elt
orBigarray.int8_unsigned_elt
), - 16-bit integers (signed or unsigned) (
Bigarray.int16_signed_elt
orBigarray.int16_unsigned_elt
), - OCaml integers (signed, 31 bits on 32-bit architectures, 63 bits on 64-bit architectures) (
Bigarray.int_elt
), - 32-bit signed integers (
Bigarray.int32_elt
), - 64-bit signed integers (
Bigarray.int64_elt
), - platform-native signed integers (32 bits on 32-bit architectures, 64 bits on 64-bit architectures) (
Bigarray.nativeint_elt
).
Each element kind is represented at the type level by one of the *_elt
types defined below (defined with a single constructor instead of abstract types for technical injectivity reasons).
- since 4.07.0 Moved from otherlibs to stdlib.
type ('a, 'b) kind = ('a, 'b) Bigarray.kind =
| Float32 : (float, float32_elt) kind
| Float64 : (float, float64_elt) kind
| Int8_signed : (int, int8_signed_elt) kind
| Int8_unsigned : (int, int8_unsigned_elt) kind
| Int16_signed : (int, int16_signed_elt) kind
| Int16_unsigned : (int, int16_unsigned_elt) kind
| Int32 : (int32, int32_elt) kind
| Int64 : (int64, int64_elt) kind
| Int : (int, int_elt) kind
| Nativeint : (nativeint, nativeint_elt) kind
| Complex32 : (Complex.t, complex32_elt) kind
| Complex64 : (Complex.t, complex64_elt) kind
| Char : (char, int8_unsigned_elt) kind
To each element kind is associated an OCaml type, which is the type of OCaml values that can be stored in the Bigarray or read back from it. This type is not necessarily the same as the type of the array elements proper: for instance, a Bigarray whose elements are of kind float32_elt
contains 32-bit single precision floats, but reading or writing one of its elements from OCaml uses the OCaml type float
, which is 64-bit double precision floats.
The GADT type ('a, 'b) kind
captures this association of an OCaml type 'a
for values read or written in the Bigarray, and of an element kind 'b
which represents the actual contents of the Bigarray. Its constructors list all possible associations of OCaml types with element kinds, and are re-exported below for backward-compatibility reasons.
Using a generalized algebraic datatype (GADT) here allows writing well-typed polymorphic functions whose return type depend on the argument type, such as:
let zero : type a b. (a, b) kind -> a = function
| Float32 -> 0.0 | Complex32 -> Complex.zero
| Float64 -> 0.0 | Complex64 -> Complex.zero
| Int8_signed -> 0 | Int8_unsigned -> 0
| Int16_signed -> 0 | Int16_unsigned -> 0
| Int32 -> 0l | Int64 -> 0L
| Int -> 0 | Nativeint -> 0n
| Char -> '\000'
val float32 : (float, float32_elt) kind
See Bigarray.char
.
val float64 : (float, float64_elt) kind
See Bigarray.char
.
val complex32 : (Complex.t, complex32_elt) kind
See Bigarray.char
.
val complex64 : (Complex.t, complex64_elt) kind
See Bigarray.char
.
val int8_signed : (int, int8_signed_elt) kind
See Bigarray.char
.
val int8_unsigned : (int, int8_unsigned_elt) kind
See Bigarray.char
.
val int16_signed : (int, int16_signed_elt) kind
See Bigarray.char
.
val int16_unsigned : (int, int16_unsigned_elt) kind
See Bigarray.char
.
See Bigarray.char
.
See Bigarray.char
.
See Bigarray.char
.
val nativeint : (nativeint, nativeint_elt) kind
See Bigarray.char
.
val char : (char, int8_unsigned_elt) kind
As shown by the types of the values above, Bigarrays of kind float32_elt
and float64_elt
are accessed using the OCaml type float
. Bigarrays of complex kinds complex32_elt
, complex64_elt
are accessed with the OCaml type Complex.t
. Bigarrays of integer kinds are accessed using the smallest OCaml integer type large enough to represent the array elements: int
for 8- and 16-bit integer Bigarrays, as well as OCaml-integer Bigarrays; int32
for 32-bit integer Bigarrays; int64
for 64-bit integer Bigarrays; and nativeint
for platform-native integer Bigarrays. Finally, Bigarrays of kind int8_unsigned_elt
can also be accessed as arrays of characters instead of arrays of small integers, by using the kind value char
instead of int8_unsigned
.
val kind_size_in_bytes : ('a, 'b) kind -> int
kind_size_in_bytes k
is the number of bytes used to store an element of type k
.
- since 4.03.0