forked from kscience/kmath
Simplify usages of LabeledPolynomial constructing fabrics. Fix bugs. Add tests for variable's interoperability.
This commit is contained in:
parent
923c52737d
commit
d3be07987c
@ -77,63 +77,63 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
|
||||
* Returns sum of the variable represented as a monic monomial and the integer represented as a constant polynomial.
|
||||
*/
|
||||
public override operator fun Symbol.plus(other: Int): LabeledPolynomial<C> =
|
||||
if (other == 0) LabeledPolynomialAsIs(mapOf(
|
||||
if (other == 0) LabeledPolynomialAsIs(
|
||||
mapOf(this@plus to 1U) to constantOne,
|
||||
))
|
||||
else LabeledPolynomialAsIs(mapOf(
|
||||
)
|
||||
else LabeledPolynomialAsIs(
|
||||
mapOf(this@plus to 1U) to constantOne,
|
||||
emptyMap<Symbol, UInt>() to constantOne * other,
|
||||
))
|
||||
)
|
||||
/**
|
||||
* Returns difference between the variable represented as a monic monomial and the integer represented as a constant polynomial.
|
||||
*/
|
||||
public override operator fun Symbol.minus(other: Int): LabeledPolynomial<C> =
|
||||
if (other == 0) LabeledPolynomialAsIs(mapOf(
|
||||
mapOf(this@minus to 1U) to -constantOne,
|
||||
))
|
||||
else LabeledPolynomialAsIs(mapOf(
|
||||
mapOf(this@minus to 1U) to -constantOne,
|
||||
emptyMap<Symbol, UInt>() to constantOne * other,
|
||||
))
|
||||
if (other == 0) LabeledPolynomialAsIs(
|
||||
mapOf(this@minus to 1U) to constantOne,
|
||||
)
|
||||
else LabeledPolynomialAsIs(
|
||||
mapOf(this@minus to 1U) to constantOne,
|
||||
emptyMap<Symbol, UInt>() to constantOne * -other,
|
||||
)
|
||||
/**
|
||||
* Returns product of the variable represented as a monic monomial and the integer represented as a constant polynomial.
|
||||
*/
|
||||
public override operator fun Symbol.times(other: Int): LabeledPolynomial<C> =
|
||||
if (other == 0) zero
|
||||
else LabeledPolynomialAsIs(mapOf(
|
||||
else LabeledPolynomialAsIs(
|
||||
mapOf(this to 1U) to constantOne * other,
|
||||
))
|
||||
)
|
||||
|
||||
/**
|
||||
* Returns sum of the integer represented as a constant polynomial and the variable represented as a monic monomial.
|
||||
*/
|
||||
public override operator fun Int.plus(other: Symbol): LabeledPolynomial<C> =
|
||||
if (this == 0) LabeledPolynomialAsIs(mapOf(
|
||||
if (this == 0) LabeledPolynomialAsIs(
|
||||
mapOf(other to 1U) to constantOne,
|
||||
))
|
||||
else LabeledPolynomialAsIs(mapOf(
|
||||
)
|
||||
else LabeledPolynomialAsIs(
|
||||
mapOf(other to 1U) to constantOne,
|
||||
emptyMap<Symbol, UInt>() to constantOne * this@plus,
|
||||
))
|
||||
)
|
||||
/**
|
||||
* Returns difference between the integer represented as a constant polynomial and the variable represented as a monic monomial.
|
||||
*/
|
||||
public override operator fun Int.minus(other: Symbol): LabeledPolynomial<C> =
|
||||
if (this == 0) LabeledPolynomialAsIs(mapOf(
|
||||
if (this == 0) LabeledPolynomialAsIs(
|
||||
mapOf(other to 1U) to -constantOne,
|
||||
))
|
||||
else LabeledPolynomialAsIs(mapOf(
|
||||
)
|
||||
else LabeledPolynomialAsIs(
|
||||
mapOf(other to 1U) to -constantOne,
|
||||
emptyMap<Symbol, UInt>() to constantOne * this@minus,
|
||||
))
|
||||
)
|
||||
/**
|
||||
* Returns product of the integer represented as a constant polynomial and the variable represented as a monic monomial.
|
||||
*/
|
||||
public override operator fun Int.times(other: Symbol): LabeledPolynomial<C> =
|
||||
if (this == 0) zero
|
||||
else LabeledPolynomialAsIs(mapOf(
|
||||
else LabeledPolynomialAsIs(
|
||||
mapOf(other to 1U) to constantOne * this@times,
|
||||
))
|
||||
)
|
||||
|
||||
/**
|
||||
* Returns sum of the polynomial and the integer represented as a polynomial.
|
||||
@ -143,7 +143,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
|
||||
public override operator fun LabeledPolynomial<C>.plus(other: Int): LabeledPolynomial<C> =
|
||||
if (other == 0) this
|
||||
else with(coefficients) {
|
||||
if (isEmpty()) LabeledPolynomialAsIs(mapOf(emptyMap<Symbol, UInt>() to other.asConstant()))
|
||||
if (isEmpty()) other.asPolynomial()
|
||||
else LabeledPolynomialAsIs(
|
||||
toMutableMap()
|
||||
.apply {
|
||||
@ -161,7 +161,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
|
||||
public override operator fun LabeledPolynomial<C>.minus(other: Int): LabeledPolynomial<C> =
|
||||
if (other == 0) this
|
||||
else with(coefficients) {
|
||||
if (isEmpty()) LabeledPolynomialAsIs(mapOf(emptyMap<Symbol, UInt>() to (-other).asConstant()))
|
||||
if (isEmpty()) (-other).asPolynomial()
|
||||
else LabeledPolynomialAsIs(
|
||||
toMutableMap()
|
||||
.apply {
|
||||
@ -180,7 +180,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
|
||||
when(other) {
|
||||
0 -> zero
|
||||
1 -> this
|
||||
else -> LabeledPolynomial(
|
||||
else -> LabeledPolynomialAsIs(
|
||||
coefficients
|
||||
.toMutableMap()
|
||||
.apply {
|
||||
@ -197,7 +197,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
|
||||
public override operator fun Int.plus(other: LabeledPolynomial<C>): LabeledPolynomial<C> =
|
||||
if (this == 0) other
|
||||
else with(other.coefficients) {
|
||||
if (isEmpty()) LabeledPolynomialAsIs(mapOf(emptyMap<Symbol, UInt>() to this@plus.asConstant()))
|
||||
if (isEmpty()) this@plus.asPolynomial()
|
||||
else LabeledPolynomialAsIs(
|
||||
toMutableMap()
|
||||
.apply {
|
||||
@ -215,7 +215,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
|
||||
public override operator fun Int.minus(other: LabeledPolynomial<C>): LabeledPolynomial<C> =
|
||||
if (this == 0) -other
|
||||
else with(other.coefficients) {
|
||||
if (isEmpty()) LabeledPolynomialAsIs(mapOf(emptyMap<Symbol, UInt>() to this@minus.asConstant()))
|
||||
if (isEmpty()) this@minus.asPolynomial()
|
||||
else LabeledPolynomialAsIs(
|
||||
toMutableMap()
|
||||
.apply {
|
||||
@ -236,7 +236,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
|
||||
when(this) {
|
||||
0 -> zero
|
||||
1 -> other
|
||||
else -> LabeledPolynomial(
|
||||
else -> LabeledPolynomialAsIs(
|
||||
other.coefficients
|
||||
.toMutableMap()
|
||||
.apply {
|
||||
@ -245,65 +245,60 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the integer [value] to polynomial.
|
||||
*/
|
||||
public override fun number(value: Int): LabeledPolynomial<C> = number(constantNumber(value))
|
||||
|
||||
/**
|
||||
* Returns sum of the variable represented as a monic monomial and the constant represented as a constant polynomial.
|
||||
*/
|
||||
public override operator fun Symbol.plus(other: C): LabeledPolynomial<C> =
|
||||
LabeledPolynomialAsIs(mapOf(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(this@plus to 1U) to constantOne,
|
||||
emptyMap<Symbol, UInt>() to other,
|
||||
))
|
||||
)
|
||||
/**
|
||||
* Returns difference between the variable represented as a monic monomial and the constant represented as a constant polynomial.
|
||||
*/
|
||||
public override operator fun Symbol.minus(other: C): LabeledPolynomial<C> =
|
||||
LabeledPolynomialAsIs(mapOf(
|
||||
mapOf(this@minus to 1U) to -constantOne,
|
||||
emptyMap<Symbol, UInt>() to other,
|
||||
))
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(this@minus to 1U) to constantOne,
|
||||
emptyMap<Symbol, UInt>() to -other,
|
||||
)
|
||||
/**
|
||||
* Returns product of the variable represented as a monic monomial and the constant represented as a constant polynomial.
|
||||
*/
|
||||
public override operator fun Symbol.times(other: C): LabeledPolynomial<C> =
|
||||
LabeledPolynomialAsIs(mapOf(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(this@times to 1U) to other,
|
||||
))
|
||||
)
|
||||
|
||||
/**
|
||||
* Returns sum of the constant represented as a constant polynomial and the variable represented as a monic monomial.
|
||||
*/
|
||||
public override operator fun C.plus(other: Symbol): LabeledPolynomial<C> =
|
||||
LabeledPolynomialAsIs(mapOf(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(other to 1U) to constantOne,
|
||||
emptyMap<Symbol, UInt>() to this@plus,
|
||||
))
|
||||
)
|
||||
/**
|
||||
* Returns difference between the constant represented as a constant polynomial and the variable represented as a monic monomial.
|
||||
*/
|
||||
public override operator fun C.minus(other: Symbol): LabeledPolynomial<C> =
|
||||
LabeledPolynomialAsIs(mapOf(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(other to 1U) to -constantOne,
|
||||
emptyMap<Symbol, UInt>() to this@minus,
|
||||
))
|
||||
)
|
||||
/**
|
||||
* Returns product of the constant represented as a constant polynomial and the variable represented as a monic monomial.
|
||||
*/
|
||||
public override operator fun C.times(other: Symbol): LabeledPolynomial<C> =
|
||||
LabeledPolynomialAsIs(mapOf(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(other to 1U) to this@times,
|
||||
))
|
||||
)
|
||||
|
||||
/**
|
||||
* Returns sum of the constant represented as a polynomial and the polynomial.
|
||||
*/
|
||||
override operator fun C.plus(other: LabeledPolynomial<C>): LabeledPolynomial<C> =
|
||||
with(other.coefficients) {
|
||||
if (isEmpty()) LabeledPolynomialAsIs(mapOf(emptyMap<Symbol, UInt>() to this@plus))
|
||||
if (isEmpty()) this@plus.asLabeledPolynomial()
|
||||
else LabeledPolynomialAsIs(
|
||||
toMutableMap()
|
||||
.apply {
|
||||
@ -318,7 +313,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
|
||||
*/
|
||||
override operator fun C.minus(other: LabeledPolynomial<C>): LabeledPolynomial<C> =
|
||||
with(other.coefficients) {
|
||||
if (isEmpty()) LabeledPolynomialAsIs(mapOf(emptyMap<Symbol, UInt>() to this@minus))
|
||||
if (isEmpty()) this@minus.asLabeledPolynomial()
|
||||
else LabeledPolynomialAsIs(
|
||||
toMutableMap()
|
||||
.apply {
|
||||
@ -347,7 +342,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
|
||||
*/
|
||||
override operator fun LabeledPolynomial<C>.plus(other: C): LabeledPolynomial<C> =
|
||||
with(coefficients) {
|
||||
if (isEmpty()) LabeledPolynomialAsIs(mapOf(emptyMap<Symbol, UInt>() to other))
|
||||
if (isEmpty()) other.asLabeledPolynomial()
|
||||
else LabeledPolynomialAsIs(
|
||||
toMutableMap()
|
||||
.apply {
|
||||
@ -362,7 +357,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
|
||||
*/
|
||||
override operator fun LabeledPolynomial<C>.minus(other: C): LabeledPolynomial<C> =
|
||||
with(coefficients) {
|
||||
if (isEmpty()) LabeledPolynomialAsIs(mapOf(emptyMap<Symbol, UInt>() to other))
|
||||
if (isEmpty()) other.asLabeledPolynomial()
|
||||
else LabeledPolynomialAsIs(
|
||||
toMutableMap()
|
||||
.apply {
|
||||
@ -387,60 +382,59 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
|
||||
/**
|
||||
* Converts the constant [value] to polynomial.
|
||||
*/
|
||||
public override fun number(value: C): LabeledPolynomial<C> =
|
||||
LabeledPolynomial(mapOf(emptyMap<Symbol, UInt>() to value))
|
||||
public override fun number(value: C): LabeledPolynomial<C> = value.asLabeledPolynomial()
|
||||
|
||||
/**
|
||||
* Represents the variable as a monic monomial.
|
||||
*/
|
||||
public override operator fun Symbol.unaryPlus(): LabeledPolynomial<C> =
|
||||
LabeledPolynomialAsIs(mapOf(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(this to 1U) to constantOne,
|
||||
))
|
||||
)
|
||||
/**
|
||||
* Returns negation of representation of the variable as a monic monomial.
|
||||
*/
|
||||
public override operator fun Symbol.unaryMinus(): LabeledPolynomial<C> =
|
||||
LabeledPolynomialAsIs(mapOf(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(this to 1U) to -constantOne,
|
||||
))
|
||||
)
|
||||
/**
|
||||
* Returns sum of the variables represented as monic monomials.
|
||||
*/
|
||||
public override operator fun Symbol.plus(other: Symbol): LabeledPolynomial<C> =
|
||||
if (this == other) LabeledPolynomialAsIs(mapOf(
|
||||
if (this == other) LabeledPolynomialAsIs(
|
||||
mapOf(this to 1U) to constantOne * 2
|
||||
))
|
||||
else LabeledPolynomialAsIs(mapOf(
|
||||
)
|
||||
else LabeledPolynomialAsIs(
|
||||
mapOf(this to 1U) to constantOne,
|
||||
mapOf(other to 1U) to constantOne,
|
||||
))
|
||||
)
|
||||
/**
|
||||
* Returns difference between the variables represented as monic monomials.
|
||||
*/
|
||||
public override operator fun Symbol.minus(other: Symbol): LabeledPolynomial<C> =
|
||||
if (this == other) zero
|
||||
else LabeledPolynomialAsIs(mapOf(
|
||||
else LabeledPolynomialAsIs(
|
||||
mapOf(this to 1U) to constantOne,
|
||||
mapOf(other to 1U) to -constantOne,
|
||||
))
|
||||
)
|
||||
/**
|
||||
* Returns product of the variables represented as monic monomials.
|
||||
*/
|
||||
public override operator fun Symbol.times(other: Symbol): LabeledPolynomial<C> =
|
||||
if (this == other) LabeledPolynomialAsIs(mapOf(
|
||||
if (this == other) LabeledPolynomialAsIs(
|
||||
mapOf(this to 2U) to constantOne
|
||||
))
|
||||
else LabeledPolynomialAsIs(mapOf(
|
||||
)
|
||||
else LabeledPolynomialAsIs(
|
||||
mapOf(this to 1U, other to 1U) to constantOne,
|
||||
))
|
||||
)
|
||||
|
||||
/**
|
||||
* Returns sum of the variable represented as a monic monomial and the polynomial.
|
||||
*/
|
||||
public override operator fun Symbol.plus(other: LabeledPolynomial<C>): LabeledPolynomial<C> =
|
||||
with(other.coefficients) {
|
||||
if (isEmpty()) LabeledPolynomialAsIs(mapOf(mapOf(this@plus to 1u) to constantOne))
|
||||
if (isEmpty()) this@plus.asPolynomial()
|
||||
else LabeledPolynomialAsIs(
|
||||
toMutableMap()
|
||||
.apply {
|
||||
@ -455,15 +449,15 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
|
||||
*/
|
||||
public override operator fun Symbol.minus(other: LabeledPolynomial<C>): LabeledPolynomial<C> =
|
||||
with(other.coefficients) {
|
||||
if (isEmpty()) LabeledPolynomialAsIs(mapOf(mapOf(this@minus to 1u) to constantOne))
|
||||
if (isEmpty()) this@minus.asPolynomial()
|
||||
else LabeledPolynomialAsIs(
|
||||
toMutableMap()
|
||||
.apply {
|
||||
val degs = mapOf(this@minus to 1U)
|
||||
val theVariableDegs = mapOf(this@minus to 1U)
|
||||
|
||||
forEach { (degs, c) -> if(degs != degs) this[degs] = -c }
|
||||
forEach { (degs, c) -> if(degs != theVariableDegs) this[degs] = -c }
|
||||
|
||||
this[degs] = constantOne - getOrElse(degs) { constantZero }
|
||||
this[theVariableDegs] = constantOne - getOrElse(theVariableDegs) { constantZero }
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -481,7 +475,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
|
||||
*/
|
||||
public override operator fun LabeledPolynomial<C>.plus(other: Symbol): LabeledPolynomial<C> =
|
||||
with(coefficients) {
|
||||
if (isEmpty()) LabeledPolynomialAsIs(mapOf(mapOf(other to 1u) to constantOne))
|
||||
if (isEmpty()) other.asPolynomial()
|
||||
else LabeledPolynomialAsIs(
|
||||
toMutableMap()
|
||||
.apply {
|
||||
@ -496,13 +490,13 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
|
||||
*/
|
||||
public override operator fun LabeledPolynomial<C>.minus(other: Symbol): LabeledPolynomial<C> =
|
||||
with(coefficients) {
|
||||
if (isEmpty()) LabeledPolynomialAsIs(mapOf(mapOf(other to 1u) to constantOne))
|
||||
if (isEmpty()) other.asPolynomial()
|
||||
else LabeledPolynomialAsIs(
|
||||
toMutableMap()
|
||||
.apply {
|
||||
val degs = mapOf(other to 1U)
|
||||
|
||||
this[degs] = constantOne - getOrElse(degs) { constantZero }
|
||||
this[degs] = getOrElse(degs) { constantZero } - constantOne
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -560,11 +554,11 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
|
||||
/**
|
||||
* Instance of zero polynomial (zero of the polynomial ring).
|
||||
*/
|
||||
override val zero: LabeledPolynomial<C> = LabeledPolynomialAsIs(mapOf(emptyMap<Symbol, UInt>() to constantZero))
|
||||
override val zero: LabeledPolynomial<C> = LabeledPolynomialAsIs()
|
||||
/**
|
||||
* Instance of unit polynomial (unit of the polynomial ring).
|
||||
*/
|
||||
override val one: LabeledPolynomial<C> = LabeledPolynomialAsIs(mapOf(emptyMap<Symbol, UInt>() to constantOne))
|
||||
override val one: LabeledPolynomial<C> = constantOne.asLabeledPolynomial()
|
||||
|
||||
/**
|
||||
* Degree of the polynomial, [see also](https://en.wikipedia.org/wiki/Degree_of_a_polynomial). If the polynomial is
|
||||
|
@ -172,11 +172,6 @@ public open class ListPolynomialSpace<C, A : Ring<C>>(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the integer [value] to polynomial.
|
||||
*/
|
||||
public override fun number(value: Int): ListPolynomial<C> = number(constantNumber(value))
|
||||
|
||||
/**
|
||||
* Returns sum of the constant represented as a polynomial and the polynomial.
|
||||
*/
|
||||
|
@ -169,11 +169,6 @@ public class NumberedPolynomialSpace<C, A : Ring<C>>(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the integer [value] to polynomial.
|
||||
*/
|
||||
public override fun number(value: Int): NumberedPolynomial<C> = number(constantNumber(value))
|
||||
|
||||
/**
|
||||
* Returns sum of the constant represented as a polynomial and the polynomial.
|
||||
*/
|
||||
|
@ -112,7 +112,7 @@ public interface PolynomialSpace<C, P: Polynomial<C>> : Ring<P> {
|
||||
/**
|
||||
* Converts the integer [value] to polynomial.
|
||||
*/
|
||||
public fun number(value: Int): P = one * value
|
||||
public fun number(value: Int): P = number(constantNumber(value))
|
||||
/**
|
||||
* Converts the integer to polynomial.
|
||||
*/
|
||||
|
@ -3,6 +3,8 @@
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:Suppress("LocalVariableName")
|
||||
|
||||
package space.kscience.kmath.functions
|
||||
|
||||
import space.kscience.kmath.expressions.Symbol
|
||||
@ -26,34 +28,118 @@ class LabeledPolynomialTest {
|
||||
val o = Rational(0)
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Variable_Int_plus() {
|
||||
// TODO
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(5),
|
||||
mapOf(x to 1u) to Rational(1),
|
||||
),
|
||||
x + 5,
|
||||
"test 1"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 1u) to Rational(1),
|
||||
),
|
||||
x + 0,
|
||||
"test 2"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Variable_Int_minus() {
|
||||
// TODO
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-5),
|
||||
mapOf(x to 1u) to Rational(1),
|
||||
),
|
||||
x - 5,
|
||||
"test 1"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 1u) to Rational(1),
|
||||
),
|
||||
x - 0,
|
||||
"test 2"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Variable_Int_times() {
|
||||
// TODO
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 1u) to Rational(5),
|
||||
),
|
||||
x * 5,
|
||||
"test 1"
|
||||
)
|
||||
assertSame(
|
||||
zero,
|
||||
x * 0,
|
||||
"test 2"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Int_Variable_plus() {
|
||||
// TODO
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(5),
|
||||
mapOf(x to 1u) to Rational(1),
|
||||
),
|
||||
5 + x,
|
||||
"test 1"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 1u) to Rational(1),
|
||||
),
|
||||
0 + x,
|
||||
"test 2"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Int_Variable_minus() {
|
||||
// TODO
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(5),
|
||||
mapOf(x to 1u) to Rational(-1),
|
||||
),
|
||||
5 - x,
|
||||
"test 1"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 1u) to Rational(-1),
|
||||
),
|
||||
0 - x,
|
||||
"test 2"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Int_Variable_times() {
|
||||
// TODO
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 1u) to Rational(5),
|
||||
),
|
||||
5 * x,
|
||||
"test 1"
|
||||
)
|
||||
assertSame(
|
||||
zero,
|
||||
0 * x,
|
||||
"test 2"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
fun test_Polynomial_Int_plus() {
|
||||
@ -516,34 +602,126 @@ class LabeledPolynomialTest {
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Variable_Constant_plus() {
|
||||
// TODO
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(5),
|
||||
mapOf(x to 1u) to Rational(1),
|
||||
),
|
||||
x + Rational(5),
|
||||
"test 1"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(0),
|
||||
mapOf(x to 1u) to Rational(1),
|
||||
),
|
||||
x + Rational(0),
|
||||
"test 2"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Variable_Constant_minus() {
|
||||
// TODO
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-5),
|
||||
mapOf(x to 1u) to Rational(1),
|
||||
),
|
||||
x - Rational(5),
|
||||
"test 1"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(0),
|
||||
mapOf(x to 1u) to Rational(1),
|
||||
),
|
||||
x - Rational(0),
|
||||
"test 2"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Variable_Constant_times() {
|
||||
// TODO
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 1u) to Rational(5),
|
||||
),
|
||||
x * Rational(5),
|
||||
"test 1"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 1u) to Rational(0),
|
||||
),
|
||||
x * Rational(0),
|
||||
"test 2"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Constant_Variable_plus() {
|
||||
// TODO
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(5),
|
||||
mapOf(x to 1u) to Rational(1),
|
||||
),
|
||||
Rational(5) + x,
|
||||
"test 1"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(0),
|
||||
mapOf(x to 1u) to Rational(1),
|
||||
),
|
||||
Rational(0) + x,
|
||||
"test 2"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Constant_Variable_minus() {
|
||||
// TODO
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(5),
|
||||
mapOf(x to 1u) to Rational(-1),
|
||||
),
|
||||
Rational(5) - x,
|
||||
"test 1"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(0),
|
||||
mapOf(x to 1u) to Rational(-1),
|
||||
),
|
||||
Rational(0) - x,
|
||||
"test 2"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Constant_Variable_times() {
|
||||
// TODO
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 1u) to Rational(5),
|
||||
),
|
||||
Rational(5) * x,
|
||||
"test 1"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 1u) to Rational(0),
|
||||
),
|
||||
Rational(0) * x,
|
||||
"test 2"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
fun test_Polynomial_Constant_plus() {
|
||||
@ -1068,59 +1246,567 @@ class LabeledPolynomialTest {
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Variable_unaryPlus(){
|
||||
// TODO
|
||||
fun test_Variable_unaryPlus() {
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 1u) to Rational(1),
|
||||
),
|
||||
+x
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Variable_unaryMinus(){
|
||||
// TODO
|
||||
fun test_Variable_unaryMinus() {
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 1u) to Rational(-1),
|
||||
),
|
||||
-x
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Variable_Variable_plus(){
|
||||
// TODO
|
||||
fun test_Variable_Variable_plus() {
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 1u) to Rational(1),
|
||||
mapOf(y to 1u) to Rational(1),
|
||||
),
|
||||
x + y,
|
||||
"test 1"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 1u) to Rational(2),
|
||||
),
|
||||
x + x,
|
||||
"test 2"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Variable_Variable_minus(){
|
||||
// TODO
|
||||
fun test_Variable_Variable_minus() {
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 1u) to Rational(1),
|
||||
mapOf(y to 1u) to Rational(-1),
|
||||
),
|
||||
x - y,
|
||||
"test 1"
|
||||
)
|
||||
assertSame(
|
||||
zero,
|
||||
x - x,
|
||||
"test 2"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Variable_Variable_times(){
|
||||
// TODO
|
||||
fun test_Variable_Variable_times() {
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 1u, y to 1u) to Rational(1),
|
||||
),
|
||||
x * y,
|
||||
"test 1"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 2u) to Rational(1),
|
||||
),
|
||||
x * x,
|
||||
"test 2"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Variable_Polynomial_plus(){
|
||||
// TODO
|
||||
fun test_Variable_Polynomial_plus() {
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(7, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
),
|
||||
x + LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
),
|
||||
"test 1"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(6, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
),
|
||||
y + LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
),
|
||||
"test 2"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
mapOf(iota to 1u) to Rational(1),
|
||||
),
|
||||
iota + LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
),
|
||||
"test 3"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Variable_Polynomial_minus(){
|
||||
// TODO
|
||||
fun test_Variable_Polynomial_minus() {
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(16, 4),
|
||||
mapOf(x to 1u) to Rational(-1, 3),
|
||||
mapOf(x to 2u) to Rational(-3, 8),
|
||||
mapOf(y to 1u) to Rational(1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(-6, 5),
|
||||
mapOf(y to 2u) to Rational(13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(-13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(-11, 8),
|
||||
),
|
||||
x - LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
),
|
||||
"test 1"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(16, 4),
|
||||
mapOf(x to 1u) to Rational(-4, 3),
|
||||
mapOf(x to 2u) to Rational(-3, 8),
|
||||
mapOf(y to 1u) to Rational(8, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(-6, 5),
|
||||
mapOf(y to 2u) to Rational(13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(-13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(-11, 8),
|
||||
),
|
||||
y - LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
),
|
||||
"test 2"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(16, 4),
|
||||
mapOf(x to 1u) to Rational(-4, 3),
|
||||
mapOf(x to 2u) to Rational(-3, 8),
|
||||
mapOf(y to 1u) to Rational(1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(-6, 5),
|
||||
mapOf(y to 2u) to Rational(13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(-13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(-11, 8),
|
||||
mapOf(iota to 1u) to Rational(1),
|
||||
),
|
||||
iota - LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
),
|
||||
"test 3"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Variable_Polynomial_times(){
|
||||
// TODO
|
||||
fun test_Variable_Polynomial_times() {
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 1u) to Rational(-16, 4),
|
||||
mapOf(x to 2u) to Rational(4, 3),
|
||||
mapOf(x to 3u) to Rational(3, 8),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 2u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 3u, y to 1u) to Rational(6, 5),
|
||||
mapOf(x to 1u, y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 2u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 3u, y to 2u) to Rational(11, 8),
|
||||
),
|
||||
x * LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
),
|
||||
"test 1"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(y to 1u) to Rational(-16, 4),
|
||||
mapOf(x to 1u, y to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(3, 8),
|
||||
mapOf(y to 2u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 2u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 2u) to Rational(6, 5),
|
||||
mapOf(y to 3u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 3u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 3u) to Rational(11, 8),
|
||||
),
|
||||
y * LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
),
|
||||
"test 2"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(iota to 1u) to Rational(-16, 4),
|
||||
mapOf(x to 1u, iota to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u, iota to 1u) to Rational(3, 8),
|
||||
mapOf(y to 1u, iota to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u, iota to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u, iota to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u, iota to 1u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u, iota to 1u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u, iota to 1u) to Rational(11, 8),
|
||||
),
|
||||
iota * LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
),
|
||||
"test 3"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Polynomial_Variable_plus(){
|
||||
// TODO
|
||||
fun test_Polynomial_Variable_plus() {
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(7, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
),
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
) + x,
|
||||
"test 1"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(6, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
),
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
) + y,
|
||||
"test 2"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
mapOf(iota to 1u) to Rational(1),
|
||||
),
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
) + iota,
|
||||
"test 3"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Polynomial_Variable_minus(){
|
||||
// TODO
|
||||
fun test_Polynomial_Variable_minus() {
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(1, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
),
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
) - x,
|
||||
"test 1"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-8, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
),
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
) - y,
|
||||
"test 2"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
mapOf(iota to 1u) to Rational(-1),
|
||||
),
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
) - iota,
|
||||
"test 3"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Ignore
|
||||
fun test_Polynomial_Variable_times(){
|
||||
// TODO
|
||||
fun test_Polynomial_Variable_times() {
|
||||
RationalField.labeledPolynomialSpace {
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(x to 1u) to Rational(-16, 4),
|
||||
mapOf(x to 2u) to Rational(4, 3),
|
||||
mapOf(x to 3u) to Rational(3, 8),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 2u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 3u, y to 1u) to Rational(6, 5),
|
||||
mapOf(x to 1u, y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 2u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 3u, y to 2u) to Rational(11, 8),
|
||||
),
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
) * x,
|
||||
"test 1"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(y to 1u) to Rational(-16, 4),
|
||||
mapOf(x to 1u, y to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(3, 8),
|
||||
mapOf(y to 2u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 2u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 2u) to Rational(6, 5),
|
||||
mapOf(y to 3u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 3u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 3u) to Rational(11, 8),
|
||||
),
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
) * y,
|
||||
"test 2"
|
||||
)
|
||||
assertEquals(
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf(iota to 1u) to Rational(-16, 4),
|
||||
mapOf(x to 1u, iota to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u, iota to 1u) to Rational(3, 8),
|
||||
mapOf(y to 1u, iota to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u, iota to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u, iota to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u, iota to 1u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u, iota to 1u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u, iota to 1u) to Rational(11, 8),
|
||||
),
|
||||
LabeledPolynomialAsIs(
|
||||
mapOf<Symbol, UInt>() to Rational(-16, 4),
|
||||
mapOf(x to 1u) to Rational(4, 3),
|
||||
mapOf(x to 2u) to Rational(3, 8),
|
||||
mapOf(y to 1u) to Rational(-1, 7),
|
||||
mapOf(x to 1u, y to 1u) to Rational(-15, 3),
|
||||
mapOf(x to 2u, y to 1u) to Rational(6, 5),
|
||||
mapOf(y to 2u) to Rational(-13, 3),
|
||||
mapOf(x to 1u, y to 2u) to Rational(13, 4),
|
||||
mapOf(x to 2u, y to 2u) to Rational(11, 8),
|
||||
) * iota,
|
||||
"test 3"
|
||||
)
|
||||
}
|
||||
}
|
||||
@Test
|
||||
fun test_Polynomial_unaryMinus() {
|
||||
|
Loading…
Reference in New Issue
Block a user