I'm programming an evolutive algorithm which, I'm having trouble trying to access the data I store in a dynamic matrix like this:
//tam_pob = size of population, is a constant value //n is a parameter received from user
float (* x)[tam_pob] = new (nothrow) float [n][tam_pob];
float(* factor)[tam_pob] = new (nothrow) float [n][tam_pob];
if(x== 0 || factor == 0)
cout<<"ERROR...";
else{
srand( time( NULL ) );
for(int j=0;j<tam_pob;j++) // individuos
for(int i=0;i<tam;i++){ //cromosomas
//filling the matrix
x[i][j]=(double) pow(-1.0,(rand()%4))*rand()+rand()/100000.0;
factor[i][j]=(double) pow(-1.0,(rand()%4))*rand()+rand()/100000.0;
}
but when I try to print the values, the program print something very different that is supposed to be stored in the matrix. Also it crashes when the value of the size of population is bigger than 250 aprox., I'm supposed to do it with even bigger size of population like 1k,10k and 100k. any ideas?