My program has a matrix of floating point values, after I performed calculations to each element in the matrix, when I print out using printf() some of the elements turned out to have the value "nan", what does nan mean?
My code is as follows:
Code:
float local_force[M][N];
/* compute the forces on each of the N particles on each processor */
for (i = 0; i < M; i++) {
for (j = 0; j < N; j++) {
if ( recv_xPos[i] == xPos[j] && recv_yPos[i] == yPos[j])
local_force[i][j] = 0; /* 0 represent infinite force in newton */
else
{
float xDis = absolute(recv_xPos[i] - xPos[j]);
float yDis = absolute(recv_yPos[i] - yPos[j]);
radius_square = pow(xDis, 2) + pow(yDis, 2);
local_force[i][j] = (recv_charge[i] * charge[j]) / radius_square;
}
}
}
Please use [code][/code]Tags