calculateTheta1 function
Calculate the argument (phase) in radians in the interval (-π, π].
Implementation
double calculateTheta1(double re, double im) {
// Zero case management, even if math.atan2(0, 0) is 0.0
if (re == 0 && im == 0) {
//print("Theta is indeterminate");
// NaN or 0.0 is acceptable for the complex number zero.
//We keep 0.0 as the default for compatibility with module 0 calculation.
return 0.0;
}
return math.atan2(im, re);
}