v0.3.0-dev-9 #324

Merged
altavir merged 265 commits from dev into master 2021-05-08 17:16:29 +03:00
3 changed files with 4 additions and 5 deletions
Showing only changes of commit fd4108b74f - Show all commits

View File

@ -102,7 +102,7 @@ public fun <T : Any> Field<T>.integrate(
require(intervals > 0) { "Number of intervals must be positive" } require(intervals > 0) { "Number of intervals must be positive" }
val rangeSize = (range.endInclusive - range.start) / intervals val rangeSize = (range.endInclusive - range.start) / intervals
val ranges = UnivariateIntegrandRanges( 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( return GaussIntegrator(this).integrate(
UnivariateIntegrand( UnivariateIntegrand(

View File

@ -24,14 +24,14 @@ class GaussIntegralTest {
@Test @Test
fun gaussUniform() { 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){ if(x in 30.0..50.0){
1.0 1.0
} else { } else {
0.0 0.0
} }
} }
assertEquals(20.0, res.value!!, 1.0) assertEquals(20.0, res.value!!, 0.5)
} }

View File

@ -20,8 +20,7 @@ public sealed class Nd4jArrayStructure<T> : MutableStructureND<T> {
*/ */
public abstract val ndArray: INDArray public abstract val ndArray: INDArray
public override val shape: IntArray public override val shape: IntArray get() = ndArray.shape().toIntArray()
get() = ndArray.shape().toIntArray()
internal abstract fun elementsIterator(): Iterator<Pair<IntArray, T>> internal abstract fun elementsIterator(): Iterator<Pair<IntArray, T>>
internal fun indicesIterator(): Iterator<IntArray> = ndArray.indicesIterator() internal fun indicesIterator(): Iterator<IntArray> = ndArray.indicesIterator()