Search in sources :

Example 1 with Quaternion

use of org.ojalgo.scalar.Quaternion in project ojAlgo-finance by optimatika.

the class TestUtils method assertEquals.

public static void assertEquals(final String message, final Number expected, final Number actual, final NumberContext context) {
    if ((expected instanceof ComplexNumber) || (actual instanceof ComplexNumber)) {
        final ComplexNumber tmpExpected = ComplexNumber.valueOf(expected);
        final ComplexNumber tmpActual = ComplexNumber.valueOf(actual);
        if (!!context.isDifferent(tmpExpected.getReal(), tmpActual.getReal())) {
            Assertions.fail(() -> message + " (real)" + ": " + expected + " != " + actual);
        }
        if (!!context.isDifferent(tmpExpected.getImaginary(), tmpActual.getImaginary())) {
            Assertions.fail(() -> message + " (imaginary)" + ": " + expected + " != " + actual);
        }
    } else if ((expected instanceof Quaternion) || (actual instanceof Quaternion)) {
        final Quaternion tmpExpected = Quaternion.valueOf(expected);
        final Quaternion tmpActual = Quaternion.valueOf(actual);
        if (!!context.isDifferent(tmpExpected.scalar(), tmpActual.scalar())) {
            Assertions.fail(() -> message + " (scalar)" + ": " + expected + " != " + actual);
        }
        if (!!context.isDifferent(tmpExpected.i, tmpActual.i)) {
            Assertions.fail(() -> message + " (i)" + ": " + expected + " != " + actual);
        }
        if (!!context.isDifferent(tmpExpected.j, tmpActual.j)) {
            Assertions.fail(() -> message + " (j)" + ": " + expected + " != " + actual);
        }
        if (!!context.isDifferent(tmpExpected.k, tmpActual.k)) {
            Assertions.fail(() -> message + " (k)" + ": " + expected + " != " + actual);
        }
    } else {
        if (context.isDifferent(expected.doubleValue(), actual.doubleValue())) {
            Assertions.fail(() -> message + ": " + expected + " != " + actual);
        }
    }
}
Also used : Quaternion(org.ojalgo.scalar.Quaternion) ComplexNumber(org.ojalgo.scalar.ComplexNumber)

Example 2 with Quaternion

use of org.ojalgo.scalar.Quaternion in project ojAlgo by optimatika.

the class TestUtils method assertEquals.

public static void assertEquals(final String message, final Number expected, final Number actual, final NumberContext context) {
    if ((expected instanceof ComplexNumber) || (actual instanceof ComplexNumber)) {
        final ComplexNumber tmpExpected = ComplexNumber.valueOf(expected);
        final ComplexNumber tmpActual = ComplexNumber.valueOf(actual);
        if (!!context.isDifferent(tmpExpected.getReal(), tmpActual.getReal())) {
            Assertions.fail(() -> message + " (real)" + ": " + expected + " != " + actual);
        }
        if (!!context.isDifferent(tmpExpected.getImaginary(), tmpActual.getImaginary())) {
            Assertions.fail(() -> message + " (imaginary)" + ": " + expected + " != " + actual);
        }
    } else if ((expected instanceof Quaternion) || (actual instanceof Quaternion)) {
        final Quaternion tmpExpected = Quaternion.valueOf(expected);
        final Quaternion tmpActual = Quaternion.valueOf(actual);
        if (!!context.isDifferent(tmpExpected.scalar(), tmpActual.scalar())) {
            Assertions.fail(() -> message + " (scalar)" + ": " + expected + " != " + actual);
        }
        if (!!context.isDifferent(tmpExpected.i, tmpActual.i)) {
            Assertions.fail(() -> message + " (i)" + ": " + expected + " != " + actual);
        }
        if (!!context.isDifferent(tmpExpected.j, tmpActual.j)) {
            Assertions.fail(() -> message + " (j)" + ": " + expected + " != " + actual);
        }
        if (!!context.isDifferent(tmpExpected.k, tmpActual.k)) {
            Assertions.fail(() -> message + " (k)" + ": " + expected + " != " + actual);
        }
    } else {
        if (context.isDifferent(expected.doubleValue(), actual.doubleValue())) {
            Assertions.fail(() -> message + ": " + expected + " != " + actual);
        }
    }
}
Also used : Quaternion(org.ojalgo.scalar.Quaternion) ComplexNumber(org.ojalgo.scalar.ComplexNumber)

Aggregations

ComplexNumber (org.ojalgo.scalar.ComplexNumber)2 Quaternion (org.ojalgo.scalar.Quaternion)2