See more details about the Array in the API

#
Multi-dimensional arrays

## Creating an Array

A three-dimensional Array with the data type DataType can be created using

Array<DataType> array({SIZE_0, SIZE_1, SIZE_2});

The number of arguments in the list can be changed to get an Array of different dimensionality.

By default, the Array is uninitialized after creation, but this can be changed by passing a second argument. For example, an Array with type double can be initialized to zero as follows.

Array<double> array({SIZE_0, SIZE_1, SIZE_2}, 0);

## Getting the Array size and accessing its elements

The Array ranges and dimensionality can be retrieved using

const vector<unsigned int> &ranges = array.getRanges();

unsigned int dimension = ranges.size();

It is also possible to access or assign values to individualt elements. Assuming the that the data type is double, we can use

double data = array[{x, y, z}];

array[{x, y, z}] = 1;

Here 0 <= x < ranges[0], 0 <= y < ranges[1], and 0 <= z < ranges[2].

## Array operations

If the DataType supports it, the following operations are possible.

**Addition**

Array<DataType> sum = array0 + array1;

**Subtraction**

Array<DataType> difference = array0 - array1;

**Multiplication**

Array<DataType> product = multiplier*array;

Here *multiplier* has the data type DataType.

**Division**

Array<DataType> quotient = array/divisor;

Here *divisor* has the the data type DataType.

## Slicing the Array

A lower-dimensional subset of an Array can be extracted using

Array<DataType> array2D = array.getSlice({x, _a_, _a_});

This extracts the subset of *array* for which the first entry is 'x'. The result is a two-dimensional Array from which we can access elements using

DataType element = array2D[{y, z}];

Next: Plotting