Hypotenuse calculus without overflow/underflow.

@param a First value.
@param b Second value.
@return The hypotenuse Sqrt(a^2 + b^2).
330620
public static double Hypotenuse(double a, double b) {
        double r = 0.0;
        double absA = Math.abs(a);
        double absB = Math.abs(b);

        if (absA > absB) {
            r = b / a;
            r = absA * Math.sqrt(1 + r * r);
        } else if (b != 0) {
            r = a / b;
            r = absB * Math.sqrt(1 + r * r);
        }

        return r;
    }
1195496
public void value2x2( double a11 , double a12, double a21 , double a22 )
    {
        // apply a rotators such that th a11 and a22 elements are the same
        double c,s;

        if( a12 + a21 == 0 ) { // is this pointless since
            c = s = 1.0 / Math.sqrt(2);
        } else {
            double aa = (a11-a22);
            double bb = (a12+a21);

            double t_hat = aa/bb;
            double t = t_hat/(1.0 + Math.sqrt(1.0+t_hat*t_hat));

            c = 1.0/ Math.sqrt(1.0+t*t);
            s = c*t;
        }

        double c2 = c*c;
        double s2 = s*s;
        double cs = c*s;

        double b11 = c2*a11 + s2*a22 - cs*(a12+a21);
        double b12 = c2*a12 - s2*a21 + cs*(a11-a22);
        double b21 = c2*a21 - s2*a12 + cs*(a11-a22);
//        double b22 = c2*a22 + s2*a11 + cs*(a12+a21);

        // apply second rotator to make A upper triangular if real eigenvalues
        if( b21*b12 >= 0 ) {
            if( b12 == 0 ) {
                c = 0;
                s = 1;
            } else {
                s = Math.sqrt(b21/(b12+b21));
                c = Math.sqrt(b12/(b12+b21));
            }

//            c2 = b12;//c*c;
//            s2 = b21;//s*s;
            cs = c*s;

            a11 = b11 - cs*(b12 + b21);
//            a12 = c2*b12 - s2*b21;
//            a21 = c2*b21 - s2*b12;
            a22 = b11 + cs*(b12 + b21);

            value0.real = a11;
            value1.real = a22;

            value0.imaginary = value1.imaginary = 0;

        } else {
            value0.real = value1.real = b11;
            value0.imaginary = Math.sqrt(-b21*b12);
            value1.imaginary = -value0.imaginary;
        }
    }
151659
protected static double change( EllipseRotated_F64 a , EllipseRotated_F64 b ) {
		double total = 0;

		total += Math.abs(a.center.x - b.center.x);
		total += Math.abs(a.center.y - b.center.y);
		total += Math.abs(a.a - b.a);
		total += Math.abs(a.b - b.b);

		// only care about the change of angle when it is not a circle
		double weight = Math.min(4,2.0*(a.a/a.b-1.0));
		total += weight*UtilAngle.distHalf(a.phi , b.phi);

		return total;
	}
1015846
@Override
    public double compute(double a, double b) {
        if (Op.isGt(a + b, 1.0)) {
            return Op.min(a, b);
        }
        return 0.0;
    }
611379
public static double distanceSquared(double[] pointA, double[] pointB,
			int offsetB) {
		assert (pointA.length == pointB.length + offsetB);
		double distance = 0.0;
		for (int i = 0; i < pointA.length; i++) {
			double d = pointA[i] - pointB[i + offsetB];
			distance += d * d;
		}
		return distance;
	}
525006
public float sDecept(float y, float A, float B, float C) {
    float tmp, tmp1, tmp2;

    tmp1 = (float) Math.floor(y - A + B) * ((float) 1.0 - C + (A - B) / B) / (A - B);
    tmp2 =
      (float) Math.floor(A + B - y) * ((float) 1.0 - C + ((float) 1.0 - A - B) / B) / ((float) 1.0
        - A - B);

    tmp = Math.abs(y - A) - B;

    return correctTo01((float) 1 + tmp * (tmp1 + tmp2 + (float) 1.0 / B));
  }
1088968
private static double js_hypot(Object[] args)
    {
        if (args == null) {
            return 0.0;
        }
        double y = 0.0;

        for (Object o : args) {
            double d = ScriptRuntime.toNumber(o);
            if (d == ScriptRuntime.NaN) {
                return d;
            }
            if ((d == Double.POSITIVE_INFINITY) || (d == Double.NEGATIVE_INFINITY)) {
                return Double.POSITIVE_INFINITY;
            }
            y += d * d;
        }
        return Math.sqrt(y);
    }
1201372
private static double cross(Coordinate a1, Coordinate a2, Coordinate b1, Coordinate b2) {
		return (a2.getX() - a1.getX()) * (b2.getY() - b1.getY()) - (a2.getY() - a1.getY()) * (b2.getX() - b1.getX());
	}
1343871
function hypot( a, b ) {
	var tmp;
	var r;
	if ( isInfinite( a ) || isInfinite( b ) ) {
		return Number.POSITIVE_INFINITY;
	}
	if ( isnan( a ) || isnan( b ) ) {
		return NaN;
	}
	if ( a === 0 && b === 0 ) {
		return 0;
	}
	a = abs( a );
	b = abs( b );
	if ( a > b ) {
		tmp = a;
		a = b;
		b = tmp;
	}
	r = a / b;
	return b * sqrt( 1 + r*r );
}
958271
public DoublePoint Subtract(DoublePoint point1, DoublePoint point2) {
        DoublePoint result = new DoublePoint(point1);
        result.Subtract(point2);
        return result;
    }
563134
@Pure
	@Inline(value="($1 ^ $2)", constantExpression=true)
	public static int bitwiseXor(int a, int b) {
		return a ^ b;
	}
1248956
public void symm2x2_fast( double a11 , double a12, double a22 )
    {
//        double p = (a11 - a22)*0.5;
//        double r = Math.sqrt(p*p + a12*a12);
//
//        value0.real = a22 + a12*a12/(r-p);
//        value1.real = a22 - a12*a12/(r+p);
//    }
//
//    public void symm2x2_std( double a11 , double a12, double a22 )
//    {
        double left  = (a11+a22)*0.5;
        double b     = (a11-a22)*0.5;
        double right = Math.sqrt(b*b+a12*a12);
        value0.real = left + right;
        value1.real = left - right;
    }
1178908
public static BigFloat sqrt(BigFloat x) {
		if (x.isNaN() || x.isNegative())
			return NaN;
		if (x.isZero() || x.isInfinity())
			return x;
		return x.context.valueOf(BigDecimalMath.sqrt(x.value, x.context.mathContext));
	}
931516
public static int safeSubtract(int a, int b) {
        int result = a - b;
        // check for a change of sign in the result when the inputs have the different signs
        if ((a ^ result) < 0 && (a ^ b) < 0) {
            throw new ArithmeticException("Subtraction overflows an int: " + a + " - " + b);
        }
        return result;
    }
396630
function ( vectorA, vectorB, vectorC ) {

		var s, a, b, c,
			tmp = THREE.GeometryUtils.__v1;

		tmp.sub( vectorA, vectorB );
		a = tmp.length();

		tmp.sub( vectorA, vectorC );
		b = tmp.length();

		tmp.sub( vectorB, vectorC );
		c = tmp.length();

		s = 0.5 * ( a + b + c );

		return Math.sqrt( s * ( s - a ) * ( s - b ) * ( s - c ) );

	}
1350783
function hypot( a, b ) {
		if ( !isNumeric( a ) || !isNumeric( b ) ) {
			throw new TypeError( 'hypot()::invalid input argument. Input arguments must be numeric.' );
		}
		var min, max, r;
		a = Math.abs( a );
		b = Math.abs( b );
		if ( a > b ) {
			min = b;
			max = a;
		} else  {
			min = a;
			max = b;
		}
		r = min / max;
		return max * Math.sqrt( 1 + r*r );
	}
309565
@Override
    public double compute(double a, double b) {
        if (Op.isEq(Op.min(a, b), 0.0)) {
            return Op.max(a, b);
        }
        return 1.0;
    }