testComplexFunctions method Null safety

Future<void> testComplexFunctions()

Implementation

Future<void> testComplexFunctions() async {
  await test('15c complex mode functions', () async {
    final m = newModel();
    m.isComplexMode = true;

    await _testOneArgComplex(m, Operations15.lnOp,
        const Complex(1.234, 5.678), const Complex(1.759674471, 1.356794138));
    await _testOneArgComplex(
        m,
        Operations15.eX15,
        const Complex(1.759674471, 1.356794138),
        const Complex(1.234000001, 5.678));
    await _testOneArgComplex(
        m,
        Operations15.lnOp,
        const Complex(1.234, -5.678),
        const Complex(1.759674471, -1.356794138));
    await _testOneArgComplex(
        m,
        Operations15.eX15,
        const Complex(1.759674471, -1.356794138),
        const Complex(1.234000001, -5.678));
    await _testOneArgComplex(
        m,
        Operations15.lnOp,
        const Complex(-1.234, 5.678),
        const Complex(1.759674471, 1.784798515));
    await _testOneArgComplex(
        m,
        Operations15.eX15,
        const Complex(1.759674471, 1.784798515),
        const Complex(-1.233999998, 5.678000001));
    await _testOneArgComplex(
        m,
        Operations15.lnOp,
        const Complex(-1.234, -5.678),
        const Complex(1.759674471, -1.784798515));
    await _testOneArgComplex(
        m,
        Operations15.eX15,
        const Complex(1.759674471, -1.784798515),
        const Complex(-1.233999998, -5.678000001));

    await _testOneArgComplex(m, Operations15.sqrtOp15,
        const Complex(1.234, 5.678), const Complex(1.876771907, 1.512703802));
    await _testOneArgComplex(
        m,
        Operations15.xSquared,
        const Complex(1.876771907, 1.512703802),
        const Complex(1.233999998, 5.677999998));
    await _testOneArgComplex(
        m,
        Operations15.sqrtOp15,
        const Complex(1.234, -5.678),
        const Complex(1.876771907, -1.512703802));
    await _testOneArgComplex(
        m,
        Operations15.xSquared,
        const Complex(1.876771907, -1.512703802),
        const Complex(1.233999998, -5.677999998));
    await _testOneArgComplex(
        m,
        Operations15.sqrtOp15,
        const Complex(-1.234, 5.678),
        const Complex(1.512703802, 1.876771907));
    await _testOneArgComplex(
        m,
        Operations15.xSquared,
        const Complex(1.512703802, 1.876771907),
        const Complex(-1.233999998, 5.677999998));
    await _testOneArgComplex(
        m,
        Operations15.sqrtOp15,
        const Complex(-1.234, -5.678),
        const Complex(1.512703802, -1.876771907));
    await _testOneArgComplex(
        m,
        Operations15.xSquared,
        const Complex(1.512703802, -1.876771907),
        const Complex(-1.233999998, -5.677999998));

    await _testOneArgComplex(
        m,
        Operations15.tenX15,
        const Complex(-1.234, -5.678),
        const Complex(0.05098501197, -0.02836565620));
    // Note:  The above produces Complex(0.05098501197, -0.02836565619)
    //        on a real 15C.  Our answer is more accurate:  The answer is
    //        (5.09850119703065e-2, -2.83656561954365e-2) to 15 radix
    //        digits.  See misc/test_float/TestFloat.java.
    await _testOneArgComplex(
        m,
        Operations15.logOp,
        const Complex(0.05098501197, -0.02836565620),
        const Complex(-1.234, -0.2204945847));

    await _testTwoArgComplex(
        m,
        Operations15.yX15,
        const Complex(5.6, 7.8),
        const Complex(1.2, 3.4),
        const Complex(-0.03277613870, -0.08229096286));

    await _testOneArgComplex(
        m,
        Operations15.reciprocal15,
        const Complex(0.15, 0.25),
        const Complex(1.764705882, -2.941176471),
        Operations15.reciprocal15);

    m.isComplexMode = false;
    m.xF = 12.34;
    Operations15.reImSwap.floatCalc!(m);
    await expect(m.xF, 0);
    await expect(m.xImaginary.asDouble, 12.34);
    await expect(m.xC, const Complex(0, 12.34));
    m.xC = Complex(56.78, m.xImaginary.asDouble);
    Operations15.reImSwap.complexCalc!(m);
    await expect(m.xF, 12.34);
    await expect(m.xImaginary.asDouble, 56.78);
    await expect(m.xC, const Complex(12.34, 56.78));

    await expect(m.isComplexMode, true);
  });
}