Added ComplexField test for expressions.

This commit is contained in:
Alexander Nozik 2018-08-25 21:22:07 +03:00
parent 520765abb9
commit 6df416f064

View File

@ -1,5 +1,7 @@
package scientifik.kmath.expressions package scientifik.kmath.expressions
import scientifik.kmath.operations.Complex
import scientifik.kmath.operations.ComplexField
import scientifik.kmath.operations.DoubleField import scientifik.kmath.operations.DoubleField
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
@ -15,4 +17,15 @@ class FieldExpressionContextTest {
assertEquals(expression("x" to 1.0), 4.0) assertEquals(expression("x" to 1.0), 4.0)
assertEquals(expression(), 9.0) assertEquals(expression(), 9.0)
} }
@Test
fun testComplex() {
val context = FieldExpressionContext(ComplexField)
val expression = with(context) {
val x = variable("x", Complex(2.0, 0.0))
x * x + 2 * x + 1.0
}
assertEquals(expression("x" to Complex(1.0, 0.0)), Complex(4.0, 0.0))
assertEquals(expression(), Complex(9.0, 0.0))
}
} }