Using memory constructs from the C++ Standard Template Library (STL) in a Chimera Compute Library (CCL) development context is generally not supported or recommended.
In some cases, std::array may work, but it is highly recommend that developers attempt to use CCL-defined constructs, such as NDArray, when possible.
NDArray Type
NDArray is an address-space agnostic, fixed-size, aggregate type designed for use in a CCL development context in an embedded environment without support for the C++ Standard Template Library (STL). It is intended to be used in place of std::array objects.
It also has experimental support for multi-dimensional representations and indexing, but usage of these features is not encourage at this time.
NDArray is not inherently a Processing Element (PE) or IMD construct. An NDArray wraps a C-style array of elements, which can be classified as either [PE] or [IMD] to specify the intended usage. Usage of elements within the array will follow same rules as other [PE] and [IMD] types.
Public Members
Raw linear array of items of type T and of size linearElementCount matching the volume of the N-dimension array, i.e. dimN * ... * dim1 * dim0.
Utility Methods
Element Getter & Setter Methods
The overload of the [] operator is designed to act like raw multidimensional C arrays in row-major order.
When the defined NDArrayis one-dimensional, i.e. sizeof...(dimensions) == 1, the [] operator returns a reference to the element at the index provided.
When the defined NDArrayis multidimensional, i.e. sizeof...(dimensions) > 1, the [] operator returns a reference to the element N * dimN-1 * ... * dim0cast as a type of NDArray<T, dimN-1, ..., dim0>.
Reshape Methods
All of these operations are only useful for multi-dimensional arrays and are considered experimental.
Returns a reference to the array, cast to a different shape with the same number of elements as the original array. TCast may also be provided as an explicit reinterpretation to another data type, in which the number of elements is proportional to the difference in element sizes. In other words, the resulting cast will represent the exact same memory size.
Data Type Casting Methods
Examples
/tests/sweep_tests/ndarray_reinterpret_cast/sweep_ndarray_reinterpret_cast.cpp container::NDArray<qVar_t<sweeps::InType>, dim1 * dim2 * dim3 * dim4> arr = readFlow.read();
// reshape input 1d NDArray to 4d NDArray.
auto reshaped = arr.reshapeCast<dim1, dim2, dim3, dim4>();
