From feb5743f58616af3c46917ce098c63778191e5db Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Thu, 13 May 2021 11:10:59 +0300 Subject: [PATCH] Change signature of one of integrate helpers --- .../kscience/kmath/commons/integration/IntegrationTest.kt | 6 +++--- .../space/kscience/kmath/integration/UnivariateIntegrand.kt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/integration/IntegrationTest.kt b/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/integration/IntegrationTest.kt index 9d475d04d..97dc94d1d 100644 --- a/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/integration/IntegrationTest.kt +++ b/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/integration/IntegrationTest.kt @@ -19,16 +19,16 @@ internal class IntegrationTest { @Test fun simpson() { - val res = CMIntegrator.simpson().integrate(0.0..2 * PI, function) + val res = CMIntegrator.simpson().integrate(0.0..2 * PI, function = function) assertTrue { abs(res) < 1e-3 } } @Test fun customSimpson() { - val res = CMIntegrator.simpson().integrate(0.0..PI, function) { + val res = CMIntegrator.simpson().integrate(0.0..PI, { targetRelativeAccuracy = 1e-4 targetAbsoluteAccuracy = 1e-4 - } + }, function) assertTrue { abs(res - 2) < 1e-3 } assertTrue { abs(res - 2) > 1e-12 } } diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/UnivariateIntegrand.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/UnivariateIntegrand.kt index bcd5005c4..51ea57a33 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/UnivariateIntegrand.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/UnivariateIntegrand.kt @@ -57,8 +57,8 @@ public fun UnivariateIntegrator.integrate( @UnstableKMathAPI public fun UnivariateIntegrator.integrate( range: ClosedRange, + featureBuilder: MutableList.() -> Unit = {}, function: (Double) -> Double, - featureBuilder: (MutableList.() -> Unit) = {}, ): Double { //TODO use dedicated feature builder class instead or add extensions to MutableList val features = buildList {