Bigarray.Array1(3) OCaml library Bigarray.Array1(3)

# [NAME](#NAME)

Bigarray.Array1 - One-dimensional arrays.

# [Module](#Module)

Module Bigarray.Array1

# [Documentation](#Documentation)

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 **Bigarray.Array2** and **Bigarray.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*

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

*val create* : **('a, 'b) Bigarray.kind -&gt;** **'c Bigarray.layout -&gt; int -&gt; ('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 **Bigarray.Genarray.create** .

*val init* : **('a, 'b) Bigarray.kind -&gt;** **'c Bigarray.layout -&gt; int -&gt; (int -&gt; 'a) -&gt; ('a, 'b, 'c) t**

**Array1.init kind layout dim f** returns a new Bigarray **b** of one dimension, whose size is **dim** . **kind** and **layout** determine the array element kind and the array layout as described for **Bigarray.Genarray.create** .

Each element **Array1.get b i** of the array is initialized to the result of **f i** .

In other words, **Array1.init kind layout dimensions f** tabulates the results of **f** applied to the indices of a new Bigarray whose layout is described by **kind** , **layout** and **dim** .

**Since** 4.12.0

*val dim* : **('a, 'b, 'c) t -&gt; int**

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

*val kind* : **('a, 'b, 'c) t -&gt; ('a, 'b) Bigarray.kind**

Return the kind of the given Bigarray.

*val layout* : **('a, 'b, 'c) t -&gt; 'c Bigarray.layout**

Return the layout of the given Bigarray.

*val change\_layout* : **('a, 'b, 'c) t -&gt;** **'d Bigarray.layout -&gt; ('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 -&gt; int**

**size\_in\_bytes a** is the number of elements in **a** multiplied by **a** 's **Bigarray.kind\_size\_in\_bytes** .

**Since** 4.03.0

*val get* : **('a, 'b, 'c) t -&gt; int -&gt; '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 -&gt; int -&gt; 'a -&gt; unit**

**Array1.set a x v** , also written **a.{x} &lt;- 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 -&gt;** **int -&gt; int -&gt; ('a, 'b, 'c) t**

Extract a sub-array of the given one-dimensional Bigarray. See **Bigarray.Genarray.sub\_left** for more details.

*val slice* : **('a, 'b, 'c) t -&gt; int -&gt; ('a, 'b, 'c) Bigarray.Array0.t**

Extract 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\_left** and **Bigarray.Genarray.slice\_right** for more details.

**Since** 4.05.0

*val blit* : **('a, 'b, 'c) t -&gt; ('a, 'b, 'c) t -&gt; unit**

Copy the first Bigarray to the second Bigarray. See **Bigarray.Genarray.blit** for more details.

*val fill* : **('a, 'b, 'c) t -&gt; 'a -&gt; unit**

Fill the given Bigarray with the given value. See **Bigarray.Genarray.fill** for more details.

*val of\_array* : **('a, 'b) Bigarray.kind -&gt;** **'c Bigarray.layout -&gt; 'a array -&gt; ('a, 'b, 'c) t**

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

*val unsafe\_get* : **('a, 'b, 'c) t -&gt; int -&gt; '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 -&gt; int -&gt; 'a -&gt; 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.

2026-09-15 OCamldoc

---

Document: Bigarray.Array1(3o) from ocaml-4 4.14.4-r3 (Chainguard OS)
Source: https://github.com/ocaml/ocaml
