I set x is array contains several variables with are inputs of a evaluation function. Each
variable has limit defined in xBoundary[index][min,max]
. Each possible variable value has step size xStep[]
.
e.g. x[0]
is between 0
and 10
since xBoundary[0][0]=0
and xBoundary[0][1]=10
. xStep[0]=0.5
then x has possible value 0,0.5,1,1.5,.....9.5,10
.
How can I access all possible value of x? I think this is a n dimensional array where n = length of x
.
The following is my code. It is infinite loop.
#include <stdio.h>
#define nx_SIZE 2 // dimension of x
double x[nx_SIZE] = {0}; // Initialize x
double xBoundary[nx_SIZE][2]={{0,5},{2,5}}; //Contains lower and upper boundary of x.
//xBoundary[][0]=min
//xBoundary[][1]=max
double xStep[nx_SIZE]={1}; //Step size for variable in x.
void iterate(int dimension) {
int i = dimension - 1;
double currentX, upperLimit;
if (i == -1){
printf("x: %f %f \n", x[0], x[1]);
//evaluate();
} else {
currentX = xBoundary[i][0];
upperLimit = xBoundary[i][1];
while (currentX < upperLimit){
x[i] = currentX;
iterate(i);
currentX = currentX + xStep[i];
} //End of while
}
}
int main (){
iterate(nx_SIZE);
return 1;
}
xBoundary
asxBoundary[nx_SIZE][2]={{0,5},{2,5}};
3. There is a variabledemantion
undeclared in your function – brokenfoot Mar 20 at 6:46