Make algebra and constants protected, fix tests

This commit is contained in:
Iaroslav 2020-06-08 23:18:08 +07:00
parent 8f1cf0179a
commit 65370f93fb
No known key found for this signature in database
GPG Key ID: 46E15E4A31B3BCD7
2 changed files with 8 additions and 8 deletions

View File

@ -3,8 +3,8 @@ package scientifik.kmath.expressions
import scientifik.kmath.operations.* import scientifik.kmath.operations.*
abstract class AsmCompiledExpression<T> internal constructor( abstract class AsmCompiledExpression<T> internal constructor(
@JvmField private val algebra: Algebra<T>, @JvmField protected val algebra: Algebra<T>,
@JvmField private val constants: MutableList<out Any> @JvmField protected val constants: MutableList<out Any>
) : Expression<T> { ) : Expression<T> {
abstract override fun invoke(arguments: Map<String, T>): T abstract override fun invoke(arguments: Map<String, T>): T
} }

View File

@ -31,7 +31,7 @@ class AsmTest {
@Test @Test
fun testSum() = testDoubleExpressionValue( fun testSum() = testDoubleExpressionValue(
25.0, 25.0,
AsmSumExpression(AsmConstantExpression(1.0), AsmVariableExpression("x")), AsmSumExpression(RealField, AsmConstantExpression(1.0), AsmVariableExpression("x")),
mapOf("x" to 24.0) mapOf("x" to 24.0)
) )
@ -45,28 +45,28 @@ class AsmTest {
@Test @Test
fun testDiv(): Unit = testDoubleExpressionValue( fun testDiv(): Unit = testDoubleExpressionValue(
0.5, 0.5,
AsmDivExpression(AsmConstantExpression(1.0), AsmConstantExpression(2.0)), AsmDivExpression(RealField, AsmConstantExpression(1.0), AsmConstantExpression(2.0)),
mapOf() mapOf()
) )
@Test @Test
fun testProduct(): Unit = testDoubleExpressionValue( fun testProduct(): Unit = testDoubleExpressionValue(
25.0, 25.0,
AsmProductExpression(AsmVariableExpression("x"), AsmVariableExpression("x")), AsmProductExpression(RealField,AsmVariableExpression("x"), AsmVariableExpression("x")),
mapOf("x" to 5.0) mapOf("x" to 5.0)
) )
@Test @Test
fun testCProduct(): Unit = testDoubleExpressionValue( fun testCProduct(): Unit = testDoubleExpressionValue(
25.0, 25.0,
AsmConstProductExpression(AsmVariableExpression("x"), 5.0), AsmConstProductExpression(RealField,AsmVariableExpression("x"), 5.0),
mapOf("x" to 5.0) mapOf("x" to 5.0)
) )
@Test @Test
fun testCProductWithOtherTypeNumber(): Unit = testDoubleExpressionValue( fun testCProductWithOtherTypeNumber(): Unit = testDoubleExpressionValue(
25.0, 25.0,
AsmConstProductExpression(AsmVariableExpression("x"), 5f), AsmConstProductExpression(RealField,AsmVariableExpression("x"), 5f),
mapOf("x" to 5.0) mapOf("x" to 5.0)
) )
@ -83,7 +83,7 @@ class AsmTest {
@Test @Test
fun testCProductWithCustomTypeNumber(): Unit = testDoubleExpressionValue( fun testCProductWithCustomTypeNumber(): Unit = testDoubleExpressionValue(
0.0, 0.0,
AsmConstProductExpression(AsmVariableExpression("x"), CustomZero), AsmConstProductExpression(RealField,AsmVariableExpression("x"), CustomZero),
mapOf("x" to 5.0) mapOf("x" to 5.0)
) )