(edited to correct a mistake and specify code is written for C++)
I am making a large array, P_arr
of size
int N = 30;
float P_arr[27000][4];
with elements given by
float ua_min = 0.0001, ua_max = 0.0075, us_min = 2, us_max = 100, g_min = 0.1, g_max = 0.8;
float ua_start = ua_min + ua_min;
float ua_end = ua_max - ua_max;
float us_start = us_min + us_min;
float us_end = us_max - us_max;
float g_start = g_min + g_min;
float g_end = g_max - g_max;
float ua_stepSize = (ua_end - ua_start) / (N - 1);
float us_stepSize = (us_end - us_start) / (N - 1);
float g_stepSize = (g_end - g_start) / (N - 1);
float ua_arr[3];
float us_arr[3];
float g_arr[3];
ua_arr[0] = ua_start;
us_arr[0] = us_start;
g_arr[0] = g_start;
for (int j = 1; j < N; j++)
{
ua_arr[j] = ua_arr[j - 1] + ua_stepSize;
us_arr[j] = us_arr[j - 1] + us_stepSize;
g_arr[j] = g_arr[j - 1] + g_stepSize;
}
int i = 0;
for (int u = 0; u < N; u++)
{
for (int w = 0; w < N; w++)
{
for (int v = 0; v < N; v++)
{
P_arr[i][2] = g_arr[v];
P_arr[i][1] = us_arr[w];
P_arr[i][0] = ua_arr[u];
i++;
}
}
}
such that the number of rows is always N ^ 3.
Once I increase N > ~ 30, and I increase the size of P_arr
accordingly, the code fails to write the P_arr
and "exits with code: -1073741571."
Is there a length limit to the array I construct? How can I get around this to define larger arrays, say with N = 100?
update
float(*P_arr)[4] = new float[42875][4];
seems to increase the limit of N -> ~ 35 and row limit to N^3 = 42875. Is my dynamic allocation incorrect as it is imposing this limit?