code: public static float cuCabs (cuComplex x)
      {
          float p = cuCreal(x);
          float q = cuCimag(x);
          float r;
          if (p == 0) return q;
          if (q == 0) return p;
          p = (float)Math.sqrt(p);
          q = (float)Math.sqrt(q);
          if (p < q) {r = p; p = q; q = r;}
          r = q / p;
          return p * (float)Math.sqrt (1.0f + r * r);
      }
docs: Returns the absolute value of the given complex number.<br />
  <br />
  Original comment:<br />
  <br />
  This implementation guards against intermediate underflow and overflow
  by scaling. Otherwise the we'd lose half the exponent range. There are
  various ways of doing guarded computation. For now chose the simplest
  and fastest solution, however this may suffer from inaccuracies if sqrt
  and division are not IEEE compliant.
  
  @param x The complex number whose absolute value should be returned
  @return The absolute value of the given complex number