From 05f742452d4ea7c707a9581160aae721d7402dd6 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 16 Mar 2021 20:56:20 +0300 Subject: [PATCH] Structure naming change --- .github/workflows/publish.yml | 2 +- CHANGELOG.md | 2 + docs/images/KM.svg | 29 +- docs/images/KM_mono.svg | 44 +- docs/images/KMath.svg | 47 +- docs/images/KMath_mono.svg | 239 +++++---- examples/build.gradle.kts | 2 +- .../kmath/benchmarks/NDFieldBenchmark.kt | 12 +- .../kmath/benchmarks/ViktorBenchmark.kt | 12 +- .../kmath/benchmarks/ViktorLogBenchmark.kt | 10 +- .../kmath/commons/fit/fitWithAutoDiff.kt | 4 +- .../kscience/kmath/operations/ComplexDemo.kt | 6 +- .../kscience/kmath/structures/ComplexND.kt | 12 +- .../kscience/kmath/structures/NDField.kt | 22 +- .../kmath/structures/ParallelRealNDField.kt | 60 +-- .../structures/StructureWriteBenchmark.kt | 4 +- .../space/kscience/kmath/ast/MstAlgebra.kt | 2 +- .../estree/TestESTreeOperationsSupport.kt | 4 +- .../kmath/asm/internal/codegenUtils.kt | 2 +- .../kmath/asm/TestAsmOperationsSupport.kt | 4 +- kmath-commons/build.gradle.kts | 2 +- .../kmath/commons/integration/CMIntegrator.kt | 8 +- .../kscience/kmath/commons/linear/CMMatrix.kt | 6 +- .../kscience/kmath/commons/linear/CMSolver.kt | 8 +- .../commons/transform/Transformations.kt | 16 +- .../DerivativeStructureExpressionTest.kt | 4 +- .../{ComplexNDField.kt => ComplexFieldND.kt} | 52 +- .../kscience/kmath/complex/Quaternion.kt | 2 +- kmath-core/api/kmath-core.api | 504 +++++++++--------- .../kmath/linear/BufferedLinearSpace.kt | 2 +- .../kscience/kmath/linear/VirtualMatrix.kt | 6 +- .../kmath/nd/{NDAlgebra.kt => AlgebraND.kt} | 60 +-- ...{BufferNDAlgebra.kt => BufferAlgebraND.kt} | 64 +-- .../nd/{RealNDField.kt => RealFieldND.kt} | 64 +-- .../nd/{ShortNDRing.kt => ShortRingND.kt} | 12 +- .../space/kscience/kmath/nd/Structure1D.kt | 8 +- .../space/kscience/kmath/nd/Structure2D.kt | 12 +- .../nd/{NDStructure.kt => StructureND.kt} | 30 +- .../space/kscience/kmath/operations/BigInt.kt | 8 +- .../kmath/structures/BufferAccessor2D.kt | 4 +- .../space/kscience/kmath/linear/MatrixTest.kt | 6 +- .../kscience/kmath/structures/NDFieldTest.kt | 6 +- .../kmath/structures/NumberNDFieldTest.kt | 8 +- kmath-coroutines/build.gradle.kts | 2 +- .../space/kscience/kmath/chains/Chain.kt | 4 +- .../kmath/coroutines/coroutinesExtra.kt | 6 +- .../kscience/kmath/streaming/RingBuffer.kt | 2 +- ...{LazyNDStructure.kt => LazyStructureND.kt} | 30 +- kmath-dimensions/build.gradle.kts | 2 +- .../kscience/kmath/dimensions/Wrappers.kt | 14 +- kmath-ejml/build.gradle.kts | 2 +- .../space/kscience/kmath/ejml/EjmlMatrix.kt | 6 +- .../kotlin/space/kscience/kmath/real/dot.kt | 2 +- .../kotlin/kaceince/kmath/real/GridTest.kt | 2 +- kmath-functions/build.gradle.kts | 8 +- .../kscience/kmath/integration/Integrand.kt | 1 + .../kscience/kmath/integration/Integrator.kt | 2 +- .../kmath/interpolation/Interpolator.kt | 6 +- .../kmath/interpolation/XYPointSet.kt | 2 +- kmath-geometry/build.gradle.kts | 2 +- .../space/kscience/kmath/histogram/Counter.kt | 3 +- .../kscience/kmath/histogram/Histogram.kt | 2 +- .../kmath/histogram/IndexedHistogramSpace.kt | 8 +- .../kmath/histogram/RealHistogramSpace.kt | 6 +- .../histogram/MultivariateHistogramTest.kt | 2 +- .../kmath/histogram/UnivariateHistogram.kt | 3 +- kmath-kotlingrad/build.gradle.kts | 2 +- kmath-memory/build.gradle.kts | 2 +- .../space/kscience/kmath/memory/MemorySpec.kt | 3 +- .../kscience/kmath/memory/ByteBufferMemory.kt | 5 +- .../kscience/kmath/memory/NativeMemory.kt | 2 +- .../kscience/kmath/nd4j/Nd4jArrayAlgebra.kt | 106 ++-- .../kscience/kmath/nd4j/Nd4jArrayStructure.kt | 4 +- .../kmath/nd4j/Nd4jArrayAlgebraTest.kt | 2 +- .../kmath/nd4j/Nd4jArrayStructureTest.kt | 6 +- kmath-stat/build.gradle.kts | 2 +- .../space/kscience/kmath/stat/Distribution.kt | 2 +- .../kmath/stat/OptimizationProblem.kt | 4 +- .../space/kscience/kmath/stat/RandomChain.kt | 2 +- .../kscience/kmath/stat/distributions.kt | 4 +- kmath-viktor/api/kmath-viktor.api | 148 ++--- kmath-viktor/build.gradle.kts | 2 +- .../kmath/viktor/ViktorNDStructure.kt | 123 ----- .../kmath/viktor/ViktorStructureND.kt | 123 +++++ 84 files changed, 1060 insertions(+), 1010 deletions(-) rename kmath-complex/src/commonMain/kotlin/space/kscience/kmath/complex/{ComplexNDField.kt => ComplexFieldND.kt} (69%) rename kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/{NDAlgebra.kt => AlgebraND.kt} (75%) rename kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/{BufferNDAlgebra.kt => BufferAlgebraND.kt} (60%) rename kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/{RealNDField.kt => RealFieldND.kt} (61%) rename kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/{ShortNDRing.kt => ShortRingND.kt} (80%) rename kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/{NDStructure.kt => StructureND.kt} (92%) rename kmath-coroutines/src/jvmMain/kotlin/space/kscience/kmath/structures/{LazyNDStructure.kt => LazyStructureND.kt} (62%) delete mode 100644 kmath-viktor/src/main/kotlin/space/kscience/kmath/viktor/ViktorNDStructure.kt create mode 100644 kmath-viktor/src/main/kotlin/space/kscience/kmath/viktor/ViktorStructureND.kt diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 42fa6d3b6..ca374574e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,7 +12,7 @@ jobs: name: publish strategy: matrix: - os: [macOS-latest, windows-latest] + os: [ macOS-latest, windows-latest ] runs-on: ${{matrix.os}} steps: - name: Checkout the repo diff --git a/CHANGELOG.md b/CHANGELOG.md index eb97698c6..17486bd2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,14 @@ ### Added - ScaleOperations interface - Field extends ScaleOperations +- Basic integration API ### Changed - Exponential operations merged with hyperbolic functions - Space is replaced by Group. Space is reserved for vector spaces. - VectorSpace is now a vector space - Buffer factories for primitives moved to MutableBuffer.Companion +- NDStructure and NDAlgebra to StructureND and AlgebraND respectively ### Deprecated diff --git a/docs/images/KM.svg b/docs/images/KM.svg index 50126cbc5..83af21f35 100644 --- a/docs/images/KM.svg +++ b/docs/images/KM.svg @@ -13,27 +13,30 @@ version="1.1">image/svg+xml + + + image/svg+xml + + image/svg+xml + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + { kotlinOptions.jvmTarget = "11" } -readme{ +readme { maturity = ru.mipt.npm.gradle.Maturity.EXPERIMENTAL } diff --git a/examples/src/benchmarks/kotlin/space/kscience/kmath/benchmarks/NDFieldBenchmark.kt b/examples/src/benchmarks/kotlin/space/kscience/kmath/benchmarks/NDFieldBenchmark.kt index aeee0dafe..e381a1559 100644 --- a/examples/src/benchmarks/kotlin/space/kscience/kmath/benchmarks/NDFieldBenchmark.kt +++ b/examples/src/benchmarks/kotlin/space/kscience/kmath/benchmarks/NDFieldBenchmark.kt @@ -13,7 +13,7 @@ internal class NDFieldBenchmark { @Benchmark fun autoFieldAdd(blackhole: Blackhole) { with(autoField) { - var res: NDStructure = one + var res: StructureND = one repeat(n) { res += one } blackhole.consume(res) } @@ -22,7 +22,7 @@ internal class NDFieldBenchmark { @Benchmark fun specializedFieldAdd(blackhole: Blackhole) { with(specializedField) { - var res: NDStructure = one + var res: StructureND = one repeat(n) { res += 1.0 } blackhole.consume(res) } @@ -32,7 +32,7 @@ internal class NDFieldBenchmark { @Benchmark fun boxingFieldAdd(blackhole: Blackhole) { with(genericField) { - var res: NDStructure = one + var res: StructureND = one repeat(n) { res += 1.0 } blackhole.consume(res) } @@ -41,8 +41,8 @@ internal class NDFieldBenchmark { private companion object { private const val dim = 1000 private const val n = 100 - private val autoField = NDAlgebra.auto(RealField, dim, dim) - private val specializedField = NDAlgebra.real(dim, dim) - private val genericField = NDAlgebra.field(RealField, Buffer.Companion::boxing, dim, dim) + private val autoField = AlgebraND.auto(RealField, dim, dim) + private val specializedField = AlgebraND.real(dim, dim) + private val genericField = AlgebraND.field(RealField, Buffer.Companion::boxing, dim, dim) } } diff --git a/examples/src/benchmarks/kotlin/space/kscience/kmath/benchmarks/ViktorBenchmark.kt b/examples/src/benchmarks/kotlin/space/kscience/kmath/benchmarks/ViktorBenchmark.kt index c511173a9..21c29affd 100644 --- a/examples/src/benchmarks/kotlin/space/kscience/kmath/benchmarks/ViktorBenchmark.kt +++ b/examples/src/benchmarks/kotlin/space/kscience/kmath/benchmarks/ViktorBenchmark.kt @@ -5,8 +5,8 @@ import kotlinx.benchmark.Blackhole import kotlinx.benchmark.Scope import kotlinx.benchmark.State import org.jetbrains.bio.viktor.F64Array -import space.kscience.kmath.nd.NDAlgebra -import space.kscience.kmath.nd.NDStructure +import space.kscience.kmath.nd.AlgebraND +import space.kscience.kmath.nd.StructureND import space.kscience.kmath.nd.auto import space.kscience.kmath.nd.real import space.kscience.kmath.operations.RealField @@ -17,7 +17,7 @@ internal class ViktorBenchmark { @Benchmark fun automaticFieldAddition(blackhole: Blackhole) { with(autoField) { - var res: NDStructure = one + var res: StructureND = one repeat(n) { res += 1.0 } blackhole.consume(res) } @@ -26,7 +26,7 @@ internal class ViktorBenchmark { @Benchmark fun realFieldAddition(blackhole: Blackhole) { with(realField) { - var res: NDStructure = one + var res: StructureND = one repeat(n) { res += 1.0 } blackhole.consume(res) } @@ -54,8 +54,8 @@ internal class ViktorBenchmark { private const val n = 100 // automatically build context most suited for given type. - private val autoField = NDAlgebra.auto(RealField, dim, dim) - private val realField = NDAlgebra.real(dim, dim) + private val autoField = AlgebraND.auto(RealField, dim, dim) + private val realField = AlgebraND.real(dim, dim) private val viktorField = ViktorNDField(dim, dim) } } diff --git a/examples/src/benchmarks/kotlin/space/kscience/kmath/benchmarks/ViktorLogBenchmark.kt b/examples/src/benchmarks/kotlin/space/kscience/kmath/benchmarks/ViktorLogBenchmark.kt index 0036b615c..e964f9bff 100644 --- a/examples/src/benchmarks/kotlin/space/kscience/kmath/benchmarks/ViktorLogBenchmark.kt +++ b/examples/src/benchmarks/kotlin/space/kscience/kmath/benchmarks/ViktorLogBenchmark.kt @@ -5,11 +5,11 @@ import kotlinx.benchmark.Blackhole import kotlinx.benchmark.Scope import kotlinx.benchmark.State import org.jetbrains.bio.viktor.F64Array -import space.kscience.kmath.nd.NDAlgebra +import space.kscience.kmath.nd.AlgebraND import space.kscience.kmath.nd.auto import space.kscience.kmath.nd.real import space.kscience.kmath.operations.RealField -import space.kscience.kmath.viktor.ViktorNDField +import space.kscience.kmath.viktor.ViktorFieldND @State(Scope.Benchmark) internal class ViktorLogBenchmark { @@ -46,8 +46,8 @@ internal class ViktorLogBenchmark { private const val n = 100 // automatically build context most suited for given type. - private val autoField = NDAlgebra.auto(RealField, dim, dim) - private val realNdField = NDAlgebra.real(dim, dim) - private val viktorField = ViktorNDField(intArrayOf(dim, dim)) + private val autoField = AlgebraND.auto(RealField, dim, dim) + private val realNdField = AlgebraND.real(dim, dim) + private val viktorField = ViktorFieldND(intArrayOf(dim, dim)) } } diff --git a/examples/src/main/kotlin/space/kscience/kmath/commons/fit/fitWithAutoDiff.kt b/examples/src/main/kotlin/space/kscience/kmath/commons/fit/fitWithAutoDiff.kt index 63b819dc9..c26fb34e9 100644 --- a/examples/src/main/kotlin/space/kscience/kmath/commons/fit/fitWithAutoDiff.kt +++ b/examples/src/main/kotlin/space/kscience/kmath/commons/fit/fitWithAutoDiff.kt @@ -90,10 +90,10 @@ fun main() { } } br() - h3{ + h3 { +"Fit result: $result" } - h3{ + h3 { +"Chi2/dof = ${result.value / (x.size - 3)}" } } diff --git a/examples/src/main/kotlin/space/kscience/kmath/operations/ComplexDemo.kt b/examples/src/main/kotlin/space/kscience/kmath/operations/ComplexDemo.kt index 5330d9e40..105fb108e 100644 --- a/examples/src/main/kotlin/space/kscience/kmath/operations/ComplexDemo.kt +++ b/examples/src/main/kotlin/space/kscience/kmath/operations/ComplexDemo.kt @@ -2,17 +2,17 @@ package space.kscience.kmath.operations import space.kscience.kmath.complex.Complex import space.kscience.kmath.complex.complex -import space.kscience.kmath.nd.NDAlgebra +import space.kscience.kmath.nd.AlgebraND fun main() { // 2d element - val element = NDAlgebra.complex(2, 2).produce { (i, j) -> + val element = AlgebraND.complex(2, 2).produce { (i, j) -> Complex(i.toDouble() - j.toDouble(), i.toDouble() + j.toDouble()) } println(element) // 1d element operation - val result = with(NDAlgebra.complex(8)) { + val result = with(AlgebraND.complex(8)) { val a = produce { (it) -> i * it - it.toDouble() } val b = 3 val c = Complex(1.0, 1.0) diff --git a/examples/src/main/kotlin/space/kscience/kmath/structures/ComplexND.kt b/examples/src/main/kotlin/space/kscience/kmath/structures/ComplexND.kt index b8cbc9a57..68af2560b 100644 --- a/examples/src/main/kotlin/space/kscience/kmath/structures/ComplexND.kt +++ b/examples/src/main/kotlin/space/kscience/kmath/structures/ComplexND.kt @@ -4,8 +4,8 @@ package space.kscience.kmath.structures import space.kscience.kmath.complex.* import space.kscience.kmath.linear.transpose -import space.kscience.kmath.nd.NDAlgebra -import space.kscience.kmath.nd.NDStructure +import space.kscience.kmath.nd.AlgebraND +import space.kscience.kmath.nd.StructureND import space.kscience.kmath.nd.as2D import space.kscience.kmath.nd.real import space.kscience.kmath.operations.invoke @@ -15,12 +15,12 @@ fun main() { val dim = 1000 val n = 1000 - val realField = NDAlgebra.real(dim, dim) - val complexField: ComplexNDField = NDAlgebra.complex(dim, dim) + val realField = AlgebraND.real(dim, dim) + val complexField: ComplexFieldND = AlgebraND.complex(dim, dim) val realTime = measureTimeMillis { realField { - var res: NDStructure = one + var res: StructureND = one repeat(n) { res += 1.0 } @@ -31,7 +31,7 @@ fun main() { val complexTime = measureTimeMillis { complexField { - var res: NDStructure = one + var res: StructureND = one repeat(n) { res += 1.0 } diff --git a/examples/src/main/kotlin/space/kscience/kmath/structures/NDField.kt b/examples/src/main/kotlin/space/kscience/kmath/structures/NDField.kt index 10fb3cb3d..b884251c4 100644 --- a/examples/src/main/kotlin/space/kscience/kmath/structures/NDField.kt +++ b/examples/src/main/kotlin/space/kscience/kmath/structures/NDField.kt @@ -24,56 +24,56 @@ fun main() { val n = 1000 // automatically build context most suited for given type. - val autoField = NDAlgebra.auto(RealField, dim, dim) + val autoField = AlgebraND.auto(RealField, dim, dim) // specialized nd-field for Double. It works as generic Double field as well - val realField = NDAlgebra.real(dim, dim) + val realField = AlgebraND.real(dim, dim) //A generic boxing field. It should be used for objects, not primitives. - val boxingField = NDAlgebra.field(RealField, Buffer.Companion::boxing, dim, dim) + val boxingField = AlgebraND.field(RealField, Buffer.Companion::boxing, dim, dim) // Nd4j specialized field. val nd4jField = Nd4jArrayField.real(dim, dim) //viktor field - val viktorField = ViktorNDField(dim,dim) + val viktorField = ViktorNDField(dim, dim) //parallel processing based on Java Streams - val parallelField = NDAlgebra.realWithStream(dim,dim) + val parallelField = AlgebraND.realWithStream(dim, dim) measureAndPrint("Boxing addition") { boxingField { - var res: NDStructure = one + var res: StructureND = one repeat(n) { res += 1.0 } } } measureAndPrint("Specialized addition") { realField { - var res: NDStructure = one + var res: StructureND = one repeat(n) { res += 1.0 } } } measureAndPrint("Nd4j specialized addition") { nd4jField { - var res: NDStructure = one + var res: StructureND = one repeat(n) { res += 1.0 } } } measureAndPrint("Viktor addition") { viktorField { - var res: NDStructure = one + var res: StructureND = one repeat(n) { res += 1.0 } } } measureAndPrint("Parallel stream addition") { parallelField { - var res: NDStructure = one + var res: StructureND = one repeat(n) { res += 1.0 } } } measureAndPrint("Automatic field addition") { autoField { - var res: NDStructure = one + var res: StructureND = one repeat(n) { res += 1.0 } } } diff --git a/examples/src/main/kotlin/space/kscience/kmath/structures/ParallelRealNDField.kt b/examples/src/main/kotlin/space/kscience/kmath/structures/ParallelRealNDField.kt index 0c914468d..8b3c5dfbb 100644 --- a/examples/src/main/kotlin/space/kscience/kmath/structures/ParallelRealNDField.kt +++ b/examples/src/main/kotlin/space/kscience/kmath/structures/ParallelRealNDField.kt @@ -12,11 +12,11 @@ import java.util.stream.IntStream * A demonstration implementation of NDField over Real using Java [DoubleStream] for parallel execution */ @OptIn(UnstableKMathAPI::class) -class StreamRealNDField( +class StreamRealFieldND( override val shape: IntArray, -) : NDField, - NumbersAddOperations>, - ExtendedField> { +) : FieldND, + NumbersAddOperations>, + ExtendedField> { private val strides = DefaultStrides(shape) override val elementContext: RealField get() = RealField @@ -28,13 +28,13 @@ class StreamRealNDField( return produce { d } } - private val NDStructure.buffer: RealBuffer + private val StructureND.buffer: RealBuffer get() = when { - !shape.contentEquals(this@StreamRealNDField.shape) -> throw ShapeMismatchException( - this@StreamRealNDField.shape, + !shape.contentEquals(this@StreamRealFieldND.shape) -> throw ShapeMismatchException( + this@StreamRealFieldND.shape, shape ) - this is NDBuffer && this.strides == this@StreamRealNDField.strides -> this.buffer as RealBuffer + this is NDBuffer && this.strides == this@StreamRealFieldND.strides -> this.buffer as RealBuffer else -> RealBuffer(strides.linearSize) { offset -> get(strides.index(offset)) } } @@ -48,14 +48,14 @@ class StreamRealNDField( return NDBuffer(strides, array.asBuffer()) } - override fun NDStructure.map( + override fun StructureND.map( transform: RealField.(Double) -> Double, ): NDBuffer { val array = Arrays.stream(buffer.array).parallel().map { RealField.transform(it) }.toArray() return NDBuffer(strides, array.asBuffer()) } - override fun NDStructure.mapIndexed( + override fun StructureND.mapIndexed( transform: RealField.(index: IntArray, Double) -> Double, ): NDBuffer { val array = IntStream.range(0, strides.linearSize).parallel().mapToDouble { offset -> @@ -69,8 +69,8 @@ class StreamRealNDField( } override fun combine( - a: NDStructure, - b: NDStructure, + a: StructureND, + b: StructureND, transform: RealField.(Double, Double) -> Double, ): NDBuffer { val array = IntStream.range(0, strides.linearSize).parallel().mapToDouble { offset -> @@ -79,29 +79,29 @@ class StreamRealNDField( return NDBuffer(strides, array.asBuffer()) } - override fun NDStructure.unaryMinus(): NDStructure = map { -it } + override fun StructureND.unaryMinus(): StructureND = map { -it } - override fun scale(a: NDStructure, value: Double): NDStructure = a.map { it * value } + override fun scale(a: StructureND, value: Double): StructureND = a.map { it * value } - override fun power(arg: NDStructure, pow: Number): NDBuffer = arg.map { power(it, pow) } + override fun power(arg: StructureND, pow: Number): NDBuffer = arg.map { power(it, pow) } - override fun exp(arg: NDStructure): NDBuffer = arg.map { exp(it) } + override fun exp(arg: StructureND): NDBuffer = arg.map { exp(it) } - override fun ln(arg: NDStructure): NDBuffer = arg.map { ln(it) } + override fun ln(arg: StructureND): NDBuffer = arg.map { ln(it) } - override fun sin(arg: NDStructure): NDBuffer = arg.map { sin(it) } - override fun cos(arg: NDStructure): NDBuffer = arg.map { cos(it) } - override fun tan(arg: NDStructure): NDBuffer = arg.map { tan(it) } - override fun asin(arg: NDStructure): NDBuffer = arg.map { asin(it) } - override fun acos(arg: NDStructure): NDBuffer = arg.map { acos(it) } - override fun atan(arg: NDStructure): NDBuffer = arg.map { atan(it) } + override fun sin(arg: StructureND): NDBuffer = arg.map { sin(it) } + override fun cos(arg: StructureND): NDBuffer = arg.map { cos(it) } + override fun tan(arg: StructureND): NDBuffer = arg.map { tan(it) } + override fun asin(arg: StructureND): NDBuffer = arg.map { asin(it) } + override fun acos(arg: StructureND): NDBuffer = arg.map { acos(it) } + override fun atan(arg: StructureND): NDBuffer = arg.map { atan(it) } - override fun sinh(arg: NDStructure): NDBuffer = arg.map { sinh(it) } - override fun cosh(arg: NDStructure): NDBuffer = arg.map { cosh(it) } - override fun tanh(arg: NDStructure): NDBuffer = arg.map { tanh(it) } - override fun asinh(arg: NDStructure): NDBuffer = arg.map { asinh(it) } - override fun acosh(arg: NDStructure): NDBuffer = arg.map { acosh(it) } - override fun atanh(arg: NDStructure): NDBuffer = arg.map { atanh(it) } + override fun sinh(arg: StructureND): NDBuffer = arg.map { sinh(it) } + override fun cosh(arg: StructureND): NDBuffer = arg.map { cosh(it) } + override fun tanh(arg: StructureND): NDBuffer = arg.map { tanh(it) } + override fun asinh(arg: StructureND): NDBuffer = arg.map { asinh(it) } + override fun acosh(arg: StructureND): NDBuffer = arg.map { acosh(it) } + override fun atanh(arg: StructureND): NDBuffer = arg.map { atanh(it) } } -fun NDAlgebra.Companion.realWithStream(vararg shape: Int): StreamRealNDField = StreamRealNDField(shape) \ No newline at end of file +fun AlgebraND.Companion.realWithStream(vararg shape: Int): StreamRealFieldND = StreamRealFieldND(shape) \ No newline at end of file diff --git a/examples/src/main/kotlin/space/kscience/kmath/structures/StructureWriteBenchmark.kt b/examples/src/main/kotlin/space/kscience/kmath/structures/StructureWriteBenchmark.kt index 66d85edff..7aa5a07fd 100644 --- a/examples/src/main/kotlin/space/kscience/kmath/structures/StructureWriteBenchmark.kt +++ b/examples/src/main/kotlin/space/kscience/kmath/structures/StructureWriteBenchmark.kt @@ -1,13 +1,13 @@ package space.kscience.kmath.structures -import space.kscience.kmath.nd.NDStructure +import space.kscience.kmath.nd.StructureND import space.kscience.kmath.nd.mapToBuffer import kotlin.system.measureTimeMillis @Suppress("UNUSED_VARIABLE") fun main() { val n = 6000 - val structure = NDStructure.buffered(intArrayOf(n, n), Buffer.Companion::auto) { 1.0 } + val structure = StructureND.buffered(intArrayOf(n, n), Buffer.Companion::auto) { 1.0 } structure.mapToBuffer { it + 1 } // warm-up val time1 = measureTimeMillis { val res = structure.mapToBuffer { it + 1 } } println("Structure mapping finished in $time1 millis") diff --git a/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/MstAlgebra.kt b/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/MstAlgebra.kt index 5ed39687b..c1aeae90e 100644 --- a/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/MstAlgebra.kt +++ b/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/MstAlgebra.kt @@ -50,7 +50,7 @@ public object MstGroup : Group, NumericAlgebra, ScaleOperations { */ @OptIn(UnstableKMathAPI::class) public object MstRing : Ring, NumbersAddOperations, ScaleOperations { - public override val zero: MST.Numeric get() = MstGroup.zero + public override val zero: MST.Numeric get() = MstGroup.zero public override val one: MST.Numeric = number(1.0) public override fun number(value: Number): MST.Numeric = MstGroup.number(value) diff --git a/kmath-ast/src/jsTest/kotlin/space/kscience/kmath/estree/TestESTreeOperationsSupport.kt b/kmath-ast/src/jsTest/kotlin/space/kscience/kmath/estree/TestESTreeOperationsSupport.kt index 27bf2f167..590d0957d 100644 --- a/kmath-ast/src/jsTest/kotlin/space/kscience/kmath/estree/TestESTreeOperationsSupport.kt +++ b/kmath-ast/src/jsTest/kotlin/space/kscience/kmath/estree/TestESTreeOperationsSupport.kt @@ -32,7 +32,9 @@ internal class TestESTreeOperationsSupport { @Test fun testMultipleCalls() { - val e = RealField.mstInExtendedField { sin(bindSymbol("x")).pow(4) - 6 * bindSymbol("x") / tanh(bindSymbol("x")) }.compile() + val e = + RealField.mstInExtendedField { sin(bindSymbol("x")).pow(4) - 6 * bindSymbol("x") / tanh(bindSymbol("x")) } + .compile() val r = Random(0) var s = 0.0 repeat(1000000) { s += e("x" to r.nextDouble()) } diff --git a/kmath-ast/src/jvmMain/kotlin/space/kscience/kmath/asm/internal/codegenUtils.kt b/kmath-ast/src/jvmMain/kotlin/space/kscience/kmath/asm/internal/codegenUtils.kt index 1124a860f..4522c966f 100644 --- a/kmath-ast/src/jvmMain/kotlin/space/kscience/kmath/asm/internal/codegenUtils.kt +++ b/kmath-ast/src/jvmMain/kotlin/space/kscience/kmath/asm/internal/codegenUtils.kt @@ -86,7 +86,7 @@ internal inline fun ClassWriter.visitField( descriptor: String, signature: String?, value: Any?, - block: FieldVisitor.() -> Unit + block: FieldVisitor.() -> Unit, ): FieldVisitor { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return visitField(access, name, descriptor, signature, value).apply(block) diff --git a/kmath-ast/src/jvmTest/kotlin/space/kscience/kmath/asm/TestAsmOperationsSupport.kt b/kmath-ast/src/jvmTest/kotlin/space/kscience/kmath/asm/TestAsmOperationsSupport.kt index e99075f07..7047c824c 100644 --- a/kmath-ast/src/jvmTest/kotlin/space/kscience/kmath/asm/TestAsmOperationsSupport.kt +++ b/kmath-ast/src/jvmTest/kotlin/space/kscience/kmath/asm/TestAsmOperationsSupport.kt @@ -32,7 +32,9 @@ internal class TestAsmOperationsSupport { @Test fun testMultipleCalls() { - val e = RealField.mstInExtendedField { sin(bindSymbol("x")).pow(4) - 6 * bindSymbol("x") / tanh(bindSymbol("x")) }.compile() + val e = + RealField.mstInExtendedField { sin(bindSymbol("x")).pow(4) - 6 * bindSymbol("x") / tanh(bindSymbol("x")) } + .compile() val r = Random(0) var s = 0.0 repeat(1000000) { s += e("x" to r.nextDouble()) } diff --git a/kmath-commons/build.gradle.kts b/kmath-commons/build.gradle.kts index 4fe16605a..56dcef29a 100644 --- a/kmath-commons/build.gradle.kts +++ b/kmath-commons/build.gradle.kts @@ -12,6 +12,6 @@ dependencies { api("org.apache.commons:commons-math3:3.6.1") } -readme{ +readme { maturity = ru.mipt.npm.gradle.Maturity.EXPERIMENTAL } \ No newline at end of file diff --git a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/integration/CMIntegrator.kt b/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/integration/CMIntegrator.kt index 8511ed66e..e1ba7d777 100644 --- a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/integration/CMIntegrator.kt +++ b/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/integration/CMIntegrator.kt @@ -80,13 +80,13 @@ public class CMIntegrator( @UnstableKMathAPI public var MutableList.targetAbsoluteAccuracy: Double? get() = filterIsInstance().lastOrNull()?.value - set(value){ - value?.let { add(CMIntegrator.TargetAbsoluteAccuracy(value))} + set(value) { + value?.let { add(CMIntegrator.TargetAbsoluteAccuracy(value)) } } @UnstableKMathAPI public var MutableList.targetRelativeAccuracy: Double? get() = filterIsInstance().lastOrNull()?.value - set(value){ - value?.let { add(CMIntegrator.TargetRelativeAccuracy(value))} + set(value) { + value?.let { add(CMIntegrator.TargetRelativeAccuracy(value)) } } \ No newline at end of file diff --git a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/linear/CMMatrix.kt b/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/linear/CMMatrix.kt index 4671598f7..4e3a44a83 100644 --- a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/linear/CMMatrix.kt +++ b/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/linear/CMMatrix.kt @@ -3,7 +3,7 @@ package space.kscience.kmath.commons.linear import org.apache.commons.math3.linear.* import space.kscience.kmath.linear.* import space.kscience.kmath.misc.UnstableKMathAPI -import space.kscience.kmath.nd.NDStructure +import space.kscience.kmath.nd.StructureND import space.kscience.kmath.operations.RealField import space.kscience.kmath.structures.RealBuffer import kotlin.reflect.KClass @@ -17,8 +17,8 @@ public class CMMatrix(public val origin: RealMatrix) : Matrix { override fun equals(other: Any?): Boolean { if (this === other) return true - if (other !is NDStructure<*>) return false - return NDStructure.contentEquals(this, other) + if (other !is StructureND<*>) return false + return StructureND.contentEquals(this, other) } override fun hashCode(): Int = origin.hashCode() diff --git a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/linear/CMSolver.kt b/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/linear/CMSolver.kt index b5fd0154e..b4706473a 100644 --- a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/linear/CMSolver.kt +++ b/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/linear/CMSolver.kt @@ -14,7 +14,7 @@ public enum class CMDecomposition { public fun CMLinearSpace.solver( a: Matrix, - decomposition: CMDecomposition = CMDecomposition.LUP + decomposition: CMDecomposition = CMDecomposition.LUP, ): DecompositionSolver = when (decomposition) { CMDecomposition.LUP -> LUDecomposition(a.toCM().origin).solver CMDecomposition.RRQR -> RRQRDecomposition(a.toCM().origin).solver @@ -26,16 +26,16 @@ public fun CMLinearSpace.solver( public fun CMLinearSpace.solve( a: Matrix, b: Matrix, - decomposition: CMDecomposition = CMDecomposition.LUP + decomposition: CMDecomposition = CMDecomposition.LUP, ): CMMatrix = solver(a, decomposition).solve(b.toCM().origin).wrap() public fun CMLinearSpace.solve( a: Matrix, b: Point, - decomposition: CMDecomposition = CMDecomposition.LUP + decomposition: CMDecomposition = CMDecomposition.LUP, ): CMVector = solver(a, decomposition).solve(b.toCM().origin).toPoint() public fun CMLinearSpace.inverse( a: Matrix, - decomposition: CMDecomposition = CMDecomposition.LUP + decomposition: CMDecomposition = CMDecomposition.LUP, ): CMMatrix = solver(a, decomposition).inverse.wrap() diff --git a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/transform/Transformations.kt b/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/transform/Transformations.kt index e174a237f..aaee594ad 100644 --- a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/transform/Transformations.kt +++ b/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/transform/Transformations.kt @@ -33,34 +33,34 @@ public object Transformations { public fun fourier( normalization: DftNormalization = DftNormalization.STANDARD, - direction: TransformType = TransformType.FORWARD + direction: TransformType = TransformType.FORWARD, ): SuspendBufferTransform = { FastFourierTransformer(normalization).transform(it.toArray(), direction).asBuffer() } public fun realFourier( normalization: DftNormalization = DftNormalization.STANDARD, - direction: TransformType = TransformType.FORWARD + direction: TransformType = TransformType.FORWARD, ): SuspendBufferTransform = { FastFourierTransformer(normalization).transform(it.asArray(), direction).asBuffer() } public fun sine( normalization: DstNormalization = DstNormalization.STANDARD_DST_I, - direction: TransformType = TransformType.FORWARD + direction: TransformType = TransformType.FORWARD, ): SuspendBufferTransform = { FastSineTransformer(normalization).transform(it.asArray(), direction).asBuffer() } public fun cosine( normalization: DctNormalization = DctNormalization.STANDARD_DCT_I, - direction: TransformType = TransformType.FORWARD + direction: TransformType = TransformType.FORWARD, ): SuspendBufferTransform = { FastCosineTransformer(normalization).transform(it.asArray(), direction).asBuffer() } public fun hadamard( - direction: TransformType = TransformType.FORWARD + direction: TransformType = TransformType.FORWARD, ): SuspendBufferTransform = { FastHadamardTransformer().transform(it.asArray(), direction).asBuffer() } @@ -72,7 +72,7 @@ public object Transformations { @FlowPreview public fun Flow>.FFT( normalization: DftNormalization = DftNormalization.STANDARD, - direction: TransformType = TransformType.FORWARD + direction: TransformType = TransformType.FORWARD, ): Flow> { val transform = Transformations.fourier(normalization, direction) return map { transform(it) } @@ -82,7 +82,7 @@ public fun Flow>.FFT( @JvmName("realFFT") public fun Flow>.FFT( normalization: DftNormalization = DftNormalization.STANDARD, - direction: TransformType = TransformType.FORWARD + direction: TransformType = TransformType.FORWARD, ): Flow> { val transform = Transformations.realFourier(normalization, direction) return map(transform) @@ -96,7 +96,7 @@ public fun Flow>.FFT( public fun Flow.FFT( bufferSize: Int = Int.MAX_VALUE, normalization: DftNormalization = DftNormalization.STANDARD, - direction: TransformType = TransformType.FORWARD + direction: TransformType = TransformType.FORWARD, ): Flow = chunked(bufferSize).FFT(normalization, direction).spread() /** diff --git a/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/expressions/DerivativeStructureExpressionTest.kt b/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/expressions/DerivativeStructureExpressionTest.kt index 19b6e28da..8d9bab652 100644 --- a/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/expressions/DerivativeStructureExpressionTest.kt +++ b/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/expressions/DerivativeStructureExpressionTest.kt @@ -27,10 +27,10 @@ internal class AutoDiffTest { val y = bindSymbol("y") val z = x * (-sin(x * y) + y) + 2.0 println(z.derivative(x)) - println(z.derivative(y,x)) + println(z.derivative(y, x)) assertEquals(z.derivative(x, y), z.derivative(y, x)) //check that improper order cause failure - assertFails { z.derivative(x,x,y) } + assertFails { z.derivative(x, x, y) } } } diff --git a/kmath-complex/src/commonMain/kotlin/space/kscience/kmath/complex/ComplexNDField.kt b/kmath-complex/src/commonMain/kotlin/space/kscience/kmath/complex/ComplexFieldND.kt similarity index 69% rename from kmath-complex/src/commonMain/kotlin/space/kscience/kmath/complex/ComplexNDField.kt rename to kmath-complex/src/commonMain/kotlin/space/kscience/kmath/complex/ComplexFieldND.kt index 382659e10..382410e45 100644 --- a/kmath-complex/src/commonMain/kotlin/space/kscience/kmath/complex/ComplexNDField.kt +++ b/kmath-complex/src/commonMain/kotlin/space/kscience/kmath/complex/ComplexFieldND.kt @@ -1,10 +1,10 @@ package space.kscience.kmath.complex import space.kscience.kmath.misc.UnstableKMathAPI -import space.kscience.kmath.nd.BufferedNDField -import space.kscience.kmath.nd.NDAlgebra +import space.kscience.kmath.nd.AlgebraND +import space.kscience.kmath.nd.BufferedFieldND import space.kscience.kmath.nd.NDBuffer -import space.kscience.kmath.nd.NDStructure +import space.kscience.kmath.nd.StructureND import space.kscience.kmath.operations.ExtendedField import space.kscience.kmath.operations.NumbersAddOperations import space.kscience.kmath.structures.Buffer @@ -16,11 +16,11 @@ import kotlin.contracts.contract * An optimized nd-field for complex numbers */ @OptIn(UnstableKMathAPI::class) -public class ComplexNDField( +public class ComplexFieldND( shape: IntArray, -) : BufferedNDField(shape, ComplexField, Buffer.Companion::complex), - NumbersAddOperations>, - ExtendedField> { +) : BufferedFieldND(shape, ComplexField, Buffer.Companion::complex), + NumbersAddOperations>, + ExtendedField> { override val zero: NDBuffer by lazy { produce { zero } } override val one: NDBuffer by lazy { produce { one } } @@ -76,44 +76,44 @@ public class ComplexNDField( // return BufferedNDFieldElement(this, buffer) // } - override fun power(arg: NDStructure, pow: Number): NDBuffer = arg.map { power(it, pow) } + override fun power(arg: StructureND, pow: Number): NDBuffer = arg.map { power(it, pow) } - override fun exp(arg: NDStructure): NDBuffer = arg.map { exp(it) } + override fun exp(arg: StructureND): NDBuffer = arg.map { exp(it) } - override fun ln(arg: NDStructure): NDBuffer = arg.map { ln(it) } + override fun ln(arg: StructureND): NDBuffer = arg.map { ln(it) } - override fun sin(arg: NDStructure): NDBuffer = arg.map { sin(it) } - override fun cos(arg: NDStructure): NDBuffer = arg.map { cos(it) } - override fun tan(arg: NDStructure): NDBuffer = arg.map { tan(it) } - override fun asin(arg: NDStructure): NDBuffer = arg.map { asin(it) } - override fun acos(arg: NDStructure): NDBuffer = arg.map { acos(it) } - override fun atan(arg: NDStructure): NDBuffer = arg.map { atan(it) } + override fun sin(arg: StructureND): NDBuffer = arg.map { sin(it) } + override fun cos(arg: StructureND): NDBuffer = arg.map { cos(it) } + override fun tan(arg: StructureND): NDBuffer = arg.map { tan(it) } + override fun asin(arg: StructureND): NDBuffer = arg.map { asin(it) } + override fun acos(arg: StructureND): NDBuffer = arg.map { acos(it) } + override fun atan(arg: StructureND): NDBuffer = arg.map { atan(it) } - override fun sinh(arg: NDStructure): NDBuffer = arg.map { sinh(it) } - override fun cosh(arg: NDStructure): NDBuffer = arg.map { cosh(it) } - override fun tanh(arg: NDStructure): NDBuffer = arg.map { tanh(it) } - override fun asinh(arg: NDStructure): NDBuffer = arg.map { asinh(it) } - override fun acosh(arg: NDStructure): NDBuffer = arg.map { acosh(it) } - override fun atanh(arg: NDStructure): NDBuffer = arg.map { atanh(it) } + override fun sinh(arg: StructureND): NDBuffer = arg.map { sinh(it) } + override fun cosh(arg: StructureND): NDBuffer = arg.map { cosh(it) } + override fun tanh(arg: StructureND): NDBuffer = arg.map { tanh(it) } + override fun asinh(arg: StructureND): NDBuffer = arg.map { asinh(it) } + override fun acosh(arg: StructureND): NDBuffer = arg.map { acosh(it) } + override fun atanh(arg: StructureND): NDBuffer = arg.map { atanh(it) } } /** * Fast element production using function inlining */ -public inline fun BufferedNDField.produceInline(initializer: ComplexField.(Int) -> Complex): NDBuffer { +public inline fun BufferedFieldND.produceInline(initializer: ComplexField.(Int) -> Complex): NDBuffer { contract { callsInPlace(initializer, InvocationKind.EXACTLY_ONCE) } val buffer = Buffer.complex(strides.linearSize) { offset -> ComplexField.initializer(offset) } return NDBuffer(strides, buffer) } -public fun NDAlgebra.Companion.complex(vararg shape: Int): ComplexNDField = ComplexNDField(shape) +public fun AlgebraND.Companion.complex(vararg shape: Int): ComplexFieldND = ComplexFieldND(shape) /** * Produce a context for n-dimensional operations inside this real field */ -public inline fun ComplexField.nd(vararg shape: Int, action: ComplexNDField.() -> R): R { +public inline fun ComplexField.nd(vararg shape: Int, action: ComplexFieldND.() -> R): R { contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) } - return ComplexNDField(shape).action() + return ComplexFieldND(shape).action() } diff --git a/kmath-complex/src/commonMain/kotlin/space/kscience/kmath/complex/Quaternion.kt b/kmath-complex/src/commonMain/kotlin/space/kscience/kmath/complex/Quaternion.kt index d391aff18..9a0346ca7 100644 --- a/kmath-complex/src/commonMain/kotlin/space/kscience/kmath/complex/Quaternion.kt +++ b/kmath-complex/src/commonMain/kotlin/space/kscience/kmath/complex/Quaternion.kt @@ -172,7 +172,7 @@ public object QuaternionField : Field, Norm, else -> super.bindSymbol(value) } - override fun number(value: Number): Quaternion =value.toQuaternion() + override fun number(value: Number): Quaternion = value.toQuaternion() public override fun sinh(arg: Quaternion): Quaternion = (exp(arg) - exp(-arg)) / 2.0 public override fun cosh(arg: Quaternion): Quaternion = (exp(arg) + exp(-arg)) / 2.0 diff --git a/kmath-core/api/kmath-core.api b/kmath-core/api/kmath-core.api index c5e13fe20..2fb28d73a 100644 --- a/kmath-core/api/kmath-core.api +++ b/kmath-core/api/kmath-core.api @@ -679,73 +679,91 @@ public final class space/kscience/kmath/misc/CumulativeKt { public abstract interface annotation class space/kscience/kmath/misc/UnstableKMathAPI : java/lang/annotation/Annotation { } -public abstract interface class space/kscience/kmath/nd/BufferNDAlgebra : space/kscience/kmath/nd/NDAlgebra { - public abstract fun combine (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDBuffer; - public abstract fun getBuffer (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/structures/Buffer; +public abstract interface class space/kscience/kmath/nd/AlgebraND { + public static final field Companion Lspace/kscience/kmath/nd/AlgebraND$Companion; + public abstract fun combine (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; + public abstract fun getElementContext ()Lspace/kscience/kmath/operations/Algebra; + public abstract fun getShape ()[I + public abstract fun invoke (Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public abstract fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; + public abstract fun mapIndexed (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; + public abstract fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; +} + +public final class space/kscience/kmath/nd/AlgebraND$Companion { +} + +public final class space/kscience/kmath/nd/AlgebraND$DefaultImpls { + public static fun invoke (Lspace/kscience/kmath/nd/AlgebraND;Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; +} + +public abstract interface class space/kscience/kmath/nd/BufferAlgebraND : space/kscience/kmath/nd/AlgebraND { + public abstract fun combine (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDBuffer; + public abstract fun getBuffer (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/structures/Buffer; public abstract fun getBufferFactory ()Lkotlin/jvm/functions/Function2; public abstract fun getStrides ()Lspace/kscience/kmath/nd/Strides; - public abstract fun map (Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDBuffer; - public abstract fun mapIndexed (Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDBuffer; + public abstract fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDBuffer; + public abstract fun mapIndexed (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDBuffer; public abstract fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDBuffer; } -public final class space/kscience/kmath/nd/BufferNDAlgebra$DefaultImpls { - public static fun combine (Lspace/kscience/kmath/nd/BufferNDAlgebra;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDBuffer; - public static fun getBuffer (Lspace/kscience/kmath/nd/BufferNDAlgebra;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/structures/Buffer; - public static fun invoke (Lspace/kscience/kmath/nd/BufferNDAlgebra;Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun map (Lspace/kscience/kmath/nd/BufferNDAlgebra;Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDBuffer; - public static fun mapIndexed (Lspace/kscience/kmath/nd/BufferNDAlgebra;Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDBuffer; - public static fun produce (Lspace/kscience/kmath/nd/BufferNDAlgebra;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDBuffer; +public final class space/kscience/kmath/nd/BufferAlgebraND$DefaultImpls { + public static fun combine (Lspace/kscience/kmath/nd/BufferAlgebraND;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDBuffer; + public static fun getBuffer (Lspace/kscience/kmath/nd/BufferAlgebraND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/structures/Buffer; + public static fun invoke (Lspace/kscience/kmath/nd/BufferAlgebraND;Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun map (Lspace/kscience/kmath/nd/BufferAlgebraND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDBuffer; + public static fun mapIndexed (Lspace/kscience/kmath/nd/BufferAlgebraND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDBuffer; + public static fun produce (Lspace/kscience/kmath/nd/BufferAlgebraND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDBuffer; } -public final class space/kscience/kmath/nd/BufferNDAlgebraKt { - public static final fun field (Lspace/kscience/kmath/nd/NDAlgebra$Companion;Lspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function2;[I)Lspace/kscience/kmath/nd/BufferedNDField; - public static final fun group (Lspace/kscience/kmath/nd/NDAlgebra$Companion;Lspace/kscience/kmath/operations/Group;Lkotlin/jvm/functions/Function2;[I)Lspace/kscience/kmath/nd/BufferedNDGroup; +public final class space/kscience/kmath/nd/BufferAlgebraNDKt { + public static final fun field (Lspace/kscience/kmath/nd/AlgebraND$Companion;Lspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function2;[I)Lspace/kscience/kmath/nd/BufferedFieldND; + public static final fun group (Lspace/kscience/kmath/nd/AlgebraND$Companion;Lspace/kscience/kmath/operations/Group;Lkotlin/jvm/functions/Function2;[I)Lspace/kscience/kmath/nd/BufferedGroupND; public static final fun ndField (Lspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function2;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ndGroup (Lspace/kscience/kmath/operations/Group;Lkotlin/jvm/functions/Function2;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ndRing (Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; - public static final fun ring (Lspace/kscience/kmath/nd/NDAlgebra$Companion;Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;[I)Lspace/kscience/kmath/nd/BufferedNDRing; + public static final fun ring (Lspace/kscience/kmath/nd/AlgebraND$Companion;Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;[I)Lspace/kscience/kmath/nd/BufferedRingND; } -public class space/kscience/kmath/nd/BufferedNDField : space/kscience/kmath/nd/BufferedNDRing, space/kscience/kmath/nd/NDField { +public class space/kscience/kmath/nd/BufferedFieldND : space/kscience/kmath/nd/BufferedRingND, space/kscience/kmath/nd/FieldND { public fun ([ILspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function2;)V public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; public synthetic fun div (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; public synthetic fun div (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun div (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public fun div (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; - public fun div (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public fun div (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun div (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public fun div (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; + public fun div (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public fun div (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun divide (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun divide (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; - public fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; - public fun number (Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; + public fun number (Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; - public fun rightSideNumberOperation (Ljava/lang/String;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; + public fun rightSideNumberOperation (Ljava/lang/String;Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; public synthetic fun scale (Ljava/lang/Object;D)Ljava/lang/Object; - public fun scale (Lspace/kscience/kmath/nd/NDStructure;D)Lspace/kscience/kmath/nd/NDStructure; + public fun scale (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/nd/StructureND; public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; - public fun times (Ljava/lang/Number;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun times (Ljava/lang/Number;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun times (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; - public fun times (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; + public fun times (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; } -public class space/kscience/kmath/nd/BufferedNDGroup : space/kscience/kmath/nd/BufferNDAlgebra, space/kscience/kmath/nd/NDGroup { +public class space/kscience/kmath/nd/BufferedGroupND : space/kscience/kmath/nd/BufferAlgebraND, space/kscience/kmath/nd/GroupND { public fun ([ILspace/kscience/kmath/operations/Group;Lkotlin/jvm/functions/Function2;)V public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun add (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun add (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun binaryOperation (Ljava/lang/String;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun binaryOperation (Ljava/lang/String;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; public synthetic fun bindSymbol (Ljava/lang/String;)Ljava/lang/Object; - public fun bindSymbol (Ljava/lang/String;)Lspace/kscience/kmath/nd/NDStructure; - public fun combine (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDBuffer; - public synthetic fun combine (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDStructure; - public fun getBuffer (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/structures/Buffer; + public fun bindSymbol (Ljava/lang/String;)Lspace/kscience/kmath/nd/StructureND; + public fun combine (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDBuffer; + public synthetic fun combine (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; + public fun getBuffer (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/structures/Buffer; public final fun getBufferFactory ()Lkotlin/jvm/functions/Function2; public synthetic fun getElementContext ()Lspace/kscience/kmath/operations/Algebra; public final fun getElementContext ()Lspace/kscience/kmath/operations/Group; @@ -753,41 +771,41 @@ public class space/kscience/kmath/nd/BufferedNDGroup : space/kscience/kmath/nd/B public fun getStrides ()Lspace/kscience/kmath/nd/Strides; public synthetic fun getZero ()Ljava/lang/Object; public fun getZero ()Lspace/kscience/kmath/nd/NDBuffer; - public fun invoke (Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public fun map (Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDBuffer; - public synthetic fun map (Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDStructure; - public fun mapIndexed (Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDBuffer; - public synthetic fun mapIndexed (Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDStructure; + public fun invoke (Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDBuffer; + public synthetic fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; + public fun mapIndexed (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDBuffer; + public synthetic fun mapIndexed (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun minus (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public fun minus (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public fun minus (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun minus (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public fun minus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public fun minus (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun plus (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public fun plus (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public fun plus (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun plus (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public fun plus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public fun plus (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDBuffer; - public synthetic fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDStructure; + public synthetic fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; - public fun unaryMinus (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun unaryMinus (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; - public fun unaryOperation (Ljava/lang/String;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun unaryOperation (Ljava/lang/String;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; - public fun unaryPlus (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun unaryPlus (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; } -public class space/kscience/kmath/nd/BufferedNDRing : space/kscience/kmath/nd/BufferedNDGroup, space/kscience/kmath/nd/NDRing { +public class space/kscience/kmath/nd/BufferedRingND : space/kscience/kmath/nd/BufferedGroupND, space/kscience/kmath/nd/RingND { public fun ([ILspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;)V public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; public synthetic fun getOne ()Ljava/lang/Object; public fun getOne ()Lspace/kscience/kmath/nd/NDBuffer; public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun multiply (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun multiply (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun times (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun times (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public fun times (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public fun times (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun times (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public fun times (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public fun times (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; } public final class space/kscience/kmath/nd/DefaultStrides : space/kscience/kmath/nd/Strides { @@ -807,6 +825,74 @@ public final class space/kscience/kmath/nd/DefaultStrides$Companion { public final fun invoke ([I)Lspace/kscience/kmath/nd/Strides; } +public abstract interface class space/kscience/kmath/nd/FieldND : space/kscience/kmath/nd/RingND, space/kscience/kmath/operations/Field, space/kscience/kmath/operations/ScaleOperations { + public abstract fun div (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public abstract fun div (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public abstract fun divide (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; +} + +public final class space/kscience/kmath/nd/FieldND$DefaultImpls { + public static fun add (Lspace/kscience/kmath/nd/FieldND;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun binaryOperation (Lspace/kscience/kmath/nd/FieldND;Ljava/lang/String;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun binaryOperationFunction (Lspace/kscience/kmath/nd/FieldND;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun bindSymbol (Lspace/kscience/kmath/nd/FieldND;Ljava/lang/String;)Lspace/kscience/kmath/nd/StructureND; + public static fun div (Lspace/kscience/kmath/nd/FieldND;Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun div (Lspace/kscience/kmath/nd/FieldND;Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; + public static fun div (Lspace/kscience/kmath/nd/FieldND;Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public static fun div (Lspace/kscience/kmath/nd/FieldND;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun divide (Lspace/kscience/kmath/nd/FieldND;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun invoke (Lspace/kscience/kmath/nd/FieldND;Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun leftSideNumberOperation (Lspace/kscience/kmath/nd/FieldND;Ljava/lang/String;Ljava/lang/Number;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun leftSideNumberOperationFunction (Lspace/kscience/kmath/nd/FieldND;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun minus (Lspace/kscience/kmath/nd/FieldND;Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun minus (Lspace/kscience/kmath/nd/FieldND;Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public static fun minus (Lspace/kscience/kmath/nd/FieldND;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun multiply (Lspace/kscience/kmath/nd/FieldND;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun number (Lspace/kscience/kmath/nd/FieldND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; + public static fun plus (Lspace/kscience/kmath/nd/FieldND;Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun plus (Lspace/kscience/kmath/nd/FieldND;Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public static fun plus (Lspace/kscience/kmath/nd/FieldND;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun rightSideNumberOperation (Lspace/kscience/kmath/nd/FieldND;Ljava/lang/String;Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; + public static fun rightSideNumberOperationFunction (Lspace/kscience/kmath/nd/FieldND;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun times (Lspace/kscience/kmath/nd/FieldND;Ljava/lang/Number;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun times (Lspace/kscience/kmath/nd/FieldND;Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun times (Lspace/kscience/kmath/nd/FieldND;Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; + public static fun times (Lspace/kscience/kmath/nd/FieldND;Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public static fun times (Lspace/kscience/kmath/nd/FieldND;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun unaryOperation (Lspace/kscience/kmath/nd/FieldND;Ljava/lang/String;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun unaryOperationFunction (Lspace/kscience/kmath/nd/FieldND;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lspace/kscience/kmath/nd/FieldND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; +} + +public abstract interface class space/kscience/kmath/nd/GroupND : space/kscience/kmath/nd/AlgebraND, space/kscience/kmath/operations/Group { + public static final field Companion Lspace/kscience/kmath/nd/GroupND$Companion; + public abstract fun add (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public abstract fun minus (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public abstract fun minus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public abstract fun plus (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public abstract fun plus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; +} + +public final class space/kscience/kmath/nd/GroupND$Companion { +} + +public final class space/kscience/kmath/nd/GroupND$DefaultImpls { + public static fun add (Lspace/kscience/kmath/nd/GroupND;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun binaryOperation (Lspace/kscience/kmath/nd/GroupND;Ljava/lang/String;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun binaryOperationFunction (Lspace/kscience/kmath/nd/GroupND;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun bindSymbol (Lspace/kscience/kmath/nd/GroupND;Ljava/lang/String;)Lspace/kscience/kmath/nd/StructureND; + public static fun invoke (Lspace/kscience/kmath/nd/GroupND;Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun minus (Lspace/kscience/kmath/nd/GroupND;Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun minus (Lspace/kscience/kmath/nd/GroupND;Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public static fun minus (Lspace/kscience/kmath/nd/GroupND;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun plus (Lspace/kscience/kmath/nd/GroupND;Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun plus (Lspace/kscience/kmath/nd/GroupND;Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public static fun plus (Lspace/kscience/kmath/nd/GroupND;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun unaryOperation (Lspace/kscience/kmath/nd/GroupND;Ljava/lang/String;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun unaryOperationFunction (Lspace/kscience/kmath/nd/GroupND;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lspace/kscience/kmath/nd/GroupND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; +} + public final class space/kscience/kmath/nd/MutableNDBuffer : space/kscience/kmath/nd/NDBuffer, space/kscience/kmath/nd/MutableNDStructure { public fun (Lspace/kscience/kmath/nd/Strides;Lspace/kscience/kmath/structures/MutableBuffer;)V public synthetic fun getBuffer ()Lspace/kscience/kmath/structures/Buffer; @@ -814,7 +900,7 @@ public final class space/kscience/kmath/nd/MutableNDBuffer : space/kscience/kmat public fun set ([ILjava/lang/Object;)V } -public abstract interface class space/kscience/kmath/nd/MutableNDStructure : space/kscience/kmath/nd/NDStructure { +public abstract interface class space/kscience/kmath/nd/MutableNDStructure : space/kscience/kmath/nd/StructureND { public abstract fun set ([ILjava/lang/Object;)V } @@ -822,25 +908,7 @@ public final class space/kscience/kmath/nd/MutableNDStructure$DefaultImpls { public static fun getDimension (Lspace/kscience/kmath/nd/MutableNDStructure;)I } -public abstract interface class space/kscience/kmath/nd/NDAlgebra { - public static final field Companion Lspace/kscience/kmath/nd/NDAlgebra$Companion; - public abstract fun combine (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDStructure; - public abstract fun getElementContext ()Lspace/kscience/kmath/operations/Algebra; - public abstract fun getShape ()[I - public abstract fun invoke (Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public abstract fun map (Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDStructure; - public abstract fun mapIndexed (Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDStructure; - public abstract fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDStructure; -} - -public final class space/kscience/kmath/nd/NDAlgebra$Companion { -} - -public final class space/kscience/kmath/nd/NDAlgebra$DefaultImpls { - public static fun invoke (Lspace/kscience/kmath/nd/NDAlgebra;Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; -} - -public class space/kscience/kmath/nd/NDBuffer : space/kscience/kmath/nd/NDStructure { +public class space/kscience/kmath/nd/NDBuffer : space/kscience/kmath/nd/StructureND { public fun (Lspace/kscience/kmath/nd/Strides;Lspace/kscience/kmath/structures/Buffer;)V public fun elements ()Lkotlin/sequences/Sequence; public fun equals (Ljava/lang/Object;)Z @@ -853,204 +921,107 @@ public class space/kscience/kmath/nd/NDBuffer : space/kscience/kmath/nd/NDStruct public fun toString ()Ljava/lang/String; } -public abstract interface class space/kscience/kmath/nd/NDField : space/kscience/kmath/nd/NDRing, space/kscience/kmath/operations/Field, space/kscience/kmath/operations/ScaleOperations { - public abstract fun div (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public abstract fun div (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public abstract fun divide (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; -} - -public final class space/kscience/kmath/nd/NDField$DefaultImpls { - public static fun add (Lspace/kscience/kmath/nd/NDField;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun binaryOperation (Lspace/kscience/kmath/nd/NDField;Ljava/lang/String;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun binaryOperationFunction (Lspace/kscience/kmath/nd/NDField;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; - public static fun bindSymbol (Lspace/kscience/kmath/nd/NDField;Ljava/lang/String;)Lspace/kscience/kmath/nd/NDStructure; - public static fun div (Lspace/kscience/kmath/nd/NDField;Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun div (Lspace/kscience/kmath/nd/NDField;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; - public static fun div (Lspace/kscience/kmath/nd/NDField;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public static fun div (Lspace/kscience/kmath/nd/NDField;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun divide (Lspace/kscience/kmath/nd/NDField;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun invoke (Lspace/kscience/kmath/nd/NDField;Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun leftSideNumberOperation (Lspace/kscience/kmath/nd/NDField;Ljava/lang/String;Ljava/lang/Number;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun leftSideNumberOperationFunction (Lspace/kscience/kmath/nd/NDField;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; - public static fun minus (Lspace/kscience/kmath/nd/NDField;Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun minus (Lspace/kscience/kmath/nd/NDField;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public static fun minus (Lspace/kscience/kmath/nd/NDField;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun multiply (Lspace/kscience/kmath/nd/NDField;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun number (Lspace/kscience/kmath/nd/NDField;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; - public static fun plus (Lspace/kscience/kmath/nd/NDField;Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun plus (Lspace/kscience/kmath/nd/NDField;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public static fun plus (Lspace/kscience/kmath/nd/NDField;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun rightSideNumberOperation (Lspace/kscience/kmath/nd/NDField;Ljava/lang/String;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; - public static fun rightSideNumberOperationFunction (Lspace/kscience/kmath/nd/NDField;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; - public static fun times (Lspace/kscience/kmath/nd/NDField;Ljava/lang/Number;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun times (Lspace/kscience/kmath/nd/NDField;Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun times (Lspace/kscience/kmath/nd/NDField;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; - public static fun times (Lspace/kscience/kmath/nd/NDField;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public static fun times (Lspace/kscience/kmath/nd/NDField;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun unaryOperation (Lspace/kscience/kmath/nd/NDField;Ljava/lang/String;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun unaryOperationFunction (Lspace/kscience/kmath/nd/NDField;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; - public static fun unaryPlus (Lspace/kscience/kmath/nd/NDField;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; -} - -public abstract interface class space/kscience/kmath/nd/NDGroup : space/kscience/kmath/nd/NDAlgebra, space/kscience/kmath/operations/Group { - public static final field Companion Lspace/kscience/kmath/nd/NDGroup$Companion; - public abstract fun add (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public abstract fun minus (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public abstract fun minus (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public abstract fun plus (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public abstract fun plus (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; -} - -public final class space/kscience/kmath/nd/NDGroup$Companion { -} - -public final class space/kscience/kmath/nd/NDGroup$DefaultImpls { - public static fun add (Lspace/kscience/kmath/nd/NDGroup;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun binaryOperation (Lspace/kscience/kmath/nd/NDGroup;Ljava/lang/String;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun binaryOperationFunction (Lspace/kscience/kmath/nd/NDGroup;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; - public static fun bindSymbol (Lspace/kscience/kmath/nd/NDGroup;Ljava/lang/String;)Lspace/kscience/kmath/nd/NDStructure; - public static fun invoke (Lspace/kscience/kmath/nd/NDGroup;Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun minus (Lspace/kscience/kmath/nd/NDGroup;Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun minus (Lspace/kscience/kmath/nd/NDGroup;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public static fun minus (Lspace/kscience/kmath/nd/NDGroup;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun plus (Lspace/kscience/kmath/nd/NDGroup;Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun plus (Lspace/kscience/kmath/nd/NDGroup;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public static fun plus (Lspace/kscience/kmath/nd/NDGroup;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun unaryOperation (Lspace/kscience/kmath/nd/NDGroup;Ljava/lang/String;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun unaryOperationFunction (Lspace/kscience/kmath/nd/NDGroup;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; - public static fun unaryPlus (Lspace/kscience/kmath/nd/NDGroup;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; -} - -public abstract interface class space/kscience/kmath/nd/NDRing : space/kscience/kmath/nd/NDGroup, space/kscience/kmath/operations/Ring { - public static final field Companion Lspace/kscience/kmath/nd/NDRing$Companion; - public abstract fun multiply (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public abstract fun times (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public abstract fun times (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; -} - -public final class space/kscience/kmath/nd/NDRing$Companion { -} - -public final class space/kscience/kmath/nd/NDRing$DefaultImpls { - public static fun add (Lspace/kscience/kmath/nd/NDRing;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun binaryOperation (Lspace/kscience/kmath/nd/NDRing;Ljava/lang/String;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun binaryOperationFunction (Lspace/kscience/kmath/nd/NDRing;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; - public static fun bindSymbol (Lspace/kscience/kmath/nd/NDRing;Ljava/lang/String;)Lspace/kscience/kmath/nd/NDStructure; - public static fun invoke (Lspace/kscience/kmath/nd/NDRing;Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun minus (Lspace/kscience/kmath/nd/NDRing;Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun minus (Lspace/kscience/kmath/nd/NDRing;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public static fun minus (Lspace/kscience/kmath/nd/NDRing;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun multiply (Lspace/kscience/kmath/nd/NDRing;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun plus (Lspace/kscience/kmath/nd/NDRing;Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun plus (Lspace/kscience/kmath/nd/NDRing;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public static fun plus (Lspace/kscience/kmath/nd/NDRing;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun times (Lspace/kscience/kmath/nd/NDRing;Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun times (Lspace/kscience/kmath/nd/NDRing;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public static fun times (Lspace/kscience/kmath/nd/NDRing;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun unaryOperation (Lspace/kscience/kmath/nd/NDRing;Ljava/lang/String;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun unaryOperationFunction (Lspace/kscience/kmath/nd/NDRing;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; - public static fun unaryPlus (Lspace/kscience/kmath/nd/NDRing;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; -} - -public abstract interface class space/kscience/kmath/nd/NDStructure { - public static final field Companion Lspace/kscience/kmath/nd/NDStructure$Companion; - public abstract fun elements ()Lkotlin/sequences/Sequence; - public abstract fun equals (Ljava/lang/Object;)Z - public abstract fun get ([I)Ljava/lang/Object; - public abstract fun getDimension ()I - public abstract fun getShape ()[I - public abstract fun hashCode ()I -} - -public final class space/kscience/kmath/nd/NDStructure$Companion { - public final fun auto (Lkotlin/reflect/KClass;Lspace/kscience/kmath/nd/Strides;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/nd/NDBuffer; - public final fun auto (Lkotlin/reflect/KClass;[ILkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/nd/NDBuffer; - public final fun buffered (Lspace/kscience/kmath/nd/Strides;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/nd/NDBuffer; - public final fun buffered ([ILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/nd/NDBuffer; - public static synthetic fun buffered$default (Lspace/kscience/kmath/nd/NDStructure$Companion;Lspace/kscience/kmath/nd/Strides;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/kmath/nd/NDBuffer; - public static synthetic fun buffered$default (Lspace/kscience/kmath/nd/NDStructure$Companion;[ILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/kmath/nd/NDBuffer; - public final fun contentEquals (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Z -} - -public final class space/kscience/kmath/nd/NDStructure$DefaultImpls { - public static fun getDimension (Lspace/kscience/kmath/nd/NDStructure;)I -} - -public final class space/kscience/kmath/nd/NDStructureKt { - public static final fun get (Lspace/kscience/kmath/nd/NDStructure;[I)Ljava/lang/Object; - public static final fun mapInPlace (Lspace/kscience/kmath/nd/MutableNDStructure;Lkotlin/jvm/functions/Function2;)V -} - -public final class space/kscience/kmath/nd/RealNDField : space/kscience/kmath/nd/BufferedNDField, space/kscience/kmath/operations/ExtendedField, space/kscience/kmath/operations/NumbersAddOperations, space/kscience/kmath/operations/ScaleOperations { +public final class space/kscience/kmath/nd/RealFieldND : space/kscience/kmath/nd/BufferedFieldND, space/kscience/kmath/operations/ExtendedField, space/kscience/kmath/operations/NumbersAddOperations, space/kscience/kmath/operations/ScaleOperations { public fun ([I)V public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; - public fun acos (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDBuffer; + public fun acos (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/NDBuffer; public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; - public fun acosh (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDBuffer; + public fun acosh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/NDBuffer; public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; - public fun asin (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDBuffer; + public fun asin (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/NDBuffer; public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; - public fun asinh (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDBuffer; + public fun asinh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/NDBuffer; public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; - public fun atan (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDBuffer; + public fun atan (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/NDBuffer; public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; - public fun atanh (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDBuffer; - public fun combine (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDBuffer; - public synthetic fun combine (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDStructure; + public fun atanh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/NDBuffer; + public fun combine (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDBuffer; + public synthetic fun combine (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; - public fun cos (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDBuffer; + public fun cos (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/NDBuffer; public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; - public fun cosh (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDBuffer; + public fun cosh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/NDBuffer; public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; - public fun exp (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDBuffer; - public synthetic fun getBuffer (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/structures/Buffer; - public fun getBuffer-LGjt3BI (Lspace/kscience/kmath/nd/NDStructure;)[D + public fun exp (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/NDBuffer; + public synthetic fun getBuffer (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/structures/Buffer; + public fun getBuffer-LGjt3BI (Lspace/kscience/kmath/nd/StructureND;)[D public synthetic fun getOne ()Ljava/lang/Object; public fun getOne ()Lspace/kscience/kmath/nd/NDBuffer; public synthetic fun getZero ()Ljava/lang/Object; public fun getZero ()Lspace/kscience/kmath/nd/NDBuffer; public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object; - public fun ln (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDBuffer; - public fun map (Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDBuffer; - public synthetic fun map (Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDStructure; - public fun mapIndexed (Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDBuffer; - public synthetic fun mapIndexed (Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDStructure; + public fun ln (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/NDBuffer; + public fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDBuffer; + public synthetic fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; + public fun mapIndexed (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDBuffer; + public synthetic fun mapIndexed (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun minus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; - public fun minus (Ljava/lang/Number;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun minus (Ljava/lang/Number;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; - public fun minus (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; + public fun minus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; public fun number (Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDBuffer; - public synthetic fun number (Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; + public synthetic fun number (Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun plus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; - public fun plus (Ljava/lang/Number;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun plus (Ljava/lang/Number;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; - public fun plus (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; + public fun plus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun pow (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; - public fun pow (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; + public fun pow (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; - public fun power (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDBuffer; + public fun power (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDBuffer; public fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDBuffer; - public synthetic fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDStructure; + public synthetic fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; public synthetic fun scale (Ljava/lang/Object;D)Ljava/lang/Object; - public fun scale (Lspace/kscience/kmath/nd/NDStructure;D)Lspace/kscience/kmath/nd/NDStructure; + public fun scale (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/nd/StructureND; public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; - public fun sin (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDBuffer; + public fun sin (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/NDBuffer; public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; - public fun sinh (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDBuffer; + public fun sinh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/NDBuffer; public synthetic fun sqrt (Ljava/lang/Object;)Ljava/lang/Object; - public fun sqrt (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun sqrt (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; - public fun tan (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDBuffer; + public fun tan (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/NDBuffer; public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; - public fun tanh (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDBuffer; + public fun tanh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/NDBuffer; public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; } -public final class space/kscience/kmath/nd/RealNDFieldKt { +public final class space/kscience/kmath/nd/RealFieldNDKt { public static final fun nd (Lspace/kscience/kmath/operations/RealField;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; - public static final fun real (Lspace/kscience/kmath/nd/NDAlgebra$Companion;[I)Lspace/kscience/kmath/nd/RealNDField; + public static final fun real (Lspace/kscience/kmath/nd/AlgebraND$Companion;[I)Lspace/kscience/kmath/nd/RealFieldND; +} + +public abstract interface class space/kscience/kmath/nd/RingND : space/kscience/kmath/nd/GroupND, space/kscience/kmath/operations/Ring { + public static final field Companion Lspace/kscience/kmath/nd/RingND$Companion; + public abstract fun multiply (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public abstract fun times (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public abstract fun times (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; +} + +public final class space/kscience/kmath/nd/RingND$Companion { +} + +public final class space/kscience/kmath/nd/RingND$DefaultImpls { + public static fun add (Lspace/kscience/kmath/nd/RingND;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun binaryOperation (Lspace/kscience/kmath/nd/RingND;Ljava/lang/String;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun binaryOperationFunction (Lspace/kscience/kmath/nd/RingND;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun bindSymbol (Lspace/kscience/kmath/nd/RingND;Ljava/lang/String;)Lspace/kscience/kmath/nd/StructureND; + public static fun invoke (Lspace/kscience/kmath/nd/RingND;Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun minus (Lspace/kscience/kmath/nd/RingND;Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun minus (Lspace/kscience/kmath/nd/RingND;Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public static fun minus (Lspace/kscience/kmath/nd/RingND;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun multiply (Lspace/kscience/kmath/nd/RingND;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun plus (Lspace/kscience/kmath/nd/RingND;Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun plus (Lspace/kscience/kmath/nd/RingND;Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public static fun plus (Lspace/kscience/kmath/nd/RingND;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun times (Lspace/kscience/kmath/nd/RingND;Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun times (Lspace/kscience/kmath/nd/RingND;Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public static fun times (Lspace/kscience/kmath/nd/RingND;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun unaryOperation (Lspace/kscience/kmath/nd/RingND;Ljava/lang/String;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public static fun unaryOperationFunction (Lspace/kscience/kmath/nd/RingND;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lspace/kscience/kmath/nd/RingND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; } public final class space/kscience/kmath/nd/ShapeMismatchException : java/lang/RuntimeException { @@ -1059,33 +1030,33 @@ public final class space/kscience/kmath/nd/ShapeMismatchException : java/lang/Ru public final fun getExpected ()[I } -public final class space/kscience/kmath/nd/ShortNDRing : space/kscience/kmath/nd/BufferedNDRing, space/kscience/kmath/operations/NumbersAddOperations { +public final class space/kscience/kmath/nd/ShortRingND : space/kscience/kmath/nd/BufferedRingND, space/kscience/kmath/operations/NumbersAddOperations { public fun ([I)V public synthetic fun getOne ()Ljava/lang/Object; public fun getOne ()Lspace/kscience/kmath/nd/NDBuffer; public synthetic fun getZero ()Ljava/lang/Object; public fun getZero ()Lspace/kscience/kmath/nd/NDBuffer; public synthetic fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; - public fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; public synthetic fun minus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; - public fun minus (Ljava/lang/Number;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun minus (Ljava/lang/Number;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; - public fun minus (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; + public fun minus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; public fun number (Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDBuffer; public synthetic fun plus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; - public fun plus (Ljava/lang/Number;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun plus (Ljava/lang/Number;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; - public fun plus (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; + public fun plus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; - public fun rightSideNumberOperation (Ljava/lang/String;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; + public fun rightSideNumberOperation (Ljava/lang/String;Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; } -public final class space/kscience/kmath/nd/ShortNDRingKt { +public final class space/kscience/kmath/nd/ShortRingNDKt { public static final fun nd (Lspace/kscience/kmath/operations/ShortRing;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; - public static final fun produceInline (Lspace/kscience/kmath/nd/BufferedNDRing;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDBuffer; + public static final fun produceInline (Lspace/kscience/kmath/nd/BufferedRingND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDBuffer; } public abstract interface class space/kscience/kmath/nd/Strides { @@ -1101,7 +1072,7 @@ public final class space/kscience/kmath/nd/Strides$DefaultImpls { public static fun indices (Lspace/kscience/kmath/nd/Strides;)Lkotlin/sequences/Sequence; } -public abstract interface class space/kscience/kmath/nd/Structure1D : space/kscience/kmath/nd/NDStructure, space/kscience/kmath/structures/Buffer { +public abstract interface class space/kscience/kmath/nd/Structure1D : space/kscience/kmath/nd/StructureND, space/kscience/kmath/structures/Buffer { public abstract fun get ([I)Ljava/lang/Object; public abstract fun getDimension ()I public abstract fun iterator ()Ljava/util/Iterator; @@ -1115,11 +1086,11 @@ public final class space/kscience/kmath/nd/Structure1D$DefaultImpls { } public final class space/kscience/kmath/nd/Structure1DKt { - public static final fun as1D (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/Structure1D; + public static final fun as1D (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/Structure1D; public static final fun asND (Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/nd/Structure1D; } -public abstract interface class space/kscience/kmath/nd/Structure2D : space/kscience/kmath/nd/NDStructure { +public abstract interface class space/kscience/kmath/nd/Structure2D : space/kscience/kmath/nd/StructureND { public static final field Companion Lspace/kscience/kmath/nd/Structure2D$Companion; public abstract fun elements ()Lkotlin/sequences/Sequence; public abstract fun get (II)Ljava/lang/Object; @@ -1144,7 +1115,36 @@ public final class space/kscience/kmath/nd/Structure2D$DefaultImpls { } public final class space/kscience/kmath/nd/Structure2DKt { - public static final fun as2D (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/Structure2D; + public static final fun as2D (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/Structure2D; +} + +public abstract interface class space/kscience/kmath/nd/StructureND { + public static final field Companion Lspace/kscience/kmath/nd/StructureND$Companion; + public abstract fun elements ()Lkotlin/sequences/Sequence; + public abstract fun equals (Ljava/lang/Object;)Z + public abstract fun get ([I)Ljava/lang/Object; + public abstract fun getDimension ()I + public abstract fun getShape ()[I + public abstract fun hashCode ()I +} + +public final class space/kscience/kmath/nd/StructureND$Companion { + public final fun auto (Lkotlin/reflect/KClass;Lspace/kscience/kmath/nd/Strides;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/nd/NDBuffer; + public final fun auto (Lkotlin/reflect/KClass;[ILkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/nd/NDBuffer; + public final fun buffered (Lspace/kscience/kmath/nd/Strides;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/nd/NDBuffer; + public final fun buffered ([ILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/nd/NDBuffer; + public static synthetic fun buffered$default (Lspace/kscience/kmath/nd/StructureND$Companion;Lspace/kscience/kmath/nd/Strides;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/kmath/nd/NDBuffer; + public static synthetic fun buffered$default (Lspace/kscience/kmath/nd/StructureND$Companion;[ILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/kmath/nd/NDBuffer; + public final fun contentEquals (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Z +} + +public final class space/kscience/kmath/nd/StructureND$DefaultImpls { + public static fun getDimension (Lspace/kscience/kmath/nd/StructureND;)I +} + +public final class space/kscience/kmath/nd/StructureNDKt { + public static final fun get (Lspace/kscience/kmath/nd/StructureND;[I)Ljava/lang/Object; + public static final fun mapInPlace (Lspace/kscience/kmath/nd/MutableNDStructure;Lkotlin/jvm/functions/Function2;)V } public abstract interface class space/kscience/kmath/operations/Algebra { @@ -1287,7 +1287,7 @@ public final class space/kscience/kmath/operations/BigIntField : space/kscience/ public final class space/kscience/kmath/operations/BigIntKt { public static final fun abs (Lspace/kscience/kmath/operations/BigInt;)Lspace/kscience/kmath/operations/BigInt; - public static final fun bigInt (Lspace/kscience/kmath/nd/NDAlgebra$Companion;[I)Lspace/kscience/kmath/nd/BufferedNDRing; + public static final fun bigInt (Lspace/kscience/kmath/nd/AlgebraND$Companion;[I)Lspace/kscience/kmath/nd/BufferedRingND; public static final fun bigInt (Lspace/kscience/kmath/structures/Buffer$Companion;ILkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/structures/Buffer; public static final fun bigInt (Lspace/kscience/kmath/structures/MutableBuffer$Companion;ILkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/structures/MutableBuffer; public static final fun parseBigInteger (Ljava/lang/String;)Lspace/kscience/kmath/operations/BigInt; diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/BufferedLinearSpace.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/BufferedLinearSpace.kt index fe92a711a..662cd6409 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/BufferedLinearSpace.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/BufferedLinearSpace.kt @@ -17,7 +17,7 @@ public class BufferedLinearSpace>( private fun ndRing( rows: Int, cols: Int, - ): BufferedNDRing = NDAlgebra.ring(elementAlgebra, bufferFactory, rows, cols) + ): BufferedRingND = AlgebraND.ring(elementAlgebra, bufferFactory, rows, cols) override fun buildMatrix(rows: Int, columns: Int, initializer: A.(i: Int, j: Int) -> T): Matrix = ndRing(rows, columns).produce { (i, j) -> elementAlgebra.initializer(i, j) }.as2D() diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/VirtualMatrix.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/VirtualMatrix.kt index 8efa08f81..56cafbdb5 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/VirtualMatrix.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/VirtualMatrix.kt @@ -1,6 +1,6 @@ package space.kscience.kmath.linear -import space.kscience.kmath.nd.NDStructure +import space.kscience.kmath.nd.StructureND /** * The matrix where each element is evaluated each time when is being accessed. @@ -19,8 +19,8 @@ public class VirtualMatrix( override fun equals(other: Any?): Boolean { if (this === other) return true - if (other !is NDStructure<*>) return false - return NDStructure.contentEquals(this, other) + if (other !is StructureND<*>) return false + return StructureND.contentEquals(this, other) } override fun hashCode(): Int { diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/NDAlgebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/AlgebraND.kt similarity index 75% rename from kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/NDAlgebra.kt rename to kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/AlgebraND.kt index 5514a8f0f..b23ce947d 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/NDAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/AlgebraND.kt @@ -21,7 +21,7 @@ public class ShapeMismatchException(public val expected: IntArray, public val ac * @param C the type of the element context. * @param N the type of the structure. */ -public interface NDAlgebra> { +public interface AlgebraND> { /** * The shape of ND-structures this algebra operates on. */ @@ -35,27 +35,27 @@ public interface NDAlgebra> { /** * Produces a new NDStructure using given initializer function. */ - public fun produce(initializer: C.(IntArray) -> T): NDStructure + public fun produce(initializer: C.(IntArray) -> T): StructureND /** * Maps elements from one structure to another one by applying [transform] to them. */ - public fun NDStructure.map(transform: C.(T) -> T): NDStructure + public fun StructureND.map(transform: C.(T) -> T): StructureND /** * Maps elements from one structure to another one by applying [transform] to them alongside with their indices. */ - public fun NDStructure.mapIndexed(transform: C.(index: IntArray, T) -> T): NDStructure + public fun StructureND.mapIndexed(transform: C.(index: IntArray, T) -> T): StructureND /** * Combines two structures into one. */ - public fun combine(a: NDStructure, b: NDStructure, transform: C.(T, T) -> T): NDStructure + public fun combine(a: StructureND, b: StructureND, transform: C.(T, T) -> T): StructureND /** - * Element-wise invocation of function working on [T] on a [NDStructure]. + * Element-wise invocation of function working on [T] on a [StructureND]. */ - public operator fun Function1.invoke(structure: NDStructure): NDStructure = + public operator fun Function1.invoke(structure: StructureND): StructureND = structure.map { value -> this@invoke(value) } /** @@ -67,7 +67,7 @@ public interface NDAlgebra> { * @return a feature object or `null` if it isn't present. */ @UnstableKMathAPI - public fun getFeature(structure: NDStructure, type: KClass): F? = structure.getFeature(type) + public fun getFeature(structure: StructureND, type: KClass): F? = structure.getFeature(type) public companion object } @@ -81,7 +81,7 @@ public interface NDAlgebra> { * @return a feature object or `null` if it isn't present. */ @UnstableKMathAPI -public inline fun NDAlgebra.getFeature(structure: NDStructure): F? = +public inline fun AlgebraND.getFeature(structure: StructureND): F? = getFeature(structure, F::class) /** @@ -90,11 +90,11 @@ public inline fun NDAlgebra.getFeature(structur * @param structures the structures to check. * @return the array of valid structures. */ -internal fun > NDAlgebra.checkShape(vararg structures: NDStructure): Array> = +internal fun > AlgebraND.checkShape(vararg structures: StructureND): Array> = structures - .map(NDStructure::shape) + .map(StructureND::shape) .singleOrNull { !shape.contentEquals(it) } - ?.let>> { throw ShapeMismatchException(shape, it) } + ?.let>> { throw ShapeMismatchException(shape, it) } ?: structures /** @@ -103,19 +103,19 @@ internal fun > NDAlgebra.checkShape(vararg structures: N * @param element the structure to check. * @return the valid structure. */ -internal fun > NDAlgebra.checkShape(element: NDStructure): NDStructure { +internal fun > AlgebraND.checkShape(element: StructureND): StructureND { if (!element.shape.contentEquals(shape)) throw ShapeMismatchException(shape, element.shape) return element } /** - * Space of [NDStructure]. + * Space of [StructureND]. * * @param T the type of the element contained in ND structure. * @param N the type of ND structure. * @param S the type of space of structure elements. */ -public interface NDGroup> : Group>, NDAlgebra { +public interface GroupND> : Group>, AlgebraND { /** * Element-wise addition. * @@ -123,7 +123,7 @@ public interface NDGroup> : Group>, NDAlgebra, b: NDStructure): NDStructure = + public override fun add(a: StructureND, b: StructureND): StructureND = combine(a, b) { aValue, bValue -> add(aValue, bValue) } // /** @@ -144,7 +144,7 @@ public interface NDGroup> : Group>, NDAlgebra.plus(arg: T): NDStructure = this.map { value -> add(arg, value) } + public operator fun StructureND.plus(arg: T): StructureND = this.map { value -> add(arg, value) } /** * Subtracts an element from ND structure of it. @@ -153,7 +153,7 @@ public interface NDGroup> : Group>, NDAlgebra.minus(arg: T): NDStructure = this.map { value -> add(arg, -value) } + public operator fun StructureND.minus(arg: T): StructureND = this.map { value -> add(arg, -value) } /** * Adds an element to ND structure of it. @@ -162,7 +162,7 @@ public interface NDGroup> : Group>, NDAlgebra): NDStructure = arg.map { value -> add(this@plus, value) } + public operator fun T.plus(arg: StructureND): StructureND = arg.map { value -> add(this@plus, value) } /** * Subtracts an ND structure from an element of it. @@ -171,19 +171,19 @@ public interface NDGroup> : Group>, NDAlgebra): NDStructure = arg.map { value -> add(-this@minus, value) } + public operator fun T.minus(arg: StructureND): StructureND = arg.map { value -> add(-this@minus, value) } public companion object } /** - * Ring of [NDStructure]. + * Ring of [StructureND]. * * @param T the type of the element contained in ND structure. * @param N the type of ND structure. * @param R the type of ring of structure elements. */ -public interface NDRing> : Ring>, NDGroup { +public interface RingND> : Ring>, GroupND { /** * Element-wise multiplication. * @@ -191,7 +191,7 @@ public interface NDRing> : Ring>, NDGroup { * @param b the multiplier. * @return the product. */ - public override fun multiply(a: NDStructure, b: NDStructure): NDStructure = + public override fun multiply(a: StructureND, b: StructureND): StructureND = combine(a, b) { aValue, bValue -> multiply(aValue, bValue) } //TODO move to extensions after KEEP-176 @@ -203,7 +203,7 @@ public interface NDRing> : Ring>, NDGroup { * @param arg the multiplier. * @return the product. */ - public operator fun NDStructure.times(arg: T): NDStructure = this.map { value -> multiply(arg, value) } + public operator fun StructureND.times(arg: T): StructureND = this.map { value -> multiply(arg, value) } /** * Multiplies an element by a ND structure of it. @@ -212,19 +212,19 @@ public interface NDRing> : Ring>, NDGroup { * @param arg the multiplier. * @return the product. */ - public operator fun T.times(arg: NDStructure): NDStructure = arg.map { value -> multiply(this@times, value) } + public operator fun T.times(arg: StructureND): StructureND = arg.map { value -> multiply(this@times, value) } public companion object } /** - * Field of [NDStructure]. + * Field of [StructureND]. * * @param T the type of the element contained in ND structure. * @param N the type of ND structure. * @param F the type field of structure elements. */ -public interface NDField> : Field>, NDRing, ScaleOperations> { +public interface FieldND> : Field>, RingND, ScaleOperations> { /** * Element-wise division. * @@ -232,7 +232,7 @@ public interface NDField> : Field>, NDRing, * @param b the divisor. * @return the quotient. */ - public override fun divide(a: NDStructure, b: NDStructure): NDStructure = + public override fun divide(a: StructureND, b: StructureND): StructureND = combine(a, b) { aValue, bValue -> divide(aValue, bValue) } //TODO move to extensions after KEEP-176 @@ -243,7 +243,7 @@ public interface NDField> : Field>, NDRing, * @param arg the divisor. * @return the quotient. */ - public operator fun NDStructure.div(arg: T): NDStructure = this.map { value -> divide(arg, value) } + public operator fun StructureND.div(arg: T): StructureND = this.map { value -> divide(arg, value) } /** * Divides an element by an ND structure of it. @@ -252,7 +252,7 @@ public interface NDField> : Field>, NDRing, * @param arg the divisor. * @return the quotient. */ - public operator fun T.div(arg: NDStructure): NDStructure = arg.map { divide(it, this@div) } + public operator fun T.div(arg: StructureND): StructureND = arg.map { divide(it, this@div) } // @ThreadLocal // public companion object { diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/BufferNDAlgebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/BufferAlgebraND.kt similarity index 60% rename from kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/BufferNDAlgebra.kt rename to kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/BufferAlgebraND.kt index bce3a0830..cef43d06f 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/BufferNDAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/BufferAlgebraND.kt @@ -6,7 +6,7 @@ import space.kscience.kmath.structures.BufferFactory import kotlin.contracts.InvocationKind import kotlin.contracts.contract -public interface BufferNDAlgebra> : NDAlgebra { +public interface BufferAlgebraND> : AlgebraND { public val strides: Strides public val bufferFactory: BufferFactory @@ -17,24 +17,24 @@ public interface BufferNDAlgebra> : NDAlgebra { } ) - public val NDStructure.buffer: Buffer + public val StructureND.buffer: Buffer get() = when { - !shape.contentEquals(this@BufferNDAlgebra.shape) -> throw ShapeMismatchException( - this@BufferNDAlgebra.shape, + !shape.contentEquals(this@BufferAlgebraND.shape) -> throw ShapeMismatchException( + this@BufferAlgebraND.shape, shape ) - this is NDBuffer && this.strides == this@BufferNDAlgebra.strides -> this.buffer + this is NDBuffer && this.strides == this@BufferAlgebraND.strides -> this.buffer else -> bufferFactory(strides.linearSize) { offset -> get(strides.index(offset)) } } - override fun NDStructure.map(transform: A.(T) -> T): NDBuffer { + override fun StructureND.map(transform: A.(T) -> T): NDBuffer { val buffer = bufferFactory(strides.linearSize) { offset -> elementContext.transform(buffer[offset]) } return NDBuffer(strides, buffer) } - override fun NDStructure.mapIndexed(transform: A.(index: IntArray, T) -> T): NDBuffer { + override fun StructureND.mapIndexed(transform: A.(index: IntArray, T) -> T): NDBuffer { val buffer = bufferFactory(strides.linearSize) { offset -> elementContext.transform( strides.index(offset), @@ -44,7 +44,7 @@ public interface BufferNDAlgebra> : NDAlgebra { return NDBuffer(strides, buffer) } - override fun combine(a: NDStructure, b: NDStructure, transform: A.(T, T) -> T): NDBuffer { + override fun combine(a: StructureND, b: StructureND, transform: A.(T, T) -> T): NDBuffer { val buffer = bufferFactory(strides.linearSize) { offset -> elementContext.transform(a.buffer[offset], b.buffer[offset]) } @@ -52,86 +52,86 @@ public interface BufferNDAlgebra> : NDAlgebra { } } -public open class BufferedNDGroup>( +public open class BufferedGroupND>( final override val shape: IntArray, final override val elementContext: A, final override val bufferFactory: BufferFactory, -) : NDGroup, BufferNDAlgebra { +) : GroupND, BufferAlgebraND { override val strides: Strides = DefaultStrides(shape) override val zero: NDBuffer by lazy { produce { zero } } - override fun NDStructure.unaryMinus(): NDStructure = produce { -get(it) } + override fun StructureND.unaryMinus(): StructureND = produce { -get(it) } } -public open class BufferedNDRing>( +public open class BufferedRingND>( shape: IntArray, elementContext: R, bufferFactory: BufferFactory, -) : BufferedNDGroup(shape, elementContext, bufferFactory), NDRing { +) : BufferedGroupND(shape, elementContext, bufferFactory), RingND { override val one: NDBuffer by lazy { produce { one } } } -public open class BufferedNDField>( +public open class BufferedFieldND>( shape: IntArray, elementContext: R, bufferFactory: BufferFactory, -) : BufferedNDRing(shape, elementContext, bufferFactory), NDField { +) : BufferedRingND(shape, elementContext, bufferFactory), FieldND { - override fun scale(a: NDStructure, value: Double): NDStructure = a.map { it * value } + override fun scale(a: StructureND, value: Double): StructureND = a.map { it * value } } // group factories -public fun > NDAlgebra.Companion.group( +public fun > AlgebraND.Companion.group( space: A, bufferFactory: BufferFactory, vararg shape: Int, -): BufferedNDGroup = BufferedNDGroup(shape, space, bufferFactory) +): BufferedGroupND = BufferedGroupND(shape, space, bufferFactory) public inline fun , R> A.ndGroup( noinline bufferFactory: BufferFactory, vararg shape: Int, - action: BufferedNDGroup.() -> R, + action: BufferedGroupND.() -> R, ): R { contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) } - return NDAlgebra.group(this, bufferFactory, *shape).run(action) + return AlgebraND.group(this, bufferFactory, *shape).run(action) } //ring factories -public fun > NDAlgebra.Companion.ring( +public fun > AlgebraND.Companion.ring( ring: A, bufferFactory: BufferFactory, vararg shape: Int, -): BufferedNDRing = BufferedNDRing(shape, ring, bufferFactory) +): BufferedRingND = BufferedRingND(shape, ring, bufferFactory) public inline fun , R> A.ndRing( noinline bufferFactory: BufferFactory, vararg shape: Int, - action: BufferedNDRing.() -> R, + action: BufferedRingND.() -> R, ): R { contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) } - return NDAlgebra.ring(this, bufferFactory, *shape).run(action) + return AlgebraND.ring(this, bufferFactory, *shape).run(action) } //field factories -public fun > NDAlgebra.Companion.field( +public fun > AlgebraND.Companion.field( field: A, bufferFactory: BufferFactory, vararg shape: Int, -): BufferedNDField = BufferedNDField(shape, field, bufferFactory) +): BufferedFieldND = BufferedFieldND(shape, field, bufferFactory) @Suppress("UNCHECKED_CAST") -public inline fun > NDAlgebra.Companion.auto( +public inline fun > AlgebraND.Companion.auto( field: A, vararg shape: Int, -): NDField = when (field) { - RealField -> RealNDField(shape) as NDField - else -> BufferedNDField(shape, field, Buffer.Companion::auto) +): FieldND = when (field) { + RealField -> RealFieldND(shape) as FieldND + else -> BufferedFieldND(shape, field, Buffer.Companion::auto) } public inline fun , R> A.ndField( noinline bufferFactory: BufferFactory, vararg shape: Int, - action: BufferedNDField.() -> R, + action: BufferedFieldND.() -> R, ): R { contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) } - return NDAlgebra.field(this, bufferFactory, *shape).run(action) + return AlgebraND.field(this, bufferFactory, *shape).run(action) } \ No newline at end of file diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/RealNDField.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/RealFieldND.kt similarity index 61% rename from kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/RealNDField.kt rename to kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/RealFieldND.kt index 9f1f14af1..643eb2eb0 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/RealNDField.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/RealFieldND.kt @@ -10,12 +10,12 @@ import kotlin.contracts.InvocationKind import kotlin.contracts.contract @OptIn(UnstableKMathAPI::class) -public class RealNDField( +public class RealFieldND( shape: IntArray, -) : BufferedNDField(shape, RealField, ::RealBuffer), - NumbersAddOperations>, - ScaleOperations>, - ExtendedField> { +) : BufferedFieldND(shape, RealField, ::RealBuffer), + NumbersAddOperations>, + ScaleOperations>, + ExtendedField> { override val zero: NDBuffer by lazy { produce { zero } } override val one: NDBuffer by lazy { produce { one } } @@ -25,18 +25,18 @@ public class RealNDField( return produce { d } } - override val NDStructure.buffer: RealBuffer + override val StructureND.buffer: RealBuffer get() = when { - !shape.contentEquals(this@RealNDField.shape) -> throw ShapeMismatchException( - this@RealNDField.shape, + !shape.contentEquals(this@RealFieldND.shape) -> throw ShapeMismatchException( + this@RealFieldND.shape, shape ) - this is NDBuffer && this.strides == this@RealNDField.strides -> this.buffer as RealBuffer + this is NDBuffer && this.strides == this@RealFieldND.strides -> this.buffer as RealBuffer else -> RealBuffer(strides.linearSize) { offset -> get(strides.index(offset)) } } @Suppress("OVERRIDE_BY_INLINE") - override inline fun NDStructure.map( + override inline fun StructureND.map( transform: RealField.(Double) -> Double, ): NDBuffer { val buffer = RealBuffer(strides.linearSize) { offset -> RealField.transform(buffer.array[offset]) } @@ -53,7 +53,7 @@ public class RealNDField( } @Suppress("OVERRIDE_BY_INLINE") - override inline fun NDStructure.mapIndexed( + override inline fun StructureND.mapIndexed( transform: RealField.(index: IntArray, Double) -> Double, ): NDBuffer = NDBuffer( strides, @@ -66,8 +66,8 @@ public class RealNDField( @Suppress("OVERRIDE_BY_INLINE") override inline fun combine( - a: NDStructure, - b: NDStructure, + a: StructureND, + b: StructureND, transform: RealField.(Double, Double) -> Double, ): NDBuffer { val buffer = RealBuffer(strides.linearSize) { offset -> @@ -76,35 +76,35 @@ public class RealNDField( return NDBuffer(strides, buffer) } - override fun scale(a: NDStructure, value: Double): NDStructure = a.map { it * value } + override fun scale(a: StructureND, value: Double): StructureND = a.map { it * value } - override fun power(arg: NDStructure, pow: Number): NDBuffer = arg.map { power(it, pow) } + override fun power(arg: StructureND, pow: Number): NDBuffer = arg.map { power(it, pow) } - override fun exp(arg: NDStructure): NDBuffer = arg.map { exp(it) } + override fun exp(arg: StructureND): NDBuffer = arg.map { exp(it) } - override fun ln(arg: NDStructure): NDBuffer = arg.map { ln(it) } + override fun ln(arg: StructureND): NDBuffer = arg.map { ln(it) } - override fun sin(arg: NDStructure): NDBuffer = arg.map { sin(it) } - override fun cos(arg: NDStructure): NDBuffer = arg.map { cos(it) } - override fun tan(arg: NDStructure): NDBuffer = arg.map { tan(it) } - override fun asin(arg: NDStructure): NDBuffer = arg.map { asin(it) } - override fun acos(arg: NDStructure): NDBuffer = arg.map { acos(it) } - override fun atan(arg: NDStructure): NDBuffer = arg.map { atan(it) } + override fun sin(arg: StructureND): NDBuffer = arg.map { sin(it) } + override fun cos(arg: StructureND): NDBuffer = arg.map { cos(it) } + override fun tan(arg: StructureND): NDBuffer = arg.map { tan(it) } + override fun asin(arg: StructureND): NDBuffer = arg.map { asin(it) } + override fun acos(arg: StructureND): NDBuffer = arg.map { acos(it) } + override fun atan(arg: StructureND): NDBuffer = arg.map { atan(it) } - override fun sinh(arg: NDStructure): NDBuffer = arg.map { sinh(it) } - override fun cosh(arg: NDStructure): NDBuffer = arg.map { cosh(it) } - override fun tanh(arg: NDStructure): NDBuffer = arg.map { tanh(it) } - override fun asinh(arg: NDStructure): NDBuffer = arg.map { asinh(it) } - override fun acosh(arg: NDStructure): NDBuffer = arg.map { acosh(it) } - override fun atanh(arg: NDStructure): NDBuffer = arg.map { atanh(it) } + override fun sinh(arg: StructureND): NDBuffer = arg.map { sinh(it) } + override fun cosh(arg: StructureND): NDBuffer = arg.map { cosh(it) } + override fun tanh(arg: StructureND): NDBuffer = arg.map { tanh(it) } + override fun asinh(arg: StructureND): NDBuffer = arg.map { asinh(it) } + override fun acosh(arg: StructureND): NDBuffer = arg.map { acosh(it) } + override fun atanh(arg: StructureND): NDBuffer = arg.map { atanh(it) } } -public fun NDAlgebra.Companion.real(vararg shape: Int): RealNDField = RealNDField(shape) +public fun AlgebraND.Companion.real(vararg shape: Int): RealFieldND = RealFieldND(shape) /** * Produce a context for n-dimensional operations inside this real field */ -public inline fun RealField.nd(vararg shape: Int, action: RealNDField.() -> R): R { +public inline fun RealField.nd(vararg shape: Int, action: RealFieldND.() -> R): R { contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) } - return RealNDField(shape).run(action) + return RealFieldND(shape).run(action) } diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/ShortNDRing.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/ShortRingND.kt similarity index 80% rename from kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/ShortNDRing.kt rename to kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/ShortRingND.kt index 2085840a4..4e39dd544 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/ShortNDRing.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/ShortRingND.kt @@ -9,10 +9,10 @@ import kotlin.contracts.InvocationKind import kotlin.contracts.contract @OptIn(UnstableKMathAPI::class) -public class ShortNDRing( +public class ShortRingND( shape: IntArray, -) : BufferedNDRing(shape, ShortRing, Buffer.Companion::auto), - NumbersAddOperations> { +) : BufferedRingND(shape, ShortRing, Buffer.Companion::auto), + NumbersAddOperations> { override val zero: NDBuffer by lazy { produce { zero } } override val one: NDBuffer by lazy { produce { one } } @@ -26,11 +26,11 @@ public class ShortNDRing( /** * Fast element production using function inlining. */ -public inline fun BufferedNDRing.produceInline(crossinline initializer: ShortRing.(Int) -> Short): NDBuffer { +public inline fun BufferedRingND.produceInline(crossinline initializer: ShortRing.(Int) -> Short): NDBuffer { return NDBuffer(strides, ShortBuffer(ShortArray(strides.linearSize) { offset -> ShortRing.initializer(offset) })) } -public inline fun ShortRing.nd(vararg shape: Int, action: ShortNDRing.() -> R): R { +public inline fun ShortRing.nd(vararg shape: Int, action: ShortRingND.() -> R): R { contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) } - return ShortNDRing(shape).run(action) + return ShortRingND(shape).run(action) } \ No newline at end of file diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure1D.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure1D.kt index ac8714803..eba51a980 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure1D.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure1D.kt @@ -6,7 +6,7 @@ import space.kscience.kmath.structures.asSequence /** * A structure that is guaranteed to be one-dimensional */ -public interface Structure1D : NDStructure, Buffer { +public interface Structure1D : StructureND, Buffer { public override val dimension: Int get() = 1 public override operator fun get(index: IntArray): T { @@ -20,7 +20,7 @@ public interface Structure1D : NDStructure, Buffer { /** * A 1D wrapper for nd-structure */ -private inline class Structure1DWrapper(val structure: NDStructure) : Structure1D { +private inline class Structure1DWrapper(val structure: StructureND) : Structure1D { override val shape: IntArray get() = structure.shape override val size: Int get() = structure.shape[0] @@ -43,9 +43,9 @@ private inline class Buffer1DWrapper(val buffer: Buffer) : Structure1D } /** - * Represent a [NDStructure] as [Structure1D]. Throw error in case of dimension mismatch + * Represent a [StructureND] as [Structure1D]. Throw error in case of dimension mismatch */ -public fun NDStructure.as1D(): Structure1D = this as? Structure1D ?: if (shape.size == 1) { +public fun StructureND.as1D(): Structure1D = this as? Structure1D ?: if (shape.size == 1) { when (this) { is NDBuffer -> Buffer1DWrapper(this.buffer) else -> Structure1DWrapper(this) diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure2D.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure2D.kt index 60dedc933..1c3b0fec8 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure2D.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure2D.kt @@ -10,7 +10,7 @@ import kotlin.reflect.KClass * * @param T the type of items. */ -public interface Structure2D : NDStructure { +public interface Structure2D : StructureND { /** * The number of rows in this structure. */ @@ -60,7 +60,7 @@ public interface Structure2D : NDStructure { /** * A 2D wrapper for nd-structure */ -private class Structure2DWrapper(val structure: NDStructure) : Structure2D { +private class Structure2DWrapper(val structure: StructureND) : Structure2D { override val shape: IntArray get() = structure.shape override val rowNum: Int get() = shape[0] @@ -79,16 +79,16 @@ private class Structure2DWrapper(val structure: NDStructure) : Structure2D } /** - * Represent a [NDStructure] as [Structure1D]. Throw error in case of dimension mismatch + * Represent a [StructureND] as [Structure1D]. Throw error in case of dimension mismatch */ -public fun NDStructure.as2D(): Structure2D = this as? Structure2D ?: when (shape.size) { +public fun StructureND.as2D(): Structure2D = this as? Structure2D ?: when (shape.size) { 2 -> Structure2DWrapper(this) else -> error("Can't create 2d-structure from ${shape.size}d-structure") } /** - * Expose inner [NDStructure] if possible + * Expose inner [StructureND] if possible */ -internal fun Structure2D.unwrap(): NDStructure = +internal fun Structure2D.unwrap(): StructureND = if (this is Structure2DWrapper) structure else this \ No newline at end of file diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/NDStructure.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/StructureND.kt similarity index 92% rename from kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/NDStructure.kt rename to kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/StructureND.kt index d758f195d..54253ba9e 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/NDStructure.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/StructureND.kt @@ -16,7 +16,7 @@ import kotlin.reflect.KClass * * @param T the type of items. */ -public interface NDStructure { +public interface StructureND { /** * The shape of structure, i.e. non-empty sequence of non-negative integers that specify sizes of dimensions of * this structure. @@ -56,9 +56,9 @@ public interface NDStructure { public companion object { /** - * Indicates whether some [NDStructure] is equal to another one. + * Indicates whether some [StructureND] is equal to another one. */ - public fun contentEquals(st1: NDStructure<*>, st2: NDStructure<*>): Boolean { + public fun contentEquals(st1: StructureND<*>, st2: StructureND<*>): Boolean { if (st1 === st2) return true // fast comparison of buffers if possible @@ -126,15 +126,15 @@ public interface NDStructure { * @param index the indices. * @return the value. */ -public operator fun NDStructure.get(vararg index: Int): T = get(index) +public operator fun StructureND.get(vararg index: Int): T = get(index) @UnstableKMathAPI -public inline fun NDStructure<*>.getFeature(): T? = getFeature(T::class) +public inline fun StructureND<*>.getFeature(): T? = getFeature(T::class) /** - * Represents mutable [NDStructure]. + * Represents mutable [StructureND]. */ -public interface MutableNDStructure : NDStructure { +public interface MutableNDStructure : StructureND { /** * Inserts an item at the specified indices. * @@ -252,7 +252,7 @@ public class DefaultStrides private constructor(override val shape: IntArray) : } /** - * Represents [NDStructure] over [Buffer]. + * Represents [StructureND] over [Buffer]. * * @param T the type of items. * @param strides The strides to access elements of [Buffer] by linear indices. @@ -261,7 +261,7 @@ public class DefaultStrides private constructor(override val shape: IntArray) : public open class NDBuffer( public val strides: Strides, buffer: Buffer, -) : NDStructure { +) : StructureND { init { if (strides.linearSize != buffer.size) { @@ -280,7 +280,7 @@ public open class NDBuffer( } override fun equals(other: Any?): Boolean { - return NDStructure.contentEquals(this, other as? NDStructure<*> ?: return false) + return StructureND.contentEquals(this, other as? StructureND<*> ?: return false) } override fun hashCode(): Int { @@ -307,7 +307,7 @@ public open class NDBuffer( /** * Transform structure to a new structure using provided [BufferFactory] and optimizing if argument is [NDBuffer] */ -public inline fun NDStructure.mapToBuffer( +public inline fun StructureND.mapToBuffer( factory: BufferFactory = Buffer.Companion::auto, crossinline transform: (T) -> R, ): NDBuffer { @@ -338,10 +338,10 @@ public class MutableNDBuffer( override operator fun set(index: IntArray, value: T): Unit = buffer.set(strides.offset(index), value) } -public inline fun NDStructure.combine( - struct: NDStructure, +public inline fun StructureND.combine( + struct: StructureND, crossinline block: (T, T) -> T, -): NDStructure { +): StructureND { require(shape.contentEquals(struct.shape)) { "Shape mismatch in structure combination" } - return NDStructure.auto(shape) { block(this[it], struct[it]) } + return StructureND.auto(shape) { block(this[it], struct[it]) } } diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/BigInt.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/BigInt.kt index 7e6a2eb81..55bb68850 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/BigInt.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/BigInt.kt @@ -1,8 +1,8 @@ package space.kscience.kmath.operations import space.kscience.kmath.misc.UnstableKMathAPI -import space.kscience.kmath.nd.BufferedNDRing -import space.kscience.kmath.nd.NDAlgebra +import space.kscience.kmath.nd.AlgebraND +import space.kscience.kmath.nd.BufferedRingND import space.kscience.kmath.operations.BigInt.Companion.BASE import space.kscience.kmath.operations.BigInt.Companion.BASE_SIZE import space.kscience.kmath.structures.Buffer @@ -464,5 +464,5 @@ public inline fun Buffer.Companion.bigInt(size: Int, initializer: (Int) -> BigIn public inline fun MutableBuffer.Companion.bigInt(size: Int, initializer: (Int) -> BigInt): MutableBuffer = boxing(size, initializer) -public fun NDAlgebra.Companion.bigInt(vararg shape: Int): BufferedNDRing = - BufferedNDRing(shape, BigIntField, Buffer.Companion::bigInt) +public fun AlgebraND.Companion.bigInt(vararg shape: Int): BufferedRingND = + BufferedRingND(shape, BigIntField, Buffer.Companion::bigInt) diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/BufferAccessor2D.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/BufferAccessor2D.kt index c65af7a98..6666c88b4 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/BufferAccessor2D.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/BufferAccessor2D.kt @@ -1,8 +1,8 @@ package space.kscience.kmath.structures import space.kscience.kmath.nd.DefaultStrides -import space.kscience.kmath.nd.NDStructure import space.kscience.kmath.nd.Structure2D +import space.kscience.kmath.nd.StructureND import space.kscience.kmath.nd.as2D /** @@ -25,7 +25,7 @@ internal class BufferAccessor2D( public fun create(mat: Structure2D): MutableBuffer = create { i, j -> mat[i, j] } //TODO optimize wrapper - public fun MutableBuffer.collect(): Structure2D = NDStructure.buffered( + public fun MutableBuffer.collect(): Structure2D = StructureND.buffered( DefaultStrides(intArrayOf(rowNum, colNum)), factory ) { (i, j) -> diff --git a/kmath-core/src/commonTest/kotlin/space/kscience/kmath/linear/MatrixTest.kt b/kmath-core/src/commonTest/kotlin/space/kscience/kmath/linear/MatrixTest.kt index 097703f49..a8a2f2586 100644 --- a/kmath-core/src/commonTest/kotlin/space/kscience/kmath/linear/MatrixTest.kt +++ b/kmath-core/src/commonTest/kotlin/space/kscience/kmath/linear/MatrixTest.kt @@ -1,7 +1,7 @@ package space.kscience.kmath.linear import space.kscience.kmath.misc.UnstableKMathAPI -import space.kscience.kmath.nd.NDStructure +import space.kscience.kmath.nd.StructureND import space.kscience.kmath.nd.as2D import kotlin.test.Test import kotlin.test.assertEquals @@ -50,8 +50,8 @@ class MatrixTest { @Test fun test2DDot() { - val firstMatrix = NDStructure.auto(2, 3) { (i, j) -> (i + j).toDouble() }.as2D() - val secondMatrix = NDStructure.auto(3, 2) { (i, j) -> (i + j).toDouble() }.as2D() + val firstMatrix = StructureND.auto(2, 3) { (i, j) -> (i + j).toDouble() }.as2D() + val secondMatrix = StructureND.auto(3, 2) { (i, j) -> (i + j).toDouble() }.as2D() LinearSpace.real.run { // val firstMatrix = produce(2, 3) { i, j -> (i + j).toDouble() } diff --git a/kmath-core/src/commonTest/kotlin/space/kscience/kmath/structures/NDFieldTest.kt b/kmath-core/src/commonTest/kotlin/space/kscience/kmath/structures/NDFieldTest.kt index 3c84d7b4b..b282ee9f5 100644 --- a/kmath-core/src/commonTest/kotlin/space/kscience/kmath/structures/NDFieldTest.kt +++ b/kmath-core/src/commonTest/kotlin/space/kscience/kmath/structures/NDFieldTest.kt @@ -1,6 +1,6 @@ package space.kscience.kmath.structures -import space.kscience.kmath.nd.NDAlgebra +import space.kscience.kmath.nd.AlgebraND import space.kscience.kmath.nd.get import space.kscience.kmath.nd.real import space.kscience.kmath.operations.invoke @@ -11,12 +11,12 @@ import kotlin.test.assertEquals internal class NDFieldTest { @Test fun verify() { - (NDAlgebra.real(12, 32)) { FieldVerifier(this, one + 3, one - 23, one * 12, 6.66) } + (AlgebraND.real(12, 32)) { FieldVerifier(this, one + 3, one - 23, one * 12, 6.66) } } @Test fun testStrides() { - val ndArray = NDAlgebra.real(10, 10).produce { (it[0] + it[1]).toDouble() } + val ndArray = AlgebraND.real(10, 10).produce { (it[0] + it[1]).toDouble() } assertEquals(ndArray[5, 5], 10.0) } } diff --git a/kmath-core/src/commonTest/kotlin/space/kscience/kmath/structures/NumberNDFieldTest.kt b/kmath-core/src/commonTest/kotlin/space/kscience/kmath/structures/NumberNDFieldTest.kt index e9e6e92fb..fb67f0308 100644 --- a/kmath-core/src/commonTest/kotlin/space/kscience/kmath/structures/NumberNDFieldTest.kt +++ b/kmath-core/src/commonTest/kotlin/space/kscience/kmath/structures/NumberNDFieldTest.kt @@ -11,7 +11,7 @@ import kotlin.test.assertEquals @Suppress("UNUSED_VARIABLE") class NumberNDFieldTest { - val algebra = NDAlgebra.real(3, 3) + val algebra = AlgebraND.real(3, 3) val array1 = algebra.produce { (i, j) -> (i + j).toDouble() } val array2 = algebra.produce { (i, j) -> (i - j).toDouble() } @@ -69,15 +69,15 @@ class NumberNDFieldTest { val division = array1.combine(array2, Double::div) } - object L2Norm : Norm, Double> { - override fun norm(arg: NDStructure): Double = + object L2Norm : Norm, Double> { + override fun norm(arg: StructureND): Double = kotlin.math.sqrt(arg.elements().sumByDouble { it.second.toDouble() }) } @Test fun testInternalContext() { algebra { - (NDAlgebra.real(*array1.shape)) { with(L2Norm) { 1 + norm(array1) + exp(array2) } } + (AlgebraND.real(*array1.shape)) { with(L2Norm) { 1 + norm(array1) + exp(array2) } } } } } diff --git a/kmath-coroutines/build.gradle.kts b/kmath-coroutines/build.gradle.kts index 4a9ca5244..b68dd2e8d 100644 --- a/kmath-coroutines/build.gradle.kts +++ b/kmath-coroutines/build.gradle.kts @@ -18,6 +18,6 @@ kotlin.sourceSets { } } -readme{ +readme { maturity = ru.mipt.npm.gradle.Maturity.EXPERIMENTAL } \ No newline at end of file diff --git a/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/chains/Chain.kt b/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/chains/Chain.kt index 5375113fe..26d078fcb 100644 --- a/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/chains/Chain.kt +++ b/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/chains/Chain.kt @@ -83,7 +83,7 @@ public class StatefulChain( private val state: S, private val seed: S.() -> R, private val forkState: ((S) -> S), - private val gen: suspend S.(R) -> R + private val gen: suspend S.(R) -> R, ) : Chain { private val mutex: Mutex = Mutex() private var value: R? = null @@ -145,7 +145,7 @@ public fun Chain.collect(mapper: suspend (Chain) -> R): Chain = public fun Chain.collectWithState( state: S, stateFork: (S) -> S, - mapper: suspend S.(Chain) -> R + mapper: suspend S.(Chain) -> R, ): Chain = object : Chain { override suspend fun next(): R = state.mapper(this@collectWithState) diff --git a/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/coroutines/coroutinesExtra.kt b/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/coroutines/coroutinesExtra.kt index 6578af0e9..7a3a52657 100644 --- a/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/coroutines/coroutinesExtra.kt +++ b/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/coroutines/coroutinesExtra.kt @@ -27,7 +27,7 @@ public class AsyncFlow internal constructor(internal val deferredFlow: Flow Flow.async( dispatcher: CoroutineDispatcher = Dispatchers.Default, - block: suspend CoroutineScope.(T) -> R + block: suspend CoroutineScope.(T) -> R, ): AsyncFlow { val flow = map { LazyDeferred(dispatcher) { block(it) } } return AsyncFlow(flow) @@ -72,12 +72,12 @@ public suspend fun AsyncFlow.collect(concurrency: Int, collector: FlowCol public suspend inline fun AsyncFlow.collect( concurrency: Int, - crossinline action: suspend (value: T) -> Unit + crossinline action: suspend (value: T) -> Unit, ): Unit = collect(concurrency, object : FlowCollector { override suspend fun emit(value: T): Unit = action(value) }) public inline fun Flow.mapParallel( dispatcher: CoroutineDispatcher = Dispatchers.Default, - crossinline transform: suspend (T) -> R + crossinline transform: suspend (T) -> R, ): Flow = flatMapMerge { value -> flow { emit(transform(value)) } }.flowOn(dispatcher) diff --git a/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/streaming/RingBuffer.kt b/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/streaming/RingBuffer.kt index efed41112..f81ad2f0d 100644 --- a/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/streaming/RingBuffer.kt +++ b/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/streaming/RingBuffer.kt @@ -13,7 +13,7 @@ import space.kscience.kmath.structures.VirtualBuffer public class RingBuffer( private val buffer: MutableBuffer, private var startIndex: Int = 0, - size: Int = 0 + size: Int = 0, ) : Buffer { private val mutex: Mutex = Mutex() diff --git a/kmath-coroutines/src/jvmMain/kotlin/space/kscience/kmath/structures/LazyNDStructure.kt b/kmath-coroutines/src/jvmMain/kotlin/space/kscience/kmath/structures/LazyStructureND.kt similarity index 62% rename from kmath-coroutines/src/jvmMain/kotlin/space/kscience/kmath/structures/LazyNDStructure.kt rename to kmath-coroutines/src/jvmMain/kotlin/space/kscience/kmath/structures/LazyStructureND.kt index 51a79f44a..468b90561 100644 --- a/kmath-coroutines/src/jvmMain/kotlin/space/kscience/kmath/structures/LazyNDStructure.kt +++ b/kmath-coroutines/src/jvmMain/kotlin/space/kscience/kmath/structures/LazyStructureND.kt @@ -3,13 +3,13 @@ package space.kscience.kmath.structures import kotlinx.coroutines.* import space.kscience.kmath.coroutines.Math import space.kscience.kmath.nd.DefaultStrides -import space.kscience.kmath.nd.NDStructure +import space.kscience.kmath.nd.StructureND -public class LazyNDStructure( +public class LazyStructureND( public val scope: CoroutineScope, public override val shape: IntArray, - public val function: suspend (IntArray) -> T -) : NDStructure { + public val function: suspend (IntArray) -> T, +) : StructureND { private val cache: MutableMap> = hashMapOf() public fun deferred(index: IntArray): Deferred = cache.getOrPut(index) { @@ -26,7 +26,7 @@ public class LazyNDStructure( } public override fun equals(other: Any?): Boolean { - return NDStructure.contentEquals(this, other as? NDStructure<*> ?: return false) + return StructureND.contentEquals(this, other as? StructureND<*> ?: return false) } public override fun hashCode(): Int { @@ -38,21 +38,21 @@ public class LazyNDStructure( } } -public fun NDStructure.deferred(index: IntArray): Deferred = - if (this is LazyNDStructure) deferred(index) else CompletableDeferred(get(index)) +public fun StructureND.deferred(index: IntArray): Deferred = + if (this is LazyStructureND) deferred(index) else CompletableDeferred(get(index)) -public suspend fun NDStructure.await(index: IntArray): T = - if (this is LazyNDStructure) await(index) else get(index) +public suspend fun StructureND.await(index: IntArray): T = + if (this is LazyStructureND) await(index) else get(index) /** * PENDING would benefit from KEEP-176 */ -public inline fun NDStructure.mapAsyncIndexed( +public inline fun StructureND.mapAsyncIndexed( scope: CoroutineScope, - crossinline function: suspend (T, index: IntArray) -> R -): LazyNDStructure = LazyNDStructure(scope, shape) { index -> function(get(index), index) } + crossinline function: suspend (T, index: IntArray) -> R, +): LazyStructureND = LazyStructureND(scope, shape) { index -> function(get(index), index) } -public inline fun NDStructure.mapAsync( +public inline fun StructureND.mapAsync( scope: CoroutineScope, - crossinline function: suspend (T) -> R -): LazyNDStructure = LazyNDStructure(scope, shape) { index -> function(get(index)) } + crossinline function: suspend (T) -> R, +): LazyStructureND = LazyStructureND(scope, shape) { index -> function(get(index)) } diff --git a/kmath-dimensions/build.gradle.kts b/kmath-dimensions/build.gradle.kts index 3355eda42..3c73f34e6 100644 --- a/kmath-dimensions/build.gradle.kts +++ b/kmath-dimensions/build.gradle.kts @@ -19,6 +19,6 @@ kotlin.sourceSets { } } -readme{ +readme { maturity = ru.mipt.npm.gradle.Maturity.PROTOTYPE } diff --git a/kmath-dimensions/src/commonMain/kotlin/space/kscience/kmath/dimensions/Wrappers.kt b/kmath-dimensions/src/commonMain/kotlin/space/kscience/kmath/dimensions/Wrappers.kt index f7e14b29f..81b008b6a 100644 --- a/kmath-dimensions/src/commonMain/kotlin/space/kscience/kmath/dimensions/Wrappers.kt +++ b/kmath-dimensions/src/commonMain/kotlin/space/kscience/kmath/dimensions/Wrappers.kt @@ -1,6 +1,9 @@ package space.kscience.kmath.dimensions -import space.kscience.kmath.linear.* +import space.kscience.kmath.linear.LinearSpace +import space.kscience.kmath.linear.Matrix +import space.kscience.kmath.linear.Point +import space.kscience.kmath.linear.transpose import space.kscience.kmath.nd.Structure2D import space.kscience.kmath.operations.RealField import space.kscience.kmath.operations.Ring @@ -95,7 +98,7 @@ public inline class DMatrixContext>(public val context: * Produce a matrix with this context and given dimensions */ public inline fun produce( - noinline initializer: A.(i: Int, j: Int) -> T + noinline initializer: A.(i: Int, j: Int) -> T, ): DMatrix { val rows = Dimension.dim() val cols = Dimension.dim() @@ -147,9 +150,10 @@ public inline class DMatrixContext>(public val context: /** * A square unit matrix */ -public inline fun DMatrixContext.one(): DMatrix = produce { i, j -> - if (i == j) 1.0 else 0.0 -} +public inline fun DMatrixContext.one(): DMatrix = + produce { i, j -> + if (i == j) 1.0 else 0.0 + } public inline fun DMatrixContext.zero(): DMatrix = produce { _, _ -> diff --git a/kmath-ejml/build.gradle.kts b/kmath-ejml/build.gradle.kts index 07f95b13f..1ce2291c4 100644 --- a/kmath-ejml/build.gradle.kts +++ b/kmath-ejml/build.gradle.kts @@ -7,6 +7,6 @@ dependencies { implementation(project(":kmath-core")) } -readme{ +readme { maturity = ru.mipt.npm.gradle.Maturity.PROTOTYPE } \ No newline at end of file diff --git a/kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlMatrix.kt b/kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlMatrix.kt index 5f93af729..c79493411 100644 --- a/kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlMatrix.kt +++ b/kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlMatrix.kt @@ -2,7 +2,7 @@ package space.kscience.kmath.ejml import org.ejml.simple.SimpleMatrix import space.kscience.kmath.linear.Matrix -import space.kscience.kmath.nd.NDStructure +import space.kscience.kmath.nd.StructureND /** * Represents featured matrix over EJML [SimpleMatrix]. @@ -18,8 +18,8 @@ public class EjmlMatrix(public val origin: SimpleMatrix) : Matrix { override fun equals(other: Any?): Boolean { if (this === other) return true - if (other !is NDStructure<*>) return false - return NDStructure.contentEquals(this, other) + if (other !is StructureND<*>) return false + return StructureND.contentEquals(this, other) } override fun hashCode(): Int = origin.hashCode() diff --git a/kmath-for-real/src/commonMain/kotlin/space/kscience/kmath/real/dot.kt b/kmath-for-real/src/commonMain/kotlin/space/kscience/kmath/real/dot.kt index 0bc5c111b..d5f093d63 100644 --- a/kmath-for-real/src/commonMain/kotlin/space/kscience/kmath/real/dot.kt +++ b/kmath-for-real/src/commonMain/kotlin/space/kscience/kmath/real/dot.kt @@ -7,6 +7,6 @@ import space.kscience.kmath.linear.Matrix /** * Optimized dot product for real matrices */ -public infix fun Matrix.dot(other: Matrix): Matrix = LinearSpace.real.run{ +public infix fun Matrix.dot(other: Matrix): Matrix = LinearSpace.real.run { this@dot dot other } \ No newline at end of file diff --git a/kmath-for-real/src/commonTest/kotlin/kaceince/kmath/real/GridTest.kt b/kmath-for-real/src/commonTest/kotlin/kaceince/kmath/real/GridTest.kt index c538a2d99..5a644c8f9 100644 --- a/kmath-for-real/src/commonTest/kotlin/kaceince/kmath/real/GridTest.kt +++ b/kmath-for-real/src/commonTest/kotlin/kaceince/kmath/real/GridTest.kt @@ -6,7 +6,7 @@ import kotlin.test.assertEquals class GridTest { @Test - fun testStepGrid(){ + fun testStepGrid() { val grid = 0.0..1.0 step 0.2 assertEquals(6, grid.size) } diff --git a/kmath-functions/build.gradle.kts b/kmath-functions/build.gradle.kts index fc52c4981..067dbd9b3 100644 --- a/kmath-functions/build.gradle.kts +++ b/kmath-functions/build.gradle.kts @@ -15,6 +15,10 @@ readme { feature("piecewise", "src/commonMain/kotlin/kscience/kmath/functions/Piecewise.kt", "Piecewise functions.") feature("polynomials", "src/commonMain/kotlin/kscience/kmath/functions/Polynomial.kt", "Polynomial functions.") - feature("linear interpolation", "src/commonMain/kotlin/kscience/kmath/interpolation/LinearInterpolator.kt", "Linear XY interpolator.") - feature("spline interpolation", "src/commonMain/kotlin/kscience/kmath/interpolation/SplineInterpolator.kt", "Cubic spline XY interpolator.") + feature("linear interpolation", + "src/commonMain/kotlin/kscience/kmath/interpolation/LinearInterpolator.kt", + "Linear XY interpolator.") + feature("spline interpolation", + "src/commonMain/kotlin/kscience/kmath/interpolation/SplineInterpolator.kt", + "Cubic spline XY interpolator.") } \ No newline at end of file diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/Integrand.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/Integrand.kt index ae964b271..336a3ef3a 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/Integrand.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/Integrand.kt @@ -17,6 +17,7 @@ public class IntegrandRelativeAccuracy(public val accuracy: Double) : IntegrandF public class IntegrandAbsoluteAccuracy(public val accuracy: Double) : IntegrandFeature public class IntegrandCalls(public val calls: Int) : IntegrandFeature + public val Integrand.calls: Int get() = getFeature()?.calls ?: 0 public class IntegrandMaxCalls(public val maxCalls: Int) : IntegrandFeature diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/Integrator.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/Integrator.kt index 7027e62c7..ebc53ad2e 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/Integrator.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/Integrator.kt @@ -3,7 +3,7 @@ package space.kscience.kmath.integration /** * A general interface for all integrators */ -public interface Integrator { +public interface Integrator { /** * Run one integration pass and return a new [Integrand] with a new set of features */ diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/Interpolator.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/Interpolator.kt index dc5227f8b..fa978a9bc 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/Interpolator.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/Interpolator.kt @@ -24,21 +24,21 @@ public interface PolynomialInterpolator> : Interpolator public fun > PolynomialInterpolator.interpolatePolynomials( x: Buffer, - y: Buffer + y: Buffer, ): PiecewisePolynomial { val pointSet = BufferXYPointSet(x, y) return interpolatePolynomials(pointSet) } public fun > PolynomialInterpolator.interpolatePolynomials( - data: Map + data: Map, ): PiecewisePolynomial { val pointSet = BufferXYPointSet(data.keys.toList().asBuffer(), data.values.toList().asBuffer()) return interpolatePolynomials(pointSet) } public fun > PolynomialInterpolator.interpolatePolynomials( - data: List> + data: List>, ): PiecewisePolynomial { val pointSet = BufferXYPointSet(data.map { it.first }.asBuffer(), data.map { it.second }.asBuffer()) return interpolatePolynomials(pointSet) diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/XYPointSet.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/XYPointSet.kt index c3bcad846..1ff7b6351 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/XYPointSet.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/XYPointSet.kt @@ -32,7 +32,7 @@ public class NDStructureColumn(public val structure: Structure2D, public v public class BufferXYPointSet( public override val x: Buffer, - public override val y: Buffer + public override val y: Buffer, ) : XYPointSet { public override val size: Int get() = x.size diff --git a/kmath-geometry/build.gradle.kts b/kmath-geometry/build.gradle.kts index e99eee38b..9d1b2d4d6 100644 --- a/kmath-geometry/build.gradle.kts +++ b/kmath-geometry/build.gradle.kts @@ -6,6 +6,6 @@ kotlin.sourceSets.commonMain { } } -readme{ +readme { maturity = ru.mipt.npm.gradle.Maturity.PROTOTYPE } diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Counter.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Counter.kt index d5f3965d9..ca0eba52f 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Counter.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Counter.kt @@ -11,7 +11,8 @@ import space.kscience.kmath.operations.RealField public interface Counter { public fun add(delta: T) public val value: T - public companion object{ + + public companion object { public fun real(): ObjectCounter = ObjectCounter(RealField) } } diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt index 9ee4a6e1e..ed76c7aa1 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt @@ -29,7 +29,7 @@ public interface Histogram> { public val bins: Iterable } -public fun interface HistogramBuilder { +public fun interface HistogramBuilder { /** * Increment appropriate bin diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt index 19128b2ac..f55080b09 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt @@ -3,9 +3,9 @@ package space.kscience.kmath.histogram import space.kscience.kmath.domains.Domain import space.kscience.kmath.linear.Point import space.kscience.kmath.misc.UnstableKMathAPI -import space.kscience.kmath.nd.NDField -import space.kscience.kmath.nd.NDStructure +import space.kscience.kmath.nd.FieldND import space.kscience.kmath.nd.Strides +import space.kscience.kmath.nd.StructureND import space.kscience.kmath.operations.Group import space.kscience.kmath.operations.ScaleOperations import space.kscience.kmath.operations.SpaceElement @@ -22,7 +22,7 @@ public data class DomainBin>( @OptIn(UnstableKMathAPI::class) public class IndexedHistogram, V : Any>( override val context: IndexedHistogramSpace, - public val values: NDStructure, + public val values: StructureND, ) : Histogram>, SpaceElement, IndexedHistogramSpace> { override fun get(point: Point): Bin? { @@ -46,7 +46,7 @@ public interface IndexedHistogramSpace, V : Any> : Group>, ScaleOperations> { //public val valueSpace: Space public val strides: Strides - public val histogramValueSpace: NDField //= NDAlgebra.space(valueSpace, Buffer.Companion::boxing, *shape), + public val histogramValueSpace: FieldND //= NDAlgebra.space(valueSpace, Buffer.Companion::boxing, *shape), /** * Resolve index of the bin including given [point] diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/RealHistogramSpace.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/RealHistogramSpace.kt index 3df0b1626..1407470c1 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/RealHistogramSpace.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/RealHistogramSpace.kt @@ -23,13 +23,13 @@ public class RealHistogramSpace( public val dimension: Int get() = lower.size private val shape = IntArray(binNums.size) { binNums[it] + 2 } - override val histogramValueSpace: RealNDField = NDAlgebra.real(*shape) + override val histogramValueSpace: RealFieldND = AlgebraND.real(*shape) override val strides: Strides get() = histogramValueSpace.strides private val binSize = RealBuffer(dimension) { (upper[it] - lower[it]) / binNums[it] } /** - * Get internal [NDStructure] bin index for given axis + * Get internal [StructureND] bin index for given axis */ private fun getIndex(axis: Int, value: Double): Int = when { value >= upper[axis] -> binNums[axis] + 1 // overflow @@ -69,7 +69,7 @@ public class RealHistogramSpace( } override fun produce(builder: HistogramBuilder.() -> Unit): IndexedHistogram { - val ndCounter = NDStructure.auto(strides) { Counter.real() } + val ndCounter = StructureND.auto(strides) { Counter.real() } val hBuilder = HistogramBuilder { point, value -> val index = getIndex(point) ndCounter[index].add(value.toDouble()) diff --git a/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/MultivariateHistogramTest.kt b/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/MultivariateHistogramTest.kt index e83f42b4b..fc00c6cdf 100644 --- a/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/MultivariateHistogramTest.kt +++ b/kmath-histograms/src/commonTest/kotlin/space/kscience/kmath/histogram/MultivariateHistogramTest.kt @@ -44,7 +44,7 @@ internal class MultivariateHistogramTest { @Test fun testHistogramAlgebra() { - RealHistogramSpace.fromRanges( + RealHistogramSpace.fromRanges( (-1.0..1.0), (-1.0..1.0), (-1.0..1.0) diff --git a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt index 03bd096d9..b1b2a10c2 100644 --- a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt +++ b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt @@ -9,7 +9,8 @@ import space.kscience.kmath.structures.asSequence @UnstableKMathAPI -public val UnivariateDomain.center: Double get() = (range.endInclusive - range.start) / 2 +public val UnivariateDomain.center: Double + get() = (range.endInclusive - range.start) / 2 /** * A univariate bin based an a range diff --git a/kmath-kotlingrad/build.gradle.kts b/kmath-kotlingrad/build.gradle.kts index 51292cbfb..a7c0c7e01 100644 --- a/kmath-kotlingrad/build.gradle.kts +++ b/kmath-kotlingrad/build.gradle.kts @@ -8,6 +8,6 @@ dependencies { api(project(":kmath-ast")) } -readme{ +readme { maturity = ru.mipt.npm.gradle.Maturity.PROTOTYPE } \ No newline at end of file diff --git a/kmath-memory/build.gradle.kts b/kmath-memory/build.gradle.kts index dbd68b042..1ccd1bed8 100644 --- a/kmath-memory/build.gradle.kts +++ b/kmath-memory/build.gradle.kts @@ -3,7 +3,7 @@ plugins { id("ru.mipt.npm.gradle.native") } -readme{ +readme { description = """ An API and basic implementation for arranging objects in a continous memory block. """.trimIndent() diff --git a/kmath-memory/src/commonMain/kotlin/space/kscience/kmath/memory/MemorySpec.kt b/kmath-memory/src/commonMain/kotlin/space/kscience/kmath/memory/MemorySpec.kt index 7c68e3abb..5ed3c3c9e 100644 --- a/kmath-memory/src/commonMain/kotlin/space/kscience/kmath/memory/MemorySpec.kt +++ b/kmath-memory/src/commonMain/kotlin/space/kscience/kmath/memory/MemorySpec.kt @@ -32,7 +32,8 @@ public fun MemoryReader.read(spec: MemorySpec, offset: Int): T = wi /** * Writes the object [value] with [spec] starting from [offset]. */ -public fun MemoryWriter.write(spec: MemorySpec, offset: Int, value: T): Unit = with(spec) { write(offset, value) } +public fun MemoryWriter.write(spec: MemorySpec, offset: Int, value: T): Unit = + with(spec) { write(offset, value) } /** * Reads array of [size] objects mapped by [spec] at certain [offset]. diff --git a/kmath-memory/src/jvmMain/kotlin/space/kscience/kmath/memory/ByteBufferMemory.kt b/kmath-memory/src/jvmMain/kotlin/space/kscience/kmath/memory/ByteBufferMemory.kt index 5145b1ed4..fe15cce49 100644 --- a/kmath-memory/src/jvmMain/kotlin/space/kscience/kmath/memory/ByteBufferMemory.kt +++ b/kmath-memory/src/jvmMain/kotlin/space/kscience/kmath/memory/ByteBufferMemory.kt @@ -13,7 +13,7 @@ import kotlin.contracts.contract internal class ByteBufferMemory( val buffer: ByteBuffer, val startOffset: Int = 0, - override val size: Int = buffer.limit() + override val size: Int = buffer.limit(), ) : Memory { @Suppress("NOTHING_TO_INLINE") private inline fun position(o: Int): Int = startOffset + o @@ -100,7 +100,8 @@ public actual fun Memory.Companion.allocate(length: Int): Memory = * Wraps a [Memory] around existing [ByteArray]. This operation is unsafe since the array is not copied * and could be mutated independently from the resulting [Memory]. */ -public actual fun Memory.Companion.wrap(array: ByteArray): Memory = ByteBufferMemory(checkNotNull(ByteBuffer.wrap(array))) +public actual fun Memory.Companion.wrap(array: ByteArray): Memory = + ByteBufferMemory(checkNotNull(ByteBuffer.wrap(array))) /** * Wraps this [ByteBuffer] to [Memory] object. diff --git a/kmath-memory/src/nativeMain/kotlin/space/kscience/kmath/memory/NativeMemory.kt b/kmath-memory/src/nativeMain/kotlin/space/kscience/kmath/memory/NativeMemory.kt index 3afb6c7a2..1274959ad 100644 --- a/kmath-memory/src/nativeMain/kotlin/space/kscience/kmath/memory/NativeMemory.kt +++ b/kmath-memory/src/nativeMain/kotlin/space/kscience/kmath/memory/NativeMemory.kt @@ -4,7 +4,7 @@ package space.kscience.kmath.memory internal class NativeMemory( val array: ByteArray, val startOffset: Int = 0, - override val size: Int = array.size + override val size: Int = array.size, ) : Memory { @Suppress("NOTHING_TO_INLINE") private inline fun position(o: Int): Int = startOffset + o diff --git a/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebra.kt b/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebra.kt index d8ce1052a..bf73ec20f 100644 --- a/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebra.kt +++ b/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebra.kt @@ -7,7 +7,7 @@ import space.kscience.kmath.nd.* import space.kscience.kmath.operations.* import space.kscience.kmath.structures.* -internal fun NDAlgebra<*, *>.checkShape(array: INDArray): INDArray { +internal fun AlgebraND<*, *>.checkShape(array: INDArray): INDArray { val arrayShape = array.shape().toIntArray() if (!shape.contentEquals(arrayShape)) throw ShapeMismatchException(shape, arrayShape) return array @@ -15,18 +15,18 @@ internal fun NDAlgebra<*, *>.checkShape(array: INDArray): INDArray { /** - * Represents [NDAlgebra] over [Nd4jArrayAlgebra]. + * Represents [AlgebraND] over [Nd4jArrayAlgebra]. * * @param T the type of ND-structure element. * @param C the type of the element context. */ -public interface Nd4jArrayAlgebra> : NDAlgebra { +public interface Nd4jArrayAlgebra> : AlgebraND { /** * Wraps [INDArray] to [N]. */ public fun INDArray.wrap(): Nd4jArrayStructure - public val NDStructure.ndArray: INDArray + public val StructureND.ndArray: INDArray get() = when { !shape.contentEquals(this@Nd4jArrayAlgebra.shape) -> throw ShapeMismatchException( this@Nd4jArrayAlgebra.shape, @@ -44,13 +44,13 @@ public interface Nd4jArrayAlgebra> : NDAlgebra { return struct } - public override fun NDStructure.map(transform: C.(T) -> T): Nd4jArrayStructure { + public override fun StructureND.map(transform: C.(T) -> T): Nd4jArrayStructure { val newStruct = ndArray.dup().wrap() newStruct.elements().forEach { (idx, value) -> newStruct[idx] = elementContext.transform(value) } return newStruct } - public override fun NDStructure.mapIndexed( + public override fun StructureND.mapIndexed( transform: C.(index: IntArray, T) -> T, ): Nd4jArrayStructure { val new = Nd4j.create(*this@Nd4jArrayAlgebra.shape).wrap() @@ -59,8 +59,8 @@ public interface Nd4jArrayAlgebra> : NDAlgebra { } public override fun combine( - a: NDStructure, - b: NDStructure, + a: StructureND, + b: StructureND, transform: C.(T, T) -> T, ): Nd4jArrayStructure { val new = Nd4j.create(*shape).wrap() @@ -70,42 +70,42 @@ public interface Nd4jArrayAlgebra> : NDAlgebra { } /** - * Represents [NDGroup] over [Nd4jArrayStructure]. + * Represents [GroupND] over [Nd4jArrayStructure]. * * @param T the type of the element contained in ND structure. * @param S the type of space of structure elements. */ -public interface Nd4JArrayGroup> : NDGroup, Nd4jArrayAlgebra { +public interface Nd4JArrayGroup> : GroupND, Nd4jArrayAlgebra { public override val zero: Nd4jArrayStructure get() = Nd4j.zeros(*shape).wrap() - public override fun add(a: NDStructure, b: NDStructure): Nd4jArrayStructure = + public override fun add(a: StructureND, b: StructureND): Nd4jArrayStructure = a.ndArray.add(b.ndArray).wrap() - public override operator fun NDStructure.minus(b: NDStructure): Nd4jArrayStructure = + public override operator fun StructureND.minus(b: StructureND): Nd4jArrayStructure = ndArray.sub(b.ndArray).wrap() - public override operator fun NDStructure.unaryMinus(): Nd4jArrayStructure = + public override operator fun StructureND.unaryMinus(): Nd4jArrayStructure = ndArray.neg().wrap() - public fun multiply(a: NDStructure, k: Number): Nd4jArrayStructure = + public fun multiply(a: StructureND, k: Number): Nd4jArrayStructure = a.ndArray.mul(k).wrap() } /** - * Represents [NDRing] over [Nd4jArrayStructure]. + * Represents [RingND] over [Nd4jArrayStructure]. * * @param T the type of the element contained in ND structure. * @param R the type of ring of structure elements. */ @OptIn(UnstableKMathAPI::class) -public interface Nd4jArrayRing> : NDRing, Nd4JArrayGroup { +public interface Nd4jArrayRing> : RingND, Nd4JArrayGroup { public override val one: Nd4jArrayStructure get() = Nd4j.ones(*shape).wrap() - public override fun multiply(a: NDStructure, b: NDStructure): Nd4jArrayStructure = + public override fun multiply(a: StructureND, b: StructureND): Nd4jArrayStructure = a.ndArray.mul(b.ndArray).wrap() // // public override operator fun Nd4jArrayStructure.minus(b: Number): Nd4jArrayStructure { @@ -131,19 +131,19 @@ public interface Nd4jArrayRing> : NDRing, Nd4JArrayGroup = intNd4jArrayRingCache.get().getOrPut(shape) { IntNd4jArrayRing(shape) } /** - * Creates an [NDRing] for [Long] values or pull it from cache if it was created previously. + * Creates an [RingND] for [Long] values or pull it from cache if it was created previously. */ public fun long(vararg shape: Int): Nd4jArrayRing = longNd4jArrayRingCache.get().getOrPut(shape) { LongNd4jArrayRing(shape) } /** - * Creates a most suitable implementation of [NDRing] using reified class. + * Creates a most suitable implementation of [RingND] using reified class. */ @Suppress("UNCHECKED_CAST") public inline fun auto(vararg shape: Int): Nd4jArrayRing> = when { @@ -155,18 +155,18 @@ public interface Nd4jArrayRing> : NDRing, Nd4JArrayGroup> : NDField, Nd4jArrayRing { +public interface Nd4jArrayField> : FieldND, Nd4jArrayRing { - public override fun divide(a: NDStructure, b: NDStructure): Nd4jArrayStructure = + public override fun divide(a: StructureND, b: StructureND): Nd4jArrayStructure = a.ndArray.div(b.ndArray).wrap() - public operator fun Number.div(b: NDStructure): Nd4jArrayStructure = b.ndArray.rdiv(this).wrap() + public operator fun Number.div(b: StructureND): Nd4jArrayStructure = b.ndArray.rdiv(this).wrap() public companion object { private val floatNd4jArrayFieldCache: ThreadLocal> = @@ -176,19 +176,19 @@ public interface Nd4jArrayField> : NDField, Nd4jArrayRing< ThreadLocal.withInitial { hashMapOf() } /** - * Creates an [NDField] for [Float] values or pull it from cache if it was created previously. + * Creates an [FieldND] for [Float] values or pull it from cache if it was created previously. */ public fun float(vararg shape: Int): Nd4jArrayRing = floatNd4jArrayFieldCache.get().getOrPut(shape) { FloatNd4jArrayField(shape) } /** - * Creates an [NDField] for [Double] values or pull it from cache if it was created previously. + * Creates an [FieldND] for [Double] values or pull it from cache if it was created previously. */ public fun real(vararg shape: Int): Nd4jArrayRing = realNd4jArrayFieldCache.get().getOrPut(shape) { RealNd4jArrayField(shape) } /** - * Creates a most suitable implementation of [NDRing] using reified class. + * Creates a most suitable implementation of [RingND] using reified class. */ @Suppress("UNCHECKED_CAST") public inline fun auto(vararg shape: Int): Nd4jArrayField> = when { @@ -200,44 +200,44 @@ public interface Nd4jArrayField> : NDField, Nd4jArrayRing< } /** - * Represents [NDField] over [Nd4jArrayRealStructure]. + * Represents [FieldND] over [Nd4jArrayRealStructure]. */ public class RealNd4jArrayField(public override val shape: IntArray) : Nd4jArrayField { public override val elementContext: RealField get() = RealField public override fun INDArray.wrap(): Nd4jArrayStructure = checkShape(this).asRealStructure() - override fun scale(a: NDStructure, value: Double): Nd4jArrayStructure { + override fun scale(a: StructureND, value: Double): Nd4jArrayStructure { return a.ndArray.mul(value).wrap() } - public override operator fun NDStructure.div(arg: Double): Nd4jArrayStructure { + public override operator fun StructureND.div(arg: Double): Nd4jArrayStructure { return ndArray.div(arg).wrap() } - public override operator fun NDStructure.plus(arg: Double): Nd4jArrayStructure { + public override operator fun StructureND.plus(arg: Double): Nd4jArrayStructure { return ndArray.add(arg).wrap() } - public override operator fun NDStructure.minus(arg: Double): Nd4jArrayStructure { + public override operator fun StructureND.minus(arg: Double): Nd4jArrayStructure { return ndArray.sub(arg).wrap() } - public override operator fun NDStructure.times(arg: Double): Nd4jArrayStructure { + public override operator fun StructureND.times(arg: Double): Nd4jArrayStructure { return ndArray.mul(arg).wrap() } - public override operator fun Double.div(arg: NDStructure): Nd4jArrayStructure { + public override operator fun Double.div(arg: StructureND): Nd4jArrayStructure { return arg.ndArray.rdiv(this).wrap() } - public override operator fun Double.minus(arg: NDStructure): Nd4jArrayStructure { + public override operator fun Double.minus(arg: StructureND): Nd4jArrayStructure { return arg.ndArray.rsub(this).wrap() } } /** - * Represents [NDField] over [Nd4jArrayStructure] of [Float]. + * Represents [FieldND] over [Nd4jArrayStructure] of [Float]. */ public class FloatNd4jArrayField(public override val shape: IntArray) : Nd4jArrayField { public override val elementContext: FloatField @@ -245,30 +245,30 @@ public class FloatNd4jArrayField(public override val shape: IntArray) : Nd4jArra public override fun INDArray.wrap(): Nd4jArrayStructure = checkShape(this).asFloatStructure() - override fun scale(a: NDStructure, value: Double): NDStructure = + override fun scale(a: StructureND, value: Double): StructureND = a.ndArray.mul(value).wrap() - public override operator fun NDStructure.div(arg: Float): Nd4jArrayStructure = + public override operator fun StructureND.div(arg: Float): Nd4jArrayStructure = ndArray.div(arg).wrap() - public override operator fun NDStructure.plus(arg: Float): Nd4jArrayStructure = + public override operator fun StructureND.plus(arg: Float): Nd4jArrayStructure = ndArray.add(arg).wrap() - public override operator fun NDStructure.minus(arg: Float): Nd4jArrayStructure = + public override operator fun StructureND.minus(arg: Float): Nd4jArrayStructure = ndArray.sub(arg).wrap() - public override operator fun NDStructure.times(arg: Float): Nd4jArrayStructure = + public override operator fun StructureND.times(arg: Float): Nd4jArrayStructure = ndArray.mul(arg).wrap() - public override operator fun Float.div(arg: NDStructure): Nd4jArrayStructure = + public override operator fun Float.div(arg: StructureND): Nd4jArrayStructure = arg.ndArray.rdiv(this).wrap() - public override operator fun Float.minus(arg: NDStructure): Nd4jArrayStructure = + public override operator fun Float.minus(arg: StructureND): Nd4jArrayStructure = arg.ndArray.rsub(this).wrap() } /** - * Represents [NDRing] over [Nd4jArrayIntStructure]. + * Represents [RingND] over [Nd4jArrayIntStructure]. */ public class IntNd4jArrayRing(public override val shape: IntArray) : Nd4jArrayRing { public override val elementContext: IntRing @@ -276,21 +276,21 @@ public class IntNd4jArrayRing(public override val shape: IntArray) : Nd4jArrayRi public override fun INDArray.wrap(): Nd4jArrayStructure = checkShape(this).asIntStructure() - public override operator fun NDStructure.plus(arg: Int): Nd4jArrayStructure = + public override operator fun StructureND.plus(arg: Int): Nd4jArrayStructure = ndArray.add(arg).wrap() - public override operator fun NDStructure.minus(arg: Int): Nd4jArrayStructure = + public override operator fun StructureND.minus(arg: Int): Nd4jArrayStructure = ndArray.sub(arg).wrap() - public override operator fun NDStructure.times(arg: Int): Nd4jArrayStructure = + public override operator fun StructureND.times(arg: Int): Nd4jArrayStructure = ndArray.mul(arg).wrap() - public override operator fun Int.minus(arg: NDStructure): Nd4jArrayStructure = + public override operator fun Int.minus(arg: StructureND): Nd4jArrayStructure = arg.ndArray.rsub(this).wrap() } /** - * Represents [NDRing] over [Nd4jArrayStructure] of [Long]. + * Represents [RingND] over [Nd4jArrayStructure] of [Long]. */ public class LongNd4jArrayRing(public override val shape: IntArray) : Nd4jArrayRing { public override val elementContext: LongRing @@ -298,15 +298,15 @@ public class LongNd4jArrayRing(public override val shape: IntArray) : Nd4jArrayR public override fun INDArray.wrap(): Nd4jArrayStructure = checkShape(this).asLongStructure() - public override operator fun NDStructure.plus(arg: Long): Nd4jArrayStructure = + public override operator fun StructureND.plus(arg: Long): Nd4jArrayStructure = ndArray.add(arg).wrap() - public override operator fun NDStructure.minus(arg: Long): Nd4jArrayStructure = + public override operator fun StructureND.minus(arg: Long): Nd4jArrayStructure = ndArray.sub(arg).wrap() - public override operator fun NDStructure.times(arg: Long): Nd4jArrayStructure = + public override operator fun StructureND.times(arg: Long): Nd4jArrayStructure = ndArray.mul(arg).wrap() - public override operator fun Long.minus(arg: NDStructure): Nd4jArrayStructure = + public override operator fun Long.minus(arg: StructureND): Nd4jArrayStructure = arg.ndArray.rsub(this).wrap() } 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 415c908a8..9b4cc1a24 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 @@ -2,10 +2,10 @@ package space.kscience.kmath.nd4j import org.nd4j.linalg.api.ndarray.INDArray import space.kscience.kmath.nd.MutableNDStructure -import space.kscience.kmath.nd.NDStructure +import space.kscience.kmath.nd.StructureND /** - * Represents a [NDStructure] wrapping an [INDArray] object. + * Represents a [StructureND] wrapping an [INDArray] object. * * @param T the type of items. */ diff --git a/kmath-nd4j/src/test/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebraTest.kt b/kmath-nd4j/src/test/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebraTest.kt index 9a067aa29..6a8d8796c 100644 --- a/kmath-nd4j/src/test/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebraTest.kt +++ b/kmath-nd4j/src/test/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebraTest.kt @@ -8,7 +8,7 @@ import kotlin.test.fail internal class Nd4jArrayAlgebraTest { @Test fun testProduce() { - val res = with(RealNd4jArrayField(intArrayOf(2, 2))){ produce { it.sum().toDouble() } } + val res = with(RealNd4jArrayField(intArrayOf(2, 2))) { produce { it.sum().toDouble() } } val expected = (Nd4j.create(2, 2) ?: fail()).asRealStructure() expected[intArrayOf(0, 0)] = 0.0 expected[intArrayOf(0, 1)] = 1.0 diff --git a/kmath-nd4j/src/test/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructureTest.kt b/kmath-nd4j/src/test/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructureTest.kt index 03369127d..5cf6dd26f 100644 --- a/kmath-nd4j/src/test/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructureTest.kt +++ b/kmath-nd4j/src/test/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructureTest.kt @@ -41,9 +41,9 @@ internal class Nd4jArrayStructureTest { @Test fun testHashCode() { - val nd1 = Nd4j.create(doubleArrayOf(1.0, 2.0, 3.0))?:fail() + val nd1 = Nd4j.create(doubleArrayOf(1.0, 2.0, 3.0)) ?: fail() val struct1 = nd1.asRealStructure() - val nd2 = Nd4j.create(doubleArrayOf(1.0, 2.0, 3.0))?:fail() + val nd2 = Nd4j.create(doubleArrayOf(1.0, 2.0, 3.0)) ?: fail() val struct2 = nd2.asRealStructure() assertEquals(struct1.hashCode(), struct2.hashCode()) } @@ -57,7 +57,7 @@ internal class Nd4jArrayStructureTest { @Test fun testGet() { - val nd = Nd4j.rand(10, 2, 3, 6)?:fail() + val nd = Nd4j.rand(10, 2, 3, 6) ?: fail() val struct = nd.asIntStructure() assertEquals(nd.getInt(0, 0, 0, 0), struct[0, 0, 0, 0]) } diff --git a/kmath-stat/build.gradle.kts b/kmath-stat/build.gradle.kts index 67a96937c..5b29a9e64 100644 --- a/kmath-stat/build.gradle.kts +++ b/kmath-stat/build.gradle.kts @@ -25,6 +25,6 @@ kotlin.sourceSets { } } -readme{ +readme { maturity = ru.mipt.npm.gradle.Maturity.EXPERIMENTAL } \ No newline at end of file diff --git a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Distribution.kt b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Distribution.kt index b5b6db1d8..dacf7a9cd 100644 --- a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Distribution.kt +++ b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Distribution.kt @@ -53,7 +53,7 @@ public fun > UnivariateDistribution.integral(from: T, to: T public fun Sampler.sampleBuffer( generator: RandomGenerator, size: Int, - bufferFactory: BufferFactory = Buffer.Companion::boxing + bufferFactory: BufferFactory = Buffer.Companion::boxing, ): Chain> { require(size > 1) //creating temporary storage once diff --git a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/OptimizationProblem.kt b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/OptimizationProblem.kt index 71f3096de..ffa24fa98 100644 --- a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/OptimizationProblem.kt +++ b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/OptimizationProblem.kt @@ -68,7 +68,7 @@ public fun > Expression.optimizeWith( configuration: F.() -> Unit, ): OptimizationResult { require(symbols.isNotEmpty()) { "Must provide a list of symbols for optimization" } - val problem = factory(symbols.toList(),configuration) + val problem = factory(symbols.toList(), configuration) problem.expression(this) return problem.optimize() } @@ -76,7 +76,7 @@ public fun > Expression.optimizeWith( /** * Optimize differentiable expression using specific [OptimizationProblemFactory] */ -public fun > DifferentiableExpression>.optimizeWith( +public fun > DifferentiableExpression>.optimizeWith( factory: OptimizationProblemFactory, vararg symbols: Symbol, configuration: F.() -> Unit, diff --git a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/RandomChain.kt b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/RandomChain.kt index 881eabdac..6e1f36c8a 100644 --- a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/RandomChain.kt +++ b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/RandomChain.kt @@ -7,7 +7,7 @@ import space.kscience.kmath.chains.Chain */ public class RandomChain( public val generator: RandomGenerator, - private val gen: suspend RandomGenerator.() -> R + private val gen: suspend RandomGenerator.() -> R, ) : Chain { override suspend fun next(): R = generator.gen() diff --git a/kmath-stat/src/jvmMain/kotlin/space/kscience/kmath/stat/distributions.kt b/kmath-stat/src/jvmMain/kotlin/space/kscience/kmath/stat/distributions.kt index d33b54818..1be436a4f 100644 --- a/kmath-stat/src/jvmMain/kotlin/space/kscience/kmath/stat/distributions.kt +++ b/kmath-stat/src/jvmMain/kotlin/space/kscience/kmath/stat/distributions.kt @@ -50,7 +50,7 @@ private fun normalSampler(method: NormalSamplerMethod, provider: UniformRandomPr } public fun Distribution.Companion.normal( - method: NormalSamplerMethod = NormalSamplerMethod.Ziggurat + method: NormalSamplerMethod = NormalSamplerMethod.Ziggurat, ): ContinuousSamplerDistribution = object : ContinuousSamplerDistribution() { override fun buildCMSampler(generator: RandomGenerator): ContinuousSampler { val provider = generator.asUniformRandomProvider() @@ -66,7 +66,7 @@ public fun Distribution.Companion.normal( public fun Distribution.Companion.normal( mean: Double, sigma: Double, - method: NormalSamplerMethod = NormalSamplerMethod.Ziggurat + method: NormalSamplerMethod = NormalSamplerMethod.Ziggurat, ): ContinuousSamplerDistribution = object : ContinuousSamplerDistribution() { private val sigma2 = sigma.pow(2) private val norm = sigma * sqrt(PI * 2) diff --git a/kmath-viktor/api/kmath-viktor.api b/kmath-viktor/api/kmath-viktor.api index ebb97b150..d48a9f9c8 100644 --- a/kmath-viktor/api/kmath-viktor.api +++ b/kmath-viktor/api/kmath-viktor.api @@ -26,130 +26,130 @@ public final class space/kscience/kmath/viktor/ViktorBuffer : space/kscience/kma public final synthetic fun unbox-impl ()Lorg/jetbrains/bio/viktor/F64FlatArray; } -public final class space/kscience/kmath/viktor/ViktorNDField : space/kscience/kmath/nd/NDField, space/kscience/kmath/operations/ExtendedField, space/kscience/kmath/operations/NumbersAddOperations, space/kscience/kmath/operations/ScaleOperations { +public final class space/kscience/kmath/viktor/ViktorFieldND : space/kscience/kmath/nd/FieldND, space/kscience/kmath/operations/ExtendedField, space/kscience/kmath/operations/NumbersAddOperations, space/kscience/kmath/operations/ScaleOperations { public fun ([I)V public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; - public fun acos-Q7Xurp0 (Lspace/kscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public fun acos-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; - public fun acosh (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun acosh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public synthetic fun add (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public fun add-s8yP2C4 (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun add (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public fun add-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; - public fun asin-Q7Xurp0 (Lspace/kscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public fun asin-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; - public fun asinh (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun asinh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; - public fun atan-Q7Xurp0 (Lspace/kscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public fun atan-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; - public fun atanh (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun atanh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun binaryOperation (Ljava/lang/String;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun binaryOperation (Ljava/lang/String;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; public synthetic fun bindSymbol (Ljava/lang/String;)Ljava/lang/Object; - public fun bindSymbol (Ljava/lang/String;)Lspace/kscience/kmath/nd/NDStructure; - public synthetic fun combine (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDStructure; - public fun combine-ZQYDhZg (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lorg/jetbrains/bio/viktor/F64Array; + public fun bindSymbol (Ljava/lang/String;)Lspace/kscience/kmath/nd/StructureND; + public synthetic fun combine (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; + public fun combine-WKhNzhk (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lorg/jetbrains/bio/viktor/F64Array; public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; - public fun cos-Q7Xurp0 (Lspace/kscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public fun cos-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; - public fun cosh (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public fun div (DLspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun cosh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public fun div (DLspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun div (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; public synthetic fun div (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public synthetic fun div (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public fun div (Lspace/kscience/kmath/nd/NDStructure;D)Lspace/kscience/kmath/nd/NDStructure; - public fun div (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; - public synthetic fun div (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public fun div (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public synthetic fun div (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public fun div (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/nd/StructureND; + public fun div (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; + public synthetic fun div (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public fun div (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun divide (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun divide (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; - public fun exp-Q7Xurp0 (Lspace/kscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public fun exp-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public synthetic fun getElementContext ()Lspace/kscience/kmath/operations/Algebra; public fun getElementContext ()Lspace/kscience/kmath/operations/RealField; - public final fun getF64Buffer (Lspace/kscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public final fun getF64Buffer (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public synthetic fun getOne ()Ljava/lang/Object; - public fun getOne-MSOxzaI ()Lorg/jetbrains/bio/viktor/F64Array; + public fun getOne-6kW2wQc ()Lorg/jetbrains/bio/viktor/F64Array; public fun getShape ()[I public synthetic fun getZero ()Ljava/lang/Object; - public fun getZero-MSOxzaI ()Lorg/jetbrains/bio/viktor/F64Array; - public fun invoke (Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun getZero-6kW2wQc ()Lorg/jetbrains/bio/viktor/F64Array; + public fun invoke (Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; - public fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object; - public fun ln-Q7Xurp0 (Lspace/kscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; - public synthetic fun map (Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDStructure; - public fun map-s8yP2C4 (Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function2;)Lorg/jetbrains/bio/viktor/F64Array; - public synthetic fun mapIndexed (Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/NDStructure; - public fun mapIndexed-s8yP2C4 (Lspace/kscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lorg/jetbrains/bio/viktor/F64Array; - public fun minus (DLspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun ln-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; + public fun map-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun mapIndexed (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; + public fun mapIndexed-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lorg/jetbrains/bio/viktor/F64Array; + public fun minus (DLspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun minus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; - public fun minus (Ljava/lang/Number;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun minus (Ljava/lang/Number;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public synthetic fun minus (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public fun minus (Lspace/kscience/kmath/nd/NDStructure;D)Lspace/kscience/kmath/nd/NDStructure; - public fun minus (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; - public synthetic fun minus (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public fun minus-s8yP2C4 (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun minus (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public fun minus (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/nd/StructureND; + public fun minus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; + public synthetic fun minus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public fun minus-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun multiply (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun multiply (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; - public fun number-Q7Xurp0 (Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array; - public fun plus (DLspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun number-8UOKELU (Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array; + public fun plus (DLspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun plus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; - public fun plus (Ljava/lang/Number;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun plus (Ljava/lang/Number;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public synthetic fun plus (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public fun plus (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; - public synthetic fun plus (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public fun plus-s8yP2C4 (Lspace/kscience/kmath/nd/NDStructure;D)Lorg/jetbrains/bio/viktor/F64Array; - public fun plus-s8yP2C4 (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun plus (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public fun plus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; + public synthetic fun plus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public fun plus-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;D)Lorg/jetbrains/bio/viktor/F64Array; + public fun plus-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public synthetic fun pow (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; - public fun pow (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; + public fun pow (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; - public fun power-s8yP2C4 (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array; - public synthetic fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/NDStructure; - public fun produce-Q7Xurp0 (Lkotlin/jvm/functions/Function2;)Lorg/jetbrains/bio/viktor/F64Array; + public fun power-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; + public fun produce-8UOKELU (Lkotlin/jvm/functions/Function2;)Lorg/jetbrains/bio/viktor/F64Array; public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; - public fun rightSideNumberOperation (Ljava/lang/String;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; + public fun rightSideNumberOperation (Ljava/lang/String;Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND; public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; public synthetic fun scale (Ljava/lang/Object;D)Ljava/lang/Object; - public fun scale-s8yP2C4 (Lspace/kscience/kmath/nd/NDStructure;D)Lorg/jetbrains/bio/viktor/F64Array; + public fun scale-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;D)Lorg/jetbrains/bio/viktor/F64Array; public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; - public fun sin-Q7Xurp0 (Lspace/kscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public fun sin-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; - public fun sinh (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun sinh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun sqrt (Ljava/lang/Object;)Ljava/lang/Object; - public fun sqrt (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun sqrt (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; - public fun tan (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun tan (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; - public fun tanh (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public fun times (DLspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun tanh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public fun times (DLspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; - public fun times (Ljava/lang/Number;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun times (Ljava/lang/Number;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun times (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; public synthetic fun times (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public synthetic fun times (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public fun times (Lspace/kscience/kmath/nd/NDStructure;D)Lspace/kscience/kmath/nd/NDStructure; - public synthetic fun times (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public fun times (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public fun times-s8yP2C4 (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun times (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public fun times (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/nd/StructureND; + public synthetic fun times (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; + public fun times (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; + public fun times-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array; public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; - public fun unaryMinus (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun unaryMinus (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; - public fun unaryOperation (Ljava/lang/String;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun unaryOperation (Ljava/lang/String;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; - public fun unaryPlus (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun unaryPlus (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; } -public final class space/kscience/kmath/viktor/ViktorNDStructure : space/kscience/kmath/nd/MutableNDStructure { - public static final synthetic fun box-impl (Lorg/jetbrains/bio/viktor/F64Array;)Lspace/kscience/kmath/viktor/ViktorNDStructure; +public final class space/kscience/kmath/viktor/ViktorStructureND : space/kscience/kmath/nd/MutableNDStructure { + public static final synthetic fun box-impl (Lorg/jetbrains/bio/viktor/F64Array;)Lspace/kscience/kmath/viktor/ViktorStructureND; public static fun constructor-impl (Lorg/jetbrains/bio/viktor/F64Array;)Lorg/jetbrains/bio/viktor/F64Array; public fun elements ()Lkotlin/sequences/Sequence; public static fun elements-impl (Lorg/jetbrains/bio/viktor/F64Array;)Lkotlin/sequences/Sequence; @@ -174,8 +174,8 @@ public final class space/kscience/kmath/viktor/ViktorNDStructure : space/kscienc public final synthetic fun unbox-impl ()Lorg/jetbrains/bio/viktor/F64Array; } -public final class space/kscience/kmath/viktor/ViktorNDStructureKt { - public static final fun ViktorNDField ([I)Lspace/kscience/kmath/viktor/ViktorNDField; +public final class space/kscience/kmath/viktor/ViktorStructureNDKt { + public static final fun ViktorNDField ([I)Lspace/kscience/kmath/viktor/ViktorFieldND; public static final fun asStructure (Lorg/jetbrains/bio/viktor/F64Array;)Lorg/jetbrains/bio/viktor/F64Array; } diff --git a/kmath-viktor/build.gradle.kts b/kmath-viktor/build.gradle.kts index b79a25ea1..94744f528 100644 --- a/kmath-viktor/build.gradle.kts +++ b/kmath-viktor/build.gradle.kts @@ -9,6 +9,6 @@ dependencies { api("org.jetbrains.bio:viktor:1.0.1") } -readme{ +readme { maturity = ru.mipt.npm.gradle.Maturity.DEVELOPMENT } \ No newline at end of file diff --git a/kmath-viktor/src/main/kotlin/space/kscience/kmath/viktor/ViktorNDStructure.kt b/kmath-viktor/src/main/kotlin/space/kscience/kmath/viktor/ViktorNDStructure.kt deleted file mode 100644 index d791ed675..000000000 --- a/kmath-viktor/src/main/kotlin/space/kscience/kmath/viktor/ViktorNDStructure.kt +++ /dev/null @@ -1,123 +0,0 @@ -package space.kscience.kmath.viktor - -import org.jetbrains.bio.viktor.F64Array -import space.kscience.kmath.misc.UnstableKMathAPI -import space.kscience.kmath.nd.* -import space.kscience.kmath.operations.ExtendedField -import space.kscience.kmath.operations.NumbersAddOperations -import space.kscience.kmath.operations.RealField -import space.kscience.kmath.operations.ScaleOperations - -@Suppress("OVERRIDE_BY_INLINE", "NOTHING_TO_INLINE") -public inline class ViktorNDStructure(public val f64Buffer: F64Array) : MutableNDStructure { - public override val shape: IntArray get() = f64Buffer.shape - - public override inline fun get(index: IntArray): Double = f64Buffer.get(*index) - - public override inline fun set(index: IntArray, value: Double) { - f64Buffer.set(*index, value = value) - } - - public override fun elements(): Sequence> = - DefaultStrides(shape).indices().map { it to get(it) } -} - -public fun F64Array.asStructure(): ViktorNDStructure = ViktorNDStructure(this) - -@OptIn(UnstableKMathAPI::class) -@Suppress("OVERRIDE_BY_INLINE", "NOTHING_TO_INLINE") -public class ViktorNDField(public override val shape: IntArray) : NDField, - NumbersAddOperations>, ExtendedField>, - ScaleOperations> { - - public val NDStructure.f64Buffer: F64Array - get() = when { - !shape.contentEquals(this@ViktorNDField.shape) -> throw ShapeMismatchException( - this@ViktorNDField.shape, - shape - ) - this is ViktorNDStructure && this.f64Buffer.shape.contentEquals(this@ViktorNDField.shape) -> this.f64Buffer - else -> produce { this@f64Buffer[it] }.f64Buffer - } - - public override val zero: ViktorNDStructure by lazy { F64Array.full(init = 0.0, shape = shape).asStructure() } - - public override val one: ViktorNDStructure by lazy { F64Array.full(init = 1.0, shape = shape).asStructure() } - - private val strides: Strides = DefaultStrides(shape) - - public override val elementContext: RealField get() = RealField - - public override fun produce(initializer: RealField.(IntArray) -> Double): ViktorNDStructure = - F64Array(*shape).apply { - this@ViktorNDField.strides.indices().forEach { index -> - set(value = RealField.initializer(index), indices = index) - } - }.asStructure() - - override fun NDStructure.unaryMinus(): NDStructure = -1 * this - - public override fun NDStructure.map(transform: RealField.(Double) -> Double): ViktorNDStructure = - F64Array(*this@ViktorNDField.shape).apply { - this@ViktorNDField.strides.indices().forEach { index -> - set(value = RealField.transform(this@map[index]), indices = index) - } - }.asStructure() - - public override fun NDStructure.mapIndexed( - transform: RealField.(index: IntArray, Double) -> Double, - ): ViktorNDStructure = F64Array(*this@ViktorNDField.shape).apply { - this@ViktorNDField.strides.indices().forEach { index -> - set(value = RealField.transform(index, this@mapIndexed[index]), indices = index) - } - }.asStructure() - - public override fun combine( - a: NDStructure, - b: NDStructure, - transform: RealField.(Double, Double) -> Double, - ): ViktorNDStructure = F64Array(*shape).apply { - this@ViktorNDField.strides.indices().forEach { index -> - set(value = RealField.transform(a[index], b[index]), indices = index) - } - }.asStructure() - - public override fun add(a: NDStructure, b: NDStructure): ViktorNDStructure = - (a.f64Buffer + b.f64Buffer).asStructure() - - public override fun scale(a: NDStructure, value: Double): ViktorNDStructure = - (a.f64Buffer * value.toDouble()).asStructure() - - public override inline fun NDStructure.plus(b: NDStructure): ViktorNDStructure = - (f64Buffer + b.f64Buffer).asStructure() - - public override inline fun NDStructure.minus(b: NDStructure): ViktorNDStructure = - (f64Buffer - b.f64Buffer).asStructure() - - public override inline fun NDStructure.times(k: Number): ViktorNDStructure = - (f64Buffer * k.toDouble()).asStructure() - - public override inline fun NDStructure.plus(arg: Double): ViktorNDStructure = - (f64Buffer.plus(arg)).asStructure() - - override fun number(value: Number): ViktorNDStructure = - F64Array.full(init = value.toDouble(), shape = shape).asStructure() - - override fun sin(arg: NDStructure): ViktorNDStructure = arg.map { sin(it) } - - override fun cos(arg: NDStructure): ViktorNDStructure = arg.map { cos(it) } - - override fun asin(arg: NDStructure): ViktorNDStructure = arg.map { asin(it) } - - override fun acos(arg: NDStructure): ViktorNDStructure = arg.map { acos(it) } - - override fun atan(arg: NDStructure): ViktorNDStructure = arg.map { atan(it) } - - override fun power(arg: NDStructure, pow: Number): ViktorNDStructure = arg.map { it.pow(pow) } - - override fun exp(arg: NDStructure): ViktorNDStructure = arg.f64Buffer.exp().asStructure() - - override fun ln(arg: NDStructure): ViktorNDStructure = arg.f64Buffer.log().asStructure() -} - -public fun ViktorNDField(vararg shape: Int): ViktorNDField = ViktorNDField(shape) \ No newline at end of file diff --git a/kmath-viktor/src/main/kotlin/space/kscience/kmath/viktor/ViktorStructureND.kt b/kmath-viktor/src/main/kotlin/space/kscience/kmath/viktor/ViktorStructureND.kt new file mode 100644 index 000000000..9195415c5 --- /dev/null +++ b/kmath-viktor/src/main/kotlin/space/kscience/kmath/viktor/ViktorStructureND.kt @@ -0,0 +1,123 @@ +package space.kscience.kmath.viktor + +import org.jetbrains.bio.viktor.F64Array +import space.kscience.kmath.misc.UnstableKMathAPI +import space.kscience.kmath.nd.* +import space.kscience.kmath.operations.ExtendedField +import space.kscience.kmath.operations.NumbersAddOperations +import space.kscience.kmath.operations.RealField +import space.kscience.kmath.operations.ScaleOperations + +@Suppress("OVERRIDE_BY_INLINE", "NOTHING_TO_INLINE") +public inline class ViktorStructureND(public val f64Buffer: F64Array) : MutableNDStructure { + public override val shape: IntArray get() = f64Buffer.shape + + public override inline fun get(index: IntArray): Double = f64Buffer.get(*index) + + public override inline fun set(index: IntArray, value: Double) { + f64Buffer.set(*index, value = value) + } + + public override fun elements(): Sequence> = + DefaultStrides(shape).indices().map { it to get(it) } +} + +public fun F64Array.asStructure(): ViktorStructureND = ViktorStructureND(this) + +@OptIn(UnstableKMathAPI::class) +@Suppress("OVERRIDE_BY_INLINE", "NOTHING_TO_INLINE") +public class ViktorFieldND(public override val shape: IntArray) : FieldND, + NumbersAddOperations>, ExtendedField>, + ScaleOperations> { + + public val StructureND.f64Buffer: F64Array + get() = when { + !shape.contentEquals(this@ViktorFieldND.shape) -> throw ShapeMismatchException( + this@ViktorFieldND.shape, + shape + ) + this is ViktorStructureND && this.f64Buffer.shape.contentEquals(this@ViktorFieldND.shape) -> this.f64Buffer + else -> produce { this@f64Buffer[it] }.f64Buffer + } + + public override val zero: ViktorStructureND by lazy { F64Array.full(init = 0.0, shape = shape).asStructure() } + + public override val one: ViktorStructureND by lazy { F64Array.full(init = 1.0, shape = shape).asStructure() } + + private val strides: Strides = DefaultStrides(shape) + + public override val elementContext: RealField get() = RealField + + public override fun produce(initializer: RealField.(IntArray) -> Double): ViktorStructureND = + F64Array(*shape).apply { + this@ViktorFieldND.strides.indices().forEach { index -> + set(value = RealField.initializer(index), indices = index) + } + }.asStructure() + + override fun StructureND.unaryMinus(): StructureND = -1 * this + + public override fun StructureND.map(transform: RealField.(Double) -> Double): ViktorStructureND = + F64Array(*this@ViktorFieldND.shape).apply { + this@ViktorFieldND.strides.indices().forEach { index -> + set(value = RealField.transform(this@map[index]), indices = index) + } + }.asStructure() + + public override fun StructureND.mapIndexed( + transform: RealField.(index: IntArray, Double) -> Double, + ): ViktorStructureND = F64Array(*this@ViktorFieldND.shape).apply { + this@ViktorFieldND.strides.indices().forEach { index -> + set(value = RealField.transform(index, this@mapIndexed[index]), indices = index) + } + }.asStructure() + + public override fun combine( + a: StructureND, + b: StructureND, + transform: RealField.(Double, Double) -> Double, + ): ViktorStructureND = F64Array(*shape).apply { + this@ViktorFieldND.strides.indices().forEach { index -> + set(value = RealField.transform(a[index], b[index]), indices = index) + } + }.asStructure() + + public override fun add(a: StructureND, b: StructureND): ViktorStructureND = + (a.f64Buffer + b.f64Buffer).asStructure() + + public override fun scale(a: StructureND, value: Double): ViktorStructureND = + (a.f64Buffer * value.toDouble()).asStructure() + + public override inline fun StructureND.plus(b: StructureND): ViktorStructureND = + (f64Buffer + b.f64Buffer).asStructure() + + public override inline fun StructureND.minus(b: StructureND): ViktorStructureND = + (f64Buffer - b.f64Buffer).asStructure() + + public override inline fun StructureND.times(k: Number): ViktorStructureND = + (f64Buffer * k.toDouble()).asStructure() + + public override inline fun StructureND.plus(arg: Double): ViktorStructureND = + (f64Buffer.plus(arg)).asStructure() + + override fun number(value: Number): ViktorStructureND = + F64Array.full(init = value.toDouble(), shape = shape).asStructure() + + override fun sin(arg: StructureND): ViktorStructureND = arg.map { sin(it) } + + override fun cos(arg: StructureND): ViktorStructureND = arg.map { cos(it) } + + override fun asin(arg: StructureND): ViktorStructureND = arg.map { asin(it) } + + override fun acos(arg: StructureND): ViktorStructureND = arg.map { acos(it) } + + override fun atan(arg: StructureND): ViktorStructureND = arg.map { atan(it) } + + override fun power(arg: StructureND, pow: Number): ViktorStructureND = arg.map { it.pow(pow) } + + override fun exp(arg: StructureND): ViktorStructureND = arg.f64Buffer.exp().asStructure() + + override fun ln(arg: StructureND): ViktorStructureND = arg.f64Buffer.log().asStructure() +} + +public fun ViktorNDField(vararg shape: Int): ViktorFieldND = ViktorFieldND(shape) \ No newline at end of file