I am running into a problem when adding two doubles together, the variable startImpatience is a vector of double and the value of each element is initialized to 1.0 in the constructor of the class.
As soon as the line startImpatience[id] += ((1.0 - dif) * dt) is reached the value of the element gets value -nan(ind).
Here is the code snippet:
double pref_magnitude = sqrt((cPreferredVelocity[id].x * cPreferredVelocity[id].x) + (cPreferredVelocity[id].y * cPreferredVelocity[id].y));
double magnitude = sqrt((cVelocity[id].x * cVelocity[id].x) + (cVelocity[id].y * cVelocity[id].y));
double dif = pref_magnitude - magnitude / pref_magnitude;
startImpatience[id] *= (1.0 - dt);
// startImpatience[id] has a value
startImpatience[id] += ((1.0 - dif) * dt);
// startImpatience[id] is -nan(ind)
Every variable of which you don't see initialization, yes they are all of type double or vector of double.
I cannot see what is wrong with the code, any help is greatly appreciated!