Dev #280

Merged
altavir merged 99 commits from dev into master 2021-04-16 19:45:55 +03:00
2 changed files with 12 additions and 8 deletions
Showing only changes of commit 19ec6a57a4 - Show all commits

View File

@ -2,7 +2,6 @@ package space.kscience.kmath.integration
import space.kscience.kmath.operations.DoubleField import space.kscience.kmath.operations.DoubleField
import space.kscience.kmath.operations.Field import space.kscience.kmath.operations.Field
import space.kscience.kmath.operations.Ring
import space.kscience.kmath.structures.* import space.kscience.kmath.structures.*
import kotlin.jvm.Synchronized import kotlin.jvm.Synchronized
import kotlin.math.ulp import kotlin.math.ulp
@ -27,14 +26,19 @@ public fun <T : Comparable<T>> GaussIntegratorRuleFactory<T>.build(
range: ClosedRange<T>, range: ClosedRange<T>,
): Pair<Buffer<T>, Buffer<T>> { ): Pair<Buffer<T>, Buffer<T>> {
val normalized = build(numPoints) val normalized = build(numPoints)
val points = with(algebra) { with(algebra) {
val length = range.endInclusive - range.start val length = range.endInclusive - range.start
normalized.first.map(bufferFactory) {
range.start + length / 2 + length * it/2 val points = normalized.first.map(bufferFactory) {
} range.start + length / 2 + length * it / 2
} }
return points to normalized.second val weights = normalized.second.map(bufferFactory) {
it * length / 2
}
return points to weights
}
} }

View File

@ -23,7 +23,7 @@ class GaussIntegralTest {
0.0 0.0
} }
} }
assertEquals(20.0, res.value!!, 0.1) assertEquals(20.0, res.value!!, 0.5)
} }