From 3bbb39f30d423e0889133befa9db2d4b7cb07677 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 24 Jan 2021 10:26:56 +0300 Subject: [PATCH] cleanup parallel field example --- .../kscience/kmath/structures/ParallelRealNDField.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/src/main/kotlin/kscience/kmath/structures/ParallelRealNDField.kt b/examples/src/main/kotlin/kscience/kmath/structures/ParallelRealNDField.kt index bce625f7f..e13f5dd47 100644 --- a/examples/src/main/kotlin/kscience/kmath/structures/ParallelRealNDField.kt +++ b/examples/src/main/kotlin/kscience/kmath/structures/ParallelRealNDField.kt @@ -12,12 +12,14 @@ import java.util.stream.IntStream * A demonstration implementation of NDField over Real using Java [DoubleStream] for parallel execution */ @OptIn(UnstableKMathAPI::class) -public class StreamRealNDField( - shape: IntArray, -) : BufferedNDField(shape, RealField, Buffer.Companion::real), +class StreamRealNDField( + override val shape: IntArray, +) : NDField, RingWithNumbers>, ExtendedField> { + private val strides = DefaultStrides(shape) + override val elementContext: RealField get() = RealField override val zero: NDBuffer by lazy { produce { zero } } override val one: NDBuffer by lazy { produce { one } } @@ -26,7 +28,7 @@ public class StreamRealNDField( return produce { d } } - override val NDStructure.buffer: RealBuffer + private val NDStructure.buffer: RealBuffer get() = when { !shape.contentEquals(this@StreamRealNDField.shape) -> throw ShapeMismatchException( this@StreamRealNDField.shape,