Change signature of one of integrate helpers
This commit is contained in:
parent
f5289abdc3
commit
feb5743f58
@ -19,16 +19,16 @@ internal class IntegrationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun simpson() {
|
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 }
|
assertTrue { abs(res) < 1e-3 }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun customSimpson() {
|
fun customSimpson() {
|
||||||
val res = CMIntegrator.simpson().integrate(0.0..PI, function) {
|
val res = CMIntegrator.simpson().integrate(0.0..PI, {
|
||||||
targetRelativeAccuracy = 1e-4
|
targetRelativeAccuracy = 1e-4
|
||||||
targetAbsoluteAccuracy = 1e-4
|
targetAbsoluteAccuracy = 1e-4
|
||||||
}
|
}, function)
|
||||||
assertTrue { abs(res - 2) < 1e-3 }
|
assertTrue { abs(res - 2) < 1e-3 }
|
||||||
assertTrue { abs(res - 2) > 1e-12 }
|
assertTrue { abs(res - 2) > 1e-12 }
|
||||||
}
|
}
|
||||||
|
@ -57,8 +57,8 @@ public fun UnivariateIntegrator<Double>.integrate(
|
|||||||
@UnstableKMathAPI
|
@UnstableKMathAPI
|
||||||
public fun UnivariateIntegrator<Double>.integrate(
|
public fun UnivariateIntegrator<Double>.integrate(
|
||||||
range: ClosedRange<Double>,
|
range: ClosedRange<Double>,
|
||||||
|
featureBuilder: MutableList<IntegrandFeature>.() -> Unit = {},
|
||||||
function: (Double) -> Double,
|
function: (Double) -> Double,
|
||||||
featureBuilder: (MutableList<IntegrandFeature>.() -> Unit) = {},
|
|
||||||
): Double {
|
): Double {
|
||||||
//TODO use dedicated feature builder class instead or add extensions to MutableList<IntegrandFeature>
|
//TODO use dedicated feature builder class instead or add extensions to MutableList<IntegrandFeature>
|
||||||
val features = buildList {
|
val features = buildList {
|
||||||
|
Loading…
Reference in New Issue
Block a user