forked from kscience/kmath
cleanup parallel field example
This commit is contained in:
parent
9829a16a32
commit
3bbb39f30d
@ -12,12 +12,14 @@ import java.util.stream.IntStream
|
|||||||
* A demonstration implementation of NDField over Real using Java [DoubleStream] for parallel execution
|
* A demonstration implementation of NDField over Real using Java [DoubleStream] for parallel execution
|
||||||
*/
|
*/
|
||||||
@OptIn(UnstableKMathAPI::class)
|
@OptIn(UnstableKMathAPI::class)
|
||||||
public class StreamRealNDField(
|
class StreamRealNDField(
|
||||||
shape: IntArray,
|
override val shape: IntArray,
|
||||||
) : BufferedNDField<Double, RealField>(shape, RealField, Buffer.Companion::real),
|
) : NDField<Double, RealField>,
|
||||||
RingWithNumbers<NDStructure<Double>>,
|
RingWithNumbers<NDStructure<Double>>,
|
||||||
ExtendedField<NDStructure<Double>> {
|
ExtendedField<NDStructure<Double>> {
|
||||||
|
|
||||||
|
private val strides = DefaultStrides(shape)
|
||||||
|
override val elementContext: RealField get() = RealField
|
||||||
override val zero: NDBuffer<Double> by lazy { produce { zero } }
|
override val zero: NDBuffer<Double> by lazy { produce { zero } }
|
||||||
override val one: NDBuffer<Double> by lazy { produce { one } }
|
override val one: NDBuffer<Double> by lazy { produce { one } }
|
||||||
|
|
||||||
@ -26,7 +28,7 @@ public class StreamRealNDField(
|
|||||||
return produce { d }
|
return produce { d }
|
||||||
}
|
}
|
||||||
|
|
||||||
override val NDStructure<Double>.buffer: RealBuffer
|
private val NDStructure<Double>.buffer: RealBuffer
|
||||||
get() = when {
|
get() = when {
|
||||||
!shape.contentEquals(this@StreamRealNDField.shape) -> throw ShapeMismatchException(
|
!shape.contentEquals(this@StreamRealNDField.shape) -> throw ShapeMismatchException(
|
||||||
this@StreamRealNDField.shape,
|
this@StreamRealNDField.shape,
|
||||||
|
Loading…
Reference in New Issue
Block a user