Refactor/ndalgebra #197

Merged
altavir merged 11 commits from refactor/ndalgebra into dev 2021-01-28 20:13:39 +03:00
Showing only changes of commit 3bbb39f30d - Show all commits

View File

@ -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,