diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/GaussIntegrator.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/GaussIntegrator.kt index 749f3cc72..ae82a40be 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/GaussIntegrator.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/GaussIntegrator.kt @@ -102,7 +102,7 @@ public fun Field.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 -> (rangeSize * i)..(rangeSize * (i + 1)) to order } ) return GaussIntegrator(this).integrate( UnivariateIntegrand( diff --git a/kmath-functions/src/commonTest/kotlin/space/kscience/kmath/integration/GaussIntegralTest.kt b/kmath-functions/src/commonTest/kotlin/space/kscience/kmath/integration/GaussIntegralTest.kt index 509821e61..195711452 100644 --- a/kmath-functions/src/commonTest/kotlin/space/kscience/kmath/integration/GaussIntegralTest.kt +++ b/kmath-functions/src/commonTest/kotlin/space/kscience/kmath/integration/GaussIntegralTest.kt @@ -24,14 +24,14 @@ class GaussIntegralTest { @Test fun gaussUniform() { - val res = DoubleField.integrate(0.0..100.0,300) { x -> + val res = DoubleField.integrate(0.0..100.0) { x -> if(x in 30.0..50.0){ 1.0 } else { 0.0 } } - assertEquals(20.0, res.value!!, 1.0) + assertEquals(20.0, res.value!!, 0.5) } diff --git a/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructure.kt b/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructure.kt index b9aa251d2..79db86fcc 100644 --- a/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructure.kt +++ b/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructure.kt @@ -20,8 +20,7 @@ public sealed class Nd4jArrayStructure : MutableStructureND { */ public abstract val ndArray: INDArray - public override val shape: IntArray - get() = ndArray.shape().toIntArray() + public override val shape: IntArray get() = ndArray.shape().toIntArray() internal abstract fun elementsIterator(): Iterator> internal fun indicesIterator(): Iterator = ndArray.indicesIterator()