forked from kscience/kmath
Fix integration borders
This commit is contained in:
parent
f86a6130e0
commit
e6c6925209
@ -98,7 +98,7 @@ public fun <T : Any> GaussIntegrator<T>.integrate(
|
||||
require(intervals > 0) { "Number of intervals must be positive" }
|
||||
val rangeSize = (range.endInclusive - range.start) / intervals
|
||||
val ranges = UnivariateIntegrandRanges(
|
||||
(0 until intervals).map { i -> (rangeSize * i)..(rangeSize * (i + 1)) to order }
|
||||
(0 until intervals).map { i -> (range.start + rangeSize * i)..(range.start + rangeSize * (i + 1)) to order }
|
||||
)
|
||||
return integrate(
|
||||
UnivariateIntegrand(
|
||||
|
@ -24,14 +24,14 @@ class GaussIntegralTest {
|
||||
|
||||
@Test
|
||||
fun gaussUniform() {
|
||||
val res = DoubleField.integrator.integrate(0.0..100.0) { x ->
|
||||
val res = DoubleField.integrator.integrate(35.0..100.0) { x ->
|
||||
if(x in 30.0..50.0){
|
||||
1.0
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
}
|
||||
assertEquals(20.0, res.valueOrNull!!, 0.5)
|
||||
assertEquals(15.0, res.valueOrNull!!, 0.5)
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user