Java Code Examples for org.apache.commons.math3.complex.Complex#isInfinite()

The following examples show how to use org.apache.commons.math3.complex.Complex#isInfinite() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BandPassTransform.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
private static ComplexPair transform(final Complex in, final double a, final double b) {
    if (in.isInfinite()) {
        return new ComplexPair(new Complex(-1), new Complex(1));
    }

    final Complex c = new Complex(1).add(in).divide(new Complex(1).subtract(in)); // bilinear

    final double a2 = a * a;
    final double b2 = b * b;
    final double ab = a * b;
    final double ab2 = 2 * ab;
    Complex v = new Complex(0).add(c.multiply(4 * (b2 * (a2 - 1) + 1)));
    v = v.add(8 * (b2 * (a2 - 1) - 1));
    v = v.multiply(c);
    v = v.add(4 * (b2 * (a2 - 1) + 1));
    v = v.sqrt();

    final Complex u = v.multiply(-1).add(c.multiply(ab2)).add(ab2);

    v = v.add(c.multiply(ab2)).add(ab2);

    final Complex d = new Complex(0).add(c.multiply(2 * (b - 1))).add(2 * (1 + b));

    return new ComplexPair(u.divide(d), v.divide(d));
}
 
Example 2
Source File: BandPassTransform.java    From iirj with Apache License 2.0 6 votes vote down vote up
private ComplexPair transform(Complex c) {
	if (c.isInfinite()) {
		return new ComplexPair(new Complex(-1), new Complex(1));
	}

	c = ((new Complex(1)).add(c)).divide((new Complex(1)).subtract(c)); // bilinear

	Complex v = new Complex(0);
	v = MathSupplement.addmul(v, 4 * (b2 * (a2 - 1) + 1), c);
	v = v.add(8 * (b2 * (a2 - 1) - 1));
	v = v.multiply(c);
	v = v.add(4 * (b2 * (a2 - 1) + 1));
	v = v.sqrt();

	Complex u = v.multiply(-1);
	u = MathSupplement.addmul(u, ab_2, c);
	u = u.add(ab_2);

	v = MathSupplement.addmul(v, ab_2, c);
	v = v.add(ab_2);

	Complex d = new Complex(0);
	d = MathSupplement.addmul(d, 2 * (b - 1), c).add(2 * (1 + b));

	return new ComplexPair(u.divide(d), v.divide(d));
}
 
Example 3
Source File: HighPassTransform.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
private static Complex transform(final Complex in, final double f) {
    if (in.isInfinite()) {
        return new Complex(1, 0);
    }
    Complex c;
    // frequency transform
    c = in.multiply(f);

    // bilinear high pass transform
    return new Complex(-1).multiply(new Complex(1).add(c)).divide(new Complex(1).subtract(c));
}
 
Example 4
Source File: LowPassTransform.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
private static Complex transform(final Complex in, final double f) {
    if (in.isInfinite()) {
        return new Complex(-1, 0);
    }
    Complex c;
    // frequency transform
    c = in.multiply(f);

    final Complex one = new Complex(1, 0);

    // bilinear low pass transform
    return one.add(c).divide(one.subtract(c));
}
 
Example 5
Source File: HighPassTransform.java    From iirj with Apache License 2.0 5 votes vote down vote up
private Complex transform(Complex c) {
	if (c.isInfinite())
		return new Complex(1, 0);

	// frequency transform
	c = c.multiply(f);

	// bilinear high pass transform
	return new Complex(-1).multiply((new Complex(1)).add(c)).divide(
			(new Complex(1)).subtract(c));
}
 
Example 6
Source File: LowPassTransform.java    From iirj with Apache License 2.0 5 votes vote down vote up
private Complex transform(Complex c) {
	if (c.isInfinite())
		return new Complex(-1, 0);

	// frequency transform
	c = c.multiply(f);

	Complex one = new Complex(1, 0);

	// bilinear low pass transform
	return (one.add(c)).divide(one.subtract(c));
}