static double sin_squareWave(double phi) { double phase = frac_nonNeg(phi/(pi()*2)); ret phase < .5 ? 1 : -1; }