Feature: Polynomials and rational functions #469
@ -295,7 +295,7 @@ public interface AbstractPolynomialSpace<C, P: AbstractPolynomial<C>> : Ring<P>
|
|||||||
* If polynomial is a constant polynomial represents and returns it as constant.
|
* If polynomial is a constant polynomial represents and returns it as constant.
|
||||||
* Otherwise, (when the polynomial is not constant polynomial) raises corresponding exception.
|
* Otherwise, (when the polynomial is not constant polynomial) raises corresponding exception.
|
||||||
*/
|
*/
|
||||||
public fun P.asConstant(): C = asConstantOrNull() ?: error("Can not represent non-constant polynomial as a constant")
|
public fun P.asConstant(): C = requireNotNull(asConstantOrNull()) { "Can not represent non-constant polynomial as a constant" }
|
||||||
|
|
||||||
override fun add(left: P, right: P): P = left + right
|
override fun add(left: P, right: P): P = left + right
|
||||||
override fun multiply(left: P, right: P): P = left * right
|
override fun multiply(left: P, right: P): P = left * right
|
||||||
|
@ -460,7 +460,7 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
|
|||||||
* If polynomial is a constant polynomial represents and returns it as constant.
|
* If polynomial is a constant polynomial represents and returns it as constant.
|
||||||
* Otherwise, (when the polynomial is not constant polynomial) raises corresponding exception.
|
* Otherwise, (when the polynomial is not constant polynomial) raises corresponding exception.
|
||||||
*/
|
*/
|
||||||
public fun P.asConstant(): C = asConstantOrNull() ?: error("Can not represent non-constant polynomial as a constant")
|
public fun P.asConstant(): C = requireNotNull(asConstantOrNull()) { "Can not represent non-constant polynomial as a constant" }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Degree of the polynomial, [see also](https://en.wikipedia.org/wiki/Degree_of_a_polynomial). If the polynomial is
|
* Degree of the polynomial, [see also](https://en.wikipedia.org/wiki/Degree_of_a_polynomial). If the polynomial is
|
||||||
|
@ -11,6 +11,7 @@ import kotlin.test.Test
|
|||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
import kotlin.test.assertFailsWith
|
import kotlin.test.assertFailsWith
|
||||||
|
|
||||||
|
|
||||||
class PolynomialUtilTest {
|
class PolynomialUtilTest {
|
||||||
@Test
|
@Test
|
||||||
fun test_substitute_Double() {
|
fun test_substitute_Double() {
|
||||||
|
Loading…
Reference in New Issue
Block a user