Change signature of one of integrate helpers

This commit is contained in:
Alexander Nozik 2021-05-13 11:10:59 +03:00
parent f5289abdc3
commit feb5743f58
2 changed files with 4 additions and 4 deletions

View File

@ -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 }
}

View File

@ -57,8 +57,8 @@ public fun UnivariateIntegrator<Double>.integrate(
@UnstableKMathAPI
public fun UnivariateIntegrator<Double>.integrate(
range: ClosedRange<Double>,
featureBuilder: MutableList<IntegrandFeature>.() -> Unit = {},
function: (Double) -> Double,
featureBuilder: (MutableList<IntegrandFeature>.() -> Unit) = {},
): Double {
//TODO use dedicated feature builder class instead or add extensions to MutableList<IntegrandFeature>
val features = buildList {