@Test
  public void testElementWiseOps() {
    IComplexNDArray n1 = Nd4j.complexScalar(1);
    IComplexNDArray n2 = Nd4j.complexScalar(2);
    assertEquals(Nd4j.complexScalar(3), n1.add(n2));
    assertFalse(n1.add(n2).equals(n1));

    IComplexNDArray n3 = Nd4j.complexScalar(3);
    IComplexNDArray n4 = Nd4j.complexScalar(4);
    IComplexNDArray subbed = n4.sub(n3);
    IComplexNDArray mulled = n4.mul(n3);
    IComplexNDArray div = n4.div(n3);

    assertFalse(subbed.equals(n4));
    assertFalse(mulled.equals(n4));
    assertEquals(Nd4j.complexScalar(1), subbed);
    assertEquals(Nd4j.complexScalar(12), mulled);
    assertEquals(Nd4j.complexScalar(1.3333333333333333), div);

    IComplexNDArray multiDimensionElementWise =
        Nd4j.createComplex(Nd4j.create(Nd4j.linspace(1, 24, 24).data(), new int[] {4, 3, 2}));
    IComplexNumber sum2 = multiDimensionElementWise.sumComplex();
    assertEquals(sum2, Nd4j.createDouble(300, 0));
    IComplexNDArray added = multiDimensionElementWise.add(Nd4j.complexScalar(1));
    IComplexDouble sum3 = (IComplexDouble) added.sumComplex();
    assertEquals(sum3, Nd4j.createDouble(324, 0));
  }
  @Test
  public void testComplexCalculation() {
    IComplexNDArray arr =
        Nd4j.createComplex(
            new IComplexNumber[][] {
              {Nd4j.createComplexNumber(1, 1), Nd4j.createComplexNumber(2, 1)},
              {Nd4j.createComplexNumber(3, 2), Nd4j.createComplexNumber(4, 2)}
            });

    IComplexNumber scalar = arr.sumComplex();
    double sum = scalar.realComponent().doubleValue();
    assertEquals(10, sum, 1e-1);

    double sumImag = scalar.imaginaryComponent().doubleValue();
    assertEquals(6, sumImag, 1e-1);

    IComplexNDArray res = arr.add(Nd4j.createComplexNumber(1, 1));
    scalar = res.sumComplex();
    sum = scalar.realComponent().doubleValue();
    assertEquals(14, sum, 1e-1);
    sumImag = scalar.imaginaryComponent().doubleValue();
    assertEquals(10, sumImag, 1e-1);

    // original array should keep as it is
    sum = arr.sumComplex().realComponent().doubleValue();
    assertEquals(10, sum, 1e-1);
  }