package ocaml-base-compiler

  1. Overview
  2. Docs
include module type of struct include Bigarray.Array1 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 ('a, 'b, 'c) t = ('a, 'b, 'c) Bigarray.Array1.t

The type of one-dimensional big arrays whose elements have OCaml type 'a, representation kind 'b, and memory layout 'c.

val create : ('a, 'b) Bigarray.kind -> 'c Bigarray.layout -> int -> ('a, 'b, 'c) t

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.

val dim : ('a, 'b, 'c) t -> int

Return the size (dimension) of the given one-dimensional big array.

val kind : ('a, 'b, 'c) t -> ('a, 'b) Bigarray.kind

Return the kind of the given big array.

val layout : ('a, 'b, 'c) t -> 'c Bigarray.layout

Return the layout of the given big array.

val change_layout : ('a, 'b, 'c) t -> 'd Bigarray.layout -> ('a, 'b, 'd) t

Array1.change_layout a layout returns a bigarray with the specified layout, sharing the data with a (and hence having the same dimension as a). No copying of elements is involved: the new array and the original array share the same storage space.

  • since 4.06.0
val size_in_bytes : ('a, 'b, 'c) t -> int

size_in_bytes a is the number of elements in a multiplied by a's kind_size_in_bytes.

  • since 4.03.0
val get : ('a, 'b, 'c) t -> 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.

val set : ('a, 'b, 'c) t -> 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.

val sub : ('a, 'b, 'c) t -> int -> int -> ('a, 'b, 'c) t

Extract a sub-array of the given one-dimensional big array. See Genarray.sub_left for more details.

val slice : ('a, 'b, 'c) t -> int -> ('a, 'b, 'c) Bigarray.Array0.t

Extract a scalar (zero-dimensional slice) of the given one-dimensional big array. The integer parameter is the index of the scalar to extract. See Bigarray.Genarray.slice_left and Bigarray.Genarray.slice_right for more details.

  • since 4.05.0
val blit : ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unit

Copy the first big array to the second big array. See Genarray.blit for more details.

val fill : ('a, 'b, 'c) t -> 'a -> unit

Fill the given big array with the given value. See Genarray.fill for more details.

val of_array : ('a, 'b) Bigarray.kind -> 'c Bigarray.layout -> 'a array -> ('a, 'b, 'c) t

Build a one-dimensional big array initialized from the given array.

val unsafe_get : ('a, 'b, 'c) t -> 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.

val unsafe_set : ('a, 'b, 'c) t -> 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.

val map_file : Unix.file_descr -> ?pos:int64 -> ('a, 'b) kind -> 'c layout -> bool -> int -> ('a, 'b, 'c) t
  • deprecated Use [array1_of_genarray (Unix.map_file ...)] instead. Note that Bigarray.Array1.map_file raises Sys_error while Unix.map_file raises Unix_error.
OCaml

Innovation. Community. Security.