@Test public void testMmul() { IComplexNDArray n = Nd4j.createComplex(Nd4j.linspace(1, 10, 10)); IComplexNDArray transposed = n.transpose(); assertEquals(true, n.isRowVector()); assertEquals(true, transposed.isColumnVector()); INDArray innerProduct = n.mmul(transposed); INDArray scalar = Nd4j.scalar(Nd4j.createComplexNumber(385, 0)); assertEquals(getFailureMessage(), scalar, innerProduct); INDArray outerProduct = transposed.mmul(n); assertEquals(true, Shape.shapeEquals(new int[] {10, 10}, outerProduct.shape())); IComplexNDArray d3 = Nd4j.createComplex(ComplexUtil.complexNumbersFor(new double[] {1, 2})).reshape(2, 1); IComplexNDArray d4 = Nd4j.createComplex(ComplexUtil.complexNumbersFor(new double[] {3, 4})); INDArray resultNDArray = d3.mmul(d4); INDArray result = Nd4j.createComplex( new IComplexNumber[][] { {Nd4j.createComplexNumber(3, 0), Nd4j.createComplexNumber(4, 0)}, {Nd4j.createComplexNumber(6, 0), Nd4j.createComplexNumber(8, 0)} }); assertEquals(getFailureMessage(), result, resultNDArray); }
@Test public void testMmulOffset() { IComplexNDArray arr = Nd4j.complexLinSpace(1, 4, 4).reshape(2, 2); IComplexNDArray row1 = arr.getRow(1); IComplexNDArray arrT = row1.transpose(); assertEquals(row1, arrT); }
@Test public void testTranspose() { IComplexNDArray ndArray = Nd4j.createComplex( new double[] { 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0, 5.0, 0.0, 6.0, 0.0, 6.999999999999999, 0.0, 8.0, 0.0, 9.0, 0.0, 10.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, new int[] {16, 1}); IComplexNDArray transposed2 = ndArray.transpose(); assertEquals(getFailureMessage(), 16, transposed2.columns()); }