forked from kscience/kmath
Added degreeBy
to Numbered...
.
This commit is contained in:
parent
b44c99c265
commit
5b8d6b601e
@ -471,6 +471,18 @@ public open class NumberedPolynomialSpace<C, A : Ring<C>>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Counts degree of the polynomial by the specified [variable].
|
||||||
|
*/
|
||||||
|
public fun NumberedPolynomial<C>.degreeBy(variable: Int): UInt =
|
||||||
|
coefficients.entries.maxOfOrNull { (degs, c) -> if (c.isZero()) 0u else degs.getOrElse(variable) { 0u } } ?: 0u
|
||||||
|
/**
|
||||||
|
* Counts degree of the polynomial by the specified [variables].
|
||||||
|
*/
|
||||||
|
public fun NumberedPolynomial<C>.degreeBy(variables: Collection<Int>): UInt =
|
||||||
|
coefficients.entries.maxOfOrNull { (degs, c) ->
|
||||||
|
if (c.isZero()) 0u else degs.withIndex().filter { (index, _) -> index in variables }.sumOf { it.value }
|
||||||
|
} ?: 0u
|
||||||
/**
|
/**
|
||||||
* Count of variables occurring in the polynomial with positive power. If there is no such variable,
|
* Count of variables occurring in the polynomial with positive power. If there is no such variable,
|
||||||
* the result is `0`.
|
* the result is `0`.
|
||||||
|
@ -126,6 +126,14 @@ public class NumberedRationalFunctionSpace<C, A: Ring<C>> (
|
|||||||
* And last index of the list is [lastVariable].
|
* And last index of the list is [lastVariable].
|
||||||
*/
|
*/
|
||||||
public val NumberedPolynomial<C>.degrees: List<UInt> get() = polynomialRing { degrees }
|
public val NumberedPolynomial<C>.degrees: List<UInt> get() = polynomialRing { degrees }
|
||||||
|
/**
|
||||||
|
* Counts degree of the polynomial by the specified [variable].
|
||||||
|
*/
|
||||||
|
public fun NumberedPolynomial<C>.degreeBy(variable: Int): UInt = polynomialRing { degreeBy(variable) }
|
||||||
|
/**
|
||||||
|
* Counts degree of the polynomial by the specified [variables].
|
||||||
|
*/
|
||||||
|
public fun NumberedPolynomial<C>.degreeBy(variables: Collection<Int>): UInt = polynomialRing { degreeBy(variables) }
|
||||||
/**
|
/**
|
||||||
* Count of variables occurring in the polynomial with positive power. If there is no such variable,
|
* Count of variables occurring in the polynomial with positive power. If there is no such variable,
|
||||||
* the result is `0`.
|
* the result is `0`.
|
||||||
|
Loading…
Reference in New Issue
Block a user