monarch_dodra:

If all (but last of) the dimensions are known at compile time, then you can dynamically allocate an array of fixed sized arrays:

//----
enum size_t gridSize = 4_000;
enum size_t total   = gridSize * gridSize;
static assert (total == 16_000_000); //16 million doubles total
static assert (total * double.sizeof == 128_000_000); //126 Megs allocated

void main()
{
double[gridSize][] gridInfo = new double[gridSize][](gridSize);
}
//----

This will give you a dense array: Eg: all the data is contiguous in memory.

Nice. This idiom should be added to the D docs.

Bye,
bearophile

Reply via email to