Hi,
I am trying to do a time evolution of a pressure wave in 2 dimensions for a computational physics class. Well, I have to define a 2d array for all the grid points I believe. Well, the best way I can think of to do this is by definining
double * grid;
outside any method with all my other variables and then
grid = new double[sizeX][sizeY];
in my init function where I initilize all my arrays and glut and whatnot.
Unfortunately, xcode is throwing me the following error for that declaration:
"error: cannot convert 'double (*)[128]' to 'double*' in assignment.
Later in the code with the code
1 2
|
grid[x][y] = exp(-1 * ( pow((x-xcenter),2)/(2*sigmaXY*sigmaXY) + pow((y-ycenter),2)/(2*sigmaXY*sigmaXY)));
P = grid[x][y];
| |
I get the errors "error: invalid types 'double[int[' for arrays subscript' for both. I found hat if I use the declaration double ** grid; it gets rid of those two errors but not the first one.
I'm sure its just an error that I haven't picked up but any help would be very much appreciated.
Further info: I am on an intel mac using xcode and the intel c++ compiler version 11.0.