plus arrays
-
dear friend what problem is following calculation? thanks here gbest is a 3x4 array for (int i =0;i<10;i++) { for (int j = 0;j<3;j++) { for (int k = 0;k<4;k++) v[i][j][k] = w*v[i][j][k] + c1*rand()(pbestArray[i][j][k]-x[i][j][k]) + c2*rand()(gbest-x[i][j][k]); x[i][j][k] = x[i][j][k] + v[i][j][k]; } } computer showed me: error C2064: term does not evaluate to a function taking 1 arguments error C2112: '-' : pointer subtraction requires integral or pointer operand
Li Zhiyuan 5/10/2006
-
dear friend what problem is following calculation? thanks here gbest is a 3x4 array for (int i =0;i<10;i++) { for (int j = 0;j<3;j++) { for (int k = 0;k<4;k++) v[i][j][k] = w*v[i][j][k] + c1*rand()(pbestArray[i][j][k]-x[i][j][k]) + c2*rand()(gbest-x[i][j][k]); x[i][j][k] = x[i][j][k] + v[i][j][k]; } } computer showed me: error C2064: term does not evaluate to a function taking 1 arguments error C2112: '-' : pointer subtraction requires integral or pointer operand
Li Zhiyuan 5/10/2006
if gbest is an array, shouldn't it have the dimensions at its side? v[i][j][k] = w*v[i][j][k] + c1*rand()(pbestArray[i][j][k]-x[i][j][k]) + c2*rand()(gbest-x[i][j][k]); shouldn't it be: v[i][j][k] = w*v[i][j][k] + c1*rand()*(pbestArray[i][j][k]-x[i][j][k]) + c2*rand()*(gbest[i][j][k]-x[i][j][k]); Hope this helps...
-
dear friend what problem is following calculation? thanks here gbest is a 3x4 array for (int i =0;i<10;i++) { for (int j = 0;j<3;j++) { for (int k = 0;k<4;k++) v[i][j][k] = w*v[i][j][k] + c1*rand()(pbestArray[i][j][k]-x[i][j][k]) + c2*rand()(gbest-x[i][j][k]); x[i][j][k] = x[i][j][k] + v[i][j][k]; } } computer showed me: error C2064: term does not evaluate to a function taking 1 arguments error C2112: '-' : pointer subtraction requires integral or pointer operand
Li Zhiyuan 5/10/2006
I guess pbestArray is a pointer to the array, so I think
pbestArray[i][j][k]-x[i][j][k]
should be(*pbestArray)[i][j][k]-x[i][j][k]
And , as Joan Murt said, you should add "*" between rand() and ...(something after it). May you good luck============ Einstein Seeing is believing.