Module Bigarray.Array1
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) tThe type of one-dimensional Bigarrays whose elements have OCaml type
'a, representation kind'b, and memory layout'c.
val create : ('a, 'b) kind -> 'c layout -> int -> ('a, 'b, 'c) tArray1.create kind layout dimreturns a new Bigarray of one dimension, whose size isdim.kindandlayoutdetermine the array element kind and the array layout as described forGenarray.create.
val dim : ('a, 'b, 'c) t -> intReturn the size (dimension) of the given one-dimensional Bigarray.
val change_layout : ('a, 'b, 'c) t -> 'd layout -> ('a, 'b, 'd) tArray1.change_layout a layoutreturns a Bigarray with the specifiedlayout, sharing the data witha(and hence having the same dimension asa). 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 -> intsize_in_bytes ais the number of elements inamultiplied bya'skind_size_in_bytes.- since
- 4.03.0
val get : ('a, 'b, 'c) t -> int -> 'aArray1.get a x, or alternativelya.{x}, returns the element ofaat indexx.xmust be greater or equal than0and strictly less thanArray1.dim aifahas C layout. Ifahas Fortran layout,xmust be greater or equal than1and less or equal thanArray1.dim a. Otherwise,Invalid_argumentis raised.
val set : ('a, 'b, 'c) t -> int -> 'a -> unitArray1.set a x v, also writtena.{x} <- v, stores the valuevat indexxina.xmust be inside the bounds ofaas described inBigarray.Array1.get; otherwise,Invalid_argumentis raised.
val sub : ('a, 'b, 'c) t -> int -> int -> ('a, 'b, 'c) tExtract a sub-array of the given one-dimensional Bigarray. See
Genarray.sub_leftfor more details.
val slice : ('a, 'b, 'c) t -> int -> ('a, 'b, 'c) Array0.tExtract a scalar (zero-dimensional slice) of the given one-dimensional Bigarray. The integer parameter is the index of the scalar to extract. See
Bigarray.Genarray.slice_leftandBigarray.Genarray.slice_rightfor more details.- since
- 4.05.0
val blit : ('a, 'b, 'c) t -> ('a, 'b, 'c) t -> unitCopy the first Bigarray to the second Bigarray. See
Genarray.blitfor more details.
val fill : ('a, 'b, 'c) t -> 'a -> unitFill the given Bigarray with the given value. See
Genarray.fillfor more details.
val of_array : ('a, 'b) kind -> 'c layout -> 'a array -> ('a, 'b, 'c) tBuild a one-dimensional Bigarray initialized from the given array.
val unsafe_get : ('a, 'b, 'c) t -> int -> 'aLike
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 -> unitLike
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.