Search in sources :

Example 1 with IComplexDouble

use of org.nd4j.linalg.api.complex.IComplexDouble in project nd4j by deeplearning4j.

the class ComplexNumberTests method testLogarithmFloat.

@Test
public void testLogarithmFloat() {
    IComplexDouble test = Nd4j.createDouble(1, 1);
    IComplexDouble test2 = Nd4j.createDouble(1, 1);
    IComplexNumber result = test.pow(test2);
    assertEquals(result.realComponent(), 0.3465736);
    assertEquals(result.imaginaryComponent(), 0.7853982);
}
Also used : IComplexNumber(org.nd4j.linalg.api.complex.IComplexNumber) IComplexDouble(org.nd4j.linalg.api.complex.IComplexDouble) Test(org.junit.Test) BaseNd4jTest(org.nd4j.linalg.BaseNd4jTest)

Example 2 with IComplexDouble

use of org.nd4j.linalg.api.complex.IComplexDouble in project nd4j by deeplearning4j.

the class ComplexNumberTests method testScalar.

@Test
public void testScalar() {
    IComplexDouble test = Nd4j.createDouble(1, 1);
    test.addi(1);
    assertEquals(2, test.realComponent().doubleValue(), 1e-1);
    assertEquals(1, test.imaginaryComponent(), 1e-1);
    test.subi(1);
    assertEquals(1, test.realComponent().doubleValue(), 1e-1);
    assertEquals(getFailureMessage(), 1, test.imaginaryComponent(), 1e-1);
    test.muli(2);
    assertEquals(2, test.realComponent().doubleValue(), 1e-1);
    assertEquals(2, test.imaginaryComponent(), 1e-1);
    test.divi(2);
    assertEquals(1, test.realComponent().doubleValue(), 1e-1);
    assertEquals(1, test.imaginaryComponent(), 1e-1);
    test.addi(Nd4j.createDouble(1, 1));
    assertEquals(2, test.realComponent().doubleValue(), 1e-1);
    assertEquals(2, test.imaginaryComponent(), 1e-1);
    test.rdivi(1);
    assertEquals(0.5d, test.realComponent().doubleValue(), 1e-1);
    assertEquals(2.0d, test.imaginaryComponent(), 1e-1);
}
Also used : IComplexDouble(org.nd4j.linalg.api.complex.IComplexDouble) Test(org.junit.Test) BaseNd4jTest(org.nd4j.linalg.BaseNd4jTest)

Example 3 with IComplexDouble

use of org.nd4j.linalg.api.complex.IComplexDouble in project nd4j by deeplearning4j.

the class ComplexNumberTests method testExponentDouble.

@Test
public void testExponentDouble() {
    IComplexDouble test = Nd4j.createDouble(1, 1);
    assertEquals(test.realComponent(), 1.4686939399158851, 1e-3);
    assertEquals(test.imaginaryComponent(), 2.2873552871788423, 1e-3);
}
Also used : IComplexDouble(org.nd4j.linalg.api.complex.IComplexDouble) Test(org.junit.Test) BaseNd4jTest(org.nd4j.linalg.BaseNd4jTest)

Example 4 with IComplexDouble

use of org.nd4j.linalg.api.complex.IComplexDouble in project nd4j by deeplearning4j.

the class ComplexNumberTests method testLogarithmDouble.

@Test
public void testLogarithmDouble() {
    IComplexDouble test = Nd4j.createDouble(1, 1);
    IComplexDouble test2 = Nd4j.createDouble(1, 1);
    IComplexNumber result = test.pow(test2);
    assertEquals(result.realComponent(), 0.3465735902799727);
    assertEquals(result.imaginaryComponent(), 0.7853981633974483);
}
Also used : IComplexNumber(org.nd4j.linalg.api.complex.IComplexNumber) IComplexDouble(org.nd4j.linalg.api.complex.IComplexDouble) Test(org.junit.Test) BaseNd4jTest(org.nd4j.linalg.BaseNd4jTest)

Example 5 with IComplexDouble

use of org.nd4j.linalg.api.complex.IComplexDouble in project nd4j by deeplearning4j.

the class ComplexNumberTests method testPowerFloat.

@Test
public void testPowerFloat() {
    IComplexDouble test = Nd4j.createDouble(1, 1);
    IComplexDouble test2 = Nd4j.createDouble(1, 1);
    IComplexNumber result = test.pow(test2);
    assertEquals(result.realComponent(), 0.2739572);
    assertEquals(result.imaginaryComponent(), 0.583700);
}
Also used : IComplexNumber(org.nd4j.linalg.api.complex.IComplexNumber) IComplexDouble(org.nd4j.linalg.api.complex.IComplexDouble) Test(org.junit.Test) BaseNd4jTest(org.nd4j.linalg.BaseNd4jTest)

Aggregations

Test (org.junit.Test)6 BaseNd4jTest (org.nd4j.linalg.BaseNd4jTest)6 IComplexDouble (org.nd4j.linalg.api.complex.IComplexDouble)6 IComplexNumber (org.nd4j.linalg.api.complex.IComplexNumber)4