Bigarray.Array3(3) OCaml library Bigarray.Array3(3)

# [NAME](#NAME)

Bigarray.Array3 - Three-dimensional arrays.

# [Module](#Module)

Module Bigarray.Array3

# [Documentation](#Documentation)

Module **Array3**  
: **sig end**

Three-dimensional arrays. The **Array3** structure provides operations similar to those of **Bigarray.Genarray** , but specialized to the case of three-dimensional arrays.

*type* **('a, 'b, 'c)** *t*

The type of three-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; int -&gt; int -&gt; ('a, 'b, 'c) t**

**Array3.create kind layout dim1 dim2 dim3** returns a new Bigarray of three dimensions, whose size is **dim1** in the first dimension, **dim2** in the second dimension, and **dim3** in the third. **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; int -&gt; (int -&gt; int -&gt; int -&gt; 'a) -&gt; ('a, 'b, 'c) t**

**Array3.init kind layout dim1 dim2 dim3 f** returns a new Bigarray **b** of three dimensions, whose size is **dim1** in the first dimension, **dim2** in the second dimension, and **dim3** in the third. **kind** and **layout** determine the array element kind and the array layout as described for **Bigarray.Genarray.create** .

Each element **Array3.get b i j k** of the array is initialized to the result of **f i j k** .

In other words, **Array3.init kind layout dim1 dim2 dim3 f** tabulates the results of **f** applied to the indices of a new Bigarray whose layout is described by **kind** , **layout** , **dim1** , **dim2** and **dim3** .

**Since** 4.12.0

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

Return the first dimension of the given three-dimensional Bigarray.

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

Return the second dimension of the given three-dimensional Bigarray.

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

Return the third dimension of the given three-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**

**Array3.change\_layout a layout** returns a Bigarray with the specified **layout** , sharing the data with **a** (and hence having the same dimensions as **a** ). No copying of elements is involved: the new array and the original array share the same storage space. The dimensions are reversed, such that **get v \[| a; b; c |]** in C layout becomes **get v \[| c+1; b+1; a+1 |]** in Fortran layout.

**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; int -&gt; int -&gt; 'a**

**Array3.get a x y z** , also written **a.{x,y,z}** , returns the element of **a** at coordinates ( **x** , **y** , **z** ). **x** , **y** and **z** must be within the bounds of **a** , as described for **Bigarray.Genarray.get** ; otherwise, **Invalid\_argument** is raised.

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

**Array3.set a x y v** , or alternatively **a.{x,y,z} &lt;- v** , stores the value **v** at coordinates ( **x** , **y** , **z** ) in **a** . **x** , **y** and **z** must be within the bounds of **a** , as described for **Bigarray.Genarray.set** ; otherwise, **Invalid\_argument** is raised.

*val sub\_left* : **('a, 'b, Bigarray.c\_layout) t -&gt;** **int -&gt; int -&gt; ('a, 'b, Bigarray.c\_layout) t**

Extract a three-dimensional sub-array of the given three-dimensional Bigarray by restricting the first dimension. See **Bigarray.Genarray.sub\_left** for more details. **Array3.sub\_left** applies only to arrays with C layout.

*val sub\_right* : **('a, 'b, Bigarray.fortran\_layout) t -&gt;** **int -&gt; int -&gt; ('a, 'b, Bigarray.fortran\_layout) t**

Extract a three-dimensional sub-array of the given three-dimensional Bigarray by restricting the second dimension. See **Bigarray.Genarray.sub\_right** for more details. **Array3.sub\_right** applies only to arrays with Fortran layout.

*val slice\_left\_1* : **('a, 'b, Bigarray.c\_layout) t -&gt;** **int -&gt; int -&gt; ('a, 'b, Bigarray.c\_layout) Bigarray.Array1.t**

Extract a one-dimensional slice of the given three-dimensional Bigarray by fixing the first two coordinates. The integer parameters are the coordinates of the slice to extract. See **Bigarray.Genarray.slice\_left** for more details. **Array3.slice\_left\_1** applies only to arrays with C layout.

*val slice\_right\_1* : **('a, 'b, Bigarray.fortran\_layout) t -&gt;** **int -&gt; int -&gt; ('a, 'b, Bigarray.fortran\_layout) Bigarray.Array1.t**

Extract a one-dimensional slice of the given three-dimensional Bigarray by fixing the last two coordinates. The integer parameters are the coordinates of the slice to extract. See **Bigarray.Genarray.slice\_right** for more details. **Array3.slice\_right\_1** applies only to arrays with Fortran layout.

*val slice\_left\_2* : **('a, 'b, Bigarray.c\_layout) t -&gt;** **int -&gt; ('a, 'b, Bigarray.c\_layout) Bigarray.Array2.t**

Extract a two-dimensional slice of the given three-dimensional Bigarray by fixing the first coordinate. The integer parameter is the first coordinate of the slice to extract. See **Bigarray.Genarray.slice\_left** for more details. **Array3.slice\_left\_2** applies only to arrays with C layout.

*val slice\_right\_2* : **('a, 'b, Bigarray.fortran\_layout) t -&gt;** **int -&gt; ('a, 'b, Bigarray.fortran\_layout) Bigarray.Array2.t**

Extract a two-dimensional slice of the given three-dimensional Bigarray by fixing the last coordinate. The integer parameter is the coordinate of the slice to extract. See **Bigarray.Genarray.slice\_right** for more details. **Array3.slice\_right\_2** applies only to arrays with Fortran layout.

*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 array array -&gt; ('a, 'b, 'c) t**

Build a three-dimensional Bigarray initialized from the given array of arrays of arrays.

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

Like **Bigarray.Array3.get** , but bounds checking is not always performed.

*val unsafe\_set* : **('a, 'b, 'c) t -&gt; int -&gt; int -&gt; int -&gt; 'a -&gt; unit**

Like **Bigarray.Array3.set** , but bounds checking is not always performed.

2026-10-27 OCamldoc

---

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