FSharp.Core


Array4D Module

Contains operations for working with rank 4 arrays.

Functions and values

Function or value Description

Array4D.create length1 length2 length3 length4 initial

Full Usage: Array4D.create length1 length2 length3 length4 initial

Parameters:
    length1 : int - The length of the first dimension.
    length2 : int - The length of the second dimension.
    length3 : int - The length of the third dimension.
    length4 : int - The length of the fourth dimension.
    initial : 'T - The initial value for each element of the array.

Returns: 'T[,,,] The created array.

Creates an array whose elements are all initially the given value

length1 : int

The length of the first dimension.

length2 : int

The length of the second dimension.

length3 : int

The length of the third dimension.

length4 : int

The length of the fourth dimension.

initial : 'T

The initial value for each element of the array.

Returns: 'T[,,,]

The created array.

Example

 Array4D.create 2 2 2 2 1
Evaluates to a 2x2x2x2 array with all entries 1

Array4D.get array index1 index2 index3 index4

Full Usage: Array4D.get array index1 index2 index3 index4

Parameters:
    array : 'T[,,,] - The input array.
    index1 : int - The index along the first dimension.
    index2 : int - The index along the second dimension.
    index3 : int - The index along the third dimension.
    index4 : int - The index along the fourth dimension.

Returns: 'T The value at the given index.

Fetches an element from a 4D array. You can also use the syntax 'array.[index1,index2,index3,index4]'

Indexer syntax is generally preferred, e.g.

 let array: float[,,,] = Array4D.zeroCreate 2 3 4 5

 array[0,2,1,3]

array : 'T[,,,]

The input array.

index1 : int

The index along the first dimension.

index2 : int

The index along the second dimension.

index3 : int

The index along the third dimension.

index4 : int

The index along the fourth dimension.

Returns: 'T

The value at the given index.

Example

 let array = Array4D.zeroCreate 2 3 4 5

 Array4D.get array 0 2 1 3

Array4D.init length1 length2 length3 length4 initializer

Full Usage: Array4D.init length1 length2 length3 length4 initializer

Parameters:
    length1 : int - The length of the first dimension.
    length2 : int - The length of the second dimension.
    length3 : int - The length of the third dimension.
    length4 : int - The length of the fourth dimension.
    initializer : int -> int -> int -> int -> 'T - The function to create an initial value at each index in the array.

Returns: 'T[,,,] The created array.

Creates an array given the dimensions and a generator function to compute the elements.

length1 : int

The length of the first dimension.

length2 : int

The length of the second dimension.

length3 : int

The length of the third dimension.

length4 : int

The length of the fourth dimension.

initializer : int -> int -> int -> int -> 'T

The function to create an initial value at each index in the array.

Returns: 'T[,,,]

The created array.

Example

 Array4D.init 2 2 2 2 (fun i j k l -> i*1000+j*100+k*10+l)
Evaluates to a 2x2x2x2 array with contents [[[[0; 1]; [10; 11]]; [[100; 101]; [110; 111]]];[[[1000; 1]; [1010; 1011]]; [[1100; 1101]; [1110; 1111]]]]

Array4D.length1 array

Full Usage: Array4D.length1 array

Parameters:
    array : 'T[,,,] - The input array.

Returns: int The length of the array in the first dimension.

Returns the length of an array in the first dimension

array : 'T[,,,]

The input array.

Returns: int

The length of the array in the first dimension.

Example

 let array = Array4D.init 2 3 4 5 (fun i j k -> 100*i + 10*j + k)

 array |> Array4D.length1
Evaluates to 2.

Array4D.length2 array

Full Usage: Array4D.length2 array

Parameters:
    array : 'T[,,,] - The input array.

Returns: int The length of the array in the second dimension.

Returns the length of an array in the second dimension.

array : 'T[,,,]

The input array.

Returns: int

The length of the array in the second dimension.

Example

 let array = Array4D.init 2 3 4 5 (fun i j k -> 100*i + 10*j + k)

 array |> Array4D.length2
Evaluates to 3.

Array4D.length3 array

Full Usage: Array4D.length3 array

Parameters:
    array : 'T[,,,] - The input array.

Returns: int The length of the array in the third dimension.

Returns the length of an array in the third dimension.

array : 'T[,,,]

The input array.

Returns: int

The length of the array in the third dimension.

Example

 let array = Array4D.init 2 3 4 5 (fun i j k -> 100*i + 10*j + k)

 array |> Array4D.length3
Evaluates to 4.

Array4D.length4 array

Full Usage: Array4D.length4 array

Parameters:
    array : 'T[,,,] - The input array.

Returns: int The length of the array in the fourth dimension.

Returns the length of an array in the fourth dimension.

array : 'T[,,,]

The input array.

Returns: int

The length of the array in the fourth dimension.

Example

 let array = Array4D.init 2 3 4 5 (fun i j k -> 100*i + 10*j + k)

 array |> Array4D.length4
Evaluates to 5.

Array4D.set array index1 index2 index3 index4 value

Full Usage: Array4D.set array index1 index2 index3 index4 value

Parameters:
    array : 'T[,,,] - The input array.
    index1 : int - The index along the first dimension.
    index2 : int - The index along the second dimension.
    index3 : int - The index along the third dimension.
    index4 : int - The index along the fourth dimension.
    value : 'T - The value to set.

Sets the value of an element in an array. You can also use the syntax 'array.[index1,index2,index3,index4] <- value'.

Indexer syntax is generally preferred, e.g.

 let array: float[,,,] = Array4D.zeroCreate 2 3 4 5

 array[0,2,1,3] <- 5.0

array : 'T[,,,]

The input array.

index1 : int

The index along the first dimension.

index2 : int

The index along the second dimension.

index3 : int

The index along the third dimension.

index4 : int

The index along the fourth dimension.

value : 'T

The value to set.

Example

 let array = Array4D.zeroCreate 2 3 4 5

 Array4D.2et array 0 2 1 3 5.0

Array4D.zeroCreate length1 length2 length3 length4

Full Usage: Array4D.zeroCreate length1 length2 length3 length4

Parameters:
    length1 : int - The length of the first dimension.
    length2 : int - The length of the second dimension.
    length3 : int - The length of the third dimension.
    length4 : int - The length of the fourth dimension.

Returns: 'T[,,,] The created array.

Creates an array where the entries are initially the "default" value.

length1 : int

The length of the first dimension.

length2 : int

The length of the second dimension.

length3 : int

The length of the third dimension.

length4 : int

The length of the fourth dimension.

Returns: 'T[,,,]

The created array.

Example

 let array : float[,,,] = Array4D.zeroCreate 2 3 3 5
After evaluation array is a 2x3x3x5 array with contents all zero.