Array3d#
-
template<const int ndims, typename T = real>
class Array3d# Class for creating a 3-dimensional array with (optionally) non-zero lower bounds.
- Template Parameters:
ndims – The number of pseudo-dimensions. Can be 0, 1, 2 or 3. If the ndims less than 3, the created array can still be accessed with 3 indices, but the second and/or third indices are ignored.
T – The array datatype.
Public Functions
-
Array3d() = default#
Default constructor.
This generates a zero-sized array.
-
inline Array3d(int i0, int i1, int j0, int j1, int k0 = 0, int k1 = 0)#
Standard constructor.
This creates an array using the lower and upper bounds for each dimension. If ndims is less than 3 then the corresponding dimensions are given an upper and lower bound of zero, resulting in a size of 1.
Example:
Array3d<1> array1d(1, 10, 1, 10, 1, 10); // array1d.sx == 10, array1d.sy == array1d.sz == 1 Array3d<2> array2d(1, 10, 1, 10, 1, 10); // array2d.sx == array2d.sy == 10, array2d.sz == 1
- Parameters:
i0, i1 – Lower and upper bounds of the 1st dimension
j0, j1 – Lower and upper bounds of the 2nd dimension
k0, k1 – Lower and upper bounds of the 3rd dimension
-
inline Array3d(int i1, int j1, int k1)#
Basic constructor.
This creates arrays with lower bounds all set to 1. If ndims is less than 3 then the corresponding dimensions are given an upper and lower bound of zero, resulting in a size of 1.
- Parameters:
i1 – Upper bound of the 1st dimension
j1 – Upper bound of the 2nd dimension
k1 – Upper bound of the 3rd dimension
-
inline Array3d(int i0, int i1, int j0, int j1, int k0, int k1, void *data_)#
Standard constructor with memory reference.
This constructor can be used when the memory has already allocated elsewhere. It takes the same arguments as the standard constructor with the addition of a pointer to the memory to use. Allocation and deallocation of this memory is the responsibility of the caller.
Example:
constexpr int nx = 10, ny = 20, nz = 30; std::array<double, nx * ny * nz> mem; auto myarray = Array3d<3>(1, nx, 1, ny, 1, nz, mem.data());
- Parameters:
i0, i1 – Lower and upper bounds of the 1st dimension
j0, j1 – Lower and upper bounds of the 2nd dimension
k0, k1 – Lower and upper bounds of the 3rd dimension
data_ – Pointer to existing array storage to use
-
auto *get_data() const#
Get a pointer to the memory used for the 3d array.