From 53db4489f8314990ba1a2fbb2831da36e8512493 Mon Sep 17 00:00:00 2001 From: Iaroslav Postovalov Date: Tue, 19 Jan 2021 01:09:44 +0700 Subject: [PATCH 01/23] Implement decomposition features by CMMatrix --- .../kscience/kmath/commons/linear/CMMatrix.kt | 38 +++++++++++++++++-- .../kscience/kmath/linear/MatrixFeatures.kt | 2 + .../kotlin/kscience/kmath/ejml/EjmlMatrix.kt | 8 +++- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt b/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt index 49888f8d6..a40657cfb 100644 --- a/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt +++ b/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt @@ -3,15 +3,45 @@ package kscience.kmath.commons.linear import kscience.kmath.linear.* import kscience.kmath.structures.Matrix import kscience.kmath.structures.NDStructure +import kscience.kmath.structures.RealBuffer import org.apache.commons.math3.linear.* -public class CMMatrix(public val origin: RealMatrix, features: Set? = null) : FeaturedMatrix { +public class CMMatrix(public val origin: RealMatrix, features: Set = emptySet()) : + FeaturedMatrix { public override val rowNum: Int get() = origin.rowDimension public override val colNum: Int get() = origin.columnDimension - public override val features: Set = features ?: sequence { - if (origin is DiagonalMatrix) yield(DiagonalFeature) - }.toHashSet() + public override val features: Set = features union hashSetOf( + *if (origin is DiagonalMatrix) arrayOf(DiagonalFeature) else emptyArray(), + object : DeterminantFeature, LupDecompositionFeature { + private val lup by lazy { LUDecomposition(origin) } + override val determinant: Double by lazy { lup.determinant } + override val l: FeaturedMatrix by lazy { CMMatrix(lup.l, setOf(LFeature)) } + override val u: FeaturedMatrix by lazy { CMMatrix(lup.u, setOf(UFeature)) } + override val p: FeaturedMatrix by lazy { CMMatrix(lup.p) } + }, + + object : CholeskyDecompositionFeature { + override val l: FeaturedMatrix by lazy { + val cholesky = CholeskyDecomposition(origin) + CMMatrix(cholesky.l, setOf(LFeature)) + } + }, + + object : QRDecompositionFeature { + private val qr by lazy { QRDecomposition(origin) } + override val q: FeaturedMatrix by lazy { CMMatrix(qr.q, setOf(OrthogonalFeature)) } + override val r: FeaturedMatrix by lazy { CMMatrix(qr.r, setOf(UFeature)) } + }, + + object : SingularValueDecompositionFeature { + private val sv by lazy { SingularValueDecomposition(origin) } + override val u: FeaturedMatrix by lazy { CMMatrix(sv.u) } + override val s: FeaturedMatrix by lazy { CMMatrix(sv.s) } + override val v: FeaturedMatrix by lazy { CMMatrix(sv.v) } + override val singularValues: Point by lazy { RealBuffer(sv.singularValues) } + }, + ) public override fun suggestFeature(vararg features: MatrixFeature): CMMatrix = CMMatrix(origin, this.features + features) diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixFeatures.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixFeatures.kt index 767b58eba..81e734949 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixFeatures.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixFeatures.kt @@ -35,6 +35,8 @@ public interface InverseMatrixFeature : MatrixFeature { /** * Matrices with this feature can compute their determinant. + * + * @param T the type of matrices' items. */ public interface DeterminantFeature : MatrixFeature { /** diff --git a/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrix.kt b/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrix.kt index 5b7d0a01b..0fb361040 100644 --- a/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrix.kt +++ b/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrix.kt @@ -48,8 +48,12 @@ public class EjmlMatrix(public val origin: SimpleMatrix, features: Set by lazy { EjmlMatrix(SimpleMatrix(qr.getQ(null, false))) } - override val r: FeaturedMatrix by lazy { EjmlMatrix(SimpleMatrix(qr.getR(null, false))) } + override val q: FeaturedMatrix by lazy { + EjmlMatrix(SimpleMatrix(qr.getQ(null, false)), setOf(OrthogonalFeature)) + } + override val r: FeaturedMatrix by lazy { + EjmlMatrix(SimpleMatrix(qr.getR(null, false)), setOf(UFeature)) + } }, object : CholeskyDecompositionFeature { From 348f114bb6231abe776b6c9f201159d8697f4acf Mon Sep 17 00:00:00 2001 From: Iaroslav Postovalov Date: Tue, 19 Jan 2021 01:10:16 +0700 Subject: [PATCH 02/23] Minor: add newline --- .../src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt b/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt index a40657cfb..845fe32b5 100644 --- a/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt +++ b/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt @@ -13,6 +13,7 @@ public class CMMatrix(public val origin: RealMatrix, features: Set = features union hashSetOf( *if (origin is DiagonalMatrix) arrayOf(DiagonalFeature) else emptyArray(), + object : DeterminantFeature, LupDecompositionFeature { private val lup by lazy { LUDecomposition(origin) } override val determinant: Double by lazy { lup.determinant } From 57b1157650de6ada389c371d0730e66f30dcc3c7 Mon Sep 17 00:00:00 2001 From: Iaroslav Postovalov Date: Wed, 20 Jan 2021 00:28:39 +0700 Subject: [PATCH 03/23] Reformat, bring back the features of CMMatrix with the new API, add missing features in QRDecomposition in EjmlMatrix --- .../kscience/kmath/commons/linear/CMMatrix.kt | 40 ++++++++++++++++--- .../kscience/kmath/linear/MatrixFeatures.kt | 4 +- .../kotlin/kscience/kmath/misc/annotations.kt | 2 +- .../kotlin/kscience/kmath/ejml/EjmlMatrix.kt | 26 +++++++----- 4 files changed, 54 insertions(+), 18 deletions(-) diff --git a/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt b/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt index 48b6e0ef1..c9b3f7117 100644 --- a/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt +++ b/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt @@ -1,11 +1,9 @@ package kscience.kmath.commons.linear -import kscience.kmath.linear.DiagonalFeature -import kscience.kmath.linear.MatrixContext -import kscience.kmath.linear.MatrixWrapper -import kscience.kmath.linear.Point +import kscience.kmath.linear.* import kscience.kmath.misc.UnstableKMathAPI import kscience.kmath.structures.Matrix +import kscience.kmath.structures.RealBuffer import org.apache.commons.math3.linear.* import kotlin.reflect.KClass import kotlin.reflect.cast @@ -17,8 +15,40 @@ public inline class CMMatrix(public val origin: RealMatrix) : Matrix { @UnstableKMathAPI override fun getFeature(type: KClass): T? = when (type) { DiagonalFeature::class -> if (origin is DiagonalMatrix) DiagonalFeature else null + + DeterminantFeature::class, LupDecompositionFeature::class -> object : + DeterminantFeature, + LupDecompositionFeature { + private val lup by lazy { LUDecomposition(origin) } + override val determinant: Double by lazy { lup.determinant } + override val l: Matrix by lazy { CMMatrix(lup.l) + LFeature } + override val u: Matrix by lazy { CMMatrix(lup.u) + UFeature } + override val p: Matrix by lazy { CMMatrix(lup.p) } + } + + CholeskyDecompositionFeature::class -> object : CholeskyDecompositionFeature { + override val l: Matrix by lazy { + val cholesky = CholeskyDecomposition(origin) + CMMatrix(cholesky.l) + LFeature + } + } + + QRDecompositionFeature::class -> object : QRDecompositionFeature { + private val qr by lazy { QRDecomposition(origin) } + override val q: Matrix by lazy { CMMatrix(qr.q) + OrthogonalFeature } + override val r: Matrix by lazy { CMMatrix(qr.r) + UFeature } + } + + SingularValueDecompositionFeature::class -> object : SingularValueDecompositionFeature { + private val sv by lazy { SingularValueDecomposition(origin) } + override val u: Matrix by lazy { CMMatrix(sv.u) } + override val s: Matrix by lazy { CMMatrix(sv.s) } + override val v: Matrix by lazy { CMMatrix(sv.v) } + override val singularValues: Point by lazy { RealBuffer(sv.singularValues) } + } + else -> null - }?.let { type.cast(it) } + }?.let(type::cast) public override operator fun get(i: Int, j: Int): Double = origin.getEntry(i, j) } diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixFeatures.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixFeatures.kt index 8a0be4338..8d5c61ab9 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixFeatures.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixFeatures.kt @@ -11,8 +11,8 @@ public interface MatrixFeature /** * Matrices with this feature are considered to have only diagonal non-null elements. */ -public interface DiagonalFeature : MatrixFeature{ - public companion object: DiagonalFeature +public interface DiagonalFeature : MatrixFeature { + public companion object : DiagonalFeature } /** diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/misc/annotations.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/misc/annotations.kt index d70ac7b39..06248a166 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/misc/annotations.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/misc/annotations.kt @@ -1,4 +1,4 @@ package kscience.kmath.misc @RequiresOptIn("This API is unstable and could change in future", RequiresOptIn.Level.WARNING) -public annotation class UnstableKMathAPI \ No newline at end of file +public annotation class UnstableKMathAPI diff --git a/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrix.kt b/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrix.kt index 1c2ded447..d81082dc4 100644 --- a/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrix.kt +++ b/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrix.kt @@ -15,21 +15,20 @@ import kotlin.reflect.cast * @property origin the underlying [SimpleMatrix]. * @author Iaroslav Postovalov */ -public inline class EjmlMatrix( - public val origin: SimpleMatrix, -) : Matrix { +public inline class EjmlMatrix(public val origin: SimpleMatrix) : Matrix { public override val rowNum: Int get() = origin.numRows() - public override val colNum: Int get() = origin.numCols() @UnstableKMathAPI - override fun getFeature(type: KClass): T? = when (type) { + public override fun getFeature(type: KClass): T? = when (type) { InverseMatrixFeature::class -> object : InverseMatrixFeature { override val inverse: Matrix by lazy { EjmlMatrix(origin.invert()) } } + DeterminantFeature::class -> object : DeterminantFeature { override val determinant: Double by lazy(origin::determinant) } + SingularValueDecompositionFeature::class -> object : SingularValueDecompositionFeature { private val svd by lazy { DecompositionFactory_DDRM.svd(origin.numRows(), origin.numCols(), true, true, false) @@ -41,15 +40,20 @@ public inline class EjmlMatrix( override val v: Matrix by lazy { EjmlMatrix(SimpleMatrix(svd.getV(null, false))) } override val singularValues: Point by lazy { RealBuffer(svd.singularValues) } } + QRDecompositionFeature::class -> object : QRDecompositionFeature { private val qr by lazy { DecompositionFactory_DDRM.qr().apply { decompose(origin.ddrm.copy()) } } - override val q: Matrix by lazy { EjmlMatrix(SimpleMatrix(qr.getQ(null, false))) } - override val r: Matrix by lazy { EjmlMatrix(SimpleMatrix(qr.getR(null, false))) } + override val q: Matrix by lazy { + EjmlMatrix(SimpleMatrix(qr.getQ(null, false))) + OrthogonalFeature + } + + override val r: Matrix by lazy { EjmlMatrix(SimpleMatrix(qr.getR(null, false))) + UFeature } } - CholeskyDecompositionFeature::class -> object : CholeskyDecompositionFeature { + + CholeskyDecompositionFeature::class -> object : CholeskyDecompositionFeature { override val l: Matrix by lazy { val cholesky = DecompositionFactory_DDRM.chol(rowNum, true).apply { decompose(origin.ddrm.copy()) } @@ -57,7 +61,8 @@ public inline class EjmlMatrix( EjmlMatrix(SimpleMatrix(cholesky.getT(null))) + LFeature } } - LupDecompositionFeature::class -> object : LupDecompositionFeature { + + LupDecompositionFeature::class -> object : LupDecompositionFeature { private val lup by lazy { DecompositionFactory_DDRM.lu(origin.numRows(), origin.numCols()).apply { decompose(origin.ddrm.copy()) } } @@ -72,8 +77,9 @@ public inline class EjmlMatrix( override val p: Matrix by lazy { EjmlMatrix(SimpleMatrix(lup.getRowPivot(null))) } } + else -> null - }?.let{type.cast(it)} + }?.let(type::cast) public override operator fun get(i: Int, j: Int): Double = origin[i, j] } From 72832bae10d65d92931de1929be53c63d87c73df Mon Sep 17 00:00:00 2001 From: Iaroslav Postovalov Date: Wed, 20 Jan 2021 16:51:36 +0700 Subject: [PATCH 04/23] Minor: reformat --- kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrix.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrix.kt b/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrix.kt index a71f0501d..0586c065c 100644 --- a/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrix.kt +++ b/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrix.kt @@ -16,11 +16,8 @@ import kotlin.reflect.cast * @property origin the underlying [SimpleMatrix]. * @author Iaroslav Postovalov */ -public class EjmlMatrix( - public val origin: SimpleMatrix, -) : Matrix { +public class EjmlMatrix(public val origin: SimpleMatrix) : Matrix { public override val rowNum: Int get() = origin.numRows() - public override val colNum: Int get() = origin.numCols() @UnstableKMathAPI From c51018b426b5d16acf5b2109c683cf62c88f5aec Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 22 Jan 2021 14:29:46 +0300 Subject: [PATCH 05/23] Regenerate readme --- README.md | 5 +++-- docs/templates/README-TEMPLATE.md | 1 + kmath-ast/README.md | 8 ++++---- kmath-core/README.md | 6 +++--- kmath-for-real/README.md | 6 +++--- kmath-nd4j/README.md | 6 +++--- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 0899f77cc..7d2a46c92 100644 --- a/README.md +++ b/README.md @@ -235,11 +235,12 @@ Release artifacts are accessible from bintray with following configuration (see ```kotlin repositories { maven("https://dl.bintray.com/mipt-npm/kscience") + // maven("https://dl.bintray.com/mipt-npm/dev") for dev versions } dependencies { - api("kscience.kmath:kmath-core:0.2.0-dev-4") - // api("kscience.kmath:kmath-core-jvm:0.2.0-dev-4") for jvm-specific version + api("kscience.kmath:kmath-core:0.2.0-dev-5") + // api("kscience.kmath:kmath-core-jvm:0.2.0-dev-5") for jvm-specific version } ``` diff --git a/docs/templates/README-TEMPLATE.md b/docs/templates/README-TEMPLATE.md index ee1df818c..82b0c0514 100644 --- a/docs/templates/README-TEMPLATE.md +++ b/docs/templates/README-TEMPLATE.md @@ -106,6 +106,7 @@ Release artifacts are accessible from bintray with following configuration (see ```kotlin repositories { maven("https://dl.bintray.com/mipt-npm/kscience") + // maven("https://dl.bintray.com/mipt-npm/dev") for dev versions } dependencies { diff --git a/kmath-ast/README.md b/kmath-ast/README.md index 19e9ee4a9..e6200d3ef 100644 --- a/kmath-ast/README.md +++ b/kmath-ast/README.md @@ -12,7 +12,7 @@ This subproject implements the following features: > #### Artifact: > -> This module artifact: `kscience.kmath:kmath-ast:0.2.0-dev-4`. +> This module artifact: `kscience.kmath:kmath-ast:0.2.0-dev-5`. > > Bintray release version: [ ![Download](https://api.bintray.com/packages/mipt-npm/kscience/kmath-ast/images/download.svg) ](https://bintray.com/mipt-npm/kscience/kmath-ast/_latestVersion) > @@ -30,7 +30,7 @@ This subproject implements the following features: > } > > dependencies { -> implementation 'kscience.kmath:kmath-ast:0.2.0-dev-4' +> implementation 'kscience.kmath:kmath-ast:0.2.0-dev-5' > } > ``` > **Gradle Kotlin DSL:** @@ -44,7 +44,7 @@ This subproject implements the following features: > } > > dependencies { -> implementation("kscience.kmath:kmath-ast:0.2.0-dev-4") +> implementation("kscience.kmath:kmath-ast:0.2.0-dev-5") > } > ``` @@ -61,7 +61,7 @@ For example, the following builder: RealField.mstInField { symbol("x") + 2 }.compile() ``` -… leads to generation of bytecode, which can be decompiled to the following Java class: +… leads to generation of bytecode, which can be decompiled to the following Java class: ```java package kscience.kmath.asm.generated; diff --git a/kmath-core/README.md b/kmath-core/README.md index 7882e5252..1ee19107b 100644 --- a/kmath-core/README.md +++ b/kmath-core/README.md @@ -12,7 +12,7 @@ The core features of KMath: > #### Artifact: > -> This module artifact: `kscience.kmath:kmath-core:0.2.0-dev-4`. +> This module artifact: `kscience.kmath:kmath-core:0.2.0-dev-5`. > > Bintray release version: [ ![Download](https://api.bintray.com/packages/mipt-npm/kscience/kmath-core/images/download.svg) ](https://bintray.com/mipt-npm/kscience/kmath-core/_latestVersion) > @@ -30,7 +30,7 @@ The core features of KMath: > } > > dependencies { -> implementation 'kscience.kmath:kmath-core:0.2.0-dev-4' +> implementation 'kscience.kmath:kmath-core:0.2.0-dev-5' > } > ``` > **Gradle Kotlin DSL:** @@ -44,6 +44,6 @@ The core features of KMath: > } > > dependencies { -> implementation("kscience.kmath:kmath-core:0.2.0-dev-4") +> implementation("kscience.kmath:kmath-core:0.2.0-dev-5") > } > ``` diff --git a/kmath-for-real/README.md b/kmath-for-real/README.md index d6b66b7da..70308f1d5 100644 --- a/kmath-for-real/README.md +++ b/kmath-for-real/README.md @@ -7,7 +7,7 @@ > #### Artifact: > -> This module artifact: `kscience.kmath:kmath-for-real:0.2.0-dev-4`. +> This module artifact: `kscience.kmath:kmath-for-real:0.2.0-dev-5`. > > Bintray release version: [ ![Download](https://api.bintray.com/packages/mipt-npm/kscience/kmath-for-real/images/download.svg) ](https://bintray.com/mipt-npm/kscience/kmath-for-real/_latestVersion) > @@ -25,7 +25,7 @@ > } > > dependencies { -> implementation 'kscience.kmath:kmath-for-real:0.2.0-dev-4' +> implementation 'kscience.kmath:kmath-for-real:0.2.0-dev-5' > } > ``` > **Gradle Kotlin DSL:** @@ -39,6 +39,6 @@ > } > > dependencies { -> implementation("kscience.kmath:kmath-for-real:0.2.0-dev-4") +> implementation("kscience.kmath:kmath-for-real:0.2.0-dev-5") > } > ``` diff --git a/kmath-nd4j/README.md b/kmath-nd4j/README.md index ff4ff4542..0176c69dd 100644 --- a/kmath-nd4j/README.md +++ b/kmath-nd4j/README.md @@ -9,7 +9,7 @@ This subproject implements the following features: > #### Artifact: > -> This module artifact: `kscience.kmath:kmath-nd4j:0.2.0-dev-4`. +> This module artifact: `kscience.kmath:kmath-nd4j:0.2.0-dev-5`. > > Bintray release version: [ ![Download](https://api.bintray.com/packages/mipt-npm/kscience/kmath-nd4j/images/download.svg) ](https://bintray.com/mipt-npm/kscience/kmath-nd4j/_latestVersion) > @@ -27,7 +27,7 @@ This subproject implements the following features: > } > > dependencies { -> implementation 'kscience.kmath:kmath-nd4j:0.2.0-dev-4' +> implementation 'kscience.kmath:kmath-nd4j:0.2.0-dev-5' > } > ``` > **Gradle Kotlin DSL:** @@ -41,7 +41,7 @@ This subproject implements the following features: > } > > dependencies { -> implementation("kscience.kmath:kmath-nd4j:0.2.0-dev-4") +> implementation("kscience.kmath:kmath-nd4j:0.2.0-dev-5") > } > ``` From 061398b009ae4819adbe95c570bc95fccfb46f82 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 22 Jan 2021 23:22:24 +0300 Subject: [PATCH 06/23] [WIP] Refactor NDStructures --- CHANGELOG.md | 1 + README.md | 2 +- build.gradle.kts | 2 +- .../kscience/kmath/benchmarks/DotBenchmark.kt | 4 +- .../benchmarks/LinearAlgebraBenchmark.kt | 1 - .../kmath/benchmarks/NDFieldBenchmark.kt | 9 +- .../kmath/benchmarks/ViktorBenchmark.kt | 4 +- .../kscience/kmath/operations/ComplexDemo.kt | 3 +- .../kscience/kmath/structures/ComplexND.kt | 13 +- .../kscience/kmath/structures/NDField.kt | 17 +- .../structures/StructureReadBenchmark.kt | 4 +- .../structures/StructureWriteBenchmark.kt | 2 + .../kscience/kmath/commons/linear/CMMatrix.kt | 3 +- .../kscience/kmath/commons/linear/CMSolver.kt | 2 +- kmath-core/README.md | 2 +- .../kmath/expressions/SymbolIndexer.kt | 2 +- .../kscience/kmath/linear/BufferMatrix.kt | 13 +- .../kscience/kmath/linear/LinearAlgebra.kt | 1 - .../kscience/kmath/linear/LupDecomposition.kt | 1 + .../kscience/kmath/linear/MatrixBuilder.kt | 9 +- .../kscience/kmath/linear/MatrixContext.kt | 1 - .../kscience/kmath/linear/MatrixFeatures.kt | 2 - .../kscience/kmath/linear/MatrixWrapper.kt | 8 +- .../kmath/linear/RealMatrixContext.kt | 1 - .../kscience/kmath/linear/VirtualMatrix.kt | 2 - .../kscience/kmath/nd/BufferNDAlgebra.kt | 128 +++++++++ .../kscience/kmath/nd/ComplexNDField.kt | 113 ++++++++ .../kotlin/kscience/kmath/nd/NDAlgebra.kt | 262 ++++++++++++++++++ .../kmath/{structures => nd}/NDStructure.kt | 96 ++++--- .../kotlin/kscience/kmath/nd/RealNDField.kt | 111 ++++++++ .../kotlin/kscience/kmath/nd/ShortNDRing.kt | 36 +++ .../kmath/{structures => nd}/Structure1D.kt | 7 +- .../kmath/{structures => nd}/Structure2D.kt | 12 +- .../kscience/kmath/operations/BigInt.kt | 1 + .../kmath/structures/BoxingNDField.kt | 81 ------ .../kscience/kmath/structures/BoxingNDRing.kt | 71 ----- .../kmath/structures/BufferAccessor2D.kt | 5 + .../kmath/structures/BufferedNDAlgebra.kt | 43 --- .../kmath/structures/BufferedNDElement.kt | 86 ------ .../kscience/kmath/structures/Buffers.kt | 2 +- .../kmath/structures/ComplexNDField.kt | 158 ----------- .../kmath/structures/ExtendedNDField.kt | 44 --- .../kmath/structures/FlaggedBuffer.kt | 2 +- .../kscience/kmath/structures/MemoryBuffer.kt | 2 +- .../kscience/kmath/structures/NDAlgebra.kt | 259 ----------------- .../kscience/kmath/structures/NDElement.kt | 134 --------- .../kscience/kmath/structures/RealNDField.kt | 140 ---------- .../kscience/kmath/structures/ShortNDRing.kt | 93 ------- .../kscience/kmath/linear/MatrixTest.kt | 5 +- .../kscience/kmath/linear/RealLUSolverTest.kt | 1 - .../kscience/kmath/structures/NDFieldTest.kt | 1 + .../kmath/structures/NumberNDFieldTest.kt | 3 +- .../kmath/structures/LazyNDStructure.kt | 4 +- .../kscience/kmath/dimensions/Wrappers.kt | 3 +- .../kotlin/kscience/kmath/ejml/EjmlMatrix.kt | 3 +- .../kscience/kmath/ejml/EjmlMatrixContext.kt | 5 +- .../kscience/kmath/ejml/EjmlMatrixTest.kt | 2 +- .../kotlin/kscience/kmath/real/RealMatrix.kt | 6 +- .../kotlin/kscience/kmath/real/realND.kt | 31 +++ .../kaceince/kmath/real/RealMatrixTest.kt | 4 +- .../kmath/interpolation/XYPointSet.kt | 2 +- .../kscience/kmath/histogram/RealHistogram.kt | 8 +- .../kscience.kmath.nd4j/Nd4jArrayAlgebra.kt | 132 ++++----- .../kscience.kmath.nd4j/Nd4jArrayStructure.kt | 4 +- .../kmath/nd4j/Nd4jArrayStructureTest.kt | 2 +- .../kmath/viktor/ViktorNDStructure.kt | 8 +- 66 files changed, 889 insertions(+), 1330 deletions(-) create mode 100644 kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt create mode 100644 kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ComplexNDField.kt create mode 100644 kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDAlgebra.kt rename kmath-core/src/commonMain/kotlin/kscience/kmath/{structures => nd}/NDStructure.kt (84%) create mode 100644 kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt create mode 100644 kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ShortNDRing.kt rename kmath-core/src/commonMain/kotlin/kscience/kmath/{structures => nd}/Structure1D.kt (89%) rename kmath-core/src/commonMain/kotlin/kscience/kmath/{structures => nd}/Structure2D.kt (92%) delete mode 100644 kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BoxingNDField.kt delete mode 100644 kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BoxingNDRing.kt delete mode 100644 kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BufferedNDAlgebra.kt delete mode 100644 kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BufferedNDElement.kt delete mode 100644 kmath-core/src/commonMain/kotlin/kscience/kmath/structures/ComplexNDField.kt delete mode 100644 kmath-core/src/commonMain/kotlin/kscience/kmath/structures/ExtendedNDField.kt delete mode 100644 kmath-core/src/commonMain/kotlin/kscience/kmath/structures/NDAlgebra.kt delete mode 100644 kmath-core/src/commonMain/kotlin/kscience/kmath/structures/NDElement.kt delete mode 100644 kmath-core/src/commonMain/kotlin/kscience/kmath/structures/RealNDField.kt delete mode 100644 kmath-core/src/commonMain/kotlin/kscience/kmath/structures/ShortNDRing.kt create mode 100644 kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/realND.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index aa70e6116..7536690b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ - Matrix LUP `inverse` renamed to `inverseWithLUP` - `NumericAlgebra` moved outside of regular algebra chain (`Ring` no longer implements it). - Features moved to NDStructure and became transparent. +- Refactored `NDStructure` algebra to be more simple, preferring under-the-hood conversion to explicit NDStructure types ### Deprecated diff --git a/README.md b/README.md index 0899f77cc..258d79be5 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ submit a feature request if you want something to be implemented first. > > **Features:** > - [algebras](kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Algebra.kt) : Algebraic structures: contexts and elements -> - [nd](kmath-core/src/commonMain/kotlin/kscience/kmath/structures/NDStructure.kt) : Many-dimensional structures +> - [nd](kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDStructure.kt) : Many-dimensional structures > - [buffers](kmath-core/src/commonMain/kotlin/kscience/kmath/structures/Buffers.kt) : One-dimensional structure > - [expressions](kmath-core/src/commonMain/kotlin/kscience/kmath/expressions) : Functional Expressions > - [domains](kmath-core/src/commonMain/kotlin/kscience/kmath/domains) : Domains diff --git a/build.gradle.kts b/build.gradle.kts index d171bd608..0572217af 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { id("ru.mipt.npm.project") } -internal val kmathVersion: String by extra("0.2.0-dev-5") +internal val kmathVersion: String by extra("0.2.0-dev-6") internal val bintrayRepo: String by extra("kscience") internal val githubProject: String by extra("kmath") diff --git a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/DotBenchmark.kt b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/DotBenchmark.kt index 5c59afaee..4a0c96f78 100644 --- a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/DotBenchmark.kt +++ b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/DotBenchmark.kt @@ -3,14 +3,12 @@ package kscience.kmath.benchmarks import kotlinx.benchmark.Benchmark import kscience.kmath.commons.linear.CMMatrixContext import kscience.kmath.ejml.EjmlMatrixContext - import kscience.kmath.linear.BufferMatrixContext import kscience.kmath.linear.RealMatrixContext -import kscience.kmath.linear.real +import kscience.kmath.nd.Matrix import kscience.kmath.operations.RealField import kscience.kmath.operations.invoke import kscience.kmath.structures.Buffer -import kscience.kmath.structures.Matrix import org.openjdk.jmh.annotations.Scope import org.openjdk.jmh.annotations.State import kotlin.random.Random diff --git a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/LinearAlgebraBenchmark.kt b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/LinearAlgebraBenchmark.kt index 5ff43ef80..9e5f76112 100644 --- a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/LinearAlgebraBenchmark.kt +++ b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/LinearAlgebraBenchmark.kt @@ -8,7 +8,6 @@ import kscience.kmath.commons.linear.inverse import kscience.kmath.ejml.EjmlMatrixContext import kscience.kmath.ejml.inverse import kscience.kmath.operations.invoke -import kscience.kmath.structures.Matrix import org.openjdk.jmh.annotations.Scope import org.openjdk.jmh.annotations.State import kotlin.random.Random diff --git a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/NDFieldBenchmark.kt b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/NDFieldBenchmark.kt index 1be8e7236..3f103dd37 100644 --- a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/NDFieldBenchmark.kt +++ b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/NDFieldBenchmark.kt @@ -1,5 +1,8 @@ package kscience.kmath.benchmarks +import kscience.kmath.nd.AbstractNDBuffer +import kscience.kmath.nd.NDField +import kscience.kmath.nd.RealNDField import kscience.kmath.operations.RealField import kscience.kmath.operations.invoke import kscience.kmath.structures.* @@ -12,7 +15,7 @@ internal class NDFieldBenchmark { @Benchmark fun autoFieldAdd() { bufferedField { - var res: NDBuffer = one + var res: AbstractNDBuffer = one repeat(n) { res += one } } } @@ -26,7 +29,7 @@ internal class NDFieldBenchmark { @Benchmark fun specializedFieldAdd() { specializedField { - var res: NDBuffer = one + var res: AbstractNDBuffer = one repeat(n) { res += 1.0 } } } @@ -35,7 +38,7 @@ internal class NDFieldBenchmark { @Benchmark fun boxingFieldAdd() { genericField { - var res: NDBuffer = one + var res: AbstractNDBuffer = one repeat(n) { res += one } } } diff --git a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorBenchmark.kt b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorBenchmark.kt index 8663e353c..49b30cf7e 100644 --- a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorBenchmark.kt +++ b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorBenchmark.kt @@ -1,10 +1,10 @@ package kscience.kmath.benchmarks +import kscience.kmath.nd.NDField +import kscience.kmath.nd.RealNDField import kscience.kmath.operations.RealField import kscience.kmath.operations.invoke import kscience.kmath.structures.BufferedNDField -import kscience.kmath.structures.NDField -import kscience.kmath.structures.RealNDField import kscience.kmath.viktor.ViktorNDField import org.jetbrains.bio.viktor.F64Array import org.openjdk.jmh.annotations.Benchmark diff --git a/examples/src/main/kotlin/kscience/kmath/operations/ComplexDemo.kt b/examples/src/main/kotlin/kscience/kmath/operations/ComplexDemo.kt index e84fd8df3..f90221582 100644 --- a/examples/src/main/kotlin/kscience/kmath/operations/ComplexDemo.kt +++ b/examples/src/main/kotlin/kscience/kmath/operations/ComplexDemo.kt @@ -1,8 +1,7 @@ package kscience.kmath.operations +import kscience.kmath.nd.NDField import kscience.kmath.structures.NDElement -import kscience.kmath.structures.NDField -import kscience.kmath.structures.complex fun main() { // 2d element diff --git a/examples/src/main/kotlin/kscience/kmath/structures/ComplexND.kt b/examples/src/main/kotlin/kscience/kmath/structures/ComplexND.kt index b69590473..7dd725f0e 100644 --- a/examples/src/main/kotlin/kscience/kmath/structures/ComplexND.kt +++ b/examples/src/main/kotlin/kscience/kmath/structures/ComplexND.kt @@ -1,6 +1,7 @@ package kscience.kmath.structures import kscience.kmath.linear.transpose +import kscience.kmath.nd.* import kscience.kmath.operations.Complex import kscience.kmath.operations.ComplexField import kscience.kmath.operations.invoke @@ -10,12 +11,12 @@ fun main() { val dim = 1000 val n = 1000 - val realField = NDField.real(dim, dim) - val complexField: ComplexNDField = NDField.complex(dim, dim) + val realField = NDAlgebra.real(dim, dim) + val complexField: ComplexNDField = NDAlgebra.complex(dim, dim) val realTime = measureTimeMillis { realField { - var res: NDBuffer = one + var res: NDStructure = one repeat(n) { res += 1.0 } @@ -26,8 +27,10 @@ fun main() { val complexTime = measureTimeMillis { complexField { - var res: NDBuffer = one - repeat(n) { res += 1.0 } + var res: NDStructure = one + repeat(n) { + res += 1.0 + } } } diff --git a/examples/src/main/kotlin/kscience/kmath/structures/NDField.kt b/examples/src/main/kotlin/kscience/kmath/structures/NDField.kt index b5130c92b..e26b8cbce 100644 --- a/examples/src/main/kotlin/kscience/kmath/structures/NDField.kt +++ b/examples/src/main/kotlin/kscience/kmath/structures/NDField.kt @@ -1,6 +1,7 @@ package kscience.kmath.structures import kotlinx.coroutines.GlobalScope +import kscience.kmath.nd.* import kscience.kmath.nd4j.Nd4jArrayField import kscience.kmath.operations.RealField import kscience.kmath.operations.invoke @@ -22,29 +23,29 @@ fun main() { val n = 1000 // automatically build context most suited for given type. - val autoField = NDField.auto(RealField, dim, dim) + val autoField = NDAlgebra.field(RealField, Buffer.Companion::auto, dim, dim) // specialized nd-field for Double. It works as generic Double field as well - val specializedField = NDField.real(dim, dim) + val specializedField = NDAlgebra.real(dim, dim) //A generic boxing field. It should be used for objects, not primitives. - val genericField = NDField.boxing(RealField, dim, dim) + val boxingField = NDAlgebra.field(RealField, Buffer.Companion::boxing, dim, dim) // Nd4j specialized field. val nd4jField = Nd4jArrayField.real(dim, dim) measureAndPrint("Automatic field addition") { autoField { - var res: NDBuffer = one + var res: NDStructure = one repeat(n) { res += 1.0 } } } measureAndPrint("Element addition") { - var res = genericField.one + var res: NDStructure = boxingField.one repeat(n) { res += 1.0 } } measureAndPrint("Specialized addition") { specializedField { - var res: NDBuffer = one + var res: NDStructure = one repeat(n) { res += 1.0 } } } @@ -70,8 +71,8 @@ fun main() { measureAndPrint("Generic addition") { //genericField.run(action) - genericField { - var res: NDBuffer = one + boxingField { + var res: NDStructure = one repeat(n) { res += 1.0 // couldn't avoid using `one` due to resolution ambiguity } } diff --git a/examples/src/main/kotlin/kscience/kmath/structures/StructureReadBenchmark.kt b/examples/src/main/kotlin/kscience/kmath/structures/StructureReadBenchmark.kt index 51fd4f956..ba7bcb5f2 100644 --- a/examples/src/main/kotlin/kscience/kmath/structures/StructureReadBenchmark.kt +++ b/examples/src/main/kotlin/kscience/kmath/structures/StructureReadBenchmark.kt @@ -1,5 +1,7 @@ package kscience.kmath.structures +import kscience.kmath.nd.DefaultStrides +import kscience.kmath.nd.NDBuffer import kotlin.system.measureTimeMillis fun main() { @@ -7,7 +9,7 @@ fun main() { val array = DoubleArray(n * n) { 1.0 } val buffer = RealBuffer(array) val strides = DefaultStrides(intArrayOf(n, n)) - val structure = BufferNDStructure(strides, buffer) + val structure = NDBuffer(strides, buffer) measureTimeMillis { var res = 0.0 diff --git a/examples/src/main/kotlin/kscience/kmath/structures/StructureWriteBenchmark.kt b/examples/src/main/kotlin/kscience/kmath/structures/StructureWriteBenchmark.kt index db55b454f..307b068df 100644 --- a/examples/src/main/kotlin/kscience/kmath/structures/StructureWriteBenchmark.kt +++ b/examples/src/main/kotlin/kscience/kmath/structures/StructureWriteBenchmark.kt @@ -1,5 +1,7 @@ package kscience.kmath.structures +import kscience.kmath.nd.NDStructure +import kscience.kmath.nd.mapToBuffer import kotlin.system.measureTimeMillis fun main() { diff --git a/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt b/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt index 850446afa..b9fc8b72a 100644 --- a/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt +++ b/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt @@ -3,9 +3,8 @@ package kscience.kmath.commons.linear import kscience.kmath.linear.DiagonalFeature import kscience.kmath.linear.MatrixContext import kscience.kmath.linear.Point -import kscience.kmath.linear.origin import kscience.kmath.misc.UnstableKMathAPI -import kscience.kmath.structures.Matrix +import kscience.kmath.nd.Matrix import org.apache.commons.math3.linear.* import kotlin.reflect.KClass import kotlin.reflect.cast diff --git a/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMSolver.kt b/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMSolver.kt index 210014e1a..aa0bf4e1a 100644 --- a/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMSolver.kt +++ b/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMSolver.kt @@ -1,7 +1,7 @@ package kscience.kmath.commons.linear import kscience.kmath.linear.Point -import kscience.kmath.structures.Matrix +import kscience.kmath.nd.Matrix import org.apache.commons.math3.linear.* public enum class CMDecomposition { diff --git a/kmath-core/README.md b/kmath-core/README.md index 7882e5252..9ed54b9eb 100644 --- a/kmath-core/README.md +++ b/kmath-core/README.md @@ -3,7 +3,7 @@ The core features of KMath: - [algebras](src/commonMain/kotlin/kscience/kmath/operations/Algebra.kt) : Algebraic structures: contexts and elements - - [nd](src/commonMain/kotlin/kscience/kmath/structures/NDStructure.kt) : Many-dimensional structures + - [nd](src/commonMain/kotlin/kscience/kmath/nd/NDStructure.kt) : Many-dimensional structures - [buffers](src/commonMain/kotlin/kscience/kmath/structures/Buffers.kt) : One-dimensional structure - [expressions](src/commonMain/kotlin/kscience/kmath/expressions) : Functional Expressions - [domains](src/commonMain/kotlin/kscience/kmath/domains) : Domains diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/expressions/SymbolIndexer.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/expressions/SymbolIndexer.kt index 6c61c7c7d..fd0661080 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/expressions/SymbolIndexer.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/expressions/SymbolIndexer.kt @@ -1,8 +1,8 @@ package kscience.kmath.expressions import kscience.kmath.linear.Point +import kscience.kmath.nd.Structure2D import kscience.kmath.structures.BufferFactory -import kscience.kmath.structures.Structure2D /** * An environment to easy transform indexed variables to symbols and back. diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/BufferMatrix.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/BufferMatrix.kt index a74d948fc..bcd1c9976 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/BufferMatrix.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/BufferMatrix.kt @@ -1,7 +1,18 @@ package kscience.kmath.linear +import kscience.kmath.nd.NDStructure +import kscience.kmath.nd.Structure2D import kscience.kmath.operations.Ring -import kscience.kmath.structures.* +import kscience.kmath.structures.Buffer +import kscience.kmath.structures.BufferFactory +import kscience.kmath.structures.asSequence + +/** + * Alias for [Structure2D] with more familiar name. + * + * @param T the type of items. + */ +public typealias Matrix = Structure2D /** * Basic implementation of Matrix space based on [NDStructure] diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/LinearAlgebra.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/LinearAlgebra.kt index 034decc2f..d9201d0f1 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/LinearAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/LinearAlgebra.kt @@ -1,7 +1,6 @@ package kscience.kmath.linear import kscience.kmath.structures.Buffer -import kscience.kmath.structures.Matrix import kscience.kmath.structures.VirtualBuffer public typealias Point = Buffer diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/LupDecomposition.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/LupDecomposition.kt index 5cf7c8f70..ddf7c3fd2 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/LupDecomposition.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/LupDecomposition.kt @@ -1,6 +1,7 @@ package kscience.kmath.linear import kscience.kmath.misc.UnstableKMathAPI +import kscience.kmath.nd.getFeature import kscience.kmath.operations.* import kscience.kmath.structures.* diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixBuilder.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixBuilder.kt index c0c209248..cb01939cc 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixBuilder.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixBuilder.kt @@ -1,6 +1,9 @@ package kscience.kmath.linear -import kscience.kmath.structures.* +import kscience.kmath.nd.Structure2D +import kscience.kmath.structures.Buffer +import kscience.kmath.structures.BufferFactory +import kscience.kmath.structures.asBuffer public class MatrixBuilder(public val rows: Int, public val columns: Int) { public operator fun invoke(vararg elements: T): Matrix { @@ -22,7 +25,7 @@ public fun Structure2D.Companion.row(vararg values: T): Matrix { public inline fun Structure2D.Companion.row( size: Int, factory: BufferFactory = Buffer.Companion::auto, - noinline builder: (Int) -> T + noinline builder: (Int) -> T, ): Matrix { val buffer = factory(size, builder) return BufferMatrix(1, size, buffer) @@ -36,7 +39,7 @@ public fun Structure2D.Companion.column(vararg values: T): Matrix { public inline fun Structure2D.Companion.column( size: Int, factory: BufferFactory = Buffer.Companion::auto, - noinline builder: (Int) -> T + noinline builder: (Int) -> T, ): Matrix { val buffer = factory(size, builder) return BufferMatrix(size, 1, buffer) diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixContext.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixContext.kt index 59a41f840..8766f2e5f 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixContext.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixContext.kt @@ -6,7 +6,6 @@ import kscience.kmath.operations.invoke import kscience.kmath.operations.sum import kscience.kmath.structures.Buffer import kscience.kmath.structures.BufferFactory -import kscience.kmath.structures.Matrix import kscience.kmath.structures.asSequence /** diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixFeatures.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixFeatures.kt index e61feec6c..250e0cc04 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixFeatures.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixFeatures.kt @@ -1,7 +1,5 @@ package kscience.kmath.linear -import kscience.kmath.structures.Matrix - /** * A marker interface representing some properties of matrices or additional transformations of them. Features are used * to optimize matrix operations performance in some cases or retrieve the APIs. diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixWrapper.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixWrapper.kt index 362db1fe7..726a91e97 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixWrapper.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixWrapper.kt @@ -1,11 +1,10 @@ package kscience.kmath.linear import kscience.kmath.misc.UnstableKMathAPI +import kscience.kmath.nd.Structure2D +import kscience.kmath.nd.getFeature import kscience.kmath.operations.Ring -import kscience.kmath.structures.Matrix -import kscience.kmath.structures.Structure2D import kscience.kmath.structures.asBuffer -import kscience.kmath.structures.getFeature import kotlin.math.sqrt import kotlin.reflect.KClass import kotlin.reflect.safeCast @@ -39,7 +38,8 @@ public class MatrixWrapper internal constructor( * Origin does not necessary store all features. */ @UnstableKMathAPI -public val Matrix.origin: Matrix get() = (this as? MatrixWrapper)?.origin ?: this +public val Matrix.origin: Matrix + get() = (this as? MatrixWrapper)?.origin ?: this /** * Add a single feature to a [Matrix] diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/RealMatrixContext.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/RealMatrixContext.kt index 8e197672f..3d544a9af 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/RealMatrixContext.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/RealMatrixContext.kt @@ -1,6 +1,5 @@ package kscience.kmath.linear -import kscience.kmath.structures.Matrix import kscience.kmath.structures.RealBuffer @Suppress("OVERRIDE_BY_INLINE") diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/VirtualMatrix.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/VirtualMatrix.kt index 0269a64d1..df4e4de09 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/VirtualMatrix.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/VirtualMatrix.kt @@ -1,7 +1,5 @@ package kscience.kmath.linear -import kscience.kmath.structures.Matrix - public class VirtualMatrix( override val rowNum: Int, override val colNum: Int, diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt new file mode 100644 index 000000000..a92e08c60 --- /dev/null +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt @@ -0,0 +1,128 @@ +package kscience.kmath.nd + +import kscience.kmath.nd.* +import kscience.kmath.operations.* +import kscience.kmath.structures.BufferFactory +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract + +public interface BufferNDAlgebra : NDAlgebra { + public val strides: Strides + public val bufferFactory: BufferFactory + + override fun produce(initializer: C.(IntArray) -> T): NDBuffer = NDBuffer( + strides, + bufferFactory(strides.linearSize) { offset -> + elementContext.initializer(strides.index(offset)) + } + ) + + public val NDStructure.ndBuffer: NDBuffer + get() = when { + !shape.contentEquals(this@BufferNDAlgebra.shape) -> throw ShapeMismatchException( + this@BufferNDAlgebra.shape, + shape + ) + this is NDBuffer && this.strides == this@BufferNDAlgebra.strides -> this + else -> produce { this@ndBuffer[it] } + } + + override fun map(arg: NDStructure, transform: C.(T) -> T): NDBuffer { + val argAsBuffer = arg.ndBuffer + val buffer = bufferFactory(strides.linearSize) { offset -> + elementContext.transform(argAsBuffer.buffer[offset]) + } + return NDBuffer(strides, buffer) + } + + override fun mapIndexed(arg: NDStructure, transform: C.(index: IntArray, T) -> T): NDStructure { + val argAsBuffer = arg.ndBuffer + val buffer = bufferFactory(strides.linearSize) { offset -> + elementContext.transform( + strides.index(offset), + argAsBuffer[offset] + ) + } + return NDBuffer(strides, buffer) + } + + override fun combine(a: NDStructure, b: NDStructure, transform: C.(T, T) -> T): NDStructure { + val aBuffer = a.ndBuffer + val bBuffer = b.ndBuffer + val buffer = bufferFactory(strides.linearSize) { offset -> + elementContext.transform(aBuffer.buffer[offset], bBuffer[offset]) + } + return NDBuffer(strides, buffer) + } +} + +public open class BufferedNDSpace>( + final override val shape: IntArray, + final override val elementContext: R, + final override val bufferFactory: BufferFactory, +) : NDSpace, BufferNDAlgebra { + override val strides: Strides = DefaultStrides(shape) + override val zero: NDBuffer by lazy { produce { zero } } +} + +public open class BufferedNDRing>( + shape: IntArray, + elementContext: R, + bufferFactory: BufferFactory, +) : BufferedNDSpace(shape, elementContext, bufferFactory), NDRing { + override val one: NDBuffer by lazy { produce { one } } +} + +public open class BufferedNDField>( + shape: IntArray, + elementContext: R, + bufferFactory: BufferFactory, +) : BufferedNDRing(shape, elementContext, bufferFactory), NDField + +// space factories +public fun > NDAlgebra.Companion.space( + space: A, + bufferFactory: BufferFactory, + vararg shape: Int, +): BufferedNDSpace = BufferedNDSpace(shape, space, bufferFactory) + +public inline fun , R> A.nd( + noinline bufferFactory: BufferFactory, + vararg shape: Int, + action: BufferedNDSpace.() -> R, +): R { + contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) } + return NDAlgebra.space(this, bufferFactory, *shape).run(action) +} + +//ring factories +public fun > NDAlgebra.Companion.ring( + ring: A, + bufferFactory: BufferFactory, + vararg shape: Int, +): BufferedNDRing = BufferedNDRing(shape, ring, bufferFactory) + +public inline fun , R> A.nd( + noinline bufferFactory: BufferFactory, + vararg shape: Int, + action: BufferedNDRing.() -> R, +): R { + contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) } + return NDAlgebra.ring(this, bufferFactory, *shape).run(action) +} + +//field factories +public fun > NDAlgebra.Companion.field( + field: A, + bufferFactory: BufferFactory, + vararg shape: Int, +): BufferedNDField = BufferedNDField(shape, field, bufferFactory) + +public inline fun , R> A.nd( + noinline bufferFactory: BufferFactory, + vararg shape: Int, + action: BufferedNDField.() -> R, +): R { + contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) } + return NDAlgebra.field(this, bufferFactory, *shape).run(action) +} \ No newline at end of file diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ComplexNDField.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ComplexNDField.kt new file mode 100644 index 000000000..dbcce5440 --- /dev/null +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ComplexNDField.kt @@ -0,0 +1,113 @@ +package kscience.kmath.nd + +import kscience.kmath.misc.UnstableKMathAPI +import kscience.kmath.operations.* +import kscience.kmath.structures.Buffer +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract + + +/** + * An optimized nd-field for complex numbers + */ +@OptIn(UnstableKMathAPI::class) +public open class ComplexNDField( + shape: IntArray, +) : BufferedNDField(shape, ComplexField, Buffer.Companion::complex), + RingWithNumbers>, + ExtendedField> { + + override val zero: NDBuffer by lazy { produce { zero } } + override val one: NDBuffer by lazy { produce { one } } + + override fun number(value: Number): NDBuffer { + val d = value.toComplex() // minimize conversions + return produce { d } + } +// +// @Suppress("OVERRIDE_BY_INLINE") +// override inline fun map( +// arg: AbstractNDBuffer, +// transform: RealField.(Double) -> Double, +// ): RealNDElement { +// check(arg) +// val array = RealBuffer(arg.strides.linearSize) { offset -> RealField.transform(arg.buffer[offset]) } +// return BufferedNDFieldElement(this, array) +// } +// +// @Suppress("OVERRIDE_BY_INLINE") +// override inline fun produce(initializer: RealField.(IntArray) -> Double): RealNDElement { +// val array = RealBuffer(strides.linearSize) { offset -> elementContext.initializer(strides.index(offset)) } +// return BufferedNDFieldElement(this, array) +// } +// +// @Suppress("OVERRIDE_BY_INLINE") +// override inline fun mapIndexed( +// arg: AbstractNDBuffer, +// transform: RealField.(index: IntArray, Double) -> Double, +// ): RealNDElement { +// check(arg) +// return BufferedNDFieldElement( +// this, +// RealBuffer(arg.strides.linearSize) { offset -> +// elementContext.transform( +// arg.strides.index(offset), +// arg.buffer[offset] +// ) +// }) +// } +// +// @Suppress("OVERRIDE_BY_INLINE") +// override inline fun combine( +// a: AbstractNDBuffer, +// b: AbstractNDBuffer, +// transform: RealField.(Double, Double) -> Double, +// ): RealNDElement { +// check(a, b) +// val buffer = RealBuffer(strides.linearSize) { offset -> +// elementContext.transform(a.buffer[offset], b.buffer[offset]) +// } +// return BufferedNDFieldElement(this, buffer) +// } + + override fun power(arg: NDStructure, pow: Number): NDBuffer = map(arg) { power(it, pow) } + + override fun exp(arg: NDStructure): NDBuffer = map(arg) { exp(it) } + + override fun ln(arg: NDStructure): NDBuffer = map(arg) { ln(it) } + + override fun sin(arg: NDStructure): NDBuffer = map(arg) { sin(it) } + override fun cos(arg: NDStructure): NDBuffer = map(arg) { cos(it) } + override fun tan(arg: NDStructure): NDBuffer = map(arg) { tan(it) } + override fun asin(arg: NDStructure): NDBuffer = map(arg) { asin(it) } + override fun acos(arg: NDStructure): NDBuffer = map(arg) { acos(it) } + override fun atan(arg: NDStructure): NDBuffer = map(arg) { atan(it) } + + override fun sinh(arg: NDStructure): NDBuffer = map(arg) { sinh(it) } + override fun cosh(arg: NDStructure): NDBuffer = map(arg) { cosh(it) } + override fun tanh(arg: NDStructure): NDBuffer = map(arg) { tanh(it) } + override fun asinh(arg: NDStructure): NDBuffer = map(arg) { asinh(it) } + override fun acosh(arg: NDStructure): NDBuffer = map(arg) { acosh(it) } + override fun atanh(arg: NDStructure): NDBuffer = map(arg) { atanh(it) } +} + + +/** + * Fast element production using function inlining + */ +public inline fun BufferedNDField.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) + +/** + * Produce a context for n-dimensional operations inside this real field + */ +public inline fun ComplexField.nd(vararg shape: Int, action: ComplexNDField.() -> R): R { + contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) } + return ComplexNDField(shape).action() +} diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDAlgebra.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDAlgebra.kt new file mode 100644 index 000000000..facc7eb38 --- /dev/null +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDAlgebra.kt @@ -0,0 +1,262 @@ +package kscience.kmath.nd + +import kscience.kmath.operations.Field +import kscience.kmath.operations.Ring +import kscience.kmath.operations.Space +import kscience.kmath.structures.* + +/** + * An exception is thrown when the expected ans actual shape of NDArray differs. + * + * @property expected the expected shape. + * @property actual the actual shape. + */ +public class ShapeMismatchException(public val expected: IntArray, public val actual: IntArray) : + RuntimeException("Shape ${actual.contentToString()} doesn't fit in expected shape ${expected.contentToString()}.") + +/** + * The base interface for all ND-algebra implementations. + * + * @param T the type of ND-structure element. + * @param C the type of the element context. + * @param N the type of the structure. + */ +public interface NDAlgebra { + /** + * The shape of ND-structures this algebra operates on. + */ + public val shape: IntArray + + /** + * The algebra over elements of ND structure. + */ + public val elementContext: C + + /** + * Produces a new [N] structure using given initializer function. + */ + public fun produce(initializer: C.(IntArray) -> T): NDStructure + + /** + * Maps elements from one structure to another one by applying [transform] to them. + */ + public fun map(arg: NDStructure, transform: C.(T) -> T): NDStructure + + /** + * Maps elements from one structure to another one by applying [transform] to them alongside with their indices. + */ + public fun mapIndexed(arg: NDStructure, transform: C.(index: IntArray, T) -> T): NDStructure + + /** + * Combines two structures into one. + */ + public fun combine(a: NDStructure, b: NDStructure, transform: C.(T, T) -> T): NDStructure + + /** + * Element-wise invocation of function working on [T] on a [NDStructure]. + */ + public operator fun Function1.invoke(structure: NDStructure): NDStructure = + map(structure) { value -> this@invoke(value) } + + public companion object +} + +/** + * Checks if given elements are consistent with this context. + * + * @param structures the structures to check. + * @return the array of valid structures. + */ +internal fun NDAlgebra.checkShape(vararg structures: NDStructure): Array> = structures + .map(NDStructure::shape) + .singleOrNull { !shape.contentEquals(it) } + ?.let>> { throw ShapeMismatchException(shape, it) } + ?: structures + +/** + * Checks if given element is consistent with this context. + * + * @param element the structure to check. + * @return the valid structure. + */ +internal fun NDAlgebra.checkShape(element: NDStructure): NDStructure { + if (!element.shape.contentEquals(shape)) throw ShapeMismatchException(shape, element.shape) + return element +} + +/** + * Space of [NDStructure]. + * + * @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 NDSpace> : Space>, NDAlgebra { + /** + * Element-wise addition. + * + * @param a the addend. + * @param b the augend. + * @return the sum. + */ + public override fun add(a: NDStructure, b: NDStructure): NDStructure = + combine(a, b) { aValue, bValue -> add(aValue, bValue) } + + /** + * Element-wise multiplication by scalar. + * + * @param a the multiplicand. + * @param k the multiplier. + * @return the product. + */ + public override fun multiply(a: NDStructure, k: Number): NDStructure = map(a) { multiply(it, k) } + + // TODO move to extensions after KEEP-176 + + /** + * Adds an ND structure to an element of it. + * + * @receiver the addend. + * @param arg the augend. + * @return the sum. + */ + public operator fun NDStructure.plus(arg: T): NDStructure = map(this) { value -> add(arg, value) } + + /** + * Subtracts an element from ND structure of it. + * + * @receiver the dividend. + * @param arg the divisor. + * @return the quotient. + */ + public operator fun NDStructure.minus(arg: T): NDStructure = map(this) { value -> add(arg, -value) } + + /** + * Adds an element to ND structure of it. + * + * @receiver the addend. + * @param arg the augend. + * @return the sum. + */ + public operator fun T.plus(arg: NDStructure): NDStructure = map(arg) { value -> add(this@plus, value) } + + /** + * Subtracts an ND structure from an element of it. + * + * @receiver the dividend. + * @param arg the divisor. + * @return the quotient. + */ + public operator fun T.minus(arg: NDStructure): NDStructure = map(arg) { value -> add(-this@minus, value) } + + public companion object +} + +/** + * Ring of [NDStructure]. + * + * @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>, NDSpace { + /** + * Element-wise multiplication. + * + * @param a the multiplicand. + * @param b the multiplier. + * @return the product. + */ + public override fun multiply(a: NDStructure, b: NDStructure): NDStructure = + combine(a, b) { aValue, bValue -> multiply(aValue, bValue) } + + //TODO move to extensions after KEEP-176 + + /** + * Multiplies an ND structure by an element of it. + * + * @receiver the multiplicand. + * @param arg the multiplier. + * @return the product. + */ + public operator fun NDStructure.times(arg: T): NDStructure = map(this) { value -> multiply(arg, value) } + + /** + * Multiplies an element by a ND structure of it. + * + * @receiver the multiplicand. + * @param arg the multiplier. + * @return the product. + */ + public operator fun T.times(arg: NDStructure): NDStructure = map(arg) { value -> multiply(this@times, value) } + + public companion object +} + +/** + * Field of [NDStructure]. + * + * @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 { + /** + * Element-wise division. + * + * @param a the dividend. + * @param b the divisor. + * @return the quotient. + */ + public override fun divide(a: NDStructure, b: NDStructure): NDStructure = + combine(a, b) { aValue, bValue -> divide(aValue, bValue) } + + //TODO move to extensions after KEEP-176 + /** + * Divides an ND structure by an element of it. + * + * @receiver the dividend. + * @param arg the divisor. + * @return the quotient. + */ + public operator fun NDStructure.div(arg: T): NDStructure = map(this) { value -> divide(arg, value) } + + /** + * Divides an element by an ND structure of it. + * + * @receiver the dividend. + * @param arg the divisor. + * @return the quotient. + */ + public operator fun T.div(arg: NDStructure): NDStructure = map(arg) { divide(it, this@div) } + +// @ThreadLocal +// public companion object { +// private val realNDFieldCache: MutableMap = hashMapOf() +// +// /** +// * Create a nd-field for [Double] values or pull it from cache if it was created previously. +// */ +// public fun real(vararg shape: Int): RealNDField = realNDFieldCache.getOrPut(shape) { RealNDField(shape) } +// +// /** +// * Create an ND field with boxing generic buffer. +// */ +// public fun > boxing( +// field: F, +// vararg shape: Int, +// bufferFactory: BufferFactory = Buffer.Companion::boxing, +// ): BufferedNDField = BufferedNDField(shape, field, bufferFactory) +// +// /** +// * Create a most suitable implementation for nd-field using reified class. +// */ +// @Suppress("UNCHECKED_CAST") +// public inline fun > auto(field: F, vararg shape: Int): NDField = +// when { +// T::class == Double::class -> real(*shape) as NDField +// T::class == Complex::class -> complex(*shape) as BufferedNDField +// else -> BoxingNDField(shape, field, Buffer.Companion::auto) +// } +// } +} diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/NDStructure.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDStructure.kt similarity index 84% rename from kmath-core/src/commonMain/kotlin/kscience/kmath/structures/NDStructure.kt rename to kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDStructure.kt index e7d89ca7e..09c6fa198 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/NDStructure.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDStructure.kt @@ -1,6 +1,10 @@ -package kscience.kmath.structures +package kscience.kmath.nd import kscience.kmath.misc.UnstableKMathAPI +import kscience.kmath.structures.Buffer +import kscience.kmath.structures.BufferFactory +import kscience.kmath.structures.MutableBuffer +import kscience.kmath.structures.asSequence import kotlin.jvm.JvmName import kotlin.native.concurrent.ThreadLocal import kotlin.reflect.KClass @@ -74,8 +78,8 @@ public interface NDStructure { strides: Strides, bufferFactory: BufferFactory = Buffer.Companion::boxing, initializer: (IntArray) -> T, - ): BufferNDStructure = - BufferNDStructure(strides, bufferFactory(strides.linearSize) { i -> initializer(strides.index(i)) }) + ): NDBuffer = + NDBuffer(strides, bufferFactory(strides.linearSize) { i -> initializer(strides.index(i)) }) /** * Inline create NDStructure with non-boxing buffer implementation if it is possible @@ -83,40 +87,40 @@ public interface NDStructure { public inline fun auto( strides: Strides, crossinline initializer: (IntArray) -> T, - ): BufferNDStructure = - BufferNDStructure(strides, Buffer.auto(strides.linearSize) { i -> initializer(strides.index(i)) }) + ): NDBuffer = + NDBuffer(strides, Buffer.auto(strides.linearSize) { i -> initializer(strides.index(i)) }) public inline fun auto( type: KClass, strides: Strides, crossinline initializer: (IntArray) -> T, - ): BufferNDStructure = - BufferNDStructure(strides, Buffer.auto(type, strides.linearSize) { i -> initializer(strides.index(i)) }) + ): NDBuffer = + NDBuffer(strides, Buffer.auto(type, strides.linearSize) { i -> initializer(strides.index(i)) }) public fun build( shape: IntArray, bufferFactory: BufferFactory = Buffer.Companion::boxing, initializer: (IntArray) -> T, - ): BufferNDStructure = build(DefaultStrides(shape), bufferFactory, initializer) + ): NDBuffer = build(DefaultStrides(shape), bufferFactory, initializer) public inline fun auto( shape: IntArray, crossinline initializer: (IntArray) -> T, - ): BufferNDStructure = + ): NDBuffer = auto(DefaultStrides(shape), initializer) @JvmName("autoVarArg") public inline fun auto( vararg shape: Int, crossinline initializer: (IntArray) -> T, - ): BufferNDStructure = + ): NDBuffer = auto(DefaultStrides(shape), initializer) public inline fun auto( type: KClass, vararg shape: Int, crossinline initializer: (IntArray) -> T, - ): BufferNDStructure = + ): NDBuffer = auto(type, DefaultStrides(shape), initializer) } } @@ -156,7 +160,7 @@ public inline fun MutableNDStructure.mapInPlace(action: (IntArray, T) -> */ public interface Strides { /** - * Shape of NDstructure + * Shape of NDStructure */ public val shape: IntArray @@ -185,7 +189,9 @@ public interface Strides { /** * Iterate over ND indices in a natural order */ - public fun indices(): Sequence = (0 until linearSize).asSequence().map { index(it) } + public fun indices(): Sequence = (0 until linearSize).asSequence().map { + index(it) + } } /** @@ -211,7 +217,7 @@ public class DefaultStrides private constructor(override val shape: IntArray) : } override fun offset(index: IntArray): Int = index.mapIndexed { i, value -> - if (value < 0 || value >= this.shape[i]) + if (value < 0 || value >= shape[i]) throw IndexOutOfBoundsException("Index $value out of shape bounds: (0,${this.shape[i]})") value * strides[i] @@ -256,23 +262,29 @@ public class DefaultStrides private constructor(override val shape: IntArray) : * Represents [NDStructure] over [Buffer]. * * @param T the type of items. + * @param strides The strides to access elements of [Buffer] by linear indices. + * @param buffer The underlying buffer. */ -public abstract class NDBuffer : NDStructure { - /** - * The underlying buffer. - */ - public abstract val buffer: Buffer +public open class NDBuffer( + public val strides: Strides, + buffer: Buffer, +) : NDStructure { - /** - * The strides to access elements of [Buffer] by linear indices. - */ - public abstract val strides: Strides + init { + if (strides.linearSize != buffer.size) { + error("Expected buffer side of ${strides.linearSize}, but found ${buffer.size}") + } + } + + public open val buffer: Buffer = buffer override operator fun get(index: IntArray): T = buffer[strides.offset(index)] override val shape: IntArray get() = strides.shape - override fun elements(): Sequence> = strides.indices().map { it to this[it] } + override fun elements(): Sequence> = strides.indices().map { + it to this[it] + } override fun equals(other: Any?): Boolean { return NDStructure.contentEquals(this, other as? NDStructure<*> ?: return false) @@ -297,46 +309,30 @@ public abstract class NDBuffer : NDStructure { } return "NDBuffer(shape=${shape.contentToString()}, buffer=$bufferRepr)" } - - } /** - * Boxing generic [NDStructure] - */ -public class BufferNDStructure( - override val strides: Strides, - override val buffer: Buffer, -) : NDBuffer() { - init { - if (strides.linearSize != buffer.size) { - error("Expected buffer side of ${strides.linearSize}, but found ${buffer.size}") - } - } -} - -/** - * Transform structure to a new structure using provided [BufferFactory] and optimizing if argument is [BufferNDStructure] + * Transform structure to a new structure using provided [BufferFactory] and optimizing if argument is [NDBuffer] */ public inline fun NDStructure.mapToBuffer( factory: BufferFactory = Buffer.Companion::auto, crossinline transform: (T) -> R, -): BufferNDStructure { - return if (this is BufferNDStructure) - BufferNDStructure(this.strides, factory.invoke(strides.linearSize) { transform(buffer[it]) }) +): NDBuffer { + return if (this is NDBuffer) + NDBuffer(this.strides, factory.invoke(strides.linearSize) { transform(buffer[it]) }) else { val strides = DefaultStrides(shape) - BufferNDStructure(strides, factory.invoke(strides.linearSize) { transform(get(strides.index(it))) }) + NDBuffer(strides, factory.invoke(strides.linearSize) { transform(get(strides.index(it))) }) } } /** * Mutable ND buffer based on linear [MutableBuffer]. */ -public class MutableBufferNDStructure( - override val strides: Strides, - override val buffer: MutableBuffer, -) : NDBuffer(), MutableNDStructure { +public class MutableNDBuffer( + strides: Strides, + buffer: MutableBuffer, +) : NDBuffer(strides,buffer), MutableNDStructure { init { require(strides.linearSize == buffer.size) { @@ -344,6 +340,8 @@ public class MutableBufferNDStructure( } } + override val buffer: MutableBuffer = super.buffer as MutableBuffer + override operator fun set(index: IntArray, value: T): Unit = buffer.set(strides.offset(index), value) } diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt new file mode 100644 index 000000000..feb3c509a --- /dev/null +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt @@ -0,0 +1,111 @@ +package kscience.kmath.nd + +import kscience.kmath.misc.UnstableKMathAPI +import kscience.kmath.operations.ExtendedField +import kscience.kmath.operations.RealField +import kscience.kmath.operations.RingWithNumbers +import kscience.kmath.structures.Buffer +import kscience.kmath.structures.RealBuffer +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract + +@OptIn(UnstableKMathAPI::class) +public open class RealNDField( + shape: IntArray, +) : BufferedNDField(shape, RealField, Buffer.Companion::real), + RingWithNumbers>, + ExtendedField> { + + override val zero: NDBuffer by lazy { produce { zero } } + override val one: NDBuffer by lazy { produce { one } } + + override fun number(value: Number): NDBuffer { + val d = value.toDouble() // minimize conversions + return produce { d } + } +// +// @Suppress("OVERRIDE_BY_INLINE") +// override inline fun map( +// arg: AbstractNDBuffer, +// transform: RealField.(Double) -> Double, +// ): RealNDElement { +// check(arg) +// val array = RealBuffer(arg.strides.linearSize) { offset -> RealField.transform(arg.buffer[offset]) } +// return BufferedNDFieldElement(this, array) +// } +// +// @Suppress("OVERRIDE_BY_INLINE") +// override inline fun produce(initializer: RealField.(IntArray) -> Double): RealNDElement { +// val array = RealBuffer(strides.linearSize) { offset -> elementContext.initializer(strides.index(offset)) } +// return BufferedNDFieldElement(this, array) +// } +// +// @Suppress("OVERRIDE_BY_INLINE") +// override inline fun mapIndexed( +// arg: AbstractNDBuffer, +// transform: RealField.(index: IntArray, Double) -> Double, +// ): RealNDElement { +// check(arg) +// return BufferedNDFieldElement( +// this, +// RealBuffer(arg.strides.linearSize) { offset -> +// elementContext.transform( +// arg.strides.index(offset), +// arg.buffer[offset] +// ) +// }) +// } +// +// @Suppress("OVERRIDE_BY_INLINE") +// override inline fun combine( +// a: AbstractNDBuffer, +// b: AbstractNDBuffer, +// transform: RealField.(Double, Double) -> Double, +// ): RealNDElement { +// check(a, b) +// val buffer = RealBuffer(strides.linearSize) { offset -> +// elementContext.transform(a.buffer[offset], b.buffer[offset]) +// } +// return BufferedNDFieldElement(this, buffer) +// } + + override fun power(arg: NDStructure, pow: Number): NDBuffer = map(arg) { power(it, pow) } + + override fun exp(arg: NDStructure): NDBuffer = map(arg) { exp(it) } + + override fun ln(arg: NDStructure): NDBuffer = map(arg) { ln(it) } + + override fun sin(arg: NDStructure): NDBuffer = map(arg) { sin(it) } + override fun cos(arg: NDStructure): NDBuffer = map(arg) { cos(it) } + override fun tan(arg: NDStructure): NDBuffer = map(arg) { tan(it) } + override fun asin(arg: NDStructure): NDBuffer = map(arg) { asin(it) } + override fun acos(arg: NDStructure): NDBuffer = map(arg) { acos(it) } + override fun atan(arg: NDStructure): NDBuffer = map(arg) { atan(it) } + + override fun sinh(arg: NDStructure): NDBuffer = map(arg) { sinh(it) } + override fun cosh(arg: NDStructure): NDBuffer = map(arg) { cosh(it) } + override fun tanh(arg: NDStructure): NDBuffer = map(arg) { tanh(it) } + override fun asinh(arg: NDStructure): NDBuffer = map(arg) { asinh(it) } + override fun acosh(arg: NDStructure): NDBuffer = map(arg) { acosh(it) } + override fun atanh(arg: NDStructure): NDBuffer = map(arg) { atanh(it) } +} + + +/** + * Fast element production using function inlining + */ +public inline fun BufferedNDField.produceInline(crossinline initializer: RealField.(Int) -> Double): NDBuffer { + contract { callsInPlace(initializer, InvocationKind.EXACTLY_ONCE) } + val array = DoubleArray(strides.linearSize) { offset -> RealField.initializer(offset) } + return NDBuffer(strides, RealBuffer(array)) +} + +public fun NDAlgebra.Companion.real(vararg shape: Int): RealNDField = RealNDField(shape) + +/** + * Produce a context for n-dimensional operations inside this real field + */ +public inline fun RealField.nd(vararg shape: Int, action: RealNDField.() -> R): R { + contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) } + return RealNDField(shape).run(action) +} diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ShortNDRing.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ShortNDRing.kt new file mode 100644 index 000000000..8663c4249 --- /dev/null +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ShortNDRing.kt @@ -0,0 +1,36 @@ +package kscience.kmath.nd + +import kscience.kmath.misc.UnstableKMathAPI +import kscience.kmath.operations.RingWithNumbers +import kscience.kmath.operations.ShortRing +import kscience.kmath.structures.Buffer +import kscience.kmath.structures.ShortBuffer +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract + +@OptIn(UnstableKMathAPI::class) +public open class ShortNDRing( + shape: IntArray, +) : BufferedNDRing(shape, ShortRing, Buffer.Companion::auto), + RingWithNumbers> { + + override val zero: NDBuffer by lazy { produce { zero } } + override val one: NDBuffer by lazy { produce { one } } + + override fun number(value: Number): NDBuffer { + val d = value.toShort() // minimize conversions + return produce { d } + } +} + +/** + * Fast element production using function inlining. + */ +public inline fun BufferedNDRing.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 { + contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) } + return ShortNDRing(shape).run(action) +} \ No newline at end of file diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/Structure1D.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure1D.kt similarity index 89% rename from kmath-core/src/commonMain/kotlin/kscience/kmath/structures/Structure1D.kt rename to kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure1D.kt index 95422ac60..d69c23fb4 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/Structure1D.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure1D.kt @@ -1,4 +1,7 @@ -package kscience.kmath.structures +package kscience.kmath.nd + +import kscience.kmath.structures.Buffer +import kscience.kmath.structures.asSequence /** * A structure that is guaranteed to be one-dimensional @@ -34,7 +37,7 @@ private inline class Buffer1DWrapper(val buffer: Buffer) : Structure1D override val size: Int get() = buffer.size override fun elements(): Sequence> = - asSequence().mapIndexed { index, value -> intArrayOf(index) to value } + buffer.asSequence().mapIndexed { index, value -> intArrayOf(index) to value } override operator fun get(index: Int): T = buffer[index] } diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/Structure2D.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt similarity index 92% rename from kmath-core/src/commonMain/kotlin/kscience/kmath/structures/Structure2D.kt rename to kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt index d20e9e53b..4c730877c 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/Structure2D.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt @@ -1,4 +1,7 @@ -package kscience.kmath.structures +package kscience.kmath.nd + +import kscience.kmath.structures.Buffer +import kscience.kmath.structures.VirtualBuffer /** * A structure that is guaranteed to be two-dimensional. @@ -73,10 +76,3 @@ public fun NDStructure.as2D(): Structure2D = if (shape.size == 2) Structure2DWrapper(this) else error("Can't create 2d-structure from ${shape.size}d-structure") - -/** - * Alias for [Structure2D] with more familiar name. - * - * @param T the type of items. - */ -public typealias Matrix = Structure2D diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/BigInt.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/BigInt.kt index 0be72e80c..9599401bc 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/BigInt.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/BigInt.kt @@ -1,6 +1,7 @@ package kscience.kmath.operations import kscience.kmath.misc.UnstableKMathAPI +import kscience.kmath.nd.NDAlgebra import kscience.kmath.operations.BigInt.Companion.BASE import kscience.kmath.operations.BigInt.Companion.BASE_SIZE import kscience.kmath.structures.* diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BoxingNDField.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BoxingNDField.kt deleted file mode 100644 index dc65b12c4..000000000 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BoxingNDField.kt +++ /dev/null @@ -1,81 +0,0 @@ -package kscience.kmath.structures - -import kscience.kmath.operations.Field -import kscience.kmath.operations.FieldElement - -public class BoxingNDField>( - public override val shape: IntArray, - public override val elementContext: F, - public val bufferFactory: BufferFactory -) : BufferedNDField { - public override val zero: BufferedNDFieldElement by lazy { produce { zero } } - public override val one: BufferedNDFieldElement by lazy { produce { one } } - public override val strides: Strides = DefaultStrides(shape) - - public fun buildBuffer(size: Int, initializer: (Int) -> T): Buffer = - bufferFactory(size, initializer) - - public override fun check(vararg elements: NDBuffer): Array> { - require(elements.all { it.strides == strides }) { "Element strides are not the same as context strides" } - return elements - } - - public override fun produce(initializer: F.(IntArray) -> T): BufferedNDFieldElement = - BufferedNDFieldElement( - this, - buildBuffer(strides.linearSize) { offset -> elementContext.initializer(strides.index(offset)) }) - - public override fun map(arg: NDBuffer, transform: F.(T) -> T): BufferedNDFieldElement { - check(arg) - - return BufferedNDFieldElement( - this, - buildBuffer(arg.strides.linearSize) { offset -> elementContext.transform(arg.buffer[offset]) }) - -// val buffer = arg.buffer.transform { _, value -> elementContext.transform(value) } -// return BufferedNDFieldElement(this, buffer) - - } - - public override fun mapIndexed( - arg: NDBuffer, - transform: F.(index: IntArray, T) -> T - ): BufferedNDFieldElement { - check(arg) - return BufferedNDFieldElement( - this, - buildBuffer(arg.strides.linearSize) { offset -> - elementContext.transform( - arg.strides.index(offset), - arg.buffer[offset] - ) - }) - -// val buffer = -// arg.buffer.transform { offset, value -> elementContext.transform(arg.strides.index(offset), value) } -// return BufferedNDFieldElement(this, buffer) - } - - public override fun combine( - a: NDBuffer, - b: NDBuffer, - transform: F.(T, T) -> T - ): BufferedNDFieldElement { - check(a, b) - return BufferedNDFieldElement( - this, - buildBuffer(strides.linearSize) { offset -> elementContext.transform(a.buffer[offset], b.buffer[offset]) }) - } - - public override fun NDBuffer.toElement(): FieldElement, *, out BufferedNDField> = - BufferedNDFieldElement(this@BoxingNDField, buffer) -} - -public inline fun , R> F.nd( - noinline bufferFactory: BufferFactory, - vararg shape: Int, - action: NDField.() -> R -): R { - val ndfield = NDField.boxing(this, *shape, bufferFactory = bufferFactory) - return ndfield.action() -} diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BoxingNDRing.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BoxingNDRing.kt deleted file mode 100644 index b6794984c..000000000 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BoxingNDRing.kt +++ /dev/null @@ -1,71 +0,0 @@ -package kscience.kmath.structures - -import kscience.kmath.operations.Ring -import kscience.kmath.operations.RingElement - -public class BoxingNDRing>( - override val shape: IntArray, - override val elementContext: R, - public val bufferFactory: BufferFactory -) : BufferedNDRing { - override val strides: Strides = DefaultStrides(shape) - override val zero: BufferedNDRingElement by lazy { produce { zero } } - override val one: BufferedNDRingElement by lazy { produce { one } } - - public fun buildBuffer(size: Int, initializer: (Int) -> T): Buffer = bufferFactory(size, initializer) - - override fun check(vararg elements: NDBuffer): Array> { - if (!elements.all { it.strides == this.strides }) error("Element strides are not the same as context strides") - return elements - } - - override fun produce(initializer: R.(IntArray) -> T): BufferedNDRingElement = - BufferedNDRingElement( - this, - buildBuffer(strides.linearSize) { offset -> elementContext.initializer(strides.index(offset)) }) - - override fun map(arg: NDBuffer, transform: R.(T) -> T): BufferedNDRingElement { - check(arg) - return BufferedNDRingElement( - this, - buildBuffer(arg.strides.linearSize) { offset -> elementContext.transform(arg.buffer[offset]) }) - -// val buffer = arg.buffer.transform { _, value -> elementContext.transform(value) } -// return BufferedNDFieldElement(this, buffer) - - } - - override fun mapIndexed( - arg: NDBuffer, - transform: R.(index: IntArray, T) -> T - ): BufferedNDRingElement { - check(arg) - return BufferedNDRingElement( - this, - buildBuffer(arg.strides.linearSize) { offset -> - elementContext.transform( - arg.strides.index(offset), - arg.buffer[offset] - ) - }) - -// val buffer = -// arg.buffer.transform { offset, value -> elementContext.transform(arg.strides.index(offset), value) } -// return BufferedNDFieldElement(this, buffer) - } - - override fun combine( - a: NDBuffer, - b: NDBuffer, - transform: R.(T, T) -> T - ): BufferedNDRingElement { - check(a, b) - - return BufferedNDRingElement( - this, - buildBuffer(strides.linearSize) { offset -> elementContext.transform(a.buffer[offset], b.buffer[offset]) }) - } - - override fun NDBuffer.toElement(): RingElement, *, out BufferedNDRing> = - BufferedNDRingElement(this@BoxingNDRing, buffer) -} diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BufferAccessor2D.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BufferAccessor2D.kt index 5d7ba611f..3c53d6c51 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BufferAccessor2D.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BufferAccessor2D.kt @@ -1,5 +1,10 @@ package kscience.kmath.structures +import kscience.kmath.nd.DefaultStrides +import kscience.kmath.nd.NDStructure +import kscience.kmath.nd.Structure2D +import kscience.kmath.nd.as2D + /** * A context that allows to operate on a [MutableBuffer] as on 2d array */ diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BufferedNDAlgebra.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BufferedNDAlgebra.kt deleted file mode 100644 index 3dcd0322c..000000000 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BufferedNDAlgebra.kt +++ /dev/null @@ -1,43 +0,0 @@ -package kscience.kmath.structures - -import kscience.kmath.operations.* - -public interface BufferedNDAlgebra : NDAlgebra> { - public val strides: Strides - - public override fun check(vararg elements: NDBuffer): Array> { - require(elements.all { it.strides == strides }) { "Strides mismatch" } - return elements - } - - /** - * Convert any [NDStructure] to buffered structure using strides from this context. - * If the structure is already [NDBuffer], conversion is free. If not, it could be expensive because iteration over - * indices. - * - * If the argument is [NDBuffer] with different strides structure, the new element will be produced. - */ - public fun NDStructure.toBuffer(): NDBuffer = - if (this is NDBuffer && this.strides == this@BufferedNDAlgebra.strides) - this - else - produce { index -> this@toBuffer[index] } - - /** - * Convert a buffer to element of this algebra - */ - public fun NDBuffer.toElement(): MathElement> -} - - -public interface BufferedNDSpace> : NDSpace>, BufferedNDAlgebra { - public override fun NDBuffer.toElement(): SpaceElement, *, out BufferedNDSpace> -} - -public interface BufferedNDRing> : NDRing>, BufferedNDSpace { - override fun NDBuffer.toElement(): RingElement, *, out BufferedNDRing> -} - -public interface BufferedNDField> : NDField>, BufferedNDRing { - override fun NDBuffer.toElement(): FieldElement, *, out BufferedNDField> -} diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BufferedNDElement.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BufferedNDElement.kt deleted file mode 100644 index d53702566..000000000 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/BufferedNDElement.kt +++ /dev/null @@ -1,86 +0,0 @@ -package kscience.kmath.structures - -import kscience.kmath.operations.* - -/** - * Base class for an element with context, containing strides - */ -public abstract class BufferedNDElement : NDBuffer(), NDElement> { - abstract override val context: BufferedNDAlgebra - - override val strides: Strides get() = context.strides - - override val shape: IntArray get() = context.shape -} - -public class BufferedNDSpaceElement>( - override val context: BufferedNDSpace, - override val buffer: Buffer -) : BufferedNDElement(), SpaceElement, BufferedNDSpaceElement, BufferedNDSpace> { - - override fun unwrap(): NDBuffer = this - - override fun NDBuffer.wrap(): BufferedNDSpaceElement { - context.check(this) - return BufferedNDSpaceElement(context, buffer) - } -} - -public class BufferedNDRingElement>( - override val context: BufferedNDRing, - override val buffer: Buffer -) : BufferedNDElement(), RingElement, BufferedNDRingElement, BufferedNDRing> { - override fun unwrap(): NDBuffer = this - - override fun NDBuffer.wrap(): BufferedNDRingElement { - context.check(this) - return BufferedNDRingElement(context, buffer) - } -} - -public class BufferedNDFieldElement>( - override val context: BufferedNDField, - override val buffer: Buffer -) : BufferedNDElement(), FieldElement, BufferedNDFieldElement, BufferedNDField> { - override fun unwrap(): NDBuffer = this - - override fun NDBuffer.wrap(): BufferedNDFieldElement { - context.check(this) - return BufferedNDFieldElement(context, buffer) - } -} - - -/** - * Element by element application of any operation on elements to the whole array. Just like in numpy. - */ -public operator fun > Function1.invoke(ndElement: BufferedNDElement): MathElement> = - ndElement.context.run { map(ndElement) { invoke(it) }.toElement() } - -/* plus and minus */ - -/** - * Summation operation for [BufferedNDElement] and single element - */ -public operator fun > BufferedNDElement.plus(arg: T): NDElement> = - context.map(this) { it + arg }.wrap() - -/** - * Subtraction operation between [BufferedNDElement] and single element - */ -public operator fun > BufferedNDElement.minus(arg: T): NDElement> = - context.map(this) { it - arg }.wrap() - -/* prod and div */ - -/** - * Product operation for [BufferedNDElement] and single element - */ -public operator fun > BufferedNDElement.times(arg: T): NDElement> = - context.map(this) { it * arg }.wrap() - -/** - * Division operation between [BufferedNDElement] and single element - */ -public operator fun > BufferedNDElement.div(arg: T): NDElement> = - context.map(this) { it / arg }.wrap() diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/Buffers.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/Buffers.kt index bfec6f871..4e7c0d1b1 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/Buffers.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/Buffers.kt @@ -43,7 +43,7 @@ public interface Buffer { * Checks content equality with another buffer. */ public fun contentEquals(other: Buffer<*>): Boolean = - asSequence().mapIndexed { index, value -> value == other[index] }.all { it } + kscience.kmath.nd.mapIndexed { index, value -> value == other[index] }.all { it } public companion object { /** diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/ComplexNDField.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/ComplexNDField.kt deleted file mode 100644 index 6de69cabe..000000000 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/ComplexNDField.kt +++ /dev/null @@ -1,158 +0,0 @@ -package kscience.kmath.structures - -import kscience.kmath.misc.UnstableKMathAPI -import kscience.kmath.operations.* -import kotlin.contracts.InvocationKind -import kotlin.contracts.contract - -public typealias ComplexNDElement = BufferedNDFieldElement - -/** - * An optimized nd-field for complex numbers - */ -@OptIn(UnstableKMathAPI::class) -public class ComplexNDField(override val shape: IntArray) : - BufferedNDField, - ExtendedNDField>, - RingWithNumbers>{ - - override val strides: Strides = DefaultStrides(shape) - override val elementContext: ComplexField get() = ComplexField - override val zero: ComplexNDElement by lazy { produce { zero } } - override val one: ComplexNDElement by lazy { produce { one } } - - override fun number(value: Number): NDBuffer { - val c = value.toComplex() - return produce { c } - } - - public inline fun buildBuffer(size: Int, crossinline initializer: (Int) -> Complex): Buffer = - Buffer.complex(size) { initializer(it) } - - /** - * Inline transform an NDStructure to another structure - */ - override fun map( - arg: NDBuffer, - transform: ComplexField.(Complex) -> Complex, - ): ComplexNDElement { - check(arg) - val array = buildBuffer(arg.strides.linearSize) { offset -> ComplexField.transform(arg.buffer[offset]) } - return BufferedNDFieldElement(this, array) - } - - override fun produce(initializer: ComplexField.(IntArray) -> Complex): ComplexNDElement { - val array = buildBuffer(strides.linearSize) { offset -> elementContext.initializer(strides.index(offset)) } - return BufferedNDFieldElement(this, array) - } - - override fun mapIndexed( - arg: NDBuffer, - transform: ComplexField.(index: IntArray, Complex) -> Complex, - ): ComplexNDElement { - check(arg) - - return BufferedNDFieldElement( - this, - buildBuffer(arg.strides.linearSize) { offset -> - elementContext.transform( - arg.strides.index(offset), - arg.buffer[offset] - ) - }) - } - - override fun combine( - a: NDBuffer, - b: NDBuffer, - transform: ComplexField.(Complex, Complex) -> Complex, - ): ComplexNDElement { - check(a, b) - - return BufferedNDFieldElement( - this, - buildBuffer(strides.linearSize) { offset -> elementContext.transform(a.buffer[offset], b.buffer[offset]) }) - } - - override fun NDBuffer.toElement(): FieldElement, *, out BufferedNDField> = - BufferedNDFieldElement(this@ComplexNDField, buffer) - - override fun power(arg: NDBuffer, pow: Number): ComplexNDElement = - map(arg) { power(it, pow) } - - override fun exp(arg: NDBuffer): ComplexNDElement = map(arg) { exp(it) } - override fun ln(arg: NDBuffer): ComplexNDElement = map(arg) { ln(it) } - - override fun sin(arg: NDBuffer): ComplexNDElement = map(arg) { sin(it) } - override fun cos(arg: NDBuffer): ComplexNDElement = map(arg) { cos(it) } - override fun tan(arg: NDBuffer): ComplexNDElement = map(arg) { tan(it) } - override fun asin(arg: NDBuffer): ComplexNDElement = map(arg) { asin(it) } - override fun acos(arg: NDBuffer): ComplexNDElement = map(arg) { acos(it) } - override fun atan(arg: NDBuffer): ComplexNDElement = map(arg) { atan(it) } - - override fun sinh(arg: NDBuffer): ComplexNDElement = map(arg) { sinh(it) } - override fun cosh(arg: NDBuffer): ComplexNDElement = map(arg) { cosh(it) } - override fun tanh(arg: NDBuffer): ComplexNDElement = map(arg) { tanh(it) } - override fun asinh(arg: NDBuffer): ComplexNDElement = map(arg) { asinh(it) } - override fun acosh(arg: NDBuffer): ComplexNDElement = map(arg) { acosh(it) } - override fun atanh(arg: NDBuffer): ComplexNDElement = map(arg) { atanh(it) } -} - - -/** - * Fast element production using function inlining - */ -public inline fun BufferedNDField.produceInline(initializer: ComplexField.(Int) -> Complex): ComplexNDElement { - val buffer = Buffer.complex(strides.linearSize) { offset -> ComplexField.initializer(offset) } - return BufferedNDFieldElement(this, buffer) -} - -/** - * Map one [ComplexNDElement] using function with indices. - */ -public inline fun ComplexNDElement.mapIndexed(transform: ComplexField.(index: IntArray, Complex) -> Complex): ComplexNDElement = - context.produceInline { offset -> transform(strides.index(offset), buffer[offset]) } - -/** - * Map one [ComplexNDElement] using function without indices. - */ -public inline fun ComplexNDElement.map(transform: ComplexField.(Complex) -> Complex): ComplexNDElement { - val buffer = Buffer.complex(strides.linearSize) { offset -> ComplexField.transform(buffer[offset]) } - return BufferedNDFieldElement(context, buffer) -} - -/** - * Element by element application of any operation on elements to the whole array. Just like in numpy - */ -public operator fun Function1.invoke(ndElement: ComplexNDElement): ComplexNDElement = - ndElement.map { this@invoke(it) } - -/* plus and minus */ - -/** - * Summation operation for [BufferedNDElement] and single element - */ -public operator fun ComplexNDElement.plus(arg: Complex): ComplexNDElement = map { it + arg } - -/** - * Subtraction operation between [BufferedNDElement] and single element - */ -public operator fun ComplexNDElement.minus(arg: Complex): ComplexNDElement = map { it - arg } - -public operator fun ComplexNDElement.plus(arg: Double): ComplexNDElement = map { it + arg } -public operator fun ComplexNDElement.minus(arg: Double): ComplexNDElement = map { it - arg } - -public fun NDField.Companion.complex(vararg shape: Int): ComplexNDField = ComplexNDField(shape) - -public fun NDElement.Companion.complex( - vararg shape: Int, - initializer: ComplexField.(IntArray) -> Complex, -): ComplexNDElement = NDField.complex(*shape).produce(initializer) - -/** - * Produce a context for n-dimensional operations inside this real field - */ -public inline fun ComplexField.nd(vararg shape: Int, action: ComplexNDField.() -> R): R { - contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) } - return NDField.complex(*shape).action() -} diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/ExtendedNDField.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/ExtendedNDField.kt deleted file mode 100644 index a9fa2763b..000000000 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/ExtendedNDField.kt +++ /dev/null @@ -1,44 +0,0 @@ -package kscience.kmath.structures - -import kscience.kmath.operations.ExtendedField - -/** - * [ExtendedField] over [NDStructure]. - * - * @param T the type of the element contained in ND structure. - * @param N the type of ND structure. - * @param F the extended field of structure elements. - */ -public interface ExtendedNDField, N : NDStructure> : NDField, ExtendedField - -///** -// * NDField that supports [ExtendedField] operations on its elements -// */ -//class ExtendedNDFieldWrapper, N : NDStructure>(private val ndField: NDField) : -// ExtendedNDField, NDField by ndField { -// -// override val shape: IntArray get() = ndField.shape -// override val elementContext: F get() = ndField.elementContext -// -// override fun produce(initializer: F.(IntArray) -> T) = ndField.produce(initializer) -// -// override fun power(arg: N, pow: Double): N { -// return produce { with(elementContext) { power(arg[it], pow) } } -// } -// -// override fun exp(arg: N): N { -// return produce { with(elementContext) { exp(arg[it]) } } -// } -// -// override fun ln(arg: N): N { -// return produce { with(elementContext) { ln(arg[it]) } } -// } -// -// override fun sin(arg: N): N { -// return produce { with(elementContext) { sin(arg[it]) } } -// } -// -// override fun cos(arg: N): N { -// return produce { with(elementContext) { cos(arg[it]) } } -// } -//} diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/FlaggedBuffer.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/FlaggedBuffer.kt index 4965e37cf..7828cea10 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/FlaggedBuffer.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/FlaggedBuffer.kt @@ -60,7 +60,7 @@ public class FlaggedRealBuffer(public val values: DoubleArray, public val flags: override operator fun get(index: Int): Double? = if (isValid(index)) values[index] else null - override operator fun iterator(): Iterator = values.indices.asSequence().map { + override operator fun iterator(): Iterator = kscience.kmath.nd.map { if (isValid(it)) values[it] else null }.iterator() } diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/MemoryBuffer.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/MemoryBuffer.kt index 66c9212cf..22331ae81 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/MemoryBuffer.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/MemoryBuffer.kt @@ -15,7 +15,7 @@ public open class MemoryBuffer(protected val memory: Memory, protected private val reader: MemoryReader = memory.reader() override operator fun get(index: Int): T = reader.read(spec, spec.objectSize * index) - override operator fun iterator(): Iterator = (0 until size).asSequence().map { get(it) }.iterator() + override operator fun iterator(): Iterator = kscience.kmath.nd.map { get(it) }.iterator() public companion object { public fun create(spec: MemorySpec, size: Int): MemoryBuffer = diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/NDAlgebra.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/NDAlgebra.kt deleted file mode 100644 index d7b019c65..000000000 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/NDAlgebra.kt +++ /dev/null @@ -1,259 +0,0 @@ -package kscience.kmath.structures - -import kscience.kmath.operations.Complex -import kscience.kmath.operations.Field -import kscience.kmath.operations.Ring -import kscience.kmath.operations.Space -import kotlin.native.concurrent.ThreadLocal - -/** - * An exception is thrown when the expected ans actual shape of NDArray differs. - * - * @property expected the expected shape. - * @property actual the actual shape. - */ -public class ShapeMismatchException(public val expected: IntArray, public val actual: IntArray) : - RuntimeException("Shape ${actual.contentToString()} doesn't fit in expected shape ${expected.contentToString()}.") - -/** - * The base interface for all ND-algebra implementations. - * - * @param T the type of ND-structure element. - * @param C the type of the element context. - * @param N the type of the structure. - */ -public interface NDAlgebra> { - /** - * The shape of ND-structures this algebra operates on. - */ - public val shape: IntArray - - /** - * The algebra over elements of ND structure. - */ - public val elementContext: C - - /** - * Produces a new [N] structure using given initializer function. - */ - public fun produce(initializer: C.(IntArray) -> T): N - - /** - * Maps elements from one structure to another one by applying [transform] to them. - */ - public fun map(arg: N, transform: C.(T) -> T): N - - /** - * Maps elements from one structure to another one by applying [transform] to them alongside with their indices. - */ - public fun mapIndexed(arg: N, transform: C.(index: IntArray, T) -> T): N - - /** - * Combines two structures into one. - */ - public fun combine(a: N, b: N, transform: C.(T, T) -> T): N - - /** - * Checks if given element is consistent with this context. - * - * @param element the structure to check. - * @return the valid structure. - */ - public fun check(element: N): N { - if (!element.shape.contentEquals(shape)) throw ShapeMismatchException(shape, element.shape) - return element - } - - /** - * Checks if given elements are consistent with this context. - * - * @param elements the structures to check. - * @return the array of valid structures. - */ - public fun check(vararg elements: N): Array = elements - .map(NDStructure::shape) - .singleOrNull { !shape.contentEquals(it) } - ?.let> { throw ShapeMismatchException(shape, it) } - ?: elements - - /** - * Element-wise invocation of function working on [T] on a [NDStructure]. - */ - public operator fun Function1.invoke(structure: N): N = map(structure) { value -> this@invoke(value) } - - public companion object -} - -/** - * Space of [NDStructure]. - * - * @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 NDSpace, N : NDStructure> : Space, NDAlgebra { - /** - * Element-wise addition. - * - * @param a the addend. - * @param b the augend. - * @return the sum. - */ - public override fun add(a: N, b: N): N = combine(a, b) { aValue, bValue -> add(aValue, bValue) } - - /** - * Element-wise multiplication by scalar. - * - * @param a the multiplicand. - * @param k the multiplier. - * @return the product. - */ - public override fun multiply(a: N, k: Number): N = map(a) { multiply(it, k) } - - // TODO move to extensions after KEEP-176 - - /** - * Adds an ND structure to an element of it. - * - * @receiver the addend. - * @param arg the augend. - * @return the sum. - */ - public operator fun N.plus(arg: T): N = map(this) { value -> add(arg, value) } - - /** - * Subtracts an element from ND structure of it. - * - * @receiver the dividend. - * @param arg the divisor. - * @return the quotient. - */ - public operator fun N.minus(arg: T): N = map(this) { value -> add(arg, -value) } - - /** - * Adds an element to ND structure of it. - * - * @receiver the addend. - * @param arg the augend. - * @return the sum. - */ - public operator fun T.plus(arg: N): N = map(arg) { value -> add(this@plus, value) } - - /** - * Subtracts an ND structure from an element of it. - * - * @receiver the dividend. - * @param arg the divisor. - * @return the quotient. - */ - public operator fun T.minus(arg: N): N = map(arg) { value -> add(-this@minus, value) } - - public companion object -} - -/** - * Ring of [NDStructure]. - * - * @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, N : NDStructure> : Ring, NDSpace { - /** - * Element-wise multiplication. - * - * @param a the multiplicand. - * @param b the multiplier. - * @return the product. - */ - public override fun multiply(a: N, b: N): N = combine(a, b) { aValue, bValue -> multiply(aValue, bValue) } - - //TODO move to extensions after KEEP-176 - - /** - * Multiplies an ND structure by an element of it. - * - * @receiver the multiplicand. - * @param arg the multiplier. - * @return the product. - */ - public operator fun N.times(arg: T): N = map(this) { value -> multiply(arg, value) } - - /** - * Multiplies an element by a ND structure of it. - * - * @receiver the multiplicand. - * @param arg the multiplier. - * @return the product. - */ - public operator fun T.times(arg: N): N = map(arg) { value -> multiply(this@times, value) } - - public companion object -} - -/** - * Field of [NDStructure]. - * - * @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, N : NDStructure> : Field, NDRing { - /** - * Element-wise division. - * - * @param a the dividend. - * @param b the divisor. - * @return the quotient. - */ - public override fun divide(a: N, b: N): N = combine(a, b) { aValue, bValue -> divide(aValue, bValue) } - - //TODO move to extensions after KEEP-176 - /** - * Divides an ND structure by an element of it. - * - * @receiver the dividend. - * @param arg the divisor. - * @return the quotient. - */ - public operator fun N.div(arg: T): N = map(this) { value -> divide(arg, value) } - - /** - * Divides an element by an ND structure of it. - * - * @receiver the dividend. - * @param arg the divisor. - * @return the quotient. - */ - public operator fun T.div(arg: N): N = map(arg) { divide(it, this@div) } - - @ThreadLocal - public companion object { - private val realNDFieldCache: MutableMap = hashMapOf() - - /** - * Create a nd-field for [Double] values or pull it from cache if it was created previously. - */ - public fun real(vararg shape: Int): RealNDField = realNDFieldCache.getOrPut(shape) { RealNDField(shape) } - - /** - * Create an ND field with boxing generic buffer. - */ - public fun > boxing( - field: F, - vararg shape: Int, - bufferFactory: BufferFactory = Buffer.Companion::boxing - ): BoxingNDField = BoxingNDField(shape, field, bufferFactory) - - /** - * Create a most suitable implementation for nd-field using reified class. - */ - @Suppress("UNCHECKED_CAST") - public inline fun > auto(field: F, vararg shape: Int): BufferedNDField = - when { - T::class == Double::class -> real(*shape) as BufferedNDField - T::class == Complex::class -> complex(*shape) as BufferedNDField - else -> BoxingNDField(shape, field, Buffer.Companion::auto) - } - } -} diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/NDElement.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/NDElement.kt deleted file mode 100644 index f2f565064..000000000 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/NDElement.kt +++ /dev/null @@ -1,134 +0,0 @@ -package kscience.kmath.structures - -import kscience.kmath.operations.Field -import kscience.kmath.operations.RealField -import kscience.kmath.operations.Ring -import kscience.kmath.operations.Space - -/** - * The root for all [NDStructure] based algebra elements. Does not implement algebra element root because of problems with recursive self-types - * @param T the type of the element of the structure - * @param C the type of the context for the element - * @param N the type of the underlying [NDStructure] - */ -public interface NDElement> : NDStructure { - public val context: NDAlgebra - - public fun unwrap(): N - - public fun N.wrap(): NDElement - - public companion object { - /** - * Create a optimized NDArray of doubles - */ - public fun real(shape: IntArray, initializer: RealField.(IntArray) -> Double = { 0.0 }): RealNDElement = - NDField.real(*shape).produce(initializer) - - public inline fun real1D(dim: Int, crossinline initializer: (Int) -> Double = { _ -> 0.0 }): RealNDElement = - real(intArrayOf(dim)) { initializer(it[0]) } - - public inline fun real2D( - dim1: Int, - dim2: Int, - crossinline initializer: (Int, Int) -> Double = { _, _ -> 0.0 } - ): RealNDElement = real(intArrayOf(dim1, dim2)) { initializer(it[0], it[1]) } - - public inline fun real3D( - dim1: Int, - dim2: Int, - dim3: Int, - crossinline initializer: (Int, Int, Int) -> Double = { _, _, _ -> 0.0 } - ): RealNDElement = real(intArrayOf(dim1, dim2, dim3)) { initializer(it[0], it[1], it[2]) } - - - /** - * Simple boxing NDArray - */ - public fun > boxing( - shape: IntArray, - field: F, - initializer: F.(IntArray) -> T - ): BufferedNDElement { - val ndField = BoxingNDField(shape, field, Buffer.Companion::boxing) - return ndField.produce(initializer) - } - - public inline fun > auto( - shape: IntArray, - field: F, - noinline initializer: F.(IntArray) -> T - ): BufferedNDFieldElement { - val ndField = NDField.auto(field, *shape) - return BufferedNDFieldElement(ndField, ndField.produce(initializer).buffer) - } - } -} - -public fun > NDElement.mapIndexed(transform: C.(index: IntArray, T) -> T): NDElement = - context.mapIndexed(unwrap(), transform).wrap() - -public fun > NDElement.map(transform: C.(T) -> T): NDElement = - context.map(unwrap(), transform).wrap() - -/** - * Element by element application of any operation on elements to the whole [NDElement] - */ -public operator fun > Function1.invoke(ndElement: NDElement): NDElement = - ndElement.map { value -> this@invoke(value) } - -/* plus and minus */ - -/** - * Summation operation for [NDElement] and single element - */ -public operator fun , N : NDStructure> NDElement.plus(arg: T): NDElement = - map { value -> arg + value } - -/** - * Subtraction operation between [NDElement] and single element - */ -public operator fun , N : NDStructure> NDElement.minus(arg: T): NDElement = - map { value -> arg - value } - -/* prod and div */ - -/** - * Product operation for [NDElement] and single element - */ -public operator fun , N : NDStructure> NDElement.times(arg: T): NDElement = - map { value -> arg * value } - -/** - * Division operation between [NDElement] and single element - */ -public operator fun , N : NDStructure> NDElement.div(arg: T): NDElement = - map { value -> arg / value } - -// /** -// * Reverse sum operation -// */ -// operator fun T.plus(arg: NDStructure): NDElement = produce { index -> -// field.run { this@plus + arg[index] } -// } -// -// /** -// * Reverse minus operation -// */ -// operator fun T.minus(arg: NDStructure): NDElement = produce { index -> -// field.run { this@minus - arg[index] } -// } -// -// /** -// * Reverse product operation -// */ -// operator fun T.times(arg: NDStructure): NDElement = produce { index -> -// field.run { this@times * arg[index] } -// } -// -// /** -// * Reverse division operation -// */ -// operator fun T.div(arg: NDStructure): NDElement = produce { index -> -// field.run { this@div / arg[index] } -// } diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/RealNDField.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/RealNDField.kt deleted file mode 100644 index 60e6de440..000000000 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/RealNDField.kt +++ /dev/null @@ -1,140 +0,0 @@ -package kscience.kmath.structures - -import kscience.kmath.misc.UnstableKMathAPI -import kscience.kmath.operations.FieldElement -import kscience.kmath.operations.RealField -import kscience.kmath.operations.RingWithNumbers - -public typealias RealNDElement = BufferedNDFieldElement - -@OptIn(UnstableKMathAPI::class) -public class RealNDField(override val shape: IntArray) : - BufferedNDField, - ExtendedNDField>, - RingWithNumbers> { - - override val strides: Strides = DefaultStrides(shape) - - override val elementContext: RealField get() = RealField - override val zero: RealNDElement by lazy { produce { zero } } - override val one: RealNDElement by lazy { produce { one } } - - override fun number(value: Number): NDBuffer { - val d = value.toDouble() - return produce { d } - } - - @Suppress("OVERRIDE_BY_INLINE") - override inline fun map( - arg: NDBuffer, - transform: RealField.(Double) -> Double, - ): RealNDElement { - check(arg) - val array = RealBuffer(arg.strides.linearSize) { offset -> RealField.transform(arg.buffer[offset]) } - return BufferedNDFieldElement(this, array) - } - - @Suppress("OVERRIDE_BY_INLINE") - override inline fun produce(initializer: RealField.(IntArray) -> Double): RealNDElement { - val array = RealBuffer(strides.linearSize) { offset -> elementContext.initializer(strides.index(offset)) } - return BufferedNDFieldElement(this, array) - } - - @Suppress("OVERRIDE_BY_INLINE") - override inline fun mapIndexed( - arg: NDBuffer, - transform: RealField.(index: IntArray, Double) -> Double, - ): RealNDElement { - check(arg) - return BufferedNDFieldElement( - this, - RealBuffer(arg.strides.linearSize) { offset -> - elementContext.transform( - arg.strides.index(offset), - arg.buffer[offset] - ) - }) - } - - @Suppress("OVERRIDE_BY_INLINE") - override inline fun combine( - a: NDBuffer, - b: NDBuffer, - transform: RealField.(Double, Double) -> Double, - ): RealNDElement { - check(a, b) - val buffer = RealBuffer(strides.linearSize) { offset -> - elementContext.transform(a.buffer[offset], b.buffer[offset]) - } - return BufferedNDFieldElement(this, buffer) - } - - override fun NDBuffer.toElement(): FieldElement, *, out BufferedNDField> = - BufferedNDFieldElement(this@RealNDField, buffer) - - override fun power(arg: NDBuffer, pow: Number): RealNDElement = map(arg) { power(it, pow) } - - override fun exp(arg: NDBuffer): RealNDElement = map(arg) { exp(it) } - - override fun ln(arg: NDBuffer): RealNDElement = map(arg) { ln(it) } - - override fun sin(arg: NDBuffer): RealNDElement = map(arg) { sin(it) } - override fun cos(arg: NDBuffer): RealNDElement = map(arg) { cos(it) } - override fun tan(arg: NDBuffer): RealNDElement = map(arg) { tan(it) } - override fun asin(arg: NDBuffer): RealNDElement = map(arg) { asin(it) } - override fun acos(arg: NDBuffer): RealNDElement = map(arg) { acos(it) } - override fun atan(arg: NDBuffer): RealNDElement = map(arg) { atan(it) } - - override fun sinh(arg: NDBuffer): RealNDElement = map(arg) { sinh(it) } - override fun cosh(arg: NDBuffer): RealNDElement = map(arg) { cosh(it) } - override fun tanh(arg: NDBuffer): RealNDElement = map(arg) { tanh(it) } - override fun asinh(arg: NDBuffer): RealNDElement = map(arg) { asinh(it) } - override fun acosh(arg: NDBuffer): RealNDElement = map(arg) { acosh(it) } - override fun atanh(arg: NDBuffer): RealNDElement = map(arg) { atanh(it) } -} - - -/** - * Fast element production using function inlining - */ -public inline fun BufferedNDField.produceInline(crossinline initializer: RealField.(Int) -> Double): RealNDElement { - val array = DoubleArray(strides.linearSize) { offset -> RealField.initializer(offset) } - return BufferedNDFieldElement(this, RealBuffer(array)) -} - -/** - * Map one [RealNDElement] using function with indices. - */ -public inline fun RealNDElement.mapIndexed(crossinline transform: RealField.(index: IntArray, Double) -> Double): RealNDElement = - context.produceInline { offset -> transform(strides.index(offset), buffer[offset]) } - -/** - * Map one [RealNDElement] using function without indices. - */ -public inline fun RealNDElement.map(crossinline transform: RealField.(Double) -> Double): RealNDElement { - val array = DoubleArray(strides.linearSize) { offset -> RealField.transform(buffer[offset]) } - return BufferedNDFieldElement(context, RealBuffer(array)) -} - -/** - * Element by element application of any operation on elements to the whole array. Just like in numpy. - */ -public operator fun Function1.invoke(ndElement: RealNDElement): RealNDElement = - ndElement.map { this@invoke(it) } - -/* plus and minus */ - -/** - * Summation operation for [BufferedNDElement] and single element - */ -public operator fun RealNDElement.plus(arg: Double): RealNDElement = map { it + arg } - -/** - * Subtraction operation between [BufferedNDElement] and single element - */ -public operator fun RealNDElement.minus(arg: Double): RealNDElement = map { it - arg } - -/** - * Produce a context for n-dimensional operations inside this real field - */ -public inline fun RealField.nd(vararg shape: Int, action: RealNDField.() -> R): R = NDField.real(*shape).run(action) diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/ShortNDRing.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/ShortNDRing.kt deleted file mode 100644 index 3b506a26a..000000000 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/ShortNDRing.kt +++ /dev/null @@ -1,93 +0,0 @@ -package kscience.kmath.structures - -import kscience.kmath.operations.RingElement -import kscience.kmath.operations.ShortRing - -public typealias ShortNDElement = BufferedNDRingElement - -public class ShortNDRing(override val shape: IntArray) : - BufferedNDRing { - - override val strides: Strides = DefaultStrides(shape) - override val elementContext: ShortRing get() = ShortRing - override val zero: ShortNDElement by lazy { produce { zero } } - override val one: ShortNDElement by lazy { produce { one } } - - public inline fun buildBuffer(size: Int, crossinline initializer: (Int) -> Short): Buffer = - ShortBuffer(ShortArray(size) { initializer(it) }) - - /** - * Inline transform an NDStructure to - */ - override fun map( - arg: NDBuffer, - transform: ShortRing.(Short) -> Short - ): ShortNDElement { - check(arg) - val array = buildBuffer(arg.strides.linearSize) { offset -> ShortRing.transform(arg.buffer[offset]) } - return BufferedNDRingElement(this, array) - } - - override fun produce(initializer: ShortRing.(IntArray) -> Short): ShortNDElement { - val array = buildBuffer(strides.linearSize) { offset -> elementContext.initializer(strides.index(offset)) } - return BufferedNDRingElement(this, array) - } - - override fun mapIndexed( - arg: NDBuffer, - transform: ShortRing.(index: IntArray, Short) -> Short - ): ShortNDElement { - check(arg) - - return BufferedNDRingElement( - this, - buildBuffer(arg.strides.linearSize) { offset -> - elementContext.transform( - arg.strides.index(offset), - arg.buffer[offset] - ) - }) - } - - override fun combine( - a: NDBuffer, - b: NDBuffer, - transform: ShortRing.(Short, Short) -> Short - ): ShortNDElement { - check(a, b) - return BufferedNDRingElement( - this, - buildBuffer(strides.linearSize) { offset -> elementContext.transform(a.buffer[offset], b.buffer[offset]) }) - } - - override fun NDBuffer.toElement(): RingElement, *, out BufferedNDRing> = - BufferedNDRingElement(this@ShortNDRing, buffer) -} - - -/** - * Fast element production using function inlining. - */ -public inline fun BufferedNDRing.produceInline(crossinline initializer: ShortRing.(Int) -> Short): ShortNDElement = - BufferedNDRingElement(this, ShortBuffer(ShortArray(strides.linearSize) { offset -> ShortRing.initializer(offset) })) - -/** - * Element by element application of any operation on elements to the whole array. - */ -public operator fun Function1.invoke(ndElement: ShortNDElement): ShortNDElement = - ndElement.context.produceInline { i -> invoke(ndElement.buffer[i]) } - - -/* plus and minus */ - -/** - * Summation operation for [ShortNDElement] and single element. - */ -public operator fun ShortNDElement.plus(arg: Short): ShortNDElement = - context.produceInline { i -> (buffer[i] + arg).toShort() } - -/** - * Subtraction operation between [ShortNDElement] and single element. - */ -public operator fun ShortNDElement.minus(arg: Short): ShortNDElement = - context.produceInline { i -> (buffer[i] - arg).toShort() } diff --git a/kmath-core/src/commonTest/kotlin/kscience/kmath/linear/MatrixTest.kt b/kmath-core/src/commonTest/kotlin/kscience/kmath/linear/MatrixTest.kt index d7755dcb5..a0ac92172 100644 --- a/kmath-core/src/commonTest/kotlin/kscience/kmath/linear/MatrixTest.kt +++ b/kmath-core/src/commonTest/kotlin/kscience/kmath/linear/MatrixTest.kt @@ -1,9 +1,8 @@ package kscience.kmath.linear +import kscience.kmath.nd.NDStructure +import kscience.kmath.nd.as2D import kscience.kmath.operations.invoke -import kscience.kmath.structures.Matrix -import kscience.kmath.structures.NDStructure -import kscience.kmath.structures.as2D import kotlin.test.Test import kotlin.test.assertEquals diff --git a/kmath-core/src/commonTest/kotlin/kscience/kmath/linear/RealLUSolverTest.kt b/kmath-core/src/commonTest/kotlin/kscience/kmath/linear/RealLUSolverTest.kt index 28dfe46ec..522e711b6 100644 --- a/kmath-core/src/commonTest/kotlin/kscience/kmath/linear/RealLUSolverTest.kt +++ b/kmath-core/src/commonTest/kotlin/kscience/kmath/linear/RealLUSolverTest.kt @@ -1,6 +1,5 @@ package kscience.kmath.linear -import kscience.kmath.structures.Matrix import kotlin.test.Test import kotlin.test.assertEquals diff --git a/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NDFieldTest.kt b/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NDFieldTest.kt index 1129a8a36..0f5f99b49 100644 --- a/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NDFieldTest.kt +++ b/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NDFieldTest.kt @@ -1,5 +1,6 @@ package kscience.kmath.structures +import kscience.kmath.nd.NDField import kscience.kmath.operations.internal.FieldVerifier import kotlin.test.Test import kotlin.test.assertEquals diff --git a/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NumberNDFieldTest.kt b/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NumberNDFieldTest.kt index 22a0d3629..baf3656fc 100644 --- a/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NumberNDFieldTest.kt +++ b/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NumberNDFieldTest.kt @@ -1,7 +1,8 @@ package kscience.kmath.structures +import kscience.kmath.nd.NDField +import kscience.kmath.nd.NDStructure import kscience.kmath.operations.Norm -import kscience.kmath.operations.invoke import kscience.kmath.structures.NDElement.Companion.real2D import kotlin.math.abs import kotlin.math.pow diff --git a/kmath-coroutines/src/jvmMain/kotlin/kscience/kmath/structures/LazyNDStructure.kt b/kmath-coroutines/src/jvmMain/kotlin/kscience/kmath/structures/LazyNDStructure.kt index 7aa746797..cac692eb2 100644 --- a/kmath-coroutines/src/jvmMain/kotlin/kscience/kmath/structures/LazyNDStructure.kt +++ b/kmath-coroutines/src/jvmMain/kotlin/kscience/kmath/structures/LazyNDStructure.kt @@ -2,6 +2,8 @@ package kscience.kmath.structures import kotlinx.coroutines.* import kscience.kmath.coroutines.Math +import kscience.kmath.nd.DefaultStrides +import kscience.kmath.nd.NDStructure public class LazyNDStructure( public val scope: CoroutineScope, @@ -19,7 +21,7 @@ public class LazyNDStructure( public override fun elements(): Sequence> { val strides = DefaultStrides(shape) - val res = runBlocking { strides.indices().toList().map { index -> index to await(index) } } + val res = runBlocking { kscience.kmath.nd.map { index -> index to await(index) } } return res.asSequence() } diff --git a/kmath-dimensions/src/commonMain/kotlin/kscience/kmath/dimensions/Wrappers.kt b/kmath-dimensions/src/commonMain/kotlin/kscience/kmath/dimensions/Wrappers.kt index 0244eae7f..52443da0e 100644 --- a/kmath-dimensions/src/commonMain/kotlin/kscience/kmath/dimensions/Wrappers.kt +++ b/kmath-dimensions/src/commonMain/kotlin/kscience/kmath/dimensions/Wrappers.kt @@ -1,9 +1,8 @@ package kscience.kmath.dimensions import kscience.kmath.linear.* +import kscience.kmath.nd.Structure2D import kscience.kmath.operations.invoke -import kscience.kmath.structures.Matrix -import kscience.kmath.structures.Structure2D /** * A matrix with compile-time controlled dimension diff --git a/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrix.kt b/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrix.kt index 82a5399fd..13e5f009b 100644 --- a/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrix.kt +++ b/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrix.kt @@ -2,8 +2,7 @@ package kscience.kmath.ejml import kscience.kmath.linear.* import kscience.kmath.misc.UnstableKMathAPI -import kscience.kmath.structures.Matrix -import kscience.kmath.structures.NDStructure +import kscience.kmath.nd.NDStructure import kscience.kmath.structures.RealBuffer import org.ejml.dense.row.factory.DecompositionFactory_DDRM import org.ejml.simple.SimpleMatrix diff --git a/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrixContext.kt b/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrixContext.kt index 8184d0110..ebd4dd586 100644 --- a/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrixContext.kt +++ b/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrixContext.kt @@ -3,10 +3,9 @@ package kscience.kmath.ejml import kscience.kmath.linear.InverseMatrixFeature import kscience.kmath.linear.MatrixContext import kscience.kmath.linear.Point -import kscience.kmath.linear.origin import kscience.kmath.misc.UnstableKMathAPI -import kscience.kmath.structures.Matrix -import kscience.kmath.structures.getFeature +import kscience.kmath.nd.Matrix +import kscience.kmath.nd.getFeature import org.ejml.simple.SimpleMatrix /** diff --git a/kmath-ejml/src/test/kotlin/kscience/kmath/ejml/EjmlMatrixTest.kt b/kmath-ejml/src/test/kotlin/kscience/kmath/ejml/EjmlMatrixTest.kt index 455b52d9d..6af70b6f5 100644 --- a/kmath-ejml/src/test/kotlin/kscience/kmath/ejml/EjmlMatrixTest.kt +++ b/kmath-ejml/src/test/kotlin/kscience/kmath/ejml/EjmlMatrixTest.kt @@ -5,7 +5,7 @@ import kscience.kmath.linear.LupDecompositionFeature import kscience.kmath.linear.MatrixFeature import kscience.kmath.linear.plus import kscience.kmath.misc.UnstableKMathAPI -import kscience.kmath.structures.getFeature +import kscience.kmath.nd.getFeature import org.ejml.dense.row.factory.DecompositionFactory_DDRM import org.ejml.simple.SimpleMatrix import kotlin.random.Random diff --git a/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt b/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt index 274030aff..defaba126 100644 --- a/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt +++ b/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt @@ -1,15 +1,11 @@ package kscience.kmath.real import kscience.kmath.linear.MatrixContext -import kscience.kmath.linear.VirtualMatrix -import kscience.kmath.linear.inverseWithLUP import kscience.kmath.linear.real import kscience.kmath.misc.UnstableKMathAPI +import kscience.kmath.nd.Matrix import kscience.kmath.structures.Buffer -import kscience.kmath.structures.Matrix import kscience.kmath.structures.RealBuffer -import kscience.kmath.structures.asIterable -import kotlin.math.pow /* * Functions for convenient "numpy-like" operations with Double matrices. diff --git a/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/realND.kt b/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/realND.kt new file mode 100644 index 000000000..f8757b132 --- /dev/null +++ b/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/realND.kt @@ -0,0 +1,31 @@ +package kscience.kmath.real + +import kscience.kmath.nd.NDBuffer +import kscience.kmath.operations.RealField +import kscience.kmath.structures.RealBuffer + +/** + * Map one [NDBuffer] using function without indices. + */ +public inline fun NDBuffer.mapInline(crossinline transform: RealField.(Double) -> Double): NDBuffer { + val array = DoubleArray(strides.linearSize) { offset -> RealField.transform(buffer[offset]) } + return NDBuffer(strides, RealBuffer(array)) +} + +/** + * Element by element application of any operation on elements to the whole array. Just like in numpy. + */ +public operator fun Function1.invoke(ndElement: NDBuffer): NDBuffer = + ndElement.mapInline { this@invoke(it) } + +/* plus and minus */ + +/** + * Summation operation for [NDBuffer] and single element + */ +public operator fun NDBuffer.plus(arg: Double): NDBuffer = mapInline { it + arg } + +/** + * Subtraction operation between [NDBuffer] and single element + */ +public operator fun NDBuffer.minus(arg: Double): NDBuffer = mapInline { it - arg } \ No newline at end of file diff --git a/kmath-for-real/src/commonTest/kotlin/kaceince/kmath/real/RealMatrixTest.kt b/kmath-for-real/src/commonTest/kotlin/kaceince/kmath/real/RealMatrixTest.kt index a89f99b3c..68aa8cf52 100644 --- a/kmath-for-real/src/commonTest/kotlin/kaceince/kmath/real/RealMatrixTest.kt +++ b/kmath-for-real/src/commonTest/kotlin/kaceince/kmath/real/RealMatrixTest.kt @@ -1,9 +1,7 @@ package kaceince.kmath.real -import kscience.kmath.linear.build +import kscience.kmath.nd.Matrix import kscience.kmath.real.* -import kscience.kmath.structures.Matrix -import kscience.kmath.structures.contentEquals import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue diff --git a/kmath-functions/src/commonMain/kotlin/kscience/kmath/interpolation/XYPointSet.kt b/kmath-functions/src/commonMain/kotlin/kscience/kmath/interpolation/XYPointSet.kt index 2abb7742c..bdece28e7 100644 --- a/kmath-functions/src/commonMain/kotlin/kscience/kmath/interpolation/XYPointSet.kt +++ b/kmath-functions/src/commonMain/kotlin/kscience/kmath/interpolation/XYPointSet.kt @@ -1,7 +1,7 @@ package kscience.kmath.interpolation +import kscience.kmath.nd.Structure2D import kscience.kmath.structures.Buffer -import kscience.kmath.structures.Structure2D public interface XYPointSet { public val size: Int diff --git a/kmath-histograms/src/commonMain/kotlin/kscience/kmath/histogram/RealHistogram.kt b/kmath-histograms/src/commonMain/kotlin/kscience/kmath/histogram/RealHistogram.kt index f95264ee1..42dbaabac 100644 --- a/kmath-histograms/src/commonMain/kotlin/kscience/kmath/histogram/RealHistogram.kt +++ b/kmath-histograms/src/commonMain/kotlin/kscience/kmath/histogram/RealHistogram.kt @@ -1,6 +1,8 @@ package kscience.kmath.histogram import kscience.kmath.linear.Point +import kscience.kmath.nd.DefaultStrides +import kscience.kmath.nd.NDStructure import kscience.kmath.operations.SpaceOperations import kscience.kmath.operations.invoke import kscience.kmath.structures.* @@ -15,7 +17,7 @@ public data class BinDef>( require(vector.size == center.size) { "Dimension mismatch for input vector. Expected ${center.size}, but found ${vector.size}" } val upper = space { center + sizes / 2.0 } val lower = space { center - sizes / 2.0 } - return vector.asSequence().mapIndexed { i, value -> value in lower[i]..upper[i] }.all { it } + return kscience.kmath.nd.mapIndexed { i, value -> value in lower[i]..upper[i] }.all { it } } } @@ -68,7 +70,7 @@ public class RealHistogram( public fun getValue(point: Buffer): Long = getValue(getIndex(point)) private fun getDef(index: IntArray): BinDef { - val center = index.mapIndexed { axis, i -> + val center = kscience.kmath.nd.mapIndexed { axis, i -> when (i) { 0 -> Double.NEGATIVE_INFINITY strides.shape[axis] - 1 -> Double.POSITIVE_INFINITY @@ -98,7 +100,7 @@ public class RealHistogram( } public override operator fun iterator(): Iterator> = - weights.elements().map { (index, value) -> MultivariateBin(getDef(index), value.sum()) } + kscience.kmath.nd.map { (index, value) -> MultivariateBin(getDef(index), value.sum()) } .iterator() /** diff --git a/kmath-nd4j/src/main/kotlin/kscience.kmath.nd4j/Nd4jArrayAlgebra.kt b/kmath-nd4j/src/main/kotlin/kscience.kmath.nd4j/Nd4jArrayAlgebra.kt index db2a44861..b958d1ccf 100644 --- a/kmath-nd4j/src/main/kotlin/kscience.kmath.nd4j/Nd4jArrayAlgebra.kt +++ b/kmath-nd4j/src/main/kotlin/kscience.kmath.nd4j/Nd4jArrayAlgebra.kt @@ -1,11 +1,9 @@ package kscience.kmath.nd4j import kscience.kmath.misc.UnstableKMathAPI +import kscience.kmath.nd.* import kscience.kmath.operations.* -import kscience.kmath.structures.NDAlgebra -import kscience.kmath.structures.NDField -import kscience.kmath.structures.NDRing -import kscience.kmath.structures.NDSpace +import kscience.kmath.structures.* import org.nd4j.linalg.api.ndarray.INDArray import org.nd4j.linalg.factory.Nd4j @@ -15,11 +13,22 @@ import org.nd4j.linalg.factory.Nd4j * @param T the type of ND-structure element. * @param C the type of the element context. */ -public interface Nd4jArrayAlgebra : NDAlgebra> { +public interface Nd4jArrayAlgebra : NDAlgebra { /** * Wraps [INDArray] to [N]. */ public fun INDArray.wrap(): Nd4jArrayStructure + public val NDStructure.ndArray: INDArray + get() = when { + !shape.contentEquals(this@Nd4jArrayAlgebra.shape) -> throw ShapeMismatchException( + this@Nd4jArrayAlgebra.shape, + shape + ) + this is Nd4jArrayStructure -> ndArray //TODO check strides + else -> { + TODO() + } + } public override fun produce(initializer: C.(IntArray) -> T): Nd4jArrayStructure { val struct = Nd4j.create(*shape)!!.wrap() @@ -27,29 +36,26 @@ public interface Nd4jArrayAlgebra : NDAlgebra> return struct } - public override fun map(arg: Nd4jArrayStructure, transform: C.(T) -> T): Nd4jArrayStructure { - check(arg) + public override fun map(arg: NDStructure, transform: C.(T) -> T): Nd4jArrayStructure { val newStruct = arg.ndArray.dup().wrap() newStruct.elements().forEach { (idx, value) -> newStruct[idx] = elementContext.transform(value) } return newStruct } public override fun mapIndexed( - arg: Nd4jArrayStructure, + arg: NDStructure, transform: C.(index: IntArray, T) -> T, ): Nd4jArrayStructure { - check(arg) val new = Nd4j.create(*shape).wrap() new.indicesIterator().forEach { idx -> new[idx] = elementContext.transform(idx, arg[idx]) } return new } public override fun combine( - a: Nd4jArrayStructure, - b: Nd4jArrayStructure, + a: NDStructure, + b: NDStructure, transform: C.(T, T) -> T, ): Nd4jArrayStructure { - check(a, b) val new = Nd4j.create(*shape).wrap() new.indicesIterator().forEach { idx -> new[idx] = elementContext.transform(a[idx], b[idx]) } return new @@ -62,38 +68,32 @@ public interface Nd4jArrayAlgebra : NDAlgebra> * @param T the type of the element contained in ND structure. * @param S the type of space of structure elements. */ -public interface Nd4jArraySpace> : NDSpace>, Nd4jArrayAlgebra { +public interface Nd4jArraySpace> : NDSpace, Nd4jArrayAlgebra { public override val zero: Nd4jArrayStructure get() = Nd4j.zeros(*shape).wrap() - public override fun add(a: Nd4jArrayStructure, b: Nd4jArrayStructure): Nd4jArrayStructure { - check(a, b) + public override fun add(a: NDStructure, b: NDStructure): Nd4jArrayStructure { return a.ndArray.add(b.ndArray).wrap() } - public override operator fun Nd4jArrayStructure.minus(b: Nd4jArrayStructure): Nd4jArrayStructure { - check(this, b) + public override operator fun NDStructure.minus(b: NDStructure): Nd4jArrayStructure { return ndArray.sub(b.ndArray).wrap() } - public override operator fun Nd4jArrayStructure.unaryMinus(): Nd4jArrayStructure { - check(this) + public override operator fun NDStructure.unaryMinus(): Nd4jArrayStructure { return ndArray.neg().wrap() } - public override fun multiply(a: Nd4jArrayStructure, k: Number): Nd4jArrayStructure { - check(a) + public override fun multiply(a: NDStructure, k: Number): Nd4jArrayStructure { return a.ndArray.mul(k).wrap() } - public override operator fun Nd4jArrayStructure.div(k: Number): Nd4jArrayStructure { - check(this) + public override operator fun NDStructure.div(k: Number): Nd4jArrayStructure { return ndArray.div(k).wrap() } - public override operator fun Nd4jArrayStructure.times(k: Number): Nd4jArrayStructure { - check(this) + public override operator fun NDStructure.times(k: Number): Nd4jArrayStructure { return ndArray.mul(k).wrap() } } @@ -105,13 +105,12 @@ public interface Nd4jArraySpace> : NDSpace> : NDRing>, Nd4jArraySpace { +public interface Nd4jArrayRing> : NDRing, Nd4jArraySpace { public override val one: Nd4jArrayStructure get() = Nd4j.ones(*shape).wrap() - public override fun multiply(a: Nd4jArrayStructure, b: Nd4jArrayStructure): Nd4jArrayStructure { - check(a, b) + public override fun multiply(a: NDStructure, b: NDStructure): Nd4jArrayStructure { return a.ndArray.mul(b.ndArray).wrap() } // @@ -168,17 +167,12 @@ public interface Nd4jArrayRing> : NDRing> : NDField>, Nd4jArrayRing { +public interface Nd4jArrayField> : NDField, Nd4jArrayRing { - public override fun divide(a: Nd4jArrayStructure, b: Nd4jArrayStructure): Nd4jArrayStructure { - check(a, b) - return a.ndArray.div(b.ndArray).wrap() - } + public override fun divide(a: NDStructure, b: NDStructure): Nd4jArrayStructure = + a.ndArray.div(b.ndArray).wrap() - public override operator fun Number.div(b: Nd4jArrayStructure): Nd4jArrayStructure { - check(b) - return b.ndArray.rdiv(this).wrap() - } + public override operator fun Number.div(b: NDStructure): Nd4jArrayStructure = b.ndArray.rdiv(this).wrap() public companion object { @@ -219,35 +213,29 @@ public class RealNd4jArrayField(public override val shape: IntArray) : Nd4jArray public override val elementContext: RealField get() = RealField - public override fun INDArray.wrap(): Nd4jArrayStructure = check(asRealStructure()) + public override fun INDArray.wrap(): Nd4jArrayStructure = checkShape(asRealStructure()) - public override operator fun Nd4jArrayStructure.div(arg: Double): Nd4jArrayStructure { - check(this) + public override operator fun NDStructure.div(arg: Double): Nd4jArrayStructure { return ndArray.div(arg).wrap() } - public override operator fun Nd4jArrayStructure.plus(arg: Double): Nd4jArrayStructure { - check(this) + public override operator fun NDStructure.plus(arg: Double): Nd4jArrayStructure { return ndArray.add(arg).wrap() } - public override operator fun Nd4jArrayStructure.minus(arg: Double): Nd4jArrayStructure { - check(this) + public override operator fun NDStructure.minus(arg: Double): Nd4jArrayStructure { return ndArray.sub(arg).wrap() } - public override operator fun Nd4jArrayStructure.times(arg: Double): Nd4jArrayStructure { - check(this) + public override operator fun NDStructure.times(arg: Double): Nd4jArrayStructure { return ndArray.mul(arg).wrap() } - public override operator fun Double.div(arg: Nd4jArrayStructure): Nd4jArrayStructure { - check(arg) + public override operator fun Double.div(arg: NDStructure): Nd4jArrayStructure { return arg.ndArray.rdiv(this).wrap() } - public override operator fun Double.minus(arg: Nd4jArrayStructure): Nd4jArrayStructure { - check(arg) + public override operator fun Double.minus(arg: NDStructure): Nd4jArrayStructure { return arg.ndArray.rsub(this).wrap() } } @@ -259,35 +247,29 @@ public class FloatNd4jArrayField(public override val shape: IntArray) : Nd4jArra public override val elementContext: FloatField get() = FloatField - public override fun INDArray.wrap(): Nd4jArrayStructure = check(asFloatStructure()) + public override fun INDArray.wrap(): Nd4jArrayStructure = checkShape(asFloatStructure()) - public override operator fun Nd4jArrayStructure.div(arg: Float): Nd4jArrayStructure { - check(this) + public override operator fun NDStructure.div(arg: Float): Nd4jArrayStructure { return ndArray.div(arg).wrap() } - public override operator fun Nd4jArrayStructure.plus(arg: Float): Nd4jArrayStructure { - check(this) + public override operator fun NDStructure.plus(arg: Float): Nd4jArrayStructure { return ndArray.add(arg).wrap() } - public override operator fun Nd4jArrayStructure.minus(arg: Float): Nd4jArrayStructure { - check(this) + public override operator fun NDStructure.minus(arg: Float): Nd4jArrayStructure { return ndArray.sub(arg).wrap() } - public override operator fun Nd4jArrayStructure.times(arg: Float): Nd4jArrayStructure { - check(this) + public override operator fun NDStructure.times(arg: Float): Nd4jArrayStructure { return ndArray.mul(arg).wrap() } - public override operator fun Float.div(arg: Nd4jArrayStructure): Nd4jArrayStructure { - check(arg) + public override operator fun Float.div(arg: NDStructure): Nd4jArrayStructure { return arg.ndArray.rdiv(this).wrap() } - public override operator fun Float.minus(arg: Nd4jArrayStructure): Nd4jArrayStructure { - check(arg) + public override operator fun Float.minus(arg: NDStructure): Nd4jArrayStructure { return arg.ndArray.rsub(this).wrap() } } @@ -301,23 +283,19 @@ public class IntNd4jArrayRing(public override val shape: IntArray) : Nd4jArrayRi public override fun INDArray.wrap(): Nd4jArrayStructure = check(asIntStructure()) - public override operator fun Nd4jArrayStructure.plus(arg: Int): Nd4jArrayStructure { - check(this) + public override operator fun NDStructure.plus(arg: Int): Nd4jArrayStructure { return ndArray.add(arg).wrap() } - public override operator fun Nd4jArrayStructure.minus(arg: Int): Nd4jArrayStructure { - check(this) + public override operator fun NDStructure.minus(arg: Int): Nd4jArrayStructure { return ndArray.sub(arg).wrap() } - public override operator fun Nd4jArrayStructure.times(arg: Int): Nd4jArrayStructure { - check(this) + public override operator fun NDStructure.times(arg: Int): Nd4jArrayStructure { return ndArray.mul(arg).wrap() } - public override operator fun Int.minus(arg: Nd4jArrayStructure): Nd4jArrayStructure { - check(arg) + public override operator fun Int.minus(arg: NDStructure): Nd4jArrayStructure { return arg.ndArray.rsub(this).wrap() } } @@ -331,23 +309,19 @@ public class LongNd4jArrayRing(public override val shape: IntArray) : Nd4jArrayR public override fun INDArray.wrap(): Nd4jArrayStructure = check(asLongStructure()) - public override operator fun Nd4jArrayStructure.plus(arg: Long): Nd4jArrayStructure { - check(this) + public override operator fun NDStructure.plus(arg: Long): Nd4jArrayStructure { return ndArray.add(arg).wrap() } - public override operator fun Nd4jArrayStructure.minus(arg: Long): Nd4jArrayStructure { - check(this) + public override operator fun NDStructure.minus(arg: Long): Nd4jArrayStructure { return ndArray.sub(arg).wrap() } - public override operator fun Nd4jArrayStructure.times(arg: Long): Nd4jArrayStructure { - check(this) + public override operator fun NDStructure.times(arg: Long): Nd4jArrayStructure { return ndArray.mul(arg).wrap() } - public override operator fun Long.minus(arg: Nd4jArrayStructure): Nd4jArrayStructure { - check(arg) + public override operator fun Long.minus(arg: NDStructure): Nd4jArrayStructure { return arg.ndArray.rsub(this).wrap() } } diff --git a/kmath-nd4j/src/main/kotlin/kscience.kmath.nd4j/Nd4jArrayStructure.kt b/kmath-nd4j/src/main/kotlin/kscience.kmath.nd4j/Nd4jArrayStructure.kt index d47a293c3..2a6b56602 100644 --- a/kmath-nd4j/src/main/kotlin/kscience.kmath.nd4j/Nd4jArrayStructure.kt +++ b/kmath-nd4j/src/main/kotlin/kscience.kmath.nd4j/Nd4jArrayStructure.kt @@ -1,7 +1,7 @@ package kscience.kmath.nd4j -import kscience.kmath.structures.MutableNDStructure -import kscience.kmath.structures.NDStructure +import kscience.kmath.nd.MutableNDStructure +import kscience.kmath.nd.NDStructure import org.nd4j.linalg.api.ndarray.INDArray /** diff --git a/kmath-nd4j/src/test/kotlin/kscience/kmath/nd4j/Nd4jArrayStructureTest.kt b/kmath-nd4j/src/test/kotlin/kscience/kmath/nd4j/Nd4jArrayStructureTest.kt index 7e46211c1..2f1606061 100644 --- a/kmath-nd4j/src/test/kotlin/kscience/kmath/nd4j/Nd4jArrayStructureTest.kt +++ b/kmath-nd4j/src/test/kotlin/kscience/kmath/nd4j/Nd4jArrayStructureTest.kt @@ -1,6 +1,6 @@ package kscience.kmath.nd4j -import kscience.kmath.structures.get +import kscience.kmath.nd.get import org.nd4j.linalg.factory.Nd4j import kotlin.test.Test import kotlin.test.assertEquals diff --git a/kmath-viktor/src/main/kotlin/kscience/kmath/viktor/ViktorNDStructure.kt b/kmath-viktor/src/main/kotlin/kscience/kmath/viktor/ViktorNDStructure.kt index 2471362cb..5dbc297b4 100644 --- a/kmath-viktor/src/main/kotlin/kscience/kmath/viktor/ViktorNDStructure.kt +++ b/kmath-viktor/src/main/kotlin/kscience/kmath/viktor/ViktorNDStructure.kt @@ -1,10 +1,10 @@ package kscience.kmath.viktor +import kscience.kmath.nd.DefaultStrides +import kscience.kmath.nd.MutableNDStructure +import kscience.kmath.nd.NDField +import kscience.kmath.nd.Strides import kscience.kmath.operations.RealField -import kscience.kmath.structures.DefaultStrides -import kscience.kmath.structures.MutableNDStructure -import kscience.kmath.structures.NDField -import kscience.kmath.structures.Strides import org.jetbrains.bio.viktor.F64Array @Suppress("OVERRIDE_BY_INLINE", "NOTHING_TO_INLINE") From 332c04b573e638a45401e334be5682f1fbaea03c Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 23 Jan 2021 19:19:13 +0300 Subject: [PATCH 07/23] [WIP] Refactor NDStructures --- .../kscience/kmath/operations/ComplexDemo.kt | 8 ++-- .../kscience/kmath/structures/NDField.kt | 13 ++++-- .../kscience/kmath/commons/linear/CMMatrix.kt | 5 +-- .../kscience/kmath/commons/linear/CMSolver.kt | 2 +- .../kscience/kmath/nd/BufferNDAlgebra.kt | 6 +-- .../kotlin/kscience/kmath/nd/RealNDField.kt | 7 ++- .../kotlin/kscience/kmath/nd/Structure2D.kt | 10 ++++- .../kscience/kmath/operations/BigInt.kt | 13 +++--- .../kscience/kmath/structures/Buffers.kt | 2 +- .../kmath/structures/FlaggedBuffer.kt | 2 +- .../kscience/kmath/structures/MemoryBuffer.kt | 2 +- .../kscience/kmath/structures/NDFieldTest.kt | 8 ++-- .../kmath/structures/NumberNDFieldTest.kt | 44 ++++++++++++------- .../kmath/structures/LazyNDStructure.kt | 2 +- .../kscience/kmath/ejml/EjmlMatrixContext.kt | 5 +-- .../kotlin/kscience/kmath/real/RealMatrix.kt | 6 +-- .../kaceince/kmath/real/RealMatrixTest.kt | 4 +- .../kscience/kmath/histogram/RealHistogram.kt | 6 +-- .../kscience.kmath.nd4j/Nd4jArrayAlgebra.kt | 18 +++++--- .../kmath/viktor/ViktorNDStructure.kt | 40 ++++++++++------- 20 files changed, 120 insertions(+), 83 deletions(-) diff --git a/examples/src/main/kotlin/kscience/kmath/operations/ComplexDemo.kt b/examples/src/main/kotlin/kscience/kmath/operations/ComplexDemo.kt index f90221582..821618af5 100644 --- a/examples/src/main/kotlin/kscience/kmath/operations/ComplexDemo.kt +++ b/examples/src/main/kotlin/kscience/kmath/operations/ComplexDemo.kt @@ -1,17 +1,17 @@ package kscience.kmath.operations -import kscience.kmath.nd.NDField -import kscience.kmath.structures.NDElement +import kscience.kmath.nd.NDAlgebra +import kscience.kmath.nd.complex fun main() { // 2d element - val element = NDElement.complex(2, 2) { (i,j) -> + val element = NDAlgebra.complex(2, 2).produce { (i,j) -> Complex(i.toDouble() - j.toDouble(), i.toDouble() + j.toDouble()) } println(element) // 1d element operation - val result = with(NDField.complex(8)) { + val result = with(NDAlgebra.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/kscience/kmath/structures/NDField.kt b/examples/src/main/kotlin/kscience/kmath/structures/NDField.kt index e26b8cbce..3e84c0be0 100644 --- a/examples/src/main/kotlin/kscience/kmath/structures/NDField.kt +++ b/examples/src/main/kotlin/kscience/kmath/structures/NDField.kt @@ -1,7 +1,10 @@ package kscience.kmath.structures import kotlinx.coroutines.GlobalScope -import kscience.kmath.nd.* +import kscience.kmath.nd.NDAlgebra +import kscience.kmath.nd.NDStructure +import kscience.kmath.nd.field +import kscience.kmath.nd.real import kscience.kmath.nd4j.Nd4jArrayField import kscience.kmath.operations.RealField import kscience.kmath.operations.invoke @@ -39,8 +42,10 @@ fun main() { } measureAndPrint("Element addition") { - var res: NDStructure = boxingField.one - repeat(n) { res += 1.0 } + boxingField { + var res: NDStructure = one + repeat(n) { res += 1.0 } + } } measureAndPrint("Specialized addition") { @@ -52,7 +57,7 @@ fun main() { measureAndPrint("Nd4j specialized addition") { nd4jField { - var res = one + var res:NDStructure = one repeat(n) { res += 1.0 } } } diff --git a/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt b/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt index b9fc8b72a..e168b3d7c 100644 --- a/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt +++ b/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt @@ -1,10 +1,7 @@ package kscience.kmath.commons.linear -import kscience.kmath.linear.DiagonalFeature -import kscience.kmath.linear.MatrixContext -import kscience.kmath.linear.Point +import kscience.kmath.linear.* import kscience.kmath.misc.UnstableKMathAPI -import kscience.kmath.nd.Matrix import org.apache.commons.math3.linear.* import kotlin.reflect.KClass import kotlin.reflect.cast diff --git a/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMSolver.kt b/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMSolver.kt index aa0bf4e1a..1c0896597 100644 --- a/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMSolver.kt +++ b/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMSolver.kt @@ -1,7 +1,7 @@ package kscience.kmath.commons.linear +import kscience.kmath.linear.Matrix import kscience.kmath.linear.Point -import kscience.kmath.nd.Matrix import org.apache.commons.math3.linear.* public enum class CMDecomposition { diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt index a92e08c60..cc1764643 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt @@ -86,7 +86,7 @@ public fun > NDAlgebra.Companion.space( vararg shape: Int, ): BufferedNDSpace = BufferedNDSpace(shape, space, bufferFactory) -public inline fun , R> A.nd( +public inline fun , R> A.ndSpace( noinline bufferFactory: BufferFactory, vararg shape: Int, action: BufferedNDSpace.() -> R, @@ -102,7 +102,7 @@ public fun > NDAlgebra.Companion.ring( vararg shape: Int, ): BufferedNDRing = BufferedNDRing(shape, ring, bufferFactory) -public inline fun , R> A.nd( +public inline fun , R> A.ndRing( noinline bufferFactory: BufferFactory, vararg shape: Int, action: BufferedNDRing.() -> R, @@ -118,7 +118,7 @@ public fun > NDAlgebra.Companion.field( vararg shape: Int, ): BufferedNDField = BufferedNDField(shape, field, bufferFactory) -public inline fun , R> A.nd( +public inline fun , R> A.ndField( noinline bufferFactory: BufferFactory, vararg shape: Int, action: BufferedNDField.() -> R, diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt index feb3c509a..7a0d8f8f9 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt @@ -94,9 +94,12 @@ public open class RealNDField( /** * Fast element production using function inlining */ -public inline fun BufferedNDField.produceInline(crossinline initializer: RealField.(Int) -> Double): NDBuffer { +public inline fun BufferedNDField.produceInline(crossinline initializer: RealField.(IntArray) -> Double): NDBuffer { contract { callsInPlace(initializer, InvocationKind.EXACTLY_ONCE) } - val array = DoubleArray(strides.linearSize) { offset -> RealField.initializer(offset) } + val array = DoubleArray(strides.linearSize) { offset -> + val index = strides.index(offset) + RealField.initializer(index) + } return NDBuffer(strides, RealBuffer(array)) } diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt index 4c730877c..b092d48e8 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt @@ -52,7 +52,15 @@ public interface Structure2D : NDStructure { for (j in 0 until colNum) yield(intArrayOf(i, j) to get(i, j)) } - public companion object + public companion object { + public inline fun real( + rows: Int, + columns: Int, + crossinline init: (i: Int, j: Int) -> Double, + ): NDBuffer = NDAlgebra.real(rows, columns).produceInline { (i, j) -> + init(i, j) + } + } } /** diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/BigInt.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/BigInt.kt index 9599401bc..e0bf817ef 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/BigInt.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/BigInt.kt @@ -1,10 +1,12 @@ package kscience.kmath.operations import kscience.kmath.misc.UnstableKMathAPI +import kscience.kmath.nd.BufferedNDRing import kscience.kmath.nd.NDAlgebra import kscience.kmath.operations.BigInt.Companion.BASE import kscience.kmath.operations.BigInt.Companion.BASE_SIZE -import kscience.kmath.structures.* +import kscience.kmath.structures.Buffer +import kscience.kmath.structures.MutableBuffer import kotlin.math.log2 import kotlin.math.max import kotlin.math.min @@ -463,10 +465,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): BoxingNDRing = - BoxingNDRing(shape, BigIntField, Buffer.Companion::bigInt) - -public fun NDElement.Companion.bigInt( - vararg shape: Int, - initializer: BigIntField.(IntArray) -> BigInt -): BufferedNDRingElement = NDAlgebra.bigInt(*shape).produce(initializer) +public fun NDAlgebra.Companion.bigInt(vararg shape: Int): BufferedNDRing = + BufferedNDRing(shape, BigIntField, Buffer.Companion::bigInt) diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/Buffers.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/Buffers.kt index 4e7c0d1b1..bfec6f871 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/Buffers.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/Buffers.kt @@ -43,7 +43,7 @@ public interface Buffer { * Checks content equality with another buffer. */ public fun contentEquals(other: Buffer<*>): Boolean = - kscience.kmath.nd.mapIndexed { index, value -> value == other[index] }.all { it } + asSequence().mapIndexed { index, value -> value == other[index] }.all { it } public companion object { /** diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/FlaggedBuffer.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/FlaggedBuffer.kt index 7828cea10..4965e37cf 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/FlaggedBuffer.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/FlaggedBuffer.kt @@ -60,7 +60,7 @@ public class FlaggedRealBuffer(public val values: DoubleArray, public val flags: override operator fun get(index: Int): Double? = if (isValid(index)) values[index] else null - override operator fun iterator(): Iterator = kscience.kmath.nd.map { + override operator fun iterator(): Iterator = values.indices.asSequence().map { if (isValid(it)) values[it] else null }.iterator() } diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/MemoryBuffer.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/MemoryBuffer.kt index 22331ae81..66c9212cf 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/MemoryBuffer.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/structures/MemoryBuffer.kt @@ -15,7 +15,7 @@ public open class MemoryBuffer(protected val memory: Memory, protected private val reader: MemoryReader = memory.reader() override operator fun get(index: Int): T = reader.read(spec, spec.objectSize * index) - override operator fun iterator(): Iterator = kscience.kmath.nd.map { get(it) }.iterator() + override operator fun iterator(): Iterator = (0 until size).asSequence().map { get(it) }.iterator() public companion object { public fun create(spec: MemorySpec, size: Int): MemoryBuffer = diff --git a/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NDFieldTest.kt b/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NDFieldTest.kt index 0f5f99b49..35d49e29d 100644 --- a/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NDFieldTest.kt +++ b/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NDFieldTest.kt @@ -1,6 +1,8 @@ package kscience.kmath.structures -import kscience.kmath.nd.NDField +import kscience.kmath.nd.NDAlgebra +import kscience.kmath.nd.get +import kscience.kmath.nd.real import kscience.kmath.operations.internal.FieldVerifier import kotlin.test.Test import kotlin.test.assertEquals @@ -8,12 +10,12 @@ import kotlin.test.assertEquals internal class NDFieldTest { @Test fun verify() { - NDField.real(12, 32).run { FieldVerifier(this, one + 3, one - 23, one * 12, 6.66) } + NDAlgebra.real(12, 32).run { FieldVerifier(this, one + 3, one - 23, one * 12, 6.66) } } @Test fun testStrides() { - val ndArray = NDElement.real(intArrayOf(10, 10)) { (it[0] + it[1]).toDouble() } + val ndArray = NDAlgebra.real(10, 10).produce { (it[0] + it[1]).toDouble() } assertEquals(ndArray[5, 5], 10.0) } } diff --git a/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NumberNDFieldTest.kt b/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NumberNDFieldTest.kt index baf3656fc..b90e0f07f 100644 --- a/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NumberNDFieldTest.kt +++ b/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NumberNDFieldTest.kt @@ -1,9 +1,8 @@ package kscience.kmath.structures -import kscience.kmath.nd.NDField -import kscience.kmath.nd.NDStructure +import kscience.kmath.nd.* import kscience.kmath.operations.Norm -import kscience.kmath.structures.NDElement.Companion.real2D +import kscience.kmath.operations.invoke import kotlin.math.abs import kotlin.math.pow import kotlin.test.Test @@ -11,25 +10,30 @@ import kotlin.test.assertEquals @Suppress("UNUSED_VARIABLE") class NumberNDFieldTest { - val array1: RealNDElement = real2D(3, 3) { i, j -> (i + j).toDouble() } - val array2: RealNDElement = real2D(3, 3) { i, j -> (i - j).toDouble() } + val algebra = NDAlgebra.real(3,3) + val array1 = algebra.produceInline { (i, j) -> (i + j).toDouble() } + val array2 = algebra.produceInline { (i, j) -> (i - j).toDouble() } @Test fun testSum() { - val sum = array1 + array2 - assertEquals(4.0, sum[2, 2]) + algebra { + val sum = array1 + array2 + assertEquals(4.0, sum[2, 2]) + } } @Test fun testProduct() { - val product = array1 * array2 - assertEquals(0.0, product[2, 2]) + algebra { + val product = array1 * array2 + assertEquals(0.0, product[2, 2]) + } } @Test fun testGeneration() { - val array = real2D(3, 3) { i, j -> (i * 10 + j).toDouble() } + val array = Structure2D.real(3, 3) { i, j -> (i * 10 + j).toDouble() } for (i in 0..2) { for (j in 0..2) { @@ -41,16 +45,20 @@ class NumberNDFieldTest { @Test fun testExternalFunction() { - val function: (Double) -> Double = { x -> x.pow(2) + 2 * x + 1 } - val result = function(array1) + 1.0 - assertEquals(10.0, result[1, 1]) + algebra { + val function: (Double) -> Double = { x -> x.pow(2) + 2 * x + 1 } + val result = function(array1) + 1.0 + assertEquals(10.0, result[1, 1]) + } } @Test fun testLibraryFunction() { - val abs: (Double) -> Double = ::abs - val result = abs(array2) - assertEquals(2.0, result[0, 2]) + algebra { + val abs: (Double) -> Double = ::abs + val result = abs(array2) + assertEquals(2.0, result[0, 2]) + } } @Test @@ -65,6 +73,8 @@ class NumberNDFieldTest { @Test fun testInternalContext() { - (NDField.real(*array1.shape)) { with(L2Norm) { 1 + norm(array1) + exp(array2) } } + algebra { + (NDAlgebra.real(*array1.shape)) { with(L2Norm) { 1 + norm(array1) + exp(array2) } } + } } } diff --git a/kmath-coroutines/src/jvmMain/kotlin/kscience/kmath/structures/LazyNDStructure.kt b/kmath-coroutines/src/jvmMain/kotlin/kscience/kmath/structures/LazyNDStructure.kt index cac692eb2..3933ef28b 100644 --- a/kmath-coroutines/src/jvmMain/kotlin/kscience/kmath/structures/LazyNDStructure.kt +++ b/kmath-coroutines/src/jvmMain/kotlin/kscience/kmath/structures/LazyNDStructure.kt @@ -21,7 +21,7 @@ public class LazyNDStructure( public override fun elements(): Sequence> { val strides = DefaultStrides(shape) - val res = runBlocking { kscience.kmath.nd.map { index -> index to await(index) } } + val res = runBlocking { strides.indices().toList().map { index -> index to await(index) } } return res.asSequence() } diff --git a/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrixContext.kt b/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrixContext.kt index ebd4dd586..eb126e00a 100644 --- a/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrixContext.kt +++ b/kmath-ejml/src/main/kotlin/kscience/kmath/ejml/EjmlMatrixContext.kt @@ -1,10 +1,7 @@ package kscience.kmath.ejml -import kscience.kmath.linear.InverseMatrixFeature -import kscience.kmath.linear.MatrixContext -import kscience.kmath.linear.Point +import kscience.kmath.linear.* import kscience.kmath.misc.UnstableKMathAPI -import kscience.kmath.nd.Matrix import kscience.kmath.nd.getFeature import org.ejml.simple.SimpleMatrix diff --git a/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt b/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt index defaba126..e7bde9980 100644 --- a/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt +++ b/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt @@ -1,11 +1,11 @@ package kscience.kmath.real -import kscience.kmath.linear.MatrixContext -import kscience.kmath.linear.real +import kscience.kmath.linear.* import kscience.kmath.misc.UnstableKMathAPI -import kscience.kmath.nd.Matrix import kscience.kmath.structures.Buffer import kscience.kmath.structures.RealBuffer +import kscience.kmath.structures.asIterable +import kotlin.math.pow /* * Functions for convenient "numpy-like" operations with Double matrices. diff --git a/kmath-for-real/src/commonTest/kotlin/kaceince/kmath/real/RealMatrixTest.kt b/kmath-for-real/src/commonTest/kotlin/kaceince/kmath/real/RealMatrixTest.kt index 68aa8cf52..309997ae3 100644 --- a/kmath-for-real/src/commonTest/kotlin/kaceince/kmath/real/RealMatrixTest.kt +++ b/kmath-for-real/src/commonTest/kotlin/kaceince/kmath/real/RealMatrixTest.kt @@ -1,7 +1,9 @@ package kaceince.kmath.real -import kscience.kmath.nd.Matrix +import kscience.kmath.linear.Matrix +import kscience.kmath.linear.build import kscience.kmath.real.* +import kscience.kmath.structures.contentEquals import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue diff --git a/kmath-histograms/src/commonMain/kotlin/kscience/kmath/histogram/RealHistogram.kt b/kmath-histograms/src/commonMain/kotlin/kscience/kmath/histogram/RealHistogram.kt index 42dbaabac..085641106 100644 --- a/kmath-histograms/src/commonMain/kotlin/kscience/kmath/histogram/RealHistogram.kt +++ b/kmath-histograms/src/commonMain/kotlin/kscience/kmath/histogram/RealHistogram.kt @@ -17,7 +17,7 @@ public data class BinDef>( require(vector.size == center.size) { "Dimension mismatch for input vector. Expected ${center.size}, but found ${vector.size}" } val upper = space { center + sizes / 2.0 } val lower = space { center - sizes / 2.0 } - return kscience.kmath.nd.mapIndexed { i, value -> value in lower[i]..upper[i] }.all { it } + return vector.asSequence().mapIndexed { i, value -> value in lower[i]..upper[i] }.all { it } } } @@ -70,7 +70,7 @@ public class RealHistogram( public fun getValue(point: Buffer): Long = getValue(getIndex(point)) private fun getDef(index: IntArray): BinDef { - val center = kscience.kmath.nd.mapIndexed { axis, i -> + val center = index.mapIndexed { axis, i -> when (i) { 0 -> Double.NEGATIVE_INFINITY strides.shape[axis] - 1 -> Double.POSITIVE_INFINITY @@ -100,7 +100,7 @@ public class RealHistogram( } public override operator fun iterator(): Iterator> = - kscience.kmath.nd.map { (index, value) -> MultivariateBin(getDef(index), value.sum()) } + weights.elements().map { (index, value) -> MultivariateBin(getDef(index), value.sum()) } .iterator() /** diff --git a/kmath-nd4j/src/main/kotlin/kscience.kmath.nd4j/Nd4jArrayAlgebra.kt b/kmath-nd4j/src/main/kotlin/kscience.kmath.nd4j/Nd4jArrayAlgebra.kt index b958d1ccf..91d45dccd 100644 --- a/kmath-nd4j/src/main/kotlin/kscience.kmath.nd4j/Nd4jArrayAlgebra.kt +++ b/kmath-nd4j/src/main/kotlin/kscience.kmath.nd4j/Nd4jArrayAlgebra.kt @@ -7,6 +7,13 @@ import kscience.kmath.structures.* import org.nd4j.linalg.api.ndarray.INDArray import org.nd4j.linalg.factory.Nd4j +internal fun NDAlgebra<*, *>.checkShape(array: INDArray): INDArray { + val arrayShape = array.shape().toIntArray() + if (!shape.contentEquals(arrayShape)) throw ShapeMismatchException(shape, arrayShape) + return array +} + + /** * Represents [NDAlgebra] over [Nd4jArrayAlgebra]. * @@ -18,8 +25,9 @@ public interface Nd4jArrayAlgebra : NDAlgebra { * Wraps [INDArray] to [N]. */ public fun INDArray.wrap(): Nd4jArrayStructure + public val NDStructure.ndArray: INDArray - get() = when { + get() = when { !shape.contentEquals(this@Nd4jArrayAlgebra.shape) -> throw ShapeMismatchException( this@Nd4jArrayAlgebra.shape, shape @@ -213,7 +221,7 @@ public class RealNd4jArrayField(public override val shape: IntArray) : Nd4jArray public override val elementContext: RealField get() = RealField - public override fun INDArray.wrap(): Nd4jArrayStructure = checkShape(asRealStructure()) + public override fun INDArray.wrap(): Nd4jArrayStructure = checkShape(this).asRealStructure() public override operator fun NDStructure.div(arg: Double): Nd4jArrayStructure { return ndArray.div(arg).wrap() @@ -247,7 +255,7 @@ public class FloatNd4jArrayField(public override val shape: IntArray) : Nd4jArra public override val elementContext: FloatField get() = FloatField - public override fun INDArray.wrap(): Nd4jArrayStructure = checkShape(asFloatStructure()) + public override fun INDArray.wrap(): Nd4jArrayStructure = checkShape(this).asFloatStructure() public override operator fun NDStructure.div(arg: Float): Nd4jArrayStructure { return ndArray.div(arg).wrap() @@ -281,7 +289,7 @@ public class IntNd4jArrayRing(public override val shape: IntArray) : Nd4jArrayRi public override val elementContext: IntRing get() = IntRing - public override fun INDArray.wrap(): Nd4jArrayStructure = check(asIntStructure()) + public override fun INDArray.wrap(): Nd4jArrayStructure = checkShape(this).asIntStructure() public override operator fun NDStructure.plus(arg: Int): Nd4jArrayStructure { return ndArray.add(arg).wrap() @@ -307,7 +315,7 @@ public class LongNd4jArrayRing(public override val shape: IntArray) : Nd4jArrayR public override val elementContext: LongRing get() = LongRing - public override fun INDArray.wrap(): Nd4jArrayStructure = check(asLongStructure()) + public override fun INDArray.wrap(): Nd4jArrayStructure = checkShape(this).asLongStructure() public override operator fun NDStructure.plus(arg: Long): Nd4jArrayStructure { return ndArray.add(arg).wrap() diff --git a/kmath-viktor/src/main/kotlin/kscience/kmath/viktor/ViktorNDStructure.kt b/kmath-viktor/src/main/kotlin/kscience/kmath/viktor/ViktorNDStructure.kt index 5dbc297b4..a6c4f3ce0 100644 --- a/kmath-viktor/src/main/kotlin/kscience/kmath/viktor/ViktorNDStructure.kt +++ b/kmath-viktor/src/main/kotlin/kscience/kmath/viktor/ViktorNDStructure.kt @@ -1,9 +1,6 @@ package kscience.kmath.viktor -import kscience.kmath.nd.DefaultStrides -import kscience.kmath.nd.MutableNDStructure -import kscience.kmath.nd.NDField -import kscience.kmath.nd.Strides +import kscience.kmath.nd.* import kscience.kmath.operations.RealField import org.jetbrains.bio.viktor.F64Array @@ -24,14 +21,25 @@ public inline class ViktorNDStructure(public val f64Buffer: F64Array) : MutableN public fun F64Array.asStructure(): ViktorNDStructure = ViktorNDStructure(this) @Suppress("OVERRIDE_BY_INLINE", "NOTHING_TO_INLINE") -public class ViktorNDField(public override val shape: IntArray) : NDField { +public class ViktorNDField(public override val shape: IntArray) : NDField { + + 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 get() = F64Array.full(init = 0.0, shape = shape).asStructure() public override val one: ViktorNDStructure get() = F64Array.full(init = 1.0, shape = shape).asStructure() - public val strides: Strides = DefaultStrides(shape) + private val strides: Strides = DefaultStrides(shape) public override val elementContext: RealField get() = RealField @@ -42,7 +50,7 @@ public class ViktorNDField(public override val shape: IntArray) : NDField Double): ViktorNDStructure = + public override fun map(arg: NDStructure, transform: RealField.(Double) -> Double): ViktorNDStructure = F64Array(*shape).apply { this@ViktorNDField.strides.indices().forEach { index -> set(value = RealField.transform(arg[index]), indices = index) @@ -50,7 +58,7 @@ public class ViktorNDField(public override val shape: IntArray) : NDField, transform: RealField.(index: IntArray, Double) -> Double ): ViktorNDStructure = F64Array(*shape).apply { this@ViktorNDField.strides.indices().forEach { index -> @@ -59,8 +67,8 @@ public class ViktorNDField(public override val shape: IntArray) : NDField, + b: NDStructure, transform: RealField.(Double, Double) -> Double ): ViktorNDStructure = F64Array(*shape).apply { this@ViktorNDField.strides.indices().forEach { index -> @@ -68,21 +76,21 @@ public class ViktorNDField(public override val shape: IntArray) : NDField, b: NDStructure): ViktorNDStructure = (a.f64Buffer + b.f64Buffer).asStructure() - public override fun multiply(a: ViktorNDStructure, k: Number): ViktorNDStructure = + public override fun multiply(a: NDStructure, k: Number): ViktorNDStructure = (a.f64Buffer * k.toDouble()).asStructure() - public override inline fun ViktorNDStructure.plus(b: ViktorNDStructure): ViktorNDStructure = + public override inline fun NDStructure.plus(b: NDStructure): ViktorNDStructure = (f64Buffer + b.f64Buffer).asStructure() - public override inline fun ViktorNDStructure.minus(b: ViktorNDStructure): ViktorNDStructure = + public override inline fun NDStructure.minus(b: NDStructure): ViktorNDStructure = (f64Buffer - b.f64Buffer).asStructure() - public override inline fun ViktorNDStructure.times(k: Number): ViktorNDStructure = + public override inline fun NDStructure.times(k: Number): ViktorNDStructure = (f64Buffer * k.toDouble()).asStructure() - public override inline fun ViktorNDStructure.plus(arg: Double): ViktorNDStructure = + public override inline fun NDStructure.plus(arg: Double): ViktorNDStructure = (f64Buffer.plus(arg)).asStructure() } \ No newline at end of file From 0baec140593ceaf32eeef23d0969d64807ba062e Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 23 Jan 2021 21:50:48 +0300 Subject: [PATCH 08/23] [WIP] Refactor NDStructures --- .../commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt | 2 +- .../src/commonMain/kotlin/kscience/kmath/nd/NDStructure.kt | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt index cc1764643..c07726ad6 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt @@ -50,7 +50,7 @@ public interface BufferNDAlgebra : NDAlgebra { val aBuffer = a.ndBuffer val bBuffer = b.ndBuffer val buffer = bufferFactory(strides.linearSize) { offset -> - elementContext.transform(aBuffer.buffer[offset], bBuffer[offset]) + elementContext.transform(aBuffer.buffer[offset], bBuffer.buffer[offset]) } return NDBuffer(strides, buffer) } diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDStructure.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDStructure.kt index 09c6fa198..4aa1c7d52 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDStructure.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDStructure.kt @@ -217,9 +217,7 @@ public class DefaultStrides private constructor(override val shape: IntArray) : } override fun offset(index: IntArray): Int = index.mapIndexed { i, value -> - if (value < 0 || value >= shape[i]) - throw IndexOutOfBoundsException("Index $value out of shape bounds: (0,${this.shape[i]})") - + if (value < 0 || value >= shape[i]) throw IndexOutOfBoundsException("Index $value out of shape bounds: (0,${this.shape[i]})") value * strides[i] }.sum() @@ -332,7 +330,7 @@ public inline fun NDStructure.mapToBuffer( public class MutableNDBuffer( strides: Strides, buffer: MutableBuffer, -) : NDBuffer(strides,buffer), MutableNDStructure { +) : NDBuffer(strides, buffer), MutableNDStructure { init { require(strides.linearSize == buffer.size) { From 1cb41f4dc2e936964937148f75bd4b52a0d80cd2 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 23 Jan 2021 22:16:27 +0300 Subject: [PATCH 09/23] Optimize Real NDField --- .../kscience/kmath/benchmarks/DotBenchmark.kt | 2 +- .../kmath/benchmarks/NDFieldBenchmark.kt | 28 ++---- .../kmath/benchmarks/ViktorBenchmark.kt | 10 +- .../kscience/kmath/structures/NDField.kt | 25 ++--- .../kscience/kmath/nd/BufferNDAlgebra.kt | 6 ++ .../kotlin/kscience/kmath/nd/RealNDField.kt | 93 ++++++++++--------- .../kotlin/kscience/kmath/nd/Structure2D.kt | 5 +- 7 files changed, 77 insertions(+), 92 deletions(-) diff --git a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/DotBenchmark.kt b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/DotBenchmark.kt index 4a0c96f78..cc8043664 100644 --- a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/DotBenchmark.kt +++ b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/DotBenchmark.kt @@ -4,8 +4,8 @@ import kotlinx.benchmark.Benchmark import kscience.kmath.commons.linear.CMMatrixContext import kscience.kmath.ejml.EjmlMatrixContext import kscience.kmath.linear.BufferMatrixContext +import kscience.kmath.linear.Matrix import kscience.kmath.linear.RealMatrixContext -import kscience.kmath.nd.Matrix import kscience.kmath.operations.RealField import kscience.kmath.operations.invoke import kscience.kmath.structures.Buffer diff --git a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/NDFieldBenchmark.kt b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/NDFieldBenchmark.kt index 3f103dd37..e465403ad 100644 --- a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/NDFieldBenchmark.kt +++ b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/NDFieldBenchmark.kt @@ -1,11 +1,9 @@ package kscience.kmath.benchmarks -import kscience.kmath.nd.AbstractNDBuffer -import kscience.kmath.nd.NDField -import kscience.kmath.nd.RealNDField +import kscience.kmath.nd.* import kscience.kmath.operations.RealField import kscience.kmath.operations.invoke -import kscience.kmath.structures.* +import kscience.kmath.structures.Buffer import org.openjdk.jmh.annotations.Benchmark import org.openjdk.jmh.annotations.Scope import org.openjdk.jmh.annotations.State @@ -14,22 +12,16 @@ import org.openjdk.jmh.annotations.State internal class NDFieldBenchmark { @Benchmark fun autoFieldAdd() { - bufferedField { - var res: AbstractNDBuffer = one + autoField { + var res: NDStructure = one repeat(n) { res += one } } } - @Benchmark - fun autoElementAdd() { - var res = genericField.one - repeat(n) { res += 1.0 } - } - @Benchmark fun specializedFieldAdd() { specializedField { - var res: AbstractNDBuffer = one + var res: NDStructure = one repeat(n) { res += 1.0 } } } @@ -38,16 +30,16 @@ internal class NDFieldBenchmark { @Benchmark fun boxingFieldAdd() { genericField { - var res: AbstractNDBuffer = one - repeat(n) { res += one } + var res: NDStructure = one + repeat(n) { res += 1.0 } } } companion object { const val dim: Int = 1000 const val n: Int = 100 - val bufferedField: BufferedNDField = NDField.auto(RealField, dim, dim) - val specializedField: RealNDField = NDField.real(dim, dim) - val genericField: BoxingNDField = NDField.boxing(RealField, dim, dim) + val autoField = NDAlgebra.auto(RealField, dim, dim) + val specializedField: RealNDField = NDAlgebra.real(dim, dim) + val genericField = NDAlgebra.field(RealField, Buffer.Companion::boxing, dim, dim) } } \ No newline at end of file diff --git a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorBenchmark.kt b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorBenchmark.kt index 49b30cf7e..892fb3457 100644 --- a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorBenchmark.kt +++ b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorBenchmark.kt @@ -1,10 +1,8 @@ package kscience.kmath.benchmarks -import kscience.kmath.nd.NDField -import kscience.kmath.nd.RealNDField +import kscience.kmath.nd.* import kscience.kmath.operations.RealField import kscience.kmath.operations.invoke -import kscience.kmath.structures.BufferedNDField import kscience.kmath.viktor.ViktorNDField import org.jetbrains.bio.viktor.F64Array import org.openjdk.jmh.annotations.Benchmark @@ -17,14 +15,14 @@ internal class ViktorBenchmark { final val n: Int = 100 // automatically build context most suited for given type. - final val autoField: BufferedNDField = NDField.auto(RealField, dim, dim) - final val realField: RealNDField = NDField.real(dim, dim) + final val autoField: BufferedNDField = NDAlgebra.auto(RealField, dim, dim) + final val realField: RealNDField = NDAlgebra.real(dim, dim) final val viktorField: ViktorNDField = ViktorNDField(intArrayOf(dim, dim)) @Benchmark fun automaticFieldAddition() { autoField { - var res = one + var res: NDStructure = one repeat(n) { res += one } } } diff --git a/examples/src/main/kotlin/kscience/kmath/structures/NDField.kt b/examples/src/main/kotlin/kscience/kmath/structures/NDField.kt index 3e84c0be0..697affeca 100644 --- a/examples/src/main/kotlin/kscience/kmath/structures/NDField.kt +++ b/examples/src/main/kotlin/kscience/kmath/structures/NDField.kt @@ -1,10 +1,7 @@ package kscience.kmath.structures import kotlinx.coroutines.GlobalScope -import kscience.kmath.nd.NDAlgebra -import kscience.kmath.nd.NDStructure -import kscience.kmath.nd.field -import kscience.kmath.nd.real +import kscience.kmath.nd.* import kscience.kmath.nd4j.Nd4jArrayField import kscience.kmath.operations.RealField import kscience.kmath.operations.invoke @@ -26,11 +23,11 @@ fun main() { val n = 1000 // automatically build context most suited for given type. - val autoField = NDAlgebra.field(RealField, Buffer.Companion::auto, dim, dim) + val autoField = NDAlgebra.auto(RealField, dim, dim) // specialized nd-field for Double. It works as generic Double field as well val specializedField = NDAlgebra.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 = NDAlgebra.field(RealField, Buffer.Companion::boxing, dim, dim) // Nd4j specialized field. val nd4jField = Nd4jArrayField.real(dim, dim) @@ -41,9 +38,9 @@ fun main() { } } - measureAndPrint("Element addition") { + measureAndPrint("Boxing addition") { boxingField { - var res: NDStructure = one + var res: NDStructure = one repeat(n) { res += 1.0 } } } @@ -57,7 +54,7 @@ fun main() { measureAndPrint("Nd4j specialized addition") { nd4jField { - var res:NDStructure = one + var res: NDStructure = one repeat(n) { res += 1.0 } } } @@ -73,14 +70,4 @@ fun main() { res.elements().forEach { it.second } } - - measureAndPrint("Generic addition") { - //genericField.run(action) - boxingField { - var res: NDStructure = one - repeat(n) { - res += 1.0 // couldn't avoid using `one` due to resolution ambiguity } - } - } - } } diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt index c07726ad6..901bb5a44 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt @@ -2,6 +2,7 @@ package kscience.kmath.nd import kscience.kmath.nd.* import kscience.kmath.operations.* +import kscience.kmath.structures.Buffer import kscience.kmath.structures.BufferFactory import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -118,6 +119,11 @@ public fun > NDAlgebra.Companion.field( vararg shape: Int, ): BufferedNDField = BufferedNDField(shape, field, bufferFactory) +public inline fun > NDAlgebra.Companion.auto( + field: A, + vararg shape: Int, +): BufferedNDField = BufferedNDField(shape, field, Buffer.Companion::auto) + public inline fun , R> A.ndField( noinline bufferFactory: BufferFactory, vararg shape: Int, diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt index 7a0d8f8f9..b96ee0e9b 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt @@ -10,7 +10,7 @@ import kotlin.contracts.InvocationKind import kotlin.contracts.contract @OptIn(UnstableKMathAPI::class) -public open class RealNDField( +public class RealNDField( shape: IntArray, ) : BufferedNDField(shape, RealField, Buffer.Companion::real), RingWithNumbers>, @@ -23,51 +23,52 @@ public open class RealNDField( val d = value.toDouble() // minimize conversions return produce { d } } -// -// @Suppress("OVERRIDE_BY_INLINE") -// override inline fun map( -// arg: AbstractNDBuffer, -// transform: RealField.(Double) -> Double, -// ): RealNDElement { -// check(arg) -// val array = RealBuffer(arg.strides.linearSize) { offset -> RealField.transform(arg.buffer[offset]) } -// return BufferedNDFieldElement(this, array) -// } -// -// @Suppress("OVERRIDE_BY_INLINE") -// override inline fun produce(initializer: RealField.(IntArray) -> Double): RealNDElement { -// val array = RealBuffer(strides.linearSize) { offset -> elementContext.initializer(strides.index(offset)) } -// return BufferedNDFieldElement(this, array) -// } -// -// @Suppress("OVERRIDE_BY_INLINE") -// override inline fun mapIndexed( -// arg: AbstractNDBuffer, -// transform: RealField.(index: IntArray, Double) -> Double, -// ): RealNDElement { -// check(arg) -// return BufferedNDFieldElement( -// this, -// RealBuffer(arg.strides.linearSize) { offset -> -// elementContext.transform( -// arg.strides.index(offset), -// arg.buffer[offset] -// ) -// }) -// } -// -// @Suppress("OVERRIDE_BY_INLINE") -// override inline fun combine( -// a: AbstractNDBuffer, -// b: AbstractNDBuffer, -// transform: RealField.(Double, Double) -> Double, -// ): RealNDElement { -// check(a, b) -// val buffer = RealBuffer(strides.linearSize) { offset -> -// elementContext.transform(a.buffer[offset], b.buffer[offset]) -// } -// return BufferedNDFieldElement(this, buffer) -// } + + @Suppress("OVERRIDE_BY_INLINE") + override inline fun map( + arg: NDStructure, + transform: RealField.(Double) -> Double, + ): NDBuffer { + val argAsBuffer = arg.ndBuffer + val buffer = RealBuffer(strides.linearSize) { offset -> RealField.transform(argAsBuffer.buffer[offset]) } + return NDBuffer(strides, buffer) + } + + @Suppress("OVERRIDE_BY_INLINE") + override inline fun produce(initializer: RealField.(IntArray) -> Double): NDBuffer { + val buffer = RealBuffer(strides.linearSize) { offset -> elementContext.initializer(strides.index(offset)) } + return NDBuffer(strides, buffer) + } + + @Suppress("OVERRIDE_BY_INLINE") + override inline fun mapIndexed( + arg: NDStructure, + transform: RealField.(index: IntArray, Double) -> Double, + ): NDBuffer { + val argAsBuffer = arg.ndBuffer + return NDBuffer( + strides, + RealBuffer(strides.linearSize) { offset -> + elementContext.transform( + strides.index(offset), + argAsBuffer.buffer[offset] + ) + }) + } + + @Suppress("OVERRIDE_BY_INLINE") + override inline fun combine( + a: NDStructure, + b: NDStructure, + transform: RealField.(Double, Double) -> Double, + ): NDBuffer { + val aBuffer = a.ndBuffer + val bBuffer = b.ndBuffer + val buffer = RealBuffer(strides.linearSize) { offset -> + elementContext.transform(aBuffer.buffer[offset], bBuffer.buffer[offset]) + } + return NDBuffer(strides, buffer) + } override fun power(arg: NDStructure, pow: Number): NDBuffer = map(arg) { power(it, pow) } diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt index b092d48e8..48fba45d9 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt @@ -1,5 +1,6 @@ package kscience.kmath.nd +import kscience.kmath.linear.Matrix import kscience.kmath.structures.Buffer import kscience.kmath.structures.VirtualBuffer @@ -57,9 +58,9 @@ public interface Structure2D : NDStructure { rows: Int, columns: Int, crossinline init: (i: Int, j: Int) -> Double, - ): NDBuffer = NDAlgebra.real(rows, columns).produceInline { (i, j) -> + ): Matrix = NDAlgebra.real(rows, columns).produceInline { (i, j) -> init(i, j) - } + }.as2D() } } From 9829a16a32197cd819645f6105976f6829d858de Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 24 Jan 2021 10:15:16 +0300 Subject: [PATCH 10/23] Optimize Real NDField --- .../kmath/benchmarks/ViktorBenchmark.kt | 30 ++--- .../kmath/benchmarks/ViktorLogBenchmark.kt | 40 +++++++ .../kscience/kmath/structures/NDField.kt | 39 +++++-- .../kmath/structures/ParallelRealNDField.kt | 103 ++++++++++++++++++ .../kscience/kmath/nd/BufferNDAlgebra.kt | 22 ++-- .../kscience/kmath/nd/ComplexNDField.kt | 2 +- .../kotlin/kscience/kmath/nd/RealNDField.kt | 56 +++++----- .../kotlin/kscience/kmath/nd/ShortNDRing.kt | 2 +- .../kotlin/kscience/kmath/nd/Structure2D.kt | 2 +- .../kmath/structures/NumberNDFieldTest.kt | 4 +- .../kmath/viktor/ViktorNDStructure.kt | 4 +- 11 files changed, 226 insertions(+), 78 deletions(-) create mode 100644 examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorLogBenchmark.kt create mode 100644 examples/src/main/kotlin/kscience/kmath/structures/ParallelRealNDField.kt diff --git a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorBenchmark.kt b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorBenchmark.kt index 892fb3457..85c5d8289 100644 --- a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorBenchmark.kt +++ b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorBenchmark.kt @@ -15,9 +15,9 @@ internal class ViktorBenchmark { final val n: Int = 100 // automatically build context most suited for given type. - final val autoField: BufferedNDField = NDAlgebra.auto(RealField, dim, dim) + final val autoField: NDField = NDAlgebra.auto(RealField, dim, dim) final val realField: RealNDField = NDAlgebra.real(dim, dim) - final val viktorField: ViktorNDField = ViktorNDField(intArrayOf(dim, dim)) + final val viktorField: ViktorNDField = ViktorNDField(dim, dim) @Benchmark fun automaticFieldAddition() { @@ -27,6 +27,14 @@ internal class ViktorBenchmark { } } + @Benchmark + fun realFieldAddition() { + realField { + var res: NDStructure = one + repeat(n) { res += one } + } + } + @Benchmark fun viktorFieldAddition() { viktorField { @@ -41,22 +49,4 @@ internal class ViktorBenchmark { var res = one repeat(n) { res = res + one } } - - @Benchmark - fun realFieldLog() { - realField { - val fortyTwo = produce { 42.0 } - var res = one - repeat(n) { res = ln(fortyTwo) } - } - } - - @Benchmark - fun rawViktorLog() { - val fortyTwo = F64Array.full(dim, dim, init = 42.0) - var res: F64Array - repeat(n) { - res = fortyTwo.log() - } - } } \ No newline at end of file diff --git a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorLogBenchmark.kt b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorLogBenchmark.kt new file mode 100644 index 000000000..e841c53c9 --- /dev/null +++ b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorLogBenchmark.kt @@ -0,0 +1,40 @@ +package kscience.kmath.benchmarks + +import kscience.kmath.nd.* +import kscience.kmath.operations.RealField +import kscience.kmath.operations.invoke +import kscience.kmath.viktor.ViktorNDField +import org.jetbrains.bio.viktor.F64Array +import org.openjdk.jmh.annotations.Benchmark +import org.openjdk.jmh.annotations.Scope +import org.openjdk.jmh.annotations.State + +@State(Scope.Benchmark) +internal class ViktorLogBenchmark { + final val dim: Int = 1000 + final val n: Int = 100 + + // automatically build context most suited for given type. + final val autoField: BufferedNDField = NDAlgebra.auto(RealField, dim, dim) + final val realField: RealNDField = NDAlgebra.real(dim, dim) + final val viktorField: ViktorNDField = ViktorNDField(intArrayOf(dim, dim)) + + + @Benchmark + fun realFieldLog() { + realField { + val fortyTwo = produce { 42.0 } + var res = one + repeat(n) { res = ln(fortyTwo) } + } + } + + @Benchmark + fun rawViktorLog() { + val fortyTwo = F64Array.full(dim, dim, init = 42.0) + var res: F64Array + repeat(n) { + res = fortyTwo.log() + } + } +} \ No newline at end of file diff --git a/examples/src/main/kotlin/kscience/kmath/structures/NDField.kt b/examples/src/main/kotlin/kscience/kmath/structures/NDField.kt index 697affeca..1e7a19cf8 100644 --- a/examples/src/main/kotlin/kscience/kmath/structures/NDField.kt +++ b/examples/src/main/kotlin/kscience/kmath/structures/NDField.kt @@ -5,6 +5,7 @@ import kscience.kmath.nd.* import kscience.kmath.nd4j.Nd4jArrayField import kscience.kmath.operations.RealField import kscience.kmath.operations.invoke +import kscience.kmath.viktor.ViktorNDField import org.nd4j.linalg.factory.Nd4j import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -25,18 +26,15 @@ fun main() { // automatically build context most suited for given type. val autoField = NDAlgebra.auto(RealField, dim, dim) // specialized nd-field for Double. It works as generic Double field as well - val specializedField = NDAlgebra.real(dim, dim) + val realField = NDAlgebra.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) // Nd4j specialized field. val nd4jField = Nd4jArrayField.real(dim, dim) - - measureAndPrint("Automatic field addition") { - autoField { - var res: NDStructure = one - repeat(n) { res += 1.0 } - } - } + //viktor field + val viktorField = ViktorNDField(dim,dim) + //parallel processing based on Java Streams + val parallelField = NDAlgebra.realWithStream(dim,dim) measureAndPrint("Boxing addition") { boxingField { @@ -46,7 +44,7 @@ fun main() { } measureAndPrint("Specialized addition") { - specializedField { + realField { var res: NDStructure = one repeat(n) { res += 1.0 } } @@ -59,8 +57,29 @@ fun main() { } } + measureAndPrint("Viktor addition") { + viktorField { + var res: NDStructure = one + repeat(n) { res += 1.0 } + } + } + + measureAndPrint("Parallel stream addition") { + parallelField { + var res: NDStructure = one + repeat(n) { res += 1.0 } + } + } + + measureAndPrint("Automatic field addition") { + autoField { + var res: NDStructure = one + repeat(n) { res += 1.0 } + } + } + measureAndPrint("Lazy addition") { - val res = specializedField.one.mapAsync(GlobalScope) { + val res = realField.one.mapAsync(GlobalScope) { var c = 0.0 repeat(n) { c += 1.0 diff --git a/examples/src/main/kotlin/kscience/kmath/structures/ParallelRealNDField.kt b/examples/src/main/kotlin/kscience/kmath/structures/ParallelRealNDField.kt new file mode 100644 index 000000000..bce625f7f --- /dev/null +++ b/examples/src/main/kotlin/kscience/kmath/structures/ParallelRealNDField.kt @@ -0,0 +1,103 @@ +package kscience.kmath.structures + +import kscience.kmath.misc.UnstableKMathAPI +import kscience.kmath.nd.* +import kscience.kmath.operations.ExtendedField +import kscience.kmath.operations.RealField +import kscience.kmath.operations.RingWithNumbers +import java.util.* +import java.util.stream.IntStream + +/** + * A demonstration implementation of NDField over Real using Java [DoubleStream] for parallel execution + */ +@OptIn(UnstableKMathAPI::class) +public class StreamRealNDField( + shape: IntArray, +) : BufferedNDField(shape, RealField, Buffer.Companion::real), + RingWithNumbers>, + ExtendedField> { + + override val zero: NDBuffer by lazy { produce { zero } } + override val one: NDBuffer by lazy { produce { one } } + + override fun number(value: Number): NDBuffer { + val d = value.toDouble() // minimize conversions + return produce { d } + } + + override val NDStructure.buffer: RealBuffer + get() = when { + !shape.contentEquals(this@StreamRealNDField.shape) -> throw ShapeMismatchException( + this@StreamRealNDField.shape, + shape + ) + this is NDBuffer && this.strides == this@StreamRealNDField.strides -> this.buffer as RealBuffer + else -> RealBuffer(strides.linearSize) { offset -> get(strides.index(offset)) } + } + + + override fun produce(initializer: RealField.(IntArray) -> Double): NDBuffer { + val array = IntStream.range(0, strides.linearSize).parallel().mapToDouble { offset -> + val index = strides.index(offset) + RealField.initializer(index) + }.toArray() + + return NDBuffer(strides, array.asBuffer()) + } + + override fun map( + arg: NDStructure, + transform: RealField.(Double) -> Double, + ): NDBuffer { + val array = Arrays.stream(arg.buffer.array).parallel().map { RealField.transform(it) }.toArray() + return NDBuffer(strides, array.asBuffer()) + } + + override fun mapIndexed( + arg: NDStructure, + transform: RealField.(index: IntArray, Double) -> Double, + ): NDBuffer { + val array = IntStream.range(0, strides.linearSize).parallel().mapToDouble { offset -> + RealField.transform( + strides.index(offset), + arg.buffer.array[offset] + ) + }.toArray() + + return NDBuffer(strides, array.asBuffer()) + } + + override fun combine( + a: NDStructure, + b: NDStructure, + transform: RealField.(Double, Double) -> Double, + ): NDBuffer { + val array = IntStream.range(0, strides.linearSize).parallel().mapToDouble { offset -> + RealField.transform(a.buffer.array[offset], b.buffer.array[offset]) + }.toArray() + return NDBuffer(strides, array.asBuffer()) + } + + override fun power(arg: NDStructure, pow: Number): NDBuffer = map(arg) { power(it, pow) } + + override fun exp(arg: NDStructure): NDBuffer = map(arg) { exp(it) } + + override fun ln(arg: NDStructure): NDBuffer = map(arg) { ln(it) } + + override fun sin(arg: NDStructure): NDBuffer = map(arg) { sin(it) } + override fun cos(arg: NDStructure): NDBuffer = map(arg) { cos(it) } + override fun tan(arg: NDStructure): NDBuffer = map(arg) { tan(it) } + override fun asin(arg: NDStructure): NDBuffer = map(arg) { asin(it) } + override fun acos(arg: NDStructure): NDBuffer = map(arg) { acos(it) } + override fun atan(arg: NDStructure): NDBuffer = map(arg) { atan(it) } + + override fun sinh(arg: NDStructure): NDBuffer = map(arg) { sinh(it) } + override fun cosh(arg: NDStructure): NDBuffer = map(arg) { cosh(it) } + override fun tanh(arg: NDStructure): NDBuffer = map(arg) { tanh(it) } + override fun asinh(arg: NDStructure): NDBuffer = map(arg) { asinh(it) } + override fun acosh(arg: NDStructure): NDBuffer = map(arg) { acosh(it) } + override fun atanh(arg: NDStructure): NDBuffer = map(arg) { atanh(it) } +} + +fun NDAlgebra.Companion.realWithStream(vararg shape: Int): StreamRealNDField = StreamRealNDField(shape) \ No newline at end of file diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt index 901bb5a44..93add36eb 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt @@ -18,40 +18,36 @@ public interface BufferNDAlgebra : NDAlgebra { } ) - public val NDStructure.ndBuffer: NDBuffer + public val NDStructure.buffer: Buffer get() = when { !shape.contentEquals(this@BufferNDAlgebra.shape) -> throw ShapeMismatchException( this@BufferNDAlgebra.shape, shape ) - this is NDBuffer && this.strides == this@BufferNDAlgebra.strides -> this - else -> produce { this@ndBuffer[it] } + this is NDBuffer && this.strides == this@BufferNDAlgebra.strides -> this.buffer + else -> bufferFactory(strides.linearSize) { offset -> get(strides.index(offset)) } } override fun map(arg: NDStructure, transform: C.(T) -> T): NDBuffer { - val argAsBuffer = arg.ndBuffer val buffer = bufferFactory(strides.linearSize) { offset -> - elementContext.transform(argAsBuffer.buffer[offset]) + elementContext.transform(arg.buffer[offset]) } return NDBuffer(strides, buffer) } override fun mapIndexed(arg: NDStructure, transform: C.(index: IntArray, T) -> T): NDStructure { - val argAsBuffer = arg.ndBuffer val buffer = bufferFactory(strides.linearSize) { offset -> elementContext.transform( strides.index(offset), - argAsBuffer[offset] + arg.buffer[offset] ) } return NDBuffer(strides, buffer) } override fun combine(a: NDStructure, b: NDStructure, transform: C.(T, T) -> T): NDStructure { - val aBuffer = a.ndBuffer - val bBuffer = b.ndBuffer val buffer = bufferFactory(strides.linearSize) { offset -> - elementContext.transform(aBuffer.buffer[offset], bBuffer.buffer[offset]) + elementContext.transform(a.buffer[offset], b.buffer[offset]) } return NDBuffer(strides, buffer) } @@ -119,10 +115,14 @@ public fun > NDAlgebra.Companion.field( vararg shape: Int, ): BufferedNDField = BufferedNDField(shape, field, bufferFactory) +@Suppress("UNCHECKED_CAST") public inline fun > NDAlgebra.Companion.auto( field: A, vararg shape: Int, -): BufferedNDField = BufferedNDField(shape, field, Buffer.Companion::auto) +): NDField = when (field) { + RealField -> RealNDField(shape) as NDField + else -> BufferedNDField(shape, field, Buffer.Companion::auto) +} public inline fun , R> A.ndField( noinline bufferFactory: BufferFactory, diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ComplexNDField.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ComplexNDField.kt index dbcce5440..074a1185b 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ComplexNDField.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ComplexNDField.kt @@ -11,7 +11,7 @@ import kotlin.contracts.contract * An optimized nd-field for complex numbers */ @OptIn(UnstableKMathAPI::class) -public open class ComplexNDField( +public class ComplexNDField( shape: IntArray, ) : BufferedNDField(shape, ComplexField, Buffer.Companion::complex), RingWithNumbers>, diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt index b96ee0e9b..91b5500cd 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt @@ -24,37 +24,46 @@ public class RealNDField( return produce { d } } + override val NDStructure.buffer: RealBuffer + get() = when { + !shape.contentEquals(this@RealNDField.shape) -> throw ShapeMismatchException( + this@RealNDField.shape, + shape + ) + this is NDBuffer && this.strides == this@RealNDField.strides -> this.buffer as RealBuffer + else -> RealBuffer(strides.linearSize) { offset -> get(strides.index(offset)) } + } + @Suppress("OVERRIDE_BY_INLINE") override inline fun map( arg: NDStructure, transform: RealField.(Double) -> Double, ): NDBuffer { - val argAsBuffer = arg.ndBuffer - val buffer = RealBuffer(strides.linearSize) { offset -> RealField.transform(argAsBuffer.buffer[offset]) } + val buffer = RealBuffer(strides.linearSize) { offset -> RealField.transform(arg.buffer.array[offset]) } return NDBuffer(strides, buffer) } @Suppress("OVERRIDE_BY_INLINE") override inline fun produce(initializer: RealField.(IntArray) -> Double): NDBuffer { - val buffer = RealBuffer(strides.linearSize) { offset -> elementContext.initializer(strides.index(offset)) } - return NDBuffer(strides, buffer) + val array = DoubleArray(strides.linearSize) { offset -> + val index = strides.index(offset) + RealField.initializer(index) + } + return NDBuffer(strides, RealBuffer(array)) } @Suppress("OVERRIDE_BY_INLINE") override inline fun mapIndexed( arg: NDStructure, transform: RealField.(index: IntArray, Double) -> Double, - ): NDBuffer { - val argAsBuffer = arg.ndBuffer - return NDBuffer( - strides, - RealBuffer(strides.linearSize) { offset -> - elementContext.transform( - strides.index(offset), - argAsBuffer.buffer[offset] - ) - }) - } + ): NDBuffer = NDBuffer( + strides, + buffer = RealBuffer(strides.linearSize) { offset -> + RealField.transform( + strides.index(offset), + arg.buffer.array[offset] + ) + }) @Suppress("OVERRIDE_BY_INLINE") override inline fun combine( @@ -62,10 +71,8 @@ public class RealNDField( b: NDStructure, transform: RealField.(Double, Double) -> Double, ): NDBuffer { - val aBuffer = a.ndBuffer - val bBuffer = b.ndBuffer val buffer = RealBuffer(strides.linearSize) { offset -> - elementContext.transform(aBuffer.buffer[offset], bBuffer.buffer[offset]) + RealField.transform(a.buffer.array[offset], b.buffer.array[offset]) } return NDBuffer(strides, buffer) } @@ -91,19 +98,6 @@ public class RealNDField( override fun atanh(arg: NDStructure): NDBuffer = map(arg) { atanh(it) } } - -/** - * Fast element production using function inlining - */ -public inline fun BufferedNDField.produceInline(crossinline initializer: RealField.(IntArray) -> Double): NDBuffer { - contract { callsInPlace(initializer, InvocationKind.EXACTLY_ONCE) } - val array = DoubleArray(strides.linearSize) { offset -> - val index = strides.index(offset) - RealField.initializer(index) - } - return NDBuffer(strides, RealBuffer(array)) -} - public fun NDAlgebra.Companion.real(vararg shape: Int): RealNDField = RealNDField(shape) /** diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ShortNDRing.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ShortNDRing.kt index 8663c4249..7ffe688cb 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ShortNDRing.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ShortNDRing.kt @@ -9,7 +9,7 @@ import kotlin.contracts.InvocationKind import kotlin.contracts.contract @OptIn(UnstableKMathAPI::class) -public open class ShortNDRing( +public class ShortNDRing( shape: IntArray, ) : BufferedNDRing(shape, ShortRing, Buffer.Companion::auto), RingWithNumbers> { diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt index 48fba45d9..42a643db1 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt @@ -58,7 +58,7 @@ public interface Structure2D : NDStructure { rows: Int, columns: Int, crossinline init: (i: Int, j: Int) -> Double, - ): Matrix = NDAlgebra.real(rows, columns).produceInline { (i, j) -> + ): Matrix = NDAlgebra.real(rows, columns).produce { (i, j) -> init(i, j) }.as2D() } diff --git a/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NumberNDFieldTest.kt b/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NumberNDFieldTest.kt index b90e0f07f..4f0c9fc6d 100644 --- a/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NumberNDFieldTest.kt +++ b/kmath-core/src/commonTest/kotlin/kscience/kmath/structures/NumberNDFieldTest.kt @@ -11,8 +11,8 @@ import kotlin.test.assertEquals @Suppress("UNUSED_VARIABLE") class NumberNDFieldTest { val algebra = NDAlgebra.real(3,3) - val array1 = algebra.produceInline { (i, j) -> (i + j).toDouble() } - val array2 = algebra.produceInline { (i, j) -> (i - j).toDouble() } + val array1 = algebra.produce { (i, j) -> (i + j).toDouble() } + val array2 = algebra.produce { (i, j) -> (i - j).toDouble() } @Test fun testSum() { diff --git a/kmath-viktor/src/main/kotlin/kscience/kmath/viktor/ViktorNDStructure.kt b/kmath-viktor/src/main/kotlin/kscience/kmath/viktor/ViktorNDStructure.kt index a6c4f3ce0..f91359a0c 100644 --- a/kmath-viktor/src/main/kotlin/kscience/kmath/viktor/ViktorNDStructure.kt +++ b/kmath-viktor/src/main/kotlin/kscience/kmath/viktor/ViktorNDStructure.kt @@ -93,4 +93,6 @@ public class ViktorNDField(public override val shape: IntArray) : NDField.plus(arg: Double): ViktorNDStructure = (f64Buffer.plus(arg)).asStructure() -} \ No newline at end of file +} + +public fun ViktorNDField(vararg shape: Int): ViktorNDField = ViktorNDField(shape) \ No newline at end of file From 3bbb39f30d423e0889133befa9db2d4b7cb07677 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 24 Jan 2021 10:26:56 +0300 Subject: [PATCH 11/23] cleanup parallel field example --- .../kscience/kmath/structures/ParallelRealNDField.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/src/main/kotlin/kscience/kmath/structures/ParallelRealNDField.kt b/examples/src/main/kotlin/kscience/kmath/structures/ParallelRealNDField.kt index bce625f7f..e13f5dd47 100644 --- a/examples/src/main/kotlin/kscience/kmath/structures/ParallelRealNDField.kt +++ b/examples/src/main/kotlin/kscience/kmath/structures/ParallelRealNDField.kt @@ -12,12 +12,14 @@ import java.util.stream.IntStream * A demonstration implementation of NDField over Real using Java [DoubleStream] for parallel execution */ @OptIn(UnstableKMathAPI::class) -public class StreamRealNDField( - shape: IntArray, -) : BufferedNDField(shape, RealField, Buffer.Companion::real), +class StreamRealNDField( + override val shape: IntArray, +) : NDField, RingWithNumbers>, ExtendedField> { + private val strides = DefaultStrides(shape) + override val elementContext: RealField get() = RealField override val zero: NDBuffer by lazy { produce { zero } } override val one: NDBuffer by lazy { produce { one } } @@ -26,7 +28,7 @@ public class StreamRealNDField( return produce { d } } - override val NDStructure.buffer: RealBuffer + private val NDStructure.buffer: RealBuffer get() = when { !shape.contentEquals(this@StreamRealNDField.shape) -> throw ShapeMismatchException( this@StreamRealNDField.shape, From aff7bbab4131380929fb906ec57901b776c395e3 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 24 Jan 2021 17:07:19 +0300 Subject: [PATCH 12/23] Matrix performance optimization --- .../kscience/kmath/benchmarks/DotBenchmark.kt | 15 ++--- .../benchmarks/LinearAlgebraBenchmark.kt | 4 +- .../kmath/benchmarks/ViktorBenchmark.kt | 6 +- .../kmath/benchmarks/ViktorLogBenchmark.kt | 11 +++- .../kmath/structures/ParallelRealNDField.kt | 40 +++++++------ .../kscience/kmath/linear/BufferMatrix.kt | 57 +++++++++++++++++++ .../kscience/kmath/linear/MatrixWrapper.kt | 6 -- .../kmath/linear/RealMatrixContext.kt | 28 +++++---- .../kscience/kmath/nd/BufferNDAlgebra.kt | 10 ++-- .../kscience/kmath/nd/ComplexNDField.kt | 30 +++++----- .../kotlin/kscience/kmath/nd/NDAlgebra.kt | 24 ++++---- .../kotlin/kscience/kmath/nd/RealNDField.kt | 46 +++++++-------- .../kotlin/kscience/kmath/nd/Structure2D.kt | 7 ++- .../kotlin/kscience/kmath/real/RealMatrix.kt | 2 +- .../kscience.kmath.nd4j/Nd4jArrayAlgebra.kt | 11 ++-- .../kmath/nd4j/Nd4jArrayAlgebraTest.kt | 4 +- .../kmath/viktor/ViktorNDStructure.kt | 43 ++++++++++---- 17 files changed, 215 insertions(+), 129 deletions(-) diff --git a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/DotBenchmark.kt b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/DotBenchmark.kt index cc8043664..2256a3e02 100644 --- a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/DotBenchmark.kt +++ b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/DotBenchmark.kt @@ -31,38 +31,35 @@ class DotBenchmark { } @Benchmark - fun commonsMathMultiplication() { + fun cmDot() { CMMatrixContext { cmMatrix1 dot cmMatrix2 } } @Benchmark - fun ejmlMultiplication() { + fun ejmlDot() { EjmlMatrixContext { ejmlMatrix1 dot ejmlMatrix2 } } @Benchmark - fun ejmlMultiplicationwithConversion() { + fun ejmlDotWithConversion() { EjmlMatrixContext { - val ejmlMatrix1 = matrix1.toEjml() - val ejmlMatrix2 = matrix2.toEjml() - - ejmlMatrix1 dot ejmlMatrix2 + matrix1 dot matrix2 } } @Benchmark - fun bufferedMultiplication() { + fun bufferedDot() { BufferMatrixContext(RealField, Buffer.Companion::real).invoke { matrix1 dot matrix2 } } @Benchmark - fun realMultiplication() { + fun realDot() { RealMatrixContext { matrix1 dot matrix2 } diff --git a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/LinearAlgebraBenchmark.kt b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/LinearAlgebraBenchmark.kt index 9e5f76112..4a06724ec 100644 --- a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/LinearAlgebraBenchmark.kt +++ b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/LinearAlgebraBenchmark.kt @@ -26,7 +26,9 @@ class LinearAlgebraBenchmark { @Benchmark fun kmathLUPInversion() { - MatrixContext.real.inverseWithLUP(matrix) + MatrixContext.real{ + inverseWithLUP(matrix) + } } @Benchmark diff --git a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorBenchmark.kt b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorBenchmark.kt index 85c5d8289..e246936f0 100644 --- a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorBenchmark.kt +++ b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorBenchmark.kt @@ -23,7 +23,7 @@ internal class ViktorBenchmark { fun automaticFieldAddition() { autoField { var res: NDStructure = one - repeat(n) { res += one } + repeat(n) { res += 1.0 } } } @@ -31,7 +31,7 @@ internal class ViktorBenchmark { fun realFieldAddition() { realField { var res: NDStructure = one - repeat(n) { res += one } + repeat(n) { res += 1.0 } } } @@ -39,7 +39,7 @@ internal class ViktorBenchmark { fun viktorFieldAddition() { viktorField { var res = one - repeat(n) { res += one } + repeat(n) { res += 1.0 } } } diff --git a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorLogBenchmark.kt b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorLogBenchmark.kt index e841c53c9..b9c39b088 100644 --- a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorLogBenchmark.kt +++ b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/ViktorLogBenchmark.kt @@ -15,7 +15,7 @@ internal class ViktorLogBenchmark { final val n: Int = 100 // automatically build context most suited for given type. - final val autoField: BufferedNDField = NDAlgebra.auto(RealField, dim, dim) + final val autoField: NDField = NDAlgebra.auto(RealField, dim, dim) final val realField: RealNDField = NDAlgebra.real(dim, dim) final val viktorField: ViktorNDField = ViktorNDField(intArrayOf(dim, dim)) @@ -29,6 +29,15 @@ internal class ViktorLogBenchmark { } } + @Benchmark + fun viktorFieldLog() { + viktorField { + val fortyTwo = produce { 42.0 } + var res = one + repeat(n) { res = ln(fortyTwo) } + } + } + @Benchmark fun rawViktorLog() { val fortyTwo = F64Array.full(dim, dim, init = 42.0) diff --git a/examples/src/main/kotlin/kscience/kmath/structures/ParallelRealNDField.kt b/examples/src/main/kotlin/kscience/kmath/structures/ParallelRealNDField.kt index e13f5dd47..48286c140 100644 --- a/examples/src/main/kotlin/kscience/kmath/structures/ParallelRealNDField.kt +++ b/examples/src/main/kotlin/kscience/kmath/structures/ParallelRealNDField.kt @@ -48,22 +48,20 @@ class StreamRealNDField( return NDBuffer(strides, array.asBuffer()) } - override fun map( - arg: NDStructure, + override fun NDStructure.map( transform: RealField.(Double) -> Double, ): NDBuffer { - val array = Arrays.stream(arg.buffer.array).parallel().map { RealField.transform(it) }.toArray() + val array = Arrays.stream(buffer.array).parallel().map { RealField.transform(it) }.toArray() return NDBuffer(strides, array.asBuffer()) } - override fun mapIndexed( - arg: NDStructure, + override fun NDStructure.mapIndexed( transform: RealField.(index: IntArray, Double) -> Double, ): NDBuffer { val array = IntStream.range(0, strides.linearSize).parallel().mapToDouble { offset -> RealField.transform( strides.index(offset), - arg.buffer.array[offset] + buffer.array[offset] ) }.toArray() @@ -81,25 +79,25 @@ class StreamRealNDField( return NDBuffer(strides, array.asBuffer()) } - override fun power(arg: NDStructure, pow: Number): NDBuffer = map(arg) { power(it, pow) } + override fun power(arg: NDStructure, pow: Number): NDBuffer = arg.map() { power(it, pow) } - override fun exp(arg: NDStructure): NDBuffer = map(arg) { exp(it) } + override fun exp(arg: NDStructure): NDBuffer = arg.map() { exp(it) } - override fun ln(arg: NDStructure): NDBuffer = map(arg) { ln(it) } + override fun ln(arg: NDStructure): NDBuffer = arg.map() { ln(it) } - override fun sin(arg: NDStructure): NDBuffer = map(arg) { sin(it) } - override fun cos(arg: NDStructure): NDBuffer = map(arg) { cos(it) } - override fun tan(arg: NDStructure): NDBuffer = map(arg) { tan(it) } - override fun asin(arg: NDStructure): NDBuffer = map(arg) { asin(it) } - override fun acos(arg: NDStructure): NDBuffer = map(arg) { acos(it) } - override fun atan(arg: NDStructure): NDBuffer = map(arg) { atan(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 sinh(arg: NDStructure): NDBuffer = map(arg) { sinh(it) } - override fun cosh(arg: NDStructure): NDBuffer = map(arg) { cosh(it) } - override fun tanh(arg: NDStructure): NDBuffer = map(arg) { tanh(it) } - override fun asinh(arg: NDStructure): NDBuffer = map(arg) { asinh(it) } - override fun acosh(arg: NDStructure): NDBuffer = map(arg) { acosh(it) } - override fun atanh(arg: NDStructure): NDBuffer = map(arg) { atanh(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) } } fun NDAlgebra.Companion.realWithStream(vararg shape: Int): StreamRealNDField = StreamRealNDField(shape) \ No newline at end of file diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/BufferMatrix.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/BufferMatrix.kt index bcd1c9976..6a66e91c8 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/BufferMatrix.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/BufferMatrix.kt @@ -3,6 +3,7 @@ package kscience.kmath.linear import kscience.kmath.nd.NDStructure import kscience.kmath.nd.Structure2D import kscience.kmath.operations.Ring +import kscience.kmath.operations.invoke import kscience.kmath.structures.Buffer import kscience.kmath.structures.BufferFactory import kscience.kmath.structures.asSequence @@ -28,6 +29,62 @@ public class BufferMatrixContext>( public override fun point(size: Int, initializer: (Int) -> T): Point = bufferFactory(size, initializer) + private fun Matrix.toBufferMatrix(): BufferMatrix = if (this is BufferMatrix) this else { + produce(rowNum, colNum) { i, j -> get(i, j) } + } + + public fun one(rows: Int, columns: Int): Matrix = VirtualMatrix(rows, columns) { i, j -> + if (i == j) 1.0 else 0.0 + } + DiagonalFeature + + public override infix fun Matrix.dot(other: Matrix): BufferMatrix { + require(colNum == other.rowNum) { "Matrix dot operation dimension mismatch: ($rowNum, $colNum) x (${other.rowNum}, ${other.colNum})" } + val bufferMatrix = toBufferMatrix() + val otherBufferMatrix = other.toBufferMatrix() + return elementContext { + produce(rowNum, other.colNum) { i, j -> + var res = one + for (l in 0 until colNum) { + res += bufferMatrix[i, l] * otherBufferMatrix[l, j] + } + res + } + } + } + + public override infix fun Matrix.dot(vector: Point): Point { + require(colNum == vector.size) { "Matrix dot vector operation dimension mismatch: ($rowNum, $colNum) x (${vector.size})" } + val bufferMatrix = toBufferMatrix() + return elementContext { + bufferFactory(rowNum) { i -> + var res = one + for (j in 0 until colNum) { + res += bufferMatrix[i, j] * vector[j] + } + res + } + } + } + + override fun add(a: Matrix, b: Matrix): BufferMatrix { + require(a.rowNum == b.rowNum) { "Row number mismatch in matrix addition. Left side: ${a.rowNum}, right side: ${b.rowNum}" } + require(a.colNum == b.colNum) { "Column number mismatch in matrix addition. Left side: ${a.colNum}, right side: ${b.colNum}" } + val aBufferMatrix = a.toBufferMatrix() + val bBufferMatrix = b.toBufferMatrix() + return elementContext { + produce(a.rowNum, a.colNum) { i, j -> + aBufferMatrix[i, j] + bBufferMatrix[i, j] + } + } + } + + override fun multiply(a: Matrix, k: Number): BufferMatrix { + val aBufferMatrix = a.toBufferMatrix() + return elementContext { + produce(a.rowNum, a.colNum) { i, j -> aBufferMatrix[i, j] * k.toDouble() } + } + } + public companion object } diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixWrapper.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixWrapper.kt index 726a91e97..df967e3c1 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixWrapper.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/MatrixWrapper.kt @@ -60,12 +60,6 @@ public operator fun Matrix.plus(newFeatures: Collection Double, -): BufferMatrix = MatrixContext.real.produce(rows, columns, initializer) - /** * Build a square matrix from given elements. */ diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/RealMatrixContext.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/RealMatrixContext.kt index 3d544a9af..da795f56b 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/RealMatrixContext.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/RealMatrixContext.kt @@ -2,10 +2,9 @@ package kscience.kmath.linear import kscience.kmath.structures.RealBuffer -@Suppress("OVERRIDE_BY_INLINE") public object RealMatrixContext : MatrixContext> { - public override inline fun produce( + public override fun produce( rows: Int, columns: Int, initializer: (i: Int, j: Int) -> Double, @@ -14,7 +13,7 @@ public object RealMatrixContext : MatrixContext> { return BufferMatrix(rows, columns, buffer) } - private fun Matrix.wrap(): BufferMatrix = if (this is BufferMatrix) this else { + public fun Matrix.toBufferMatrix(): BufferMatrix = if (this is BufferMatrix) this else { produce(rowNum, colNum) { i, j -> get(i, j) } } @@ -24,10 +23,12 @@ public object RealMatrixContext : MatrixContext> { public override infix fun Matrix.dot(other: Matrix): BufferMatrix { require(colNum == other.rowNum) { "Matrix dot operation dimension mismatch: ($rowNum, $colNum) x (${other.rowNum}, ${other.colNum})" } + val bufferMatrix = toBufferMatrix() + val otherBufferMatrix = other.toBufferMatrix() return produce(rowNum, other.colNum) { i, j -> var res = 0.0 for (l in 0 until colNum) { - res += get(i, l) * other.get(l, j) + res += bufferMatrix[i, l] * otherBufferMatrix[l, j] } res } @@ -35,10 +36,11 @@ public object RealMatrixContext : MatrixContext> { public override infix fun Matrix.dot(vector: Point): Point { require(colNum == vector.size) { "Matrix dot vector operation dimension mismatch: ($rowNum, $colNum) x (${vector.size})" } + val bufferMatrix = toBufferMatrix() return RealBuffer(rowNum) { i -> var res = 0.0 for (j in 0 until colNum) { - res += get(i, j) * vector[j] + res += bufferMatrix[i, j] * vector[j] } res } @@ -47,17 +49,23 @@ public object RealMatrixContext : MatrixContext> { override fun add(a: Matrix, b: Matrix): BufferMatrix { require(a.rowNum == b.rowNum) { "Row number mismatch in matrix addition. Left side: ${a.rowNum}, right side: ${b.rowNum}" } require(a.colNum == b.colNum) { "Column number mismatch in matrix addition. Left side: ${a.colNum}, right side: ${b.colNum}" } + val aBufferMatrix = a.toBufferMatrix() + val bBufferMatrix = b.toBufferMatrix() return produce(a.rowNum, a.colNum) { i, j -> - a[i, j] + b[i, j] + aBufferMatrix[i, j] + bBufferMatrix[i, j] } } - override fun Matrix.times(value: Double): BufferMatrix = - produce(rowNum, colNum) { i, j -> get(i, j) * value } + override fun Matrix.times(value: Double): BufferMatrix { + val bufferMatrix = toBufferMatrix() + return produce(rowNum, colNum) { i, j -> bufferMatrix[i, j] * value } + } - override fun multiply(a: Matrix, k: Number): BufferMatrix = - produce(a.rowNum, a.colNum) { i, j -> a[i, j] * k.toDouble() } + override fun multiply(a: Matrix, k: Number): BufferMatrix { + val aBufferMatrix = a.toBufferMatrix() + return produce(a.rowNum, a.colNum) { i, j -> aBufferMatrix[i, j] * k.toDouble() } + } } diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt index 93add36eb..2d72162a6 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt @@ -28,24 +28,24 @@ public interface BufferNDAlgebra : NDAlgebra { else -> bufferFactory(strides.linearSize) { offset -> get(strides.index(offset)) } } - override fun map(arg: NDStructure, transform: C.(T) -> T): NDBuffer { + override fun NDStructure.map(transform: C.(T) -> T): NDBuffer { val buffer = bufferFactory(strides.linearSize) { offset -> - elementContext.transform(arg.buffer[offset]) + elementContext.transform(buffer[offset]) } return NDBuffer(strides, buffer) } - override fun mapIndexed(arg: NDStructure, transform: C.(index: IntArray, T) -> T): NDStructure { + override fun NDStructure.mapIndexed(transform: C.(index: IntArray, T) -> T): NDBuffer { val buffer = bufferFactory(strides.linearSize) { offset -> elementContext.transform( strides.index(offset), - arg.buffer[offset] + buffer[offset] ) } return NDBuffer(strides, buffer) } - override fun combine(a: NDStructure, b: NDStructure, transform: C.(T, T) -> T): NDStructure { + override fun combine(a: NDStructure, b: NDStructure, transform: C.(T, T) -> T): NDBuffer { val buffer = bufferFactory(strides.linearSize) { offset -> elementContext.transform(a.buffer[offset], b.buffer[offset]) } diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ComplexNDField.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ComplexNDField.kt index 074a1185b..00e79f2e4 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ComplexNDField.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/ComplexNDField.kt @@ -70,25 +70,25 @@ public class ComplexNDField( // return BufferedNDFieldElement(this, buffer) // } - override fun power(arg: NDStructure, pow: Number): NDBuffer = map(arg) { power(it, pow) } + override fun power(arg: NDStructure, pow: Number): NDBuffer = arg.map() { power(it, pow) } - override fun exp(arg: NDStructure): NDBuffer = map(arg) { exp(it) } + override fun exp(arg: NDStructure): NDBuffer = arg.map() { exp(it) } - override fun ln(arg: NDStructure): NDBuffer = map(arg) { ln(it) } + override fun ln(arg: NDStructure): NDBuffer = arg.map() { ln(it) } - override fun sin(arg: NDStructure): NDBuffer = map(arg) { sin(it) } - override fun cos(arg: NDStructure): NDBuffer = map(arg) { cos(it) } - override fun tan(arg: NDStructure): NDBuffer = map(arg) { tan(it) } - override fun asin(arg: NDStructure): NDBuffer = map(arg) { asin(it) } - override fun acos(arg: NDStructure): NDBuffer = map(arg) { acos(it) } - override fun atan(arg: NDStructure): NDBuffer = map(arg) { atan(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 sinh(arg: NDStructure): NDBuffer = map(arg) { sinh(it) } - override fun cosh(arg: NDStructure): NDBuffer = map(arg) { cosh(it) } - override fun tanh(arg: NDStructure): NDBuffer = map(arg) { tanh(it) } - override fun asinh(arg: NDStructure): NDBuffer = map(arg) { asinh(it) } - override fun acosh(arg: NDStructure): NDBuffer = map(arg) { acosh(it) } - override fun atanh(arg: NDStructure): NDBuffer = map(arg) { atanh(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) } } diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDAlgebra.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDAlgebra.kt index facc7eb38..749fb1a13 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDAlgebra.kt @@ -40,12 +40,12 @@ public interface NDAlgebra { /** * Maps elements from one structure to another one by applying [transform] to them. */ - public fun map(arg: NDStructure, transform: C.(T) -> T): NDStructure + public fun NDStructure.map(transform: C.(T) -> T): NDStructure /** * Maps elements from one structure to another one by applying [transform] to them alongside with their indices. */ - public fun mapIndexed(arg: NDStructure, transform: C.(index: IntArray, T) -> T): NDStructure + public fun NDStructure.mapIndexed(transform: C.(index: IntArray, T) -> T): NDStructure /** * Combines two structures into one. @@ -56,7 +56,7 @@ public interface NDAlgebra { * Element-wise invocation of function working on [T] on a [NDStructure]. */ public operator fun Function1.invoke(structure: NDStructure): NDStructure = - map(structure) { value -> this@invoke(value) } + structure.map() { value -> this@invoke(value) } public companion object } @@ -109,7 +109,7 @@ public interface NDSpace> : Space>, NDAlgebra, k: Number): NDStructure = map(a) { multiply(it, k) } + public override fun multiply(a: NDStructure, k: Number): NDStructure = a.map() { multiply(it, k) } // TODO move to extensions after KEEP-176 @@ -120,7 +120,7 @@ public interface NDSpace> : Space>, NDAlgebra.plus(arg: T): NDStructure = map(this) { value -> add(arg, value) } + public operator fun NDStructure.plus(arg: T): NDStructure = this.map() { value -> add(arg, value) } /** * Subtracts an element from ND structure of it. @@ -129,7 +129,7 @@ public interface NDSpace> : Space>, NDAlgebra.minus(arg: T): NDStructure = map(this) { value -> add(arg, -value) } + public operator fun NDStructure.minus(arg: T): NDStructure = this.map() { value -> add(arg, -value) } /** * Adds an element to ND structure of it. @@ -138,7 +138,7 @@ public interface NDSpace> : Space>, NDAlgebra): NDStructure = map(arg) { value -> add(this@plus, value) } + public operator fun T.plus(arg: NDStructure): NDStructure = arg.map() { value -> add(this@plus, value) } /** * Subtracts an ND structure from an element of it. @@ -147,7 +147,7 @@ public interface NDSpace> : Space>, NDAlgebra): NDStructure = map(arg) { value -> add(-this@minus, value) } + public operator fun T.minus(arg: NDStructure): NDStructure = arg.map() { value -> add(-this@minus, value) } public companion object } @@ -179,7 +179,7 @@ public interface NDRing> : Ring>, NDSpace { * @param arg the multiplier. * @return the product. */ - public operator fun NDStructure.times(arg: T): NDStructure = map(this) { value -> multiply(arg, value) } + public operator fun NDStructure.times(arg: T): NDStructure = this.map() { value -> multiply(arg, value) } /** * Multiplies an element by a ND structure of it. @@ -188,7 +188,7 @@ public interface NDRing> : Ring>, NDSpace { * @param arg the multiplier. * @return the product. */ - public operator fun T.times(arg: NDStructure): NDStructure = map(arg) { value -> multiply(this@times, value) } + public operator fun T.times(arg: NDStructure): NDStructure = arg.map() { value -> multiply(this@times, value) } public companion object } @@ -219,7 +219,7 @@ public interface NDField> : Field>, NDRing * @param arg the divisor. * @return the quotient. */ - public operator fun NDStructure.div(arg: T): NDStructure = map(this) { value -> divide(arg, value) } + public operator fun NDStructure.div(arg: T): NDStructure = this.map() { value -> divide(arg, value) } /** * Divides an element by an ND structure of it. @@ -228,7 +228,7 @@ public interface NDField> : Field>, NDRing * @param arg the divisor. * @return the quotient. */ - public operator fun T.div(arg: NDStructure): NDStructure = map(arg) { divide(it, this@div) } + public operator fun T.div(arg: NDStructure): NDStructure = arg.map() { divide(it, this@div) } // @ThreadLocal // public companion object { diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt index 91b5500cd..8e0f9e171 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/RealNDField.kt @@ -35,16 +35,15 @@ public class RealNDField( } @Suppress("OVERRIDE_BY_INLINE") - override inline fun map( - arg: NDStructure, + override inline fun NDStructure.map( transform: RealField.(Double) -> Double, ): NDBuffer { - val buffer = RealBuffer(strides.linearSize) { offset -> RealField.transform(arg.buffer.array[offset]) } + val buffer = RealBuffer(strides.linearSize) { offset -> RealField.transform(buffer.array[offset]) } return NDBuffer(strides, buffer) } @Suppress("OVERRIDE_BY_INLINE") - override inline fun produce(initializer: RealField.(IntArray) -> Double): NDBuffer { + override inline fun produce(initializer: RealField.(IntArray) -> Double): NDBuffer { val array = DoubleArray(strides.linearSize) { offset -> val index = strides.index(offset) RealField.initializer(index) @@ -53,15 +52,14 @@ public class RealNDField( } @Suppress("OVERRIDE_BY_INLINE") - override inline fun mapIndexed( - arg: NDStructure, + override inline fun NDStructure.mapIndexed( transform: RealField.(index: IntArray, Double) -> Double, ): NDBuffer = NDBuffer( strides, buffer = RealBuffer(strides.linearSize) { offset -> RealField.transform( strides.index(offset), - arg.buffer.array[offset] + buffer.array[offset] ) }) @@ -70,32 +68,32 @@ public class RealNDField( a: NDStructure, b: NDStructure, transform: RealField.(Double, Double) -> Double, - ): NDBuffer { + ): NDBuffer { val buffer = RealBuffer(strides.linearSize) { offset -> RealField.transform(a.buffer.array[offset], b.buffer.array[offset]) } - return NDBuffer(strides, buffer) + return NDBuffer(strides, buffer) } - override fun power(arg: NDStructure, pow: Number): NDBuffer = map(arg) { power(it, pow) } + override fun power(arg: NDStructure, pow: Number): NDBuffer = arg.map { power(it, pow) } - override fun exp(arg: NDStructure): NDBuffer = map(arg) { exp(it) } + override fun exp(arg: NDStructure): NDBuffer = arg.map { exp(it) } - override fun ln(arg: NDStructure): NDBuffer = map(arg) { ln(it) } + override fun ln(arg: NDStructure): NDBuffer = arg.map { ln(it) } - override fun sin(arg: NDStructure): NDBuffer = map(arg) { sin(it) } - override fun cos(arg: NDStructure): NDBuffer = map(arg) { cos(it) } - override fun tan(arg: NDStructure): NDBuffer = map(arg) { tan(it) } - override fun asin(arg: NDStructure): NDBuffer = map(arg) { asin(it) } - override fun acos(arg: NDStructure): NDBuffer = map(arg) { acos(it) } - override fun atan(arg: NDStructure): NDBuffer = map(arg) { atan(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 sinh(arg: NDStructure): NDBuffer = map(arg) { sinh(it) } - override fun cosh(arg: NDStructure): NDBuffer = map(arg) { cosh(it) } - override fun tanh(arg: NDStructure): NDBuffer = map(arg) { tanh(it) } - override fun asinh(arg: NDStructure): NDBuffer = map(arg) { asinh(it) } - override fun acosh(arg: NDStructure): NDBuffer = map(arg) { acosh(it) } - override fun atanh(arg: NDStructure): NDBuffer = map(arg) { atanh(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) } } public fun NDAlgebra.Companion.real(vararg shape: Int): RealNDField = RealNDField(shape) diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt index 42a643db1..32e0704fc 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/Structure2D.kt @@ -1,6 +1,7 @@ package kscience.kmath.nd -import kscience.kmath.linear.Matrix +import kscience.kmath.linear.BufferMatrix +import kscience.kmath.linear.RealMatrixContext import kscience.kmath.structures.Buffer import kscience.kmath.structures.VirtualBuffer @@ -58,9 +59,9 @@ public interface Structure2D : NDStructure { rows: Int, columns: Int, crossinline init: (i: Int, j: Int) -> Double, - ): Matrix = NDAlgebra.real(rows, columns).produce { (i, j) -> + ): BufferMatrix = RealMatrixContext.produce(rows,columns) { i, j -> init(i, j) - }.as2D() + } } } diff --git a/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt b/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt index e7bde9980..044cafb0b 100644 --- a/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt +++ b/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt @@ -140,7 +140,7 @@ public fun RealMatrix.min(): Double? = elements().map { (_, value) -> value }.mi public fun RealMatrix.max(): Double? = elements().map { (_, value) -> value }.maxOrNull() public fun RealMatrix.average(): Double = elements().map { (_, value) -> value }.average() -public inline fun RealMatrix.map(transform: (Double) -> Double): RealMatrix = +public inline fun RealMatrix.map(crossinline transform: (Double) -> Double): RealMatrix = MatrixContext.real.produce(rowNum, colNum) { i, j -> transform(get(i, j)) } diff --git a/kmath-nd4j/src/main/kotlin/kscience.kmath.nd4j/Nd4jArrayAlgebra.kt b/kmath-nd4j/src/main/kotlin/kscience.kmath.nd4j/Nd4jArrayAlgebra.kt index 91d45dccd..b9c95034e 100644 --- a/kmath-nd4j/src/main/kotlin/kscience.kmath.nd4j/Nd4jArrayAlgebra.kt +++ b/kmath-nd4j/src/main/kotlin/kscience.kmath.nd4j/Nd4jArrayAlgebra.kt @@ -44,18 +44,17 @@ public interface Nd4jArrayAlgebra : NDAlgebra { return struct } - public override fun map(arg: NDStructure, transform: C.(T) -> T): Nd4jArrayStructure { - val newStruct = arg.ndArray.dup().wrap() + public override fun NDStructure.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 mapIndexed( - arg: NDStructure, + public override fun NDStructure.mapIndexed( transform: C.(index: IntArray, T) -> T, ): Nd4jArrayStructure { - val new = Nd4j.create(*shape).wrap() - new.indicesIterator().forEach { idx -> new[idx] = elementContext.transform(idx, arg[idx]) } + val new = Nd4j.create(*this@Nd4jArrayAlgebra.shape).wrap() + new.indicesIterator().forEach { idx -> new[idx] = elementContext.transform(idx, this[idx]) } return new } diff --git a/kmath-nd4j/src/test/kotlin/kscience/kmath/nd4j/Nd4jArrayAlgebraTest.kt b/kmath-nd4j/src/test/kotlin/kscience/kmath/nd4j/Nd4jArrayAlgebraTest.kt index 650d5670c..04959d290 100644 --- a/kmath-nd4j/src/test/kotlin/kscience/kmath/nd4j/Nd4jArrayAlgebraTest.kt +++ b/kmath-nd4j/src/test/kotlin/kscience/kmath/nd4j/Nd4jArrayAlgebraTest.kt @@ -1,7 +1,7 @@ package kscience.kmath.nd4j -import org.nd4j.linalg.factory.Nd4j import kscience.kmath.operations.invoke +import org.nd4j.linalg.factory.Nd4j import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.fail @@ -20,7 +20,7 @@ internal class Nd4jArrayAlgebraTest { @Test fun testMap() { - val res = (IntNd4jArrayRing(intArrayOf(2, 2))) { map(one) { it + it * 2 } } + val res = (IntNd4jArrayRing(intArrayOf(2, 2))) { one.map() { it + it * 2 } } val expected = (Nd4j.create(2, 2) ?: fail()).asIntStructure() expected[intArrayOf(0, 0)] = 3 expected[intArrayOf(0, 1)] = 3 diff --git a/kmath-viktor/src/main/kotlin/kscience/kmath/viktor/ViktorNDStructure.kt b/kmath-viktor/src/main/kotlin/kscience/kmath/viktor/ViktorNDStructure.kt index f91359a0c..d3e4806b0 100644 --- a/kmath-viktor/src/main/kotlin/kscience/kmath/viktor/ViktorNDStructure.kt +++ b/kmath-viktor/src/main/kotlin/kscience/kmath/viktor/ViktorNDStructure.kt @@ -1,7 +1,10 @@ package kscience.kmath.viktor +import kscience.kmath.misc.UnstableKMathAPI import kscience.kmath.nd.* +import kscience.kmath.operations.ExtendedField import kscience.kmath.operations.RealField +import kscience.kmath.operations.RingWithNumbers import org.jetbrains.bio.viktor.F64Array @Suppress("OVERRIDE_BY_INLINE", "NOTHING_TO_INLINE") @@ -20,8 +23,10 @@ public inline class ViktorNDStructure(public val f64Buffer: F64Array) : MutableN 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 { +public class ViktorNDField(public override val shape: IntArray) : NDField, + RingWithNumbers>, ExtendedField> { public val NDStructure.f64Buffer: F64Array get() = when { @@ -50,26 +55,25 @@ public class ViktorNDField(public override val shape: IntArray) : NDField, transform: RealField.(Double) -> Double): ViktorNDStructure = - F64Array(*shape).apply { + 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(arg[index]), indices = index) + set(value = RealField.transform(this@map[index]), indices = index) } }.asStructure() - public override fun mapIndexed( - arg: NDStructure, - transform: RealField.(index: IntArray, Double) -> Double - ): ViktorNDStructure = F64Array(*shape).apply { + 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, arg[index]), indices = 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 + 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) @@ -93,6 +97,25 @@ public class ViktorNDField(public override val shape: IntArray) : NDField.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 From 8a2f1586e20394844b5be88e8ac15072c9601a9c Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 24 Jan 2021 17:11:14 +0300 Subject: [PATCH 13/23] suppress unused --- examples/src/main/kotlin/kscience/kmath/structures/ComplexND.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/src/main/kotlin/kscience/kmath/structures/ComplexND.kt b/examples/src/main/kotlin/kscience/kmath/structures/ComplexND.kt index 7dd725f0e..b6cac4b27 100644 --- a/examples/src/main/kotlin/kscience/kmath/structures/ComplexND.kt +++ b/examples/src/main/kotlin/kscience/kmath/structures/ComplexND.kt @@ -1,3 +1,5 @@ +@file:Suppress("unused") + package kscience.kmath.structures import kscience.kmath.linear.transpose From b20081f161d3ba8814c1ad7a7a55fb33788ea9bb Mon Sep 17 00:00:00 2001 From: Iaroslav Postovalov Date: Sun, 24 Jan 2021 22:12:43 +0700 Subject: [PATCH 14/23] Fix capitalization of LUP related references (LUP -> Lup) --- CHANGELOG.md | 2 +- .../benchmarks/LinearAlgebraBenchmark.kt | 4 ++-- .../kscience/kmath/linear/LupDecomposition.kt | 24 +++++++++---------- .../kscience/kmath/linear/RealLUSolverTest.kt | 4 ++-- .../kotlin/kscience/kmath/real/RealMatrix.kt | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa70e6116..3ee260775 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,7 +32,7 @@ - Use `Point` instead of specialized type in `kmath-for-real` - Optimized dot product for buffer matrices moved to `kmath-for-real` - EjmlMatrix context is an object -- Matrix LUP `inverse` renamed to `inverseWithLUP` +- Matrix LUP `inverse` renamed to `inverseWithLup` - `NumericAlgebra` moved outside of regular algebra chain (`Ring` no longer implements it). - Features moved to NDStructure and became transparent. diff --git a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/LinearAlgebraBenchmark.kt b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/LinearAlgebraBenchmark.kt index 5ff43ef80..283210174 100644 --- a/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/LinearAlgebraBenchmark.kt +++ b/examples/src/benchmarks/kotlin/kscience/kmath/benchmarks/LinearAlgebraBenchmark.kt @@ -26,8 +26,8 @@ class LinearAlgebraBenchmark { } @Benchmark - fun kmathLUPInversion() { - MatrixContext.real.inverseWithLUP(matrix) + fun kmathLupInversion() { + MatrixContext.real.inverseWithLup(matrix) } @Benchmark diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/LupDecomposition.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/LupDecomposition.kt index 5cf7c8f70..645df429c 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/LupDecomposition.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/linear/LupDecomposition.kt @@ -151,7 +151,7 @@ public inline fun , F : Field> GenericMatrixContext public fun MatrixContext>.lup(matrix: Matrix): LupDecomposition = lup(Buffer.Companion::real, RealField, matrix) { it < 1e-11 } -public fun LupDecomposition.solveWithLUP( +public fun LupDecomposition.solveWithLup( factory: MutableBufferFactory, matrix: Matrix, ): Matrix { @@ -199,14 +199,14 @@ public fun LupDecomposition.solveWithLUP( } } -public inline fun LupDecomposition.solveWithLUP(matrix: Matrix): Matrix = - solveWithLUP(MutableBuffer.Companion::auto, matrix) +public inline fun LupDecomposition.solveWithLup(matrix: Matrix): Matrix = + solveWithLup(MutableBuffer.Companion::auto, matrix) /** - * Solve a linear equation **a*x = b** using LUP decomposition + * Solves a system of linear equations *ax = b** using LUP decomposition. */ @OptIn(UnstableKMathAPI::class) -public inline fun , F : Field> GenericMatrixContext>.solveWithLUP( +public inline fun , F : Field> GenericMatrixContext>.solveWithLup( a: Matrix, b: Matrix, noinline bufferFactory: MutableBufferFactory = MutableBuffer.Companion::auto, @@ -214,26 +214,26 @@ public inline fun , F : Field> GenericMatrixContext ): Matrix { // Use existing decomposition if it is provided by matrix val decomposition = a.getFeature() ?: lup(bufferFactory, elementContext, a, checkSingular) - return decomposition.solveWithLUP(bufferFactory, b) + return decomposition.solveWithLup(bufferFactory, b) } -public inline fun , F : Field> GenericMatrixContext>.inverseWithLUP( +public inline fun , F : Field> GenericMatrixContext>.inverseWithLup( matrix: Matrix, noinline bufferFactory: MutableBufferFactory = MutableBuffer.Companion::auto, noinline checkSingular: (T) -> Boolean, -): Matrix = solveWithLUP(matrix, one(matrix.rowNum, matrix.colNum), bufferFactory, checkSingular) +): Matrix = solveWithLup(matrix, one(matrix.rowNum, matrix.colNum), bufferFactory, checkSingular) @OptIn(UnstableKMathAPI::class) -public fun RealMatrixContext.solveWithLUP(a: Matrix, b: Matrix): Matrix { +public fun RealMatrixContext.solveWithLup(a: Matrix, b: Matrix): Matrix { // Use existing decomposition if it is provided by matrix val bufferFactory: MutableBufferFactory = MutableBuffer.Companion::real val decomposition: LupDecomposition = a.getFeature() ?: lup(bufferFactory, RealField, a) { it < 1e-11 } - return decomposition.solveWithLUP(bufferFactory, b) + return decomposition.solveWithLup(bufferFactory, b) } /** * Inverses a square matrix using LUP decomposition. Non square matrix will throw a error. */ -public fun RealMatrixContext.inverseWithLUP(matrix: Matrix): Matrix = - solveWithLUP(matrix, one(matrix.rowNum, matrix.colNum)) \ No newline at end of file +public fun RealMatrixContext.inverseWithLup(matrix: Matrix): Matrix = + solveWithLup(matrix, one(matrix.rowNum, matrix.colNum)) \ No newline at end of file diff --git a/kmath-core/src/commonTest/kotlin/kscience/kmath/linear/RealLUSolverTest.kt b/kmath-core/src/commonTest/kotlin/kscience/kmath/linear/RealLUSolverTest.kt index 28dfe46ec..d2822a221 100644 --- a/kmath-core/src/commonTest/kotlin/kscience/kmath/linear/RealLUSolverTest.kt +++ b/kmath-core/src/commonTest/kotlin/kscience/kmath/linear/RealLUSolverTest.kt @@ -9,7 +9,7 @@ class RealLUSolverTest { @Test fun testInvertOne() { val matrix = MatrixContext.real.one(2, 2) - val inverted = MatrixContext.real.inverseWithLUP(matrix) + val inverted = MatrixContext.real.inverseWithLup(matrix) assertEquals(matrix, inverted) } @@ -37,7 +37,7 @@ class RealLUSolverTest { 1.0, 3.0 ) - val inverted = MatrixContext.real.inverseWithLUP(matrix) + val inverted = MatrixContext.real.inverseWithLup(matrix) val expected = Matrix.square( 0.375, -0.125, diff --git a/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt b/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt index 274030aff..69e211624 100644 --- a/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt +++ b/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt @@ -2,7 +2,7 @@ package kscience.kmath.real import kscience.kmath.linear.MatrixContext import kscience.kmath.linear.VirtualMatrix -import kscience.kmath.linear.inverseWithLUP +import kscience.kmath.linear.inverseWithLup import kscience.kmath.linear.real import kscience.kmath.misc.UnstableKMathAPI import kscience.kmath.structures.Buffer @@ -152,7 +152,7 @@ public inline fun RealMatrix.map(transform: (Double) -> Double): RealMatrix = /** * Inverse a square real matrix using LUP decomposition */ -public fun RealMatrix.inverseWithLUP(): RealMatrix = MatrixContext.real.inverseWithLUP(this) +public fun RealMatrix.inverseWithLup(): RealMatrix = MatrixContext.real.inverseWithLup(this) //extended operations From e0b8a0bfe595bd16601e0d66d2acf779ff51d52d Mon Sep 17 00:00:00 2001 From: Iaroslav Postovalov Date: Sun, 24 Jan 2021 22:30:52 +0700 Subject: [PATCH 15/23] Update the changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ee260775..fdf01d4de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ - Matrix LUP `inverse` renamed to `inverseWithLup` - `NumericAlgebra` moved outside of regular algebra chain (`Ring` no longer implements it). - Features moved to NDStructure and became transparent. +- Capitalization of LUP in many names changed to Lup. ### Deprecated From 228c0b3886862a0b1a03d18ba5e9b366ccd994d4 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Thu, 28 Jan 2021 20:04:33 +0300 Subject: [PATCH 16/23] misc --- examples/build.gradle.kts | 3 ++- kmath-histograms/build.gradle.kts | 18 ++++++++++++++---- .../histogram/MultivariateHistogramTest.kt | 1 - .../kmath/histogram/UnivariateHistogram.kt | 11 ++++++----- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts index c079eaa84..4e780ff36 100644 --- a/examples/build.gradle.kts +++ b/examples/build.gradle.kts @@ -68,11 +68,12 @@ benchmark { targets.register("benchmarks") // This one matches sourceSet name above - configurations.register("fast") { + configurations.register("dot") { warmups = 1 // number of warmup iterations iterations = 3 // number of iterations iterationTime = 500 // time in seconds per iteration iterationTimeUnit = "ms" // time unity for iterationTime, default is seconds + include("DotBenchmark") } } diff --git a/kmath-histograms/build.gradle.kts b/kmath-histograms/build.gradle.kts index 7de21ad89..40196416e 100644 --- a/kmath-histograms/build.gradle.kts +++ b/kmath-histograms/build.gradle.kts @@ -1,8 +1,18 @@ plugins { id("ru.mipt.npm.mpp") } -kotlin.sourceSets.commonMain { - dependencies { - api(project(":kmath-core")) - api(project(":kmath-for-real")) +kotlin.sourceSets { + commonMain { + dependencies { + api(project(":kmath-core")) + } + } + commonTest{ + dependencies{ + implementation(project(":kmath-for-real")) + } } } + +readme { + this.maturity = ru.mipt.npm.gradle.Maturity.PROTOTYPE +} diff --git a/kmath-histograms/src/commonTest/kotlin/scietifik/kmath/histogram/MultivariateHistogramTest.kt b/kmath-histograms/src/commonTest/kotlin/scietifik/kmath/histogram/MultivariateHistogramTest.kt index af22afc6b..87a2b3e68 100644 --- a/kmath-histograms/src/commonTest/kotlin/scietifik/kmath/histogram/MultivariateHistogramTest.kt +++ b/kmath-histograms/src/commonTest/kotlin/scietifik/kmath/histogram/MultivariateHistogramTest.kt @@ -5,7 +5,6 @@ import kscience.kmath.histogram.fill import kscience.kmath.histogram.put import kscience.kmath.real.RealVector import kscience.kmath.real.invoke -import kscience.kmath.structures.Buffer import kotlin.random.Random import kotlin.test.* diff --git a/kmath-histograms/src/jvmMain/kotlin/kscience/kmath/histogram/UnivariateHistogram.kt b/kmath-histograms/src/jvmMain/kotlin/kscience/kmath/histogram/UnivariateHistogram.kt index 2f3855892..d07c2ba01 100644 --- a/kmath-histograms/src/jvmMain/kotlin/kscience/kmath/histogram/UnivariateHistogram.kt +++ b/kmath-histograms/src/jvmMain/kotlin/kscience/kmath/histogram/UnivariateHistogram.kt @@ -1,6 +1,6 @@ package kscience.kmath.histogram -import kscience.kmath.real.RealVector +import kscience.kmath.linear.Point import kscience.kmath.structures.Buffer import kscience.kmath.structures.asBuffer import java.util.* @@ -11,12 +11,12 @@ import kotlin.math.floor public class UnivariateBin( public val position: Double, public val size: Double, - public val counter: LongCounter = LongCounter() + public val counter: LongCounter = LongCounter(), ) : Bin { //TODO add weighting public override val value: Number get() = counter.sum() - public override val center: RealVector get() = doubleArrayOf(position).asBuffer() + public override val center: Point get() = doubleArrayOf(position).asBuffer() public override val dimension: Int get() = 1 public operator fun contains(value: Double): Boolean = value in (position - size / 2)..(position + size / 2) @@ -27,8 +27,9 @@ public class UnivariateBin( /** * Univariate histogram with log(n) bin search speed */ -public class UnivariateHistogram private constructor(private val factory: (Double) -> UnivariateBin) : - MutableHistogram { +public class UnivariateHistogram private constructor( + private val factory: (Double) -> UnivariateBin, +) : MutableHistogram { private val bins: TreeMap = TreeMap() From 2e52457b96836c54590dd1fb2674adad86cadd90 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Thu, 28 Jan 2021 20:10:42 +0300 Subject: [PATCH 17/23] fix merge --- .../main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt | 1 - .../src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt b/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt index 16034e5f9..811c0c2d5 100644 --- a/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt +++ b/kmath-commons/src/main/kotlin/kscience/kmath/commons/linear/CMMatrix.kt @@ -2,7 +2,6 @@ package kscience.kmath.commons.linear import kscience.kmath.linear.* import kscience.kmath.misc.UnstableKMathAPI -import kscience.kmath.structures.Matrix import kscience.kmath.structures.RealBuffer import org.apache.commons.math3.linear.* import kotlin.reflect.KClass diff --git a/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt b/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt index 98abf9a73..d0e4a7325 100644 --- a/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt +++ b/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealMatrix.kt @@ -1,12 +1,8 @@ package kscience.kmath.real -import kscience.kmath.linear.MatrixContext -import kscience.kmath.linear.VirtualMatrix -import kscience.kmath.linear.inverseWithLup -import kscience.kmath.linear.real +import kscience.kmath.linear.* import kscience.kmath.misc.UnstableKMathAPI import kscience.kmath.structures.Buffer -import kscience.kmath.structures.Matrix import kscience.kmath.structures.RealBuffer import kscience.kmath.structures.asIterable import kotlin.math.pow From 5f6c133550e3ddda09b63bd1a455fdf270402894 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 30 Jan 2021 11:24:34 +0300 Subject: [PATCH 18/23] Histogram refactor --- CHANGELOG.md | 1 + .../kscience/kmath/histogram/RealHistogram.kt | 48 +++---- .../kmath/histogram/UnivariateHistogram.kt | 123 +++++++++++++----- 3 files changed, 117 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e2aa8f51..68a1829d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ - Features moved to NDStructure and became transparent. - Capitalization of LUP in many names changed to Lup. - Refactored `NDStructure` algebra to be more simple, preferring under-the-hood conversion to explicit NDStructure types +- Refactor histograms. They are marked as prototype ### Deprecated diff --git a/kmath-histograms/src/commonMain/kotlin/kscience/kmath/histogram/RealHistogram.kt b/kmath-histograms/src/commonMain/kotlin/kscience/kmath/histogram/RealHistogram.kt index 085641106..11eb77735 100644 --- a/kmath-histograms/src/commonMain/kotlin/kscience/kmath/histogram/RealHistogram.kt +++ b/kmath-histograms/src/commonMain/kotlin/kscience/kmath/histogram/RealHistogram.kt @@ -8,10 +8,10 @@ import kscience.kmath.operations.invoke import kscience.kmath.structures.* import kotlin.math.floor -public data class BinDef>( +public data class BinDefinition>( public val space: SpaceOperations>, public val center: Point, - public val sizes: Point + public val sizes: Point, ) { public fun contains(vector: Point): Boolean { require(vector.size == center.size) { "Dimension mismatch for input vector. Expected ${center.size}, but found ${vector.size}" } @@ -22,14 +22,17 @@ public data class BinDef>( } -public class MultivariateBin>(public val def: BinDef, public override val value: Number) : Bin { +public class MultivariateBin>( + public val definition: BinDefinition, + public override val value: Number, +) : Bin { public override val dimension: Int - get() = def.center.size + get() = definition.center.size public override val center: Point - get() = def.center + get() = definition.center - public override operator fun contains(point: Point): Boolean = def.contains(point) + public override operator fun contains(point: Point): Boolean = definition.contains(point) } /** @@ -38,11 +41,11 @@ public class MultivariateBin>(public val def: BinDef, publi public class RealHistogram( private val lower: Buffer, private val upper: Buffer, - private val binNums: IntArray = IntArray(lower.size) { 20 } + private val binNums: IntArray = IntArray(lower.size) { 20 }, ) : MutableHistogram> { private val strides = DefaultStrides(IntArray(binNums.size) { binNums[it] + 2 }) - private val values: NDStructure = NDStructure.auto(strides) { LongCounter() } - private val weights: NDStructure = NDStructure.auto(strides) { DoubleCounter() } + private val counts: NDStructure = NDStructure.auto(strides) { LongCounter() } + private val values: NDStructure = NDStructure.auto(strides) { DoubleCounter() } public override val dimension: Int get() = lower.size private val binSize = RealBuffer(dimension) { (upper[it] - lower[it]) / binNums[it] } @@ -65,11 +68,11 @@ public class RealHistogram( private fun getIndex(point: Buffer): IntArray = IntArray(dimension) { getIndex(it, point[it]) } - private fun getValue(index: IntArray): Long = values[index].sum() + private fun getValue(index: IntArray): Long = counts[index].sum() public fun getValue(point: Buffer): Long = getValue(getIndex(point)) - private fun getDef(index: IntArray): BinDef { + private fun getBinDefinition(index: IntArray): BinDefinition { val center = index.mapIndexed { axis, i -> when (i) { 0 -> Double.NEGATIVE_INFINITY @@ -78,14 +81,14 @@ public class RealHistogram( } }.asBuffer() - return BinDef(RealBufferFieldOperations, center, binSize) + return BinDefinition(RealBufferFieldOperations, center, binSize) } - public fun getDef(point: Buffer): BinDef = getDef(getIndex(point)) + public fun getBinDefinition(point: Buffer): BinDefinition = getBinDefinition(getIndex(point)) public override operator fun get(point: Buffer): MultivariateBin? { val index = getIndex(point) - return MultivariateBin(getDef(index), getValue(index)) + return MultivariateBin(getBinDefinition(index), getValue(index)) } // fun put(point: Point){ @@ -95,23 +98,24 @@ public class RealHistogram( public override fun putWithWeight(point: Buffer, weight: Double) { val index = getIndex(point) - values[index].increment() - weights[index].add(weight) + counts[index].increment() + values[index].add(weight) } public override operator fun iterator(): Iterator> = - weights.elements().map { (index, value) -> MultivariateBin(getDef(index), value.sum()) } - .iterator() + values.elements().map { (index, value) -> + MultivariateBin(getBinDefinition(index), value.sum()) + }.iterator() /** - * Convert this histogram into NDStructure containing bin values but not bin descriptions + * NDStructure containing number of events in bins without weights */ - public fun values(): NDStructure = NDStructure.auto(values.shape) { values[it].sum() } + public fun counts(): NDStructure = NDStructure.auto(counts.shape) { counts[it].sum() } /** - * Sum of weights + * NDStructure containing values of bins including weights */ - public fun weights(): NDStructure = NDStructure.auto(weights.shape) { weights[it].sum() } + public fun values(): NDStructure = NDStructure.auto(values.shape) { values[it].sum() } public companion object { /** diff --git a/kmath-histograms/src/jvmMain/kotlin/kscience/kmath/histogram/UnivariateHistogram.kt b/kmath-histograms/src/jvmMain/kotlin/kscience/kmath/histogram/UnivariateHistogram.kt index d07c2ba01..049f61d5a 100644 --- a/kmath-histograms/src/jvmMain/kotlin/kscience/kmath/histogram/UnivariateHistogram.kt +++ b/kmath-histograms/src/jvmMain/kotlin/kscience/kmath/histogram/UnivariateHistogram.kt @@ -1,8 +1,10 @@ package kscience.kmath.histogram import kscience.kmath.linear.Point +import kscience.kmath.misc.UnstableKMathAPI import kscience.kmath.structures.Buffer import kscience.kmath.structures.asBuffer +import kscience.kmath.structures.asSequence import java.util.* import kotlin.math.floor @@ -11,29 +13,36 @@ import kotlin.math.floor public class UnivariateBin( public val position: Double, public val size: Double, - public val counter: LongCounter = LongCounter(), ) : Bin { - //TODO add weighting - public override val value: Number get() = counter.sum() + //internal mutation operations + internal val counter: LongCounter = LongCounter() + internal val weightCounter: DoubleCounter = DoubleCounter() + + /** + * The precise number of events ignoring weighting + */ + public val count: Long get() = counter.sum() + + /** + * The value of histogram including weighting + */ + public override val value: Double get() = weightCounter.sum() public override val center: Point get() = doubleArrayOf(position).asBuffer() public override val dimension: Int get() = 1 public operator fun contains(value: Double): Boolean = value in (position - size / 2)..(position + size / 2) public override fun contains(point: Buffer): Boolean = contains(point[0]) - internal operator fun inc(): UnivariateBin = this.also { counter.increment() } } /** * Univariate histogram with log(n) bin search speed */ -public class UnivariateHistogram private constructor( - private val factory: (Double) -> UnivariateBin, -) : MutableHistogram { +public abstract class UnivariateHistogram( + protected val bins: TreeMap = TreeMap(), +) : Histogram { - private val bins: TreeMap = TreeMap() - - private operator fun get(value: Double): UnivariateBin? { + public operator fun get(value: Double): UnivariateBin? { // check ceiling entry and return it if it is what needed val ceil = bins.ceilingEntry(value)?.value if (ceil != null && value in ceil) return ceil @@ -44,38 +53,38 @@ public class UnivariateHistogram private constructor( return null } - private fun createBin(value: Double): UnivariateBin = factory(value).also { - synchronized(this) { bins[it.position] = it } - } - public override operator fun get(point: Buffer): UnivariateBin? = get(point[0]) public override val dimension: Int get() = 1 public override operator fun iterator(): Iterator = bins.values.iterator() - /** - * Thread safe put operation - */ - public fun put(value: Double) { - (get(value) ?: createBin(value)).inc() - } - - override fun putWithWeight(point: Buffer, weight: Double) { - if (weight != 1.0) TODO("Implement weighting") - put(point[0]) - } - public companion object { - public fun uniform(binSize: Double, start: Double = 0.0): UnivariateHistogram = UnivariateHistogram { value -> - val center = start + binSize * floor((value - start) / binSize + 0.5) - UnivariateBin(center, binSize) - } + /** + * Build a histogram with a uniform binning with a start at [start] and a bin size of [binSize] + */ + public fun uniformBuilder(binSize: Double, start: Double = 0.0): UnivariateHistogramBuilder = + UnivariateHistogramBuilder { value -> + val center = start + binSize * floor((value - start) / binSize + 0.5) + UnivariateBin(center, binSize) + } - public fun custom(borders: DoubleArray): UnivariateHistogram { + /** + * Build and fill a [UnivariateHistogram]. Returns a read-only histogram. + */ + public fun uniform( + binSize: Double, + start: Double = 0.0, + builder: UnivariateHistogramBuilder.() -> Unit, + ): UnivariateHistogram = uniformBuilder(binSize, start).apply(builder) + + /** + * Create a histogram with custom cell borders + */ + public fun customBuilder(borders: DoubleArray): UnivariateHistogramBuilder { val sorted = borders.sortedArray() - return UnivariateHistogram { value -> + return UnivariateHistogramBuilder { value -> when { value < sorted.first() -> UnivariateBin( Double.NEGATIVE_INFINITY, @@ -96,7 +105,55 @@ public class UnivariateHistogram private constructor( } } } + + /** + * Build and fill a histogram with custom borders. Returns a read-only histogram. + */ + public fun custom( + borders: DoubleArray, + builder: UnivariateHistogramBuilder.() -> Unit, + ): UnivariateHistogram = customBuilder(borders).apply(builder) } } -public fun UnivariateHistogram.fill(sequence: Iterable): Unit = sequence.forEach(::put) +public class UnivariateHistogramBuilder( + private val factory: (Double) -> UnivariateBin, +) : UnivariateHistogram(), MutableHistogram { + + private fun createBin(value: Double): UnivariateBin = factory(value).also { + synchronized(this) { bins[it.position] = it } + } + + /** + * Thread safe put operation + */ + public fun put(value: Double, weight: Double = 1.0) { + (get(value) ?: createBin(value)).apply{ + counter.increment() + weightCounter.add(weight) + } + } + + override fun putWithWeight(point: Buffer, weight: Double) { + put(point[0], weight) + } + + /** + * Put several items into a single bin + */ + public fun putMany(value: Double, count: Int, weight: Double = count.toDouble()){ + (get(value) ?: createBin(value)).apply{ + counter.add(count.toLong()) + weightCounter.add(weight) + } + } +} + +@UnstableKMathAPI +public fun UnivariateHistogramBuilder.fill(items: Iterable): Unit = items.forEach(::put) + +@UnstableKMathAPI +public fun UnivariateHistogramBuilder.fill(array: DoubleArray): Unit = array.forEach(::put) + +@UnstableKMathAPI +public fun UnivariateHistogramBuilder.fill(buffer: Buffer): Unit = buffer.asSequence().forEach(::put) \ No newline at end of file From 8e89b5eba356abebd626c302002c915e757a56da Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 30 Jan 2021 20:06:21 +0300 Subject: [PATCH 19/23] Create publish.yml Add publish workflow --- .github/workflows/publish.yml | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..0d472b1b9 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,40 @@ +name: Bintray Publish + +on: + release: + types: + - created + +jobs: + build-on-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Gradle clean + run: ./gradlew clean + - name: Gradle build + run: ./gradlew build + - name: Run release task + run: ./gradlew release -PbintrayUser=${{ secrets.BINTRAY_USER }} -PbintrayApiKey=${{ secrets.BINTRAY_KEY }} + build-on-macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Gradle clean + run: ./gradlew clean + - name: Gradle build + run: ./gradlew build + - name: Run release task + run: ./gradlew release -PbintrayUser=${{ secrets.BINTRAY_USER }} -PbintrayApiKey=${{ secrets.BINTRAY_KEY }} From 85927c9f6be9e74978c71d1a52affeedfb459522 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 30 Jan 2021 20:12:14 +0300 Subject: [PATCH 20/23] Documentation update. --- .github/workflows/{gradle.yml => build.yml} | 6 ++ README.md | 81 ++++++++++--------- build.gradle.kts | 4 - docs/templates/README-TEMPLATE.md | 55 ++++++------- examples/build.gradle.kts | 4 + gradle/wrapper/gradle-wrapper.properties | 2 +- kmath-ast/README.md | 8 +- kmath-core/README.md | 15 ++-- kmath-core/build.gradle.kts | 20 ++++- kmath-for-real/README.md | 6 +- kmath-functions/README.md | 47 +++++++++++ kmath-functions/build.gradle.kts | 11 +++ kmath-functions/docs/README-TEMPLATE.md | 7 ++ .../kscience/kmath/functions/Piecewise.kt | 3 +- kmath-nd4j/README.md | 6 +- settings.gradle.kts | 2 +- 16 files changed, 184 insertions(+), 93 deletions(-) rename .github/workflows/{gradle.yml => build.yml} (91%) create mode 100644 kmath-functions/README.md create mode 100644 kmath-functions/docs/README-TEMPLATE.md diff --git a/.github/workflows/gradle.yml b/.github/workflows/build.yml similarity index 91% rename from .github/workflows/gradle.yml rename to .github/workflows/build.yml index 467a867bc..626062abf 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/build.yml @@ -12,6 +12,8 @@ jobs: uses: actions/setup-java@v1 with: java-version: 11 + - name: Grant execute permission for gradlew + run: chmod +x gradlew - name: Install Chrome run: | sudo apt install -y libappindicator1 fonts-liberation @@ -47,6 +49,8 @@ jobs: uses: actions/setup-java@v1 with: java-version: 11 + - name: Grant execute permission for gradlew + run: chmod +x gradlew - name: Cache gradle uses: actions/cache@v2 with: @@ -77,6 +81,8 @@ jobs: uses: actions/setup-java@v1 with: java-version: 11 + - name: Grant execute permission for gradlew + run: chmod +x gradlew - name: Add msys to path run: SETX PATH "%PATH%;C:\msys64\mingw64\bin" - name: Cache gradle diff --git a/README.md b/README.md index 258d79be5..8dfb783aa 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Bintray-dev: [ ![Download](https://api.bintray.com/packages/mipt-npm/dev/kmat # KMath -Could be pronounced as `key-math`. The Kotlin MATHematics library was initially intended as a Kotlin-based analog to +Could be pronounced as `key-math`. The **K**otlin **Math**ematics library was initially intended as a Kotlin-based analog to Python's NumPy library. Later we found that kotlin is much more flexible language and allows superior architecture designs. In contrast to `numpy` and `scipy` it is modular and has a lightweight core. The `numpy`-like experience could be achieved with [kmath-for-real](/kmath-for-real) extension module. @@ -32,49 +32,46 @@ be achieved with [kmath-for-real](/kmath-for-real) extension module. * Provide the best performance out of the box. We have specialized libraries for that. Need only API wrappers for them. * Cover all cases as immediately and in one bundle. We will modularize everything and add new features gradually. * Provide specialized behavior in the core. API is made generic on purpose, so one needs to specialize for types, like -for `Double` in the core. For that we will have specialization modules like `for-real`, which will give better +for `Double` in the core. For that we will have specialization modules like `kmath-for-real`, which will give better experience for those, who want to work with specific types. -## Features +## Features and stability -Current feature list is [here](/docs/features.md) +KMath is a modular library. Different modules provide different features with different API stability guarantees. All core modules are released with the same version, but with different API change policy. The features are described in module definitions below. The module stability could have following levels: -* **Algebra** - * Algebraic structures like rings, spaces and fields (**TODO** add example to wiki) - * Basic linear algebra operations (sums, products, etc.), backed by the `Space` API. - * Complex numbers backed by the `Field` API (meaning they will be usable in any structure like vectors and - N-dimensional arrays). - * Advanced linear algebra operations like matrix inversion and LU decomposition. +* **PROTOTYPE**. On this level there are no compatibility guarantees. All methods and classes form those modules could break any moment. You can still use it, but be sure to fix the specific version. +* **EXPERIMENTAL**. The general API is decided, but some changes could be made. Volatile API is marked with `@UnstableKmathAPI` or other stability warning annotations. +* **DEVELOPMENT**. API breaking genrally follows semantic versioning ideology. There could be changes in minor versions, but not in patch versions. API is protected with [binary-compatibility-validator](https://github.com/Kotlin/binary-compatibility-validator) tool. +* **STABLE**. The API stabilized. Breaking changes are allowed only in major releases. -* **Array-like structures** Full support of many-dimensional array-like structures -including mixed arithmetic operations and function operations over arrays and numbers (with the added benefit of static type checking). + -* **Expressions** By writing a single mathematical expression once, users will be able to apply different types of -objects to the expression by providing a context. Expressions can be used for a wide variety of purposes from high -performance calculations to code generation. -* **Histograms** Fast multi-dimensional histograms. + + -* **Streaming** Streaming operations on mathematical objects and objects buffers. + -* **Type-safe dimensions** Type-safe dimensions for matrix operations. + -* **Commons-math wrapper** It is planned to gradually wrap most parts of -[Apache commons-math](http://commons.apache.org/proper/commons-math/) library in Kotlin code and maybe rewrite some -parts to better suit the Kotlin programming paradigm, however there is no established roadmap for that. Feel free to -submit a feature request if you want something to be implemented first. - -## Planned features + -* **Messaging** A mathematical notation to support multi-language and multi-node communication for mathematical tasks. + + + + + + -* **Array statistics** + -* **Integration** Univariate and multivariate integration framework. + -* **Probability and distributions** + -* **Fitting** Non-linear curve fitting facilities + + + ## Modules @@ -113,10 +110,13 @@ submit a feature request if you want something to be implemented first. > **Maturity**: DEVELOPMENT > > **Features:** -> - [algebras](kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Algebra.kt) : Algebraic structures: contexts and elements -> - [nd](kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDStructure.kt) : Many-dimensional structures +> - [algebras](kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Algebra.kt) : Algebraic structures like rings, spaces and fields. +> - [nd](kmath-core/src/commonMain/kotlin/kscience/kmath/structures/NDStructure.kt) : Many-dimensional structures and operations on them. +> - [linear](kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Algebra.kt) : Basic linear algebra operations (sums, products, etc.), backed by the `Space` API. Advanced linear algebra operations like matrix inversion and LU decomposition. > - [buffers](kmath-core/src/commonMain/kotlin/kscience/kmath/structures/Buffers.kt) : One-dimensional structure -> - [expressions](kmath-core/src/commonMain/kotlin/kscience/kmath/expressions) : Functional Expressions +> - [expressions](kmath-core/src/commonMain/kotlin/kscience/kmath/expressions) : By writing a single mathematical expression once, users will be able to apply different types of +objects to the expression by providing a context. Expressions can be used for a wide variety of purposes from high +performance calculations to code generation. > - [domains](kmath-core/src/commonMain/kotlin/kscience/kmath/domains) : Domains > - [autodif](kmath-core/src/commonMain/kotlin/kscience/kmath/expressions/SimpleAutoDiff.kt) : Automatic differentiation @@ -155,9 +155,16 @@ One can still use generic algebras though.
* ### [kmath-functions](kmath-functions) -> +> Functions and interpolation > -> **Maturity**: EXPERIMENTAL +> **Maturity**: PROTOTYPE +> +> **Features:** +> - [piecewise](kmath-functions/src/commonMain/kotlin/kscience/kmath/functions/Piecewise.kt) : Piecewise functions. +> - [polynomials](kmath-functions/src/commonMain/kotlin/kscience/kmath/functions/Polynomial.kt) : Polynomial functions. +> - [linear interpolation](kmath-functions/src/commonMain/kotlin/kscience/kmath/interpolation/LinearInterpolator.kt) : Linear XY interpolator. +> - [spline interpolation](kmath-functions/src/commonMain/kotlin/kscience/kmath/interpolation/SplineInterpolator.kt) : Cubic spline XY interpolator. +
* ### [kmath-geometry](kmath-geometry) @@ -169,7 +176,7 @@ One can still use generic algebras though. * ### [kmath-histograms](kmath-histograms) > > -> **Maturity**: EXPERIMENTAL +> **Maturity**: PROTOTYPE
* ### [kmath-kotlingrad](kmath-kotlingrad) @@ -238,8 +245,8 @@ repositories { } dependencies { - api("kscience.kmath:kmath-core:0.2.0-dev-4") - // api("kscience.kmath:kmath-core-jvm:0.2.0-dev-4") for jvm-specific version + api("kscience.kmath:kmath-core:0.2.0-dev-6") + // api("kscience.kmath:kmath-core-jvm:0.2.0-dev-6") for jvm-specific version } ``` diff --git a/build.gradle.kts b/build.gradle.kts index 0572217af..41f762a5f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -35,10 +35,6 @@ readme { readmeTemplate = file("docs/templates/README-TEMPLATE.md") } -apiValidation { - validationDisabled = true -} - ksciencePublish { spaceRepo = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven" } diff --git a/docs/templates/README-TEMPLATE.md b/docs/templates/README-TEMPLATE.md index ee1df818c..44b27acf3 100644 --- a/docs/templates/README-TEMPLATE.md +++ b/docs/templates/README-TEMPLATE.md @@ -9,7 +9,7 @@ Bintray-dev: [ ![Download](https://api.bintray.com/packages/mipt-npm/dev/kmat # KMath -Could be pronounced as `key-math`. The Kotlin MATHematics library was initially intended as a Kotlin-based analog to +Could be pronounced as `key-math`. The **K**otlin **Math**ematics library was initially intended as a Kotlin-based analog to Python's NumPy library. Later we found that kotlin is much more flexible language and allows superior architecture designs. In contrast to `numpy` and `scipy` it is modular and has a lightweight core. The `numpy`-like experience could be achieved with [kmath-for-real](/kmath-for-real) extension module. @@ -32,49 +32,46 @@ be achieved with [kmath-for-real](/kmath-for-real) extension module. * Provide the best performance out of the box. We have specialized libraries for that. Need only API wrappers for them. * Cover all cases as immediately and in one bundle. We will modularize everything and add new features gradually. * Provide specialized behavior in the core. API is made generic on purpose, so one needs to specialize for types, like -for `Double` in the core. For that we will have specialization modules like `for-real`, which will give better +for `Double` in the core. For that we will have specialization modules like `kmath-for-real`, which will give better experience for those, who want to work with specific types. -## Features +## Features and stability -Current feature list is [here](/docs/features.md) +KMath is a modular library. Different modules provide different features with different API stability guarantees. All core modules are released with the same version, but with different API change policy. The features are described in module definitions below. The module stability could have following levels: -* **Algebra** - * Algebraic structures like rings, spaces and fields (**TODO** add example to wiki) - * Basic linear algebra operations (sums, products, etc.), backed by the `Space` API. - * Complex numbers backed by the `Field` API (meaning they will be usable in any structure like vectors and - N-dimensional arrays). - * Advanced linear algebra operations like matrix inversion and LU decomposition. +* **PROTOTYPE**. On this level there are no compatibility guarantees. All methods and classes form those modules could break any moment. You can still use it, but be sure to fix the specific version. +* **EXPERIMENTAL**. The general API is decided, but some changes could be made. Volatile API is marked with `@UnstableKmathAPI` or other stability warning annotations. +* **DEVELOPMENT**. API breaking genrally follows semantic versioning ideology. There could be changes in minor versions, but not in patch versions. API is protected with [binary-compatibility-validator](https://github.com/Kotlin/binary-compatibility-validator) tool. +* **STABLE**. The API stabilized. Breaking changes are allowed only in major releases. -* **Array-like structures** Full support of many-dimensional array-like structures -including mixed arithmetic operations and function operations over arrays and numbers (with the added benefit of static type checking). + -* **Expressions** By writing a single mathematical expression once, users will be able to apply different types of -objects to the expression by providing a context. Expressions can be used for a wide variety of purposes from high -performance calculations to code generation. -* **Histograms** Fast multi-dimensional histograms. + + -* **Streaming** Streaming operations on mathematical objects and objects buffers. + -* **Type-safe dimensions** Type-safe dimensions for matrix operations. + -* **Commons-math wrapper** It is planned to gradually wrap most parts of -[Apache commons-math](http://commons.apache.org/proper/commons-math/) library in Kotlin code and maybe rewrite some -parts to better suit the Kotlin programming paradigm, however there is no established roadmap for that. Feel free to -submit a feature request if you want something to be implemented first. - -## Planned features + -* **Messaging** A mathematical notation to support multi-language and multi-node communication for mathematical tasks. + + + + + + -* **Array statistics** + -* **Integration** Univariate and multivariate integration framework. + -* **Probability and distributions** + -* **Fitting** Non-linear curve fitting facilities + + + ## Modules diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts index 4e780ff36..1810e1a88 100644 --- a/examples/build.gradle.kts +++ b/examples/build.gradle.kts @@ -87,3 +87,7 @@ kotlin.sourceSets.all { tasks.withType { kotlinOptions.jvmTarget = "11" } + +readme{ + maturity = ru.mipt.npm.gradle.Maturity.EXPERIMENTAL +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index da9702f9e..28ff446a2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/kmath-ast/README.md b/kmath-ast/README.md index 19e9ee4a9..33b118973 100644 --- a/kmath-ast/README.md +++ b/kmath-ast/README.md @@ -12,7 +12,7 @@ This subproject implements the following features: > #### Artifact: > -> This module artifact: `kscience.kmath:kmath-ast:0.2.0-dev-4`. +> This module artifact: `kscience.kmath:kmath-ast:0.2.0-dev-6`. > > Bintray release version: [ ![Download](https://api.bintray.com/packages/mipt-npm/kscience/kmath-ast/images/download.svg) ](https://bintray.com/mipt-npm/kscience/kmath-ast/_latestVersion) > @@ -30,7 +30,7 @@ This subproject implements the following features: > } > > dependencies { -> implementation 'kscience.kmath:kmath-ast:0.2.0-dev-4' +> implementation 'kscience.kmath:kmath-ast:0.2.0-dev-6' > } > ``` > **Gradle Kotlin DSL:** @@ -44,7 +44,7 @@ This subproject implements the following features: > } > > dependencies { -> implementation("kscience.kmath:kmath-ast:0.2.0-dev-4") +> implementation("kscience.kmath:kmath-ast:0.2.0-dev-6") > } > ``` @@ -61,7 +61,7 @@ For example, the following builder: RealField.mstInField { symbol("x") + 2 }.compile() ``` -… leads to generation of bytecode, which can be decompiled to the following Java class: +… leads to generation of bytecode, which can be decompiled to the following Java class: ```java package kscience.kmath.asm.generated; diff --git a/kmath-core/README.md b/kmath-core/README.md index 9ed54b9eb..504171fe2 100644 --- a/kmath-core/README.md +++ b/kmath-core/README.md @@ -2,17 +2,20 @@ The core features of KMath: - - [algebras](src/commonMain/kotlin/kscience/kmath/operations/Algebra.kt) : Algebraic structures: contexts and elements - - [nd](src/commonMain/kotlin/kscience/kmath/nd/NDStructure.kt) : Many-dimensional structures + - [algebras](src/commonMain/kotlin/kscience/kmath/operations/Algebra.kt) : Algebraic structures like rings, spaces and fields. + - [nd](src/commonMain/kotlin/kscience/kmath/structures/NDStructure.kt) : Many-dimensional structures and operations on them. + - [linear](src/commonMain/kotlin/kscience/kmath/operations/Algebra.kt) : Basic linear algebra operations (sums, products, etc.), backed by the `Space` API. Advanced linear algebra operations like matrix inversion and LU decomposition. - [buffers](src/commonMain/kotlin/kscience/kmath/structures/Buffers.kt) : One-dimensional structure - - [expressions](src/commonMain/kotlin/kscience/kmath/expressions) : Functional Expressions + - [expressions](src/commonMain/kotlin/kscience/kmath/expressions) : By writing a single mathematical expression once, users will be able to apply different types of +objects to the expression by providing a context. Expressions can be used for a wide variety of purposes from high +performance calculations to code generation. - [domains](src/commonMain/kotlin/kscience/kmath/domains) : Domains - [autodif](src/commonMain/kotlin/kscience/kmath/expressions/SimpleAutoDiff.kt) : Automatic differentiation > #### Artifact: > -> This module artifact: `kscience.kmath:kmath-core:0.2.0-dev-4`. +> This module artifact: `kscience.kmath:kmath-core:0.2.0-dev-6`. > > Bintray release version: [ ![Download](https://api.bintray.com/packages/mipt-npm/kscience/kmath-core/images/download.svg) ](https://bintray.com/mipt-npm/kscience/kmath-core/_latestVersion) > @@ -30,7 +33,7 @@ The core features of KMath: > } > > dependencies { -> implementation 'kscience.kmath:kmath-core:0.2.0-dev-4' +> implementation 'kscience.kmath:kmath-core:0.2.0-dev-6' > } > ``` > **Gradle Kotlin DSL:** @@ -44,6 +47,6 @@ The core features of KMath: > } > > dependencies { -> implementation("kscience.kmath:kmath-core:0.2.0-dev-4") +> implementation("kscience.kmath:kmath-core:0.2.0-dev-6") > } > ``` diff --git a/kmath-core/build.gradle.kts b/kmath-core/build.gradle.kts index 9ed7e690b..8c495bddc 100644 --- a/kmath-core/build.gradle.kts +++ b/kmath-core/build.gradle.kts @@ -16,16 +16,26 @@ readme { feature( id = "algebras", - description = "Algebraic structures: contexts and elements", + description = """ + Algebraic structures like rings, spaces and fields. + """.trimIndent(), ref = "src/commonMain/kotlin/kscience/kmath/operations/Algebra.kt" ) feature( id = "nd", - description = "Many-dimensional structures", + description = "Many-dimensional structures and operations on them.", ref = "src/commonMain/kotlin/kscience/kmath/structures/NDStructure.kt" ) + feature( + id = "linear", + description = """ + Basic linear algebra operations (sums, products, etc.), backed by the `Space` API. Advanced linear algebra operations like matrix inversion and LU decomposition. + """.trimIndent(), + ref = "src/commonMain/kotlin/kscience/kmath/operations/Algebra.kt" + ) + feature( id = "buffers", description = "One-dimensional structure", @@ -34,7 +44,11 @@ readme { feature( id = "expressions", - description = "Functional Expressions", + description = """ + By writing a single mathematical expression once, users will be able to apply different types of + objects to the expression by providing a context. Expressions can be used for a wide variety of purposes from high + performance calculations to code generation. + """.trimIndent(), ref = "src/commonMain/kotlin/kscience/kmath/expressions" ) diff --git a/kmath-for-real/README.md b/kmath-for-real/README.md index d6b66b7da..9b191121d 100644 --- a/kmath-for-real/README.md +++ b/kmath-for-real/README.md @@ -7,7 +7,7 @@ > #### Artifact: > -> This module artifact: `kscience.kmath:kmath-for-real:0.2.0-dev-4`. +> This module artifact: `kscience.kmath:kmath-for-real:0.2.0-dev-6`. > > Bintray release version: [ ![Download](https://api.bintray.com/packages/mipt-npm/kscience/kmath-for-real/images/download.svg) ](https://bintray.com/mipt-npm/kscience/kmath-for-real/_latestVersion) > @@ -25,7 +25,7 @@ > } > > dependencies { -> implementation 'kscience.kmath:kmath-for-real:0.2.0-dev-4' +> implementation 'kscience.kmath:kmath-for-real:0.2.0-dev-6' > } > ``` > **Gradle Kotlin DSL:** @@ -39,6 +39,6 @@ > } > > dependencies { -> implementation("kscience.kmath:kmath-for-real:0.2.0-dev-4") +> implementation("kscience.kmath:kmath-for-real:0.2.0-dev-6") > } > ``` diff --git a/kmath-functions/README.md b/kmath-functions/README.md new file mode 100644 index 000000000..993baafc4 --- /dev/null +++ b/kmath-functions/README.md @@ -0,0 +1,47 @@ +# Functions (`kmath-functions`) + +Functions and interpolations: + + - [piecewise](src/commonMain/kotlin/kscience/kmath/functions/Piecewise.kt) : Piecewise functions. + - [polynomials](src/commonMain/kotlin/kscience/kmath/functions/Polynomial.kt) : Polynomial functions. + - [linear interpolation](src/commonMain/kotlin/kscience/kmath/interpolation/LinearInterpolator.kt) : Linear XY interpolator. + - [spline interpolation](src/commonMain/kotlin/kscience/kmath/interpolation/SplineInterpolator.kt) : Cubic spline XY interpolator. + + +> #### Artifact: +> +> This module artifact: `kscience.kmath:kmath-functions:0.2.0-dev-6`. +> +> Bintray release version: [ ![Download](https://api.bintray.com/packages/mipt-npm/kscience/kmath-functions/images/download.svg) ](https://bintray.com/mipt-npm/kscience/kmath-functions/_latestVersion) +> +> Bintray development version: [ ![Download](https://api.bintray.com/packages/mipt-npm/dev/kmath-functions/images/download.svg) ](https://bintray.com/mipt-npm/dev/kmath-functions/_latestVersion) +> +> **Gradle:** +> +> ```gradle +> repositories { +> maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } +> maven { url 'https://dl.bintray.com/mipt-npm/kscience' } +> maven { url 'https://dl.bintray.com/mipt-npm/dev' } +> maven { url 'https://dl.bintray.com/hotkeytlt/maven' } +> +> } +> +> dependencies { +> implementation 'kscience.kmath:kmath-functions:0.2.0-dev-6' +> } +> ``` +> **Gradle Kotlin DSL:** +> +> ```kotlin +> repositories { +> maven("https://dl.bintray.com/kotlin/kotlin-eap") +> maven("https://dl.bintray.com/mipt-npm/kscience") +> maven("https://dl.bintray.com/mipt-npm/dev") +> maven("https://dl.bintray.com/hotkeytlt/maven") +> } +> +> dependencies { +> implementation("kscience.kmath:kmath-functions:0.2.0-dev-6") +> } +> ``` diff --git a/kmath-functions/build.gradle.kts b/kmath-functions/build.gradle.kts index 2a4539c10..3af61a199 100644 --- a/kmath-functions/build.gradle.kts +++ b/kmath-functions/build.gradle.kts @@ -7,3 +7,14 @@ kotlin.sourceSets.commonMain { api(project(":kmath-core")) } } + +readme { + description = "Functions and interpolation" + maturity = ru.mipt.npm.gradle.Maturity.PROTOTYPE + propertyByTemplate("artifact", rootProject.file("docs/templates/ARTIFACT-TEMPLATE.md")) + + 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.") +} \ No newline at end of file diff --git a/kmath-functions/docs/README-TEMPLATE.md b/kmath-functions/docs/README-TEMPLATE.md new file mode 100644 index 000000000..8a34a7cc4 --- /dev/null +++ b/kmath-functions/docs/README-TEMPLATE.md @@ -0,0 +1,7 @@ +# Functions (`kmath-functions`) + +Functions and interpolations: + +${features} + +${artifact} diff --git a/kmath-functions/src/commonMain/kotlin/kscience/kmath/functions/Piecewise.kt b/kmath-functions/src/commonMain/kotlin/kscience/kmath/functions/Piecewise.kt index a8c020c05..8394ab39d 100644 --- a/kmath-functions/src/commonMain/kotlin/kscience/kmath/functions/Piecewise.kt +++ b/kmath-functions/src/commonMain/kotlin/kscience/kmath/functions/Piecewise.kt @@ -6,8 +6,7 @@ public fun interface Piecewise { public fun findPiece(arg: T): R? } -public fun interface PiecewisePolynomial : - Piecewise> +public fun interface PiecewisePolynomial : Piecewise> /** * Ordered list of pieces in piecewise function diff --git a/kmath-nd4j/README.md b/kmath-nd4j/README.md index ff4ff4542..5ef42bab3 100644 --- a/kmath-nd4j/README.md +++ b/kmath-nd4j/README.md @@ -9,7 +9,7 @@ This subproject implements the following features: > #### Artifact: > -> This module artifact: `kscience.kmath:kmath-nd4j:0.2.0-dev-4`. +> This module artifact: `kscience.kmath:kmath-nd4j:0.2.0-dev-6`. > > Bintray release version: [ ![Download](https://api.bintray.com/packages/mipt-npm/kscience/kmath-nd4j/images/download.svg) ](https://bintray.com/mipt-npm/kscience/kmath-nd4j/_latestVersion) > @@ -27,7 +27,7 @@ This subproject implements the following features: > } > > dependencies { -> implementation 'kscience.kmath:kmath-nd4j:0.2.0-dev-4' +> implementation 'kscience.kmath:kmath-nd4j:0.2.0-dev-6' > } > ``` > **Gradle Kotlin DSL:** @@ -41,7 +41,7 @@ This subproject implements the following features: > } > > dependencies { -> implementation("kscience.kmath:kmath-nd4j:0.2.0-dev-4") +> implementation("kscience.kmath:kmath-nd4j:0.2.0-dev-6") > } > ``` diff --git a/settings.gradle.kts b/settings.gradle.kts index a1ea40148..44ba32752 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,7 +8,7 @@ pluginManagement { maven("https://dl.bintray.com/kotlin/kotlinx") } - val toolsVersion = "0.7.3-1.4.30-RC" + val toolsVersion = "0.7.4" val kotlinVersion = "1.4.30-RC" plugins { From 28240954b0c32a4418d73a6dcf6c2f00727eea95 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sat, 30 Jan 2021 20:23:15 +0300 Subject: [PATCH 21/23] Documentation update. API generated --- .github/workflows/publish.yml | 147 +- README.md | 21 +- kmath-commons/build.gradle.kts | 4 + kmath-core/api/kmath-core.api | 3364 +++++++++++++++++++++++++++++ kmath-coroutines/build.gradle.kts | 4 + kmath-ejml/build.gradle.kts | 4 + kmath-functions/README.md | 8 +- kmath-geometry/build.gradle.kts | 4 + kmath-kotlingrad/build.gradle.kts | 4 + kmath-memory/api/kmath-memory.api | 72 + kmath-memory/build.gradle.kts | 7 + kmath-stat/build.gradle.kts | 4 + kmath-viktor/api/kmath-viktor.api | 189 ++ kmath-viktor/build.gradle.kts | 4 + 14 files changed, 3787 insertions(+), 49 deletions(-) create mode 100644 kmath-core/api/kmath-core.api create mode 100644 kmath-memory/api/kmath-memory.api create mode 100644 kmath-viktor/api/kmath-viktor.api diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0d472b1b9..40b172908 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,40 +1,117 @@ name: Bintray Publish on: - release: - types: - - created + release: + types: + - created jobs: - build-on-windows: - runs-on: windows-latest - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Gradle clean - run: ./gradlew clean - - name: Gradle build - run: ./gradlew build - - name: Run release task - run: ./gradlew release -PbintrayUser=${{ secrets.BINTRAY_USER }} -PbintrayApiKey=${{ secrets.BINTRAY_KEY }} - build-on-macos: - runs-on: macos-latest - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Gradle clean - run: ./gradlew clean - - name: Gradle build - run: ./gradlew build - - name: Run release task - run: ./gradlew release -PbintrayUser=${{ secrets.BINTRAY_USER }} -PbintrayApiKey=${{ secrets.BINTRAY_KEY }} + build-ubuntu: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Install Chrome + run: | + sudo apt install -y libappindicator1 fonts-liberation + wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb + sudo dpkg -i google-chrome*.deb + - name: Cache gradle + uses: actions/cache@v2 + with: + path: | + .gradle + build + ~/.gradle + key: gradle + restore-keys: gradle + + - name: Cache konan + uses: actions/cache@v2 + with: + path: | + ~/.konan/dependencies + ~/.konan/kotlin-native-prebuilt-linux-* + key: ${{ runner.os }}-konan + restore-keys: ${{ runner.os }}-konan + - name: Build with Gradle + run: ./gradlew -Dorg.gradle.daemon=false --build-cache build + - name: Run release task + run: ./gradlew release -PbintrayUser=${{ secrets.BINTRAY_USER }} -PbintrayApiKey=${{ secrets.BINTRAY_KEY }} + + build-osx: + runs-on: macos-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Cache gradle + uses: actions/cache@v2 + with: + path: | + .gradle + build + ~/.gradle + key: gradle + restore-keys: gradle + + - name: Cache konan + uses: actions/cache@v2 + with: + path: | + ~/.konan/dependencies + ~/.konan/kotlin-native-prebuilt-macos-* + key: ${{ runner.os }}-konan + restore-keys: ${{ runner.os }}-konan + - name: Build with Gradle + run: sudo ./gradlew -Dorg.gradle.daemon=false --build-cache build + - name: Run release task + run: ./gradlew release -PbintrayUser=${{ secrets.BINTRAY_USER }} -PbintrayApiKey=${{ secrets.BINTRAY_KEY }} + + build-windows: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Add msys to path + run: SETX PATH "%PATH%;C:\msys64\mingw64\bin" + - name: Cache gradle + uses: actions/cache@v2 + with: + path: | + .gradle + build + ~/.gradle + key: ${{ runner.os }}-gradle + restore-keys: ${{ runner.os }}-gradle + + - name: Cache konan + uses: actions/cache@v2 + with: + path: | + ~/.konan/dependencies + ~/.konan/kotlin-native-prebuilt-mingw-* + key: ${{ runner.os }}-konan + restore-keys: ${{ runner.os }}-konan + - name: Build with Gradle + run: ./gradlew --build-cache build + - name: Run release task + run: ./gradlew release -PbintrayUser=${{ secrets.BINTRAY_USER }} -PbintrayApiKey=${{ secrets.BINTRAY_KEY }} + diff --git a/README.md b/README.md index 8dfb783aa..6ab51098d 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ performance calculations to code generation. * ### [kmath-ejml](kmath-ejml) > > -> **Maturity**: EXPERIMENTAL +> **Maturity**: PROTOTYPE
* ### [kmath-for-real](kmath-for-real) @@ -160,17 +160,17 @@ One can still use generic algebras though. > **Maturity**: PROTOTYPE > > **Features:** -> - [piecewise](kmath-functions/src/commonMain/kotlin/kscience/kmath/functions/Piecewise.kt) : Piecewise functions. -> - [polynomials](kmath-functions/src/commonMain/kotlin/kscience/kmath/functions/Polynomial.kt) : Polynomial functions. -> - [linear interpolation](kmath-functions/src/commonMain/kotlin/kscience/kmath/interpolation/LinearInterpolator.kt) : Linear XY interpolator. -> - [spline interpolation](kmath-functions/src/commonMain/kotlin/kscience/kmath/interpolation/SplineInterpolator.kt) : Cubic spline XY interpolator. +> - [piecewise](kmath-functions/Piecewise functions.) : src/commonMain/kotlin/kscience/kmath/functions/Piecewise.kt +> - [polynomials](kmath-functions/Polynomial functions.) : src/commonMain/kotlin/kscience/kmath/functions/Polynomial.kt +> - [linear interpolation](kmath-functions/Linear XY interpolator.) : src/commonMain/kotlin/kscience/kmath/interpolation/LinearInterpolator.kt +> - [spline interpolation](kmath-functions/Cubic spline XY interpolator.) : src/commonMain/kotlin/kscience/kmath/interpolation/SplineInterpolator.kt
* ### [kmath-geometry](kmath-geometry) > > -> **Maturity**: EXPERIMENTAL +> **Maturity**: PROTOTYPE
* ### [kmath-histograms](kmath-histograms) @@ -182,13 +182,13 @@ One can still use generic algebras though. * ### [kmath-kotlingrad](kmath-kotlingrad) > > -> **Maturity**: EXPERIMENTAL +> **Maturity**: PROTOTYPE
* ### [kmath-memory](kmath-memory) -> +> An API and basic implementation for arranging objects in a continous memory block. > -> **Maturity**: EXPERIMENTAL +> **Maturity**: DEVELOPMENT
* ### [kmath-nd4j](kmath-nd4j) @@ -212,7 +212,7 @@ One can still use generic algebras though. * ### [kmath-viktor](kmath-viktor) > > -> **Maturity**: EXPERIMENTAL +> **Maturity**: DEVELOPMENT
@@ -242,6 +242,7 @@ Release artifacts are accessible from bintray with following configuration (see ```kotlin repositories { maven("https://dl.bintray.com/mipt-npm/kscience") + // maven("https://dl.bintray.com/mipt-npm/dev") for dev versions } dependencies { diff --git a/kmath-commons/build.gradle.kts b/kmath-commons/build.gradle.kts index 6a44c92f2..45630a435 100644 --- a/kmath-commons/build.gradle.kts +++ b/kmath-commons/build.gradle.kts @@ -10,3 +10,7 @@ dependencies { api(project(":kmath-functions")) api("org.apache.commons:commons-math3:3.6.1") } + +readme{ + maturity = ru.mipt.npm.gradle.Maturity.EXPERIMENTAL +} \ No newline at end of file diff --git a/kmath-core/api/kmath-core.api b/kmath-core/api/kmath-core.api new file mode 100644 index 000000000..ab0555932 --- /dev/null +++ b/kmath-core/api/kmath-core.api @@ -0,0 +1,3364 @@ +public abstract interface class kscience/kmath/domains/Domain { + public abstract fun contains (Lkscience/kmath/structures/Buffer;)Z + public abstract fun getDimension ()I +} + +public final class kscience/kmath/domains/HyperSquareDomain : kscience/kmath/domains/RealDomain { + public synthetic fun ([D[DLkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun contains (Lkscience/kmath/structures/Buffer;)Z + public fun getDimension ()I + public fun getLowerBound (I)Ljava/lang/Double; + public fun getLowerBound (ILkscience/kmath/structures/Buffer;)Ljava/lang/Double; + public fun getUpperBound (I)Ljava/lang/Double; + public fun getUpperBound (ILkscience/kmath/structures/Buffer;)Ljava/lang/Double; + public fun nearestInDomain (Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public fun volume ()D +} + +public abstract interface class kscience/kmath/domains/RealDomain : kscience/kmath/domains/Domain { + public abstract fun getLowerBound (I)Ljava/lang/Double; + public abstract fun getLowerBound (ILkscience/kmath/structures/Buffer;)Ljava/lang/Double; + public abstract fun getUpperBound (I)Ljava/lang/Double; + public abstract fun getUpperBound (ILkscience/kmath/structures/Buffer;)Ljava/lang/Double; + public abstract fun nearestInDomain (Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public abstract fun volume ()D +} + +public final class kscience/kmath/domains/UnconstrainedDomain : kscience/kmath/domains/RealDomain { + public fun (I)V + public fun contains (Lkscience/kmath/structures/Buffer;)Z + public fun getDimension ()I + public fun getLowerBound (I)Ljava/lang/Double; + public fun getLowerBound (ILkscience/kmath/structures/Buffer;)Ljava/lang/Double; + public fun getUpperBound (I)Ljava/lang/Double; + public fun getUpperBound (ILkscience/kmath/structures/Buffer;)Ljava/lang/Double; + public fun nearestInDomain (Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public fun volume ()D +} + +public final class kscience/kmath/domains/UnivariateDomain : kscience/kmath/domains/RealDomain { + public static final synthetic fun box-impl (Lkotlin/ranges/ClosedFloatingPointRange;)Lkscience/kmath/domains/UnivariateDomain; + public static fun constructor-impl (Lkotlin/ranges/ClosedFloatingPointRange;)Lkotlin/ranges/ClosedFloatingPointRange; + public fun contains (Lkscience/kmath/structures/Buffer;)Z + public static final fun contains-impl (Lkotlin/ranges/ClosedFloatingPointRange;D)Z + public static fun contains-impl (Lkotlin/ranges/ClosedFloatingPointRange;Lkscience/kmath/structures/Buffer;)Z + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Lkotlin/ranges/ClosedFloatingPointRange;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Lkotlin/ranges/ClosedFloatingPointRange;Lkotlin/ranges/ClosedFloatingPointRange;)Z + public fun getDimension ()I + public static fun getDimension-impl (Lkotlin/ranges/ClosedFloatingPointRange;)I + public fun getLowerBound (I)Ljava/lang/Double; + public fun getLowerBound (ILkscience/kmath/structures/Buffer;)Ljava/lang/Double; + public static fun getLowerBound-impl (Lkotlin/ranges/ClosedFloatingPointRange;I)Ljava/lang/Double; + public static fun getLowerBound-impl (Lkotlin/ranges/ClosedFloatingPointRange;ILkscience/kmath/structures/Buffer;)Ljava/lang/Double; + public final fun getRange ()Lkotlin/ranges/ClosedFloatingPointRange; + public fun getUpperBound (I)Ljava/lang/Double; + public fun getUpperBound (ILkscience/kmath/structures/Buffer;)Ljava/lang/Double; + public static fun getUpperBound-impl (Lkotlin/ranges/ClosedFloatingPointRange;I)Ljava/lang/Double; + public static fun getUpperBound-impl (Lkotlin/ranges/ClosedFloatingPointRange;ILkscience/kmath/structures/Buffer;)Ljava/lang/Double; + public fun hashCode ()I + public static fun hashCode-impl (Lkotlin/ranges/ClosedFloatingPointRange;)I + public fun nearestInDomain (Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public static fun nearestInDomain-impl (Lkotlin/ranges/ClosedFloatingPointRange;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Lkotlin/ranges/ClosedFloatingPointRange;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Lkotlin/ranges/ClosedFloatingPointRange; + public fun volume ()D + public static fun volume-impl (Lkotlin/ranges/ClosedFloatingPointRange;)D +} + +public abstract interface class kscience/kmath/expressions/AutoDiffProcessor { + public abstract fun process (Lkotlin/jvm/functions/Function1;)Lkscience/kmath/expressions/DifferentiableExpression; +} + +public class kscience/kmath/expressions/AutoDiffValue { + public fun (Ljava/lang/Object;)V + public final fun getValue ()Ljava/lang/Object; +} + +public final class kscience/kmath/expressions/DerivationResult { + public fun (Ljava/lang/Object;Ljava/util/Map;Lkscience/kmath/operations/Field;)V + public final fun derivative (Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public final fun div ()Ljava/lang/Object; + public final fun getContext ()Lkscience/kmath/operations/Field; + public final fun getValue ()Ljava/lang/Object; +} + +public abstract interface class kscience/kmath/expressions/DifferentiableExpression : kscience/kmath/expressions/Expression { + public abstract fun derivativeOrNull (Ljava/util/List;)Lkscience/kmath/expressions/Expression; +} + +public final class kscience/kmath/expressions/DifferentiableExpressionKt { + public static final fun derivative (Lkscience/kmath/expressions/DifferentiableExpression;Ljava/lang/String;)Lkscience/kmath/expressions/Expression; + public static final fun derivative (Lkscience/kmath/expressions/DifferentiableExpression;Ljava/util/List;)Lkscience/kmath/expressions/Expression; + public static final fun derivative (Lkscience/kmath/expressions/DifferentiableExpression;[Lkscience/kmath/expressions/Symbol;)Lkscience/kmath/expressions/Expression; +} + +public abstract interface class kscience/kmath/expressions/Expression { + public abstract fun invoke (Ljava/util/Map;)Ljava/lang/Object; +} + +public abstract interface class kscience/kmath/expressions/ExpressionAlgebra : kscience/kmath/operations/Algebra { + public abstract fun bindOrNull (Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public abstract fun const (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun symbol (Ljava/lang/String;)Ljava/lang/Object; +} + +public final class kscience/kmath/expressions/ExpressionAlgebra$DefaultImpls { + public static fun binaryOperation (Lkscience/kmath/expressions/ExpressionAlgebra;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperationFunction (Lkscience/kmath/expressions/ExpressionAlgebra;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun symbol (Lkscience/kmath/expressions/ExpressionAlgebra;Ljava/lang/String;)Ljava/lang/Object; + public static fun unaryOperation (Lkscience/kmath/expressions/ExpressionAlgebra;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperationFunction (Lkscience/kmath/expressions/ExpressionAlgebra;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + +public final class kscience/kmath/expressions/ExpressionBuildersKt { + public static final fun extendedFieldExpression (Lkscience/kmath/operations/ExtendedField;Lkotlin/jvm/functions/Function1;)Lkscience/kmath/expressions/Expression; + public static final fun fieldExpression (Lkscience/kmath/operations/Field;Lkotlin/jvm/functions/Function1;)Lkscience/kmath/expressions/Expression; + public static final fun ringExpression (Lkscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function1;)Lkscience/kmath/expressions/Expression; + public static final fun spaceExpression (Lkscience/kmath/operations/Space;Lkotlin/jvm/functions/Function1;)Lkscience/kmath/expressions/Expression; +} + +public final class kscience/kmath/expressions/ExpressionKt { + public static final fun bind (Lkscience/kmath/expressions/ExpressionAlgebra;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public static final fun binding (Lkscience/kmath/expressions/ExpressionAlgebra;)Lkotlin/properties/ReadOnlyProperty; + public static final fun callByString (Lkscience/kmath/expressions/Expression;[Lkotlin/Pair;)Ljava/lang/Object; + public static final fun callBySymbol (Lkscience/kmath/expressions/Expression;[Lkotlin/Pair;)Ljava/lang/Object; + public static final fun getSymbol ()Lkotlin/properties/ReadOnlyProperty; + public static final fun invoke (Lkscience/kmath/expressions/Expression;)Ljava/lang/Object; +} + +public abstract class kscience/kmath/expressions/FirstDerivativeExpression : kscience/kmath/expressions/DifferentiableExpression { + public fun ()V + public final fun derivativeOrNull (Ljava/util/List;)Lkscience/kmath/expressions/Expression; + public abstract fun derivativeOrNull (Lkscience/kmath/expressions/Symbol;)Lkscience/kmath/expressions/Expression; +} + +public abstract class kscience/kmath/expressions/FunctionalExpressionAlgebra : kscience/kmath/expressions/ExpressionAlgebra { + public fun (Lkscience/kmath/operations/Algebra;)V + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;Lkscience/kmath/expressions/Expression;Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun bindOrNull (Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public fun bindOrNull (Lkscience/kmath/expressions/Symbol;)Lkscience/kmath/expressions/Expression; + public synthetic fun const (Ljava/lang/Object;)Ljava/lang/Object; + public fun const (Ljava/lang/Object;)Lkscience/kmath/expressions/Expression; + public final fun getAlgebra ()Lkscience/kmath/operations/Algebra; + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun symbol (Ljava/lang/String;)Lkscience/kmath/expressions/Expression; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + +public final class kscience/kmath/expressions/FunctionalExpressionAlgebraKt { + public static final fun expressionInExtendedField (Lkscience/kmath/operations/ExtendedField;Lkotlin/jvm/functions/Function1;)Lkscience/kmath/expressions/Expression; + public static final fun expressionInField (Lkscience/kmath/operations/Field;Lkotlin/jvm/functions/Function1;)Lkscience/kmath/expressions/Expression; + public static final fun expressionInRing (Lkscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function1;)Lkscience/kmath/expressions/Expression; + public static final fun expressionInSpace (Lkscience/kmath/operations/Space;Lkotlin/jvm/functions/Function1;)Lkscience/kmath/expressions/Expression; +} + +public class kscience/kmath/expressions/FunctionalExpressionExtendedField : kscience/kmath/expressions/FunctionalExpressionField, kscience/kmath/operations/ExtendedField { + public fun (Lkscience/kmath/operations/ExtendedField;)V + public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; + public fun acos (Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun acosh (Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; + public fun asin (Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun asinh (Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; + public fun atan (Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun atanh (Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; + public fun cos (Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun cosh (Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; + public fun exp (Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + 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;Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object; + public fun ln (Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun number (Ljava/lang/Number;)Lkscience/kmath/expressions/Expression; + public synthetic fun pow (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun pow (Lkscience/kmath/expressions/Expression;Ljava/lang/Number;)Lkscience/kmath/expressions/Expression; + public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun power (Lkscience/kmath/expressions/Expression;Ljava/lang/Number;)Lkscience/kmath/expressions/Expression; + public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperation (Ljava/lang/String;Lkscience/kmath/expressions/Expression;Ljava/lang/Number;)Lkscience/kmath/expressions/Expression; + public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; + public fun sin (Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun sinh (Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public synthetic fun sqrt (Ljava/lang/Object;)Ljava/lang/Object; + public fun sqrt (Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; + public fun tan (Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun tanh (Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + +public class kscience/kmath/expressions/FunctionalExpressionField : kscience/kmath/expressions/FunctionalExpressionRing, kscience/kmath/operations/Field { + public fun (Lkscience/kmath/operations/Field;)V + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun div (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun div (Ljava/lang/Number;Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public synthetic fun div (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public final fun div (Ljava/lang/Object;Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public final fun div (Lkscience/kmath/expressions/Expression;Ljava/lang/Object;)Lkscience/kmath/expressions/Expression; + public fun div (Lkscience/kmath/expressions/Expression;Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun divide (Lkscience/kmath/expressions/Expression;Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + +public class kscience/kmath/expressions/FunctionalExpressionRing : kscience/kmath/expressions/FunctionalExpressionSpace, kscience/kmath/operations/Ring { + public fun (Lkscience/kmath/operations/Ring;)V + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun getOne ()Ljava/lang/Object; + public fun getOne ()Lkscience/kmath/expressions/Expression; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply (Lkscience/kmath/expressions/Expression;Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public synthetic fun times (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public final fun times (Ljava/lang/Object;Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public final fun times (Lkscience/kmath/expressions/Expression;Ljava/lang/Object;)Lkscience/kmath/expressions/Expression; + public fun times (Lkscience/kmath/expressions/Expression;Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + +public class kscience/kmath/expressions/FunctionalExpressionSpace : kscience/kmath/expressions/FunctionalExpressionAlgebra, kscience/kmath/operations/Space { + public fun (Lkscience/kmath/operations/Space;)V + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun add (Lkscience/kmath/expressions/Expression;Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun div (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun div (Lkscience/kmath/expressions/Expression;Ljava/lang/Number;)Lkscience/kmath/expressions/Expression; + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero ()Lkscience/kmath/expressions/Expression; + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public final fun minus (Ljava/lang/Object;Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public final fun minus (Lkscience/kmath/expressions/Expression;Ljava/lang/Object;)Lkscience/kmath/expressions/Expression; + public fun minus (Lkscience/kmath/expressions/Expression;Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun multiply (Lkscience/kmath/expressions/Expression;Ljava/lang/Number;)Lkscience/kmath/expressions/Expression; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public final fun plus (Ljava/lang/Object;Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public final fun plus (Lkscience/kmath/expressions/Expression;Ljava/lang/Object;)Lkscience/kmath/expressions/Expression; + public fun plus (Lkscience/kmath/expressions/Expression;Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Ljava/lang/Number;Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public synthetic fun times (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun times (Lkscience/kmath/expressions/Expression;Ljava/lang/Number;)Lkscience/kmath/expressions/Expression; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryPlus (Lkscience/kmath/expressions/Expression;)Lkscience/kmath/expressions/Expression; +} + +public final class kscience/kmath/expressions/SimpleAutoDiffExpression : kscience/kmath/expressions/FirstDerivativeExpression { + public fun (Lkscience/kmath/operations/Field;Lkotlin/jvm/functions/Function1;)V + public fun derivativeOrNull (Lkscience/kmath/expressions/Symbol;)Lkscience/kmath/expressions/Expression; + public final fun getField ()Lkscience/kmath/operations/Field; + public final fun getFunction ()Lkotlin/jvm/functions/Function1; + public fun invoke (Ljava/util/Map;)Ljava/lang/Object; +} + +public final class kscience/kmath/expressions/SimpleAutoDiffExtendedField : kscience/kmath/expressions/SimpleAutoDiffField, kscience/kmath/operations/ExtendedField { + public fun (Lkscience/kmath/operations/ExtendedField;Ljava/util/Map;)V + public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; + public fun acos (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun acosh (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; + public fun asin (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun asinh (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; + public fun atan (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun atanh (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;Lkscience/kmath/expressions/AutoDiffValue;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; + public fun cos (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun cosh (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun div (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun div (Ljava/lang/Number;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + 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 (Lkscience/kmath/expressions/AutoDiffValue;Ljava/lang/Number;)Lkscience/kmath/expressions/AutoDiffValue; + public fun div (Lkscience/kmath/expressions/AutoDiffValue;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; + public fun exp (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + 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;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object; + public fun ln (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun minus (Lkscience/kmath/expressions/AutoDiffValue;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun plus (Lkscience/kmath/expressions/AutoDiffValue;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun pow (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun pow (Lkscience/kmath/expressions/AutoDiffValue;Ljava/lang/Number;)Lkscience/kmath/expressions/AutoDiffValue; + public final fun pow (Lkscience/kmath/expressions/AutoDiffValue;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun power (Lkscience/kmath/expressions/AutoDiffValue;Ljava/lang/Number;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperation (Ljava/lang/String;Lkscience/kmath/expressions/AutoDiffValue;Ljava/lang/Number;)Lkscience/kmath/expressions/AutoDiffValue; + public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; + public fun sin (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun sinh (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public final fun sqr (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun sqrt (Ljava/lang/Object;)Ljava/lang/Object; + public fun sqrt (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; + public fun tan (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun tanh (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Ljava/lang/Number;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + 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 fun times (Lkscience/kmath/expressions/AutoDiffValue;Ljava/lang/Number;)Lkscience/kmath/expressions/AutoDiffValue; + public fun times (Lkscience/kmath/expressions/AutoDiffValue;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryPlus (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; +} + +public class kscience/kmath/expressions/SimpleAutoDiffField : kscience/kmath/expressions/ExpressionAlgebra, kscience/kmath/operations/Field, kscience/kmath/operations/RingWithNumbers { + public fun (Lkscience/kmath/operations/Field;Ljava/util/Map;)V + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun add (Lkscience/kmath/expressions/AutoDiffValue;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;Lkscience/kmath/expressions/AutoDiffValue;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun bindOrNull (Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public fun bindOrNull (Lkscience/kmath/expressions/Symbol;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun const (Ljava/lang/Object;)Ljava/lang/Object; + public fun const (Ljava/lang/Object;)Lkscience/kmath/expressions/AutoDiffValue; + public final fun const (Lkotlin/jvm/functions/Function1;)Lkscience/kmath/expressions/AutoDiffValue; + public final fun derive (Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object; + public synthetic fun div (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun div (Ljava/lang/Number;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + 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 (Lkscience/kmath/expressions/AutoDiffValue;Ljava/lang/Number;)Lkscience/kmath/expressions/AutoDiffValue; + public fun div (Lkscience/kmath/expressions/AutoDiffValue;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun divide (Lkscience/kmath/expressions/AutoDiffValue;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public final fun getContext ()Lkscience/kmath/operations/Field; + public final fun getD (Lkscience/kmath/expressions/AutoDiffValue;)Ljava/lang/Object; + public synthetic fun getOne ()Ljava/lang/Object; + public fun getOne ()Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero ()Lkscience/kmath/expressions/AutoDiffValue; + 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;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + 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;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + 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 fun minus (Lkscience/kmath/expressions/AutoDiffValue;Ljava/lang/Number;)Lkscience/kmath/expressions/AutoDiffValue; + public fun minus (Lkscience/kmath/expressions/AutoDiffValue;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply (Lkscience/kmath/expressions/AutoDiffValue;Ljava/lang/Number;)Lkscience/kmath/expressions/AutoDiffValue; + public fun multiply (Lkscience/kmath/expressions/AutoDiffValue;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun number (Ljava/lang/Number;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun plus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun plus (Ljava/lang/Number;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + 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 fun plus (Lkscience/kmath/expressions/AutoDiffValue;Ljava/lang/Number;)Lkscience/kmath/expressions/AutoDiffValue; + public fun plus (Lkscience/kmath/expressions/AutoDiffValue;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperation (Ljava/lang/String;Lkscience/kmath/expressions/AutoDiffValue;Ljava/lang/Number;)Lkscience/kmath/expressions/AutoDiffValue; + public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public final fun setD (Lkscience/kmath/expressions/AutoDiffValue;Ljava/lang/Object;)V + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun symbol (Ljava/lang/String;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Ljava/lang/Number;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + 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 fun times (Lkscience/kmath/expressions/AutoDiffValue;Ljava/lang/Number;)Lkscience/kmath/expressions/AutoDiffValue; + public fun times (Lkscience/kmath/expressions/AutoDiffValue;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryPlus (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; +} + +public final class kscience/kmath/expressions/SimpleAutoDiffKt { + public static final fun acos (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public static final fun acosh (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public static final fun asin (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public static final fun asinh (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public static final fun atan (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public static final fun atanh (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public static final fun cos (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public static final fun cosh (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public static final fun exp (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public static final fun grad (Lkscience/kmath/expressions/DerivationResult;[Lkscience/kmath/expressions/Symbol;)Lkscience/kmath/structures/Buffer; + public static final fun ln (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public static final fun pow (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;D)Lkscience/kmath/expressions/AutoDiffValue; + public static final fun pow (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;I)Lkscience/kmath/expressions/AutoDiffValue; + public static final fun pow (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public static final fun simpleAutoDiff (Lkscience/kmath/operations/Field;)Lkscience/kmath/expressions/AutoDiffProcessor; + public static final fun simpleAutoDiff (Lkscience/kmath/operations/Field;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Lkscience/kmath/expressions/DerivationResult; + public static final fun simpleAutoDiff (Lkscience/kmath/operations/Field;[Lkotlin/Pair;Lkotlin/jvm/functions/Function1;)Lkscience/kmath/expressions/DerivationResult; + public static final fun sin (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public static final fun sinh (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public static final fun sqr (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public static final fun sqrt (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public static final fun tan (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; + public static final fun tanh (Lkscience/kmath/expressions/SimpleAutoDiffField;Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; +} + +public final class kscience/kmath/expressions/SimpleSymbolIndexer : kscience/kmath/expressions/SymbolIndexer { + public static final synthetic fun box-impl (Ljava/util/List;)Lkscience/kmath/expressions/SimpleSymbolIndexer; + public static fun constructor-impl (Ljava/util/List;)Ljava/util/List; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Ljava/util/List;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Ljava/util/List;Ljava/util/List;)Z + public fun get (Ljava/util/List;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public fun get (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/expressions/Symbol;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public fun get (Lkscience/kmath/structures/Buffer;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public fun get ([DLkscience/kmath/expressions/Symbol;)D + public fun get ([Ljava/lang/Object;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public static fun get-impl (Ljava/util/List;Ljava/util/List;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public static fun get-impl (Ljava/util/List;Lkscience/kmath/nd/Structure2D;Lkscience/kmath/expressions/Symbol;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public static fun get-impl (Ljava/util/List;Lkscience/kmath/structures/Buffer;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public static fun get-impl (Ljava/util/List;[DLkscience/kmath/expressions/Symbol;)D + public static fun get-impl (Ljava/util/List;[Ljava/lang/Object;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public fun getSymbols ()Ljava/util/List; + public fun hashCode ()I + public static fun hashCode-impl (Ljava/util/List;)I + public fun indexOf (Lkscience/kmath/expressions/Symbol;)I + public static fun indexOf-impl (Ljava/util/List;Lkscience/kmath/expressions/Symbol;)I + public fun toDoubleArray (Ljava/util/Map;)[D + public static fun toDoubleArray-impl (Ljava/util/List;Ljava/util/Map;)[D + public fun toList (Ljava/util/Map;)Ljava/util/List; + public static fun toList-impl (Ljava/util/List;Ljava/util/Map;)Ljava/util/List; + public fun toMap ([D)Ljava/util/Map; + public static fun toMap-impl (Ljava/util/List;[D)Ljava/util/Map; + public fun toPoint (Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkscience/kmath/structures/Buffer; + public static fun toPoint-impl (Ljava/util/List;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkscience/kmath/structures/Buffer; + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Ljava/util/List;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Ljava/util/List; +} + +public final class kscience/kmath/expressions/StringSymbol : kscience/kmath/expressions/Symbol { + public static final synthetic fun box-impl (Ljava/lang/String;)Lkscience/kmath/expressions/StringSymbol; + public static fun constructor-impl (Ljava/lang/String;)Ljava/lang/String; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Ljava/lang/String;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Ljava/lang/String;Ljava/lang/String;)Z + public fun getIdentity ()Ljava/lang/String; + public fun hashCode ()I + public static fun hashCode-impl (Ljava/lang/String;)I + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Ljava/lang/String;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Ljava/lang/String; +} + +public abstract interface class kscience/kmath/expressions/Symbol { + public static final field Companion Lkscience/kmath/expressions/Symbol$Companion; + public abstract fun getIdentity ()Ljava/lang/String; +} + +public final class kscience/kmath/expressions/Symbol$Companion : kotlin/properties/ReadOnlyProperty { + public synthetic fun getValue (Ljava/lang/Object;Lkotlin/reflect/KProperty;)Ljava/lang/Object; + public fun getValue (Ljava/lang/Object;Lkotlin/reflect/KProperty;)Lkscience/kmath/expressions/Symbol; +} + +public abstract interface class kscience/kmath/expressions/SymbolIndexer { + public abstract fun get (Ljava/util/List;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public abstract fun get (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/expressions/Symbol;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public abstract fun get (Lkscience/kmath/structures/Buffer;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public abstract fun get ([DLkscience/kmath/expressions/Symbol;)D + public abstract fun get ([Ljava/lang/Object;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public abstract fun getSymbols ()Ljava/util/List; + public abstract fun indexOf (Lkscience/kmath/expressions/Symbol;)I + public abstract fun toDoubleArray (Ljava/util/Map;)[D + public abstract fun toList (Ljava/util/Map;)Ljava/util/List; + public abstract fun toMap ([D)Ljava/util/Map; + public abstract fun toPoint (Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkscience/kmath/structures/Buffer; +} + +public final class kscience/kmath/expressions/SymbolIndexer$DefaultImpls { + public static fun get (Lkscience/kmath/expressions/SymbolIndexer;Ljava/util/List;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public static fun get (Lkscience/kmath/expressions/SymbolIndexer;Lkscience/kmath/nd/Structure2D;Lkscience/kmath/expressions/Symbol;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public static fun get (Lkscience/kmath/expressions/SymbolIndexer;Lkscience/kmath/structures/Buffer;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public static fun get (Lkscience/kmath/expressions/SymbolIndexer;[DLkscience/kmath/expressions/Symbol;)D + public static fun get (Lkscience/kmath/expressions/SymbolIndexer;[Ljava/lang/Object;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; + public static fun indexOf (Lkscience/kmath/expressions/SymbolIndexer;Lkscience/kmath/expressions/Symbol;)I + public static fun toDoubleArray (Lkscience/kmath/expressions/SymbolIndexer;Ljava/util/Map;)[D + public static fun toList (Lkscience/kmath/expressions/SymbolIndexer;Ljava/util/Map;)Ljava/util/List; + public static fun toMap (Lkscience/kmath/expressions/SymbolIndexer;[D)Ljava/util/Map; + public static fun toPoint (Lkscience/kmath/expressions/SymbolIndexer;Ljava/util/Map;Lkotlin/jvm/functions/Function2;)Lkscience/kmath/structures/Buffer; +} + +public final class kscience/kmath/expressions/SymbolIndexerKt { + public static final fun withSymbols (Ljava/util/Collection;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static final fun withSymbols ([Lkscience/kmath/expressions/Symbol;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; +} + +public final class kscience/kmath/linear/BufferMatrix : kscience/kmath/nd/Structure2D { + public fun (IILkscience/kmath/structures/Buffer;)V + public fun elements ()Lkotlin/sequences/Sequence; + public fun equals (Ljava/lang/Object;)Z + public fun get (II)Ljava/lang/Object; + public fun get ([I)Ljava/lang/Object; + public final fun getBuffer ()Lkscience/kmath/structures/Buffer; + public fun getColNum ()I + public fun getColumns ()Lkscience/kmath/structures/Buffer; + public fun getDimension ()I + public fun getFeature (Lkotlin/reflect/KClass;)Ljava/lang/Object; + public fun getRowNum ()I + public fun getRows ()Lkscience/kmath/structures/Buffer; + public fun getShape ()[I + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class kscience/kmath/linear/BufferMatrixContext : kscience/kmath/linear/GenericMatrixContext { + public static final field Companion Lkscience/kmath/linear/BufferMatrixContext$Companion; + public fun (Lkscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;)V + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun add (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/linear/BufferMatrix; + public synthetic fun add (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun div (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun div (Lkscience/kmath/nd/Structure2D;Ljava/lang/Number;)Lkscience/kmath/nd/Structure2D; + public fun dot (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/linear/BufferMatrix; + public synthetic fun dot (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public fun dot (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public fun getElementContext ()Lkscience/kmath/operations/Ring; + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun minus (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/linear/BufferMatrix; + public synthetic fun minus (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun multiply (Lkscience/kmath/nd/Structure2D;Ljava/lang/Number;)Lkscience/kmath/linear/BufferMatrix; + public synthetic fun multiply (Lkscience/kmath/nd/Structure2D;Ljava/lang/Number;)Lkscience/kmath/nd/Structure2D; + public final fun one (II)Lkscience/kmath/nd/Structure2D; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun plus (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public fun point (ILkotlin/jvm/functions/Function1;)Lkscience/kmath/structures/Buffer; + public fun produce (IILkotlin/jvm/functions/Function2;)Lkscience/kmath/linear/BufferMatrix; + public synthetic fun produce (IILkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/Structure2D; + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun symbol (Ljava/lang/String;)Lkscience/kmath/nd/Structure2D; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Ljava/lang/Number;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public synthetic fun times (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun times (Ljava/lang/Object;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/linear/BufferMatrix; + public synthetic fun times (Ljava/lang/Object;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public fun times (Lkscience/kmath/nd/Structure2D;Ljava/lang/Number;)Lkscience/kmath/nd/Structure2D; + public fun times (Lkscience/kmath/nd/Structure2D;Ljava/lang/Object;)Lkscience/kmath/linear/BufferMatrix; + public synthetic fun times (Lkscience/kmath/nd/Structure2D;Ljava/lang/Object;)Lkscience/kmath/nd/Structure2D; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/linear/BufferMatrix; + public synthetic fun unaryMinus (Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryPlus (Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; +} + +public final class kscience/kmath/linear/BufferMatrixContext$Companion { +} + +public final class kscience/kmath/linear/BufferVectorSpace : kscience/kmath/linear/VectorSpace { + public fun (ILkscience/kmath/operations/Space;Lkotlin/jvm/functions/Function2;)V + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun add (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun div (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun div (Lkscience/kmath/structures/Buffer;Ljava/lang/Number;)Lkscience/kmath/structures/Buffer; + public final fun getBufferFactory ()Lkotlin/jvm/functions/Function2; + public fun getSize ()I + public fun getSpace ()Lkscience/kmath/operations/Space; + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero ()Lkscience/kmath/structures/Buffer; + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun minus (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun multiply (Lkscience/kmath/structures/Buffer;Ljava/lang/Number;)Lkscience/kmath/structures/Buffer; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun plus (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public fun produce (Lkotlin/jvm/functions/Function2;)Lkscience/kmath/structures/Buffer; + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun symbol (Ljava/lang/String;)Lkscience/kmath/structures/Buffer; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Ljava/lang/Number;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public synthetic fun times (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun times (Lkscience/kmath/structures/Buffer;Ljava/lang/Number;)Lkscience/kmath/structures/Buffer; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryPlus (Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; +} + +public abstract interface class kscience/kmath/linear/CholeskyDecompositionFeature : kscience/kmath/linear/MatrixFeature { + public abstract fun getL ()Lkscience/kmath/nd/Structure2D; +} + +public abstract interface class kscience/kmath/linear/DeterminantFeature : kscience/kmath/linear/MatrixFeature { + public abstract fun getDeterminant ()Ljava/lang/Object; +} + +public abstract interface class kscience/kmath/linear/DiagonalFeature : kscience/kmath/linear/MatrixFeature { + public static final field Companion Lkscience/kmath/linear/DiagonalFeature$Companion; +} + +public final class kscience/kmath/linear/DiagonalFeature$Companion : kscience/kmath/linear/DiagonalFeature { +} + +public abstract interface class kscience/kmath/linear/GenericMatrixContext : kscience/kmath/linear/MatrixContext { + public abstract fun add (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public abstract fun dot (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public abstract fun dot (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public abstract fun getElementContext ()Lkscience/kmath/operations/Ring; + public abstract fun minus (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public abstract fun multiply (Lkscience/kmath/nd/Structure2D;Ljava/lang/Number;)Lkscience/kmath/nd/Structure2D; + public abstract fun times (Lkscience/kmath/nd/Structure2D;Ljava/lang/Object;)Lkscience/kmath/nd/Structure2D; + public abstract fun unaryMinus (Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; +} + +public final class kscience/kmath/linear/GenericMatrixContext$DefaultImpls { + public static fun add (Lkscience/kmath/linear/GenericMatrixContext;Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static fun binaryOperation (Lkscience/kmath/linear/GenericMatrixContext;Ljava/lang/String;Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static fun binaryOperationFunction (Lkscience/kmath/linear/GenericMatrixContext;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun div (Lkscience/kmath/linear/GenericMatrixContext;Lkscience/kmath/nd/Structure2D;Ljava/lang/Number;)Lkscience/kmath/nd/Structure2D; + public static fun dot (Lkscience/kmath/linear/GenericMatrixContext;Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static fun dot (Lkscience/kmath/linear/GenericMatrixContext;Lkscience/kmath/nd/Structure2D;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public static fun minus (Lkscience/kmath/linear/GenericMatrixContext;Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static fun multiply (Lkscience/kmath/linear/GenericMatrixContext;Lkscience/kmath/nd/Structure2D;Ljava/lang/Number;)Lkscience/kmath/nd/Structure2D; + public static fun plus (Lkscience/kmath/linear/GenericMatrixContext;Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static fun point (Lkscience/kmath/linear/GenericMatrixContext;ILkotlin/jvm/functions/Function1;)Lkscience/kmath/structures/Buffer; + public static fun symbol (Lkscience/kmath/linear/GenericMatrixContext;Ljava/lang/String;)Lkscience/kmath/nd/Structure2D; + public static fun times (Lkscience/kmath/linear/GenericMatrixContext;Ljava/lang/Number;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static fun times (Lkscience/kmath/linear/GenericMatrixContext;Ljava/lang/Object;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static fun times (Lkscience/kmath/linear/GenericMatrixContext;Lkscience/kmath/nd/Structure2D;Ljava/lang/Number;)Lkscience/kmath/nd/Structure2D; + public static fun times (Lkscience/kmath/linear/GenericMatrixContext;Lkscience/kmath/nd/Structure2D;Ljava/lang/Object;)Lkscience/kmath/nd/Structure2D; + public static fun unaryMinus (Lkscience/kmath/linear/GenericMatrixContext;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static fun unaryOperation (Lkscience/kmath/linear/GenericMatrixContext;Ljava/lang/String;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static fun unaryOperationFunction (Lkscience/kmath/linear/GenericMatrixContext;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lkscience/kmath/linear/GenericMatrixContext;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; +} + +public abstract interface class kscience/kmath/linear/InverseMatrixFeature : kscience/kmath/linear/MatrixFeature { + public abstract fun getInverse ()Lkscience/kmath/nd/Structure2D; +} + +public final class kscience/kmath/linear/LFeature : kscience/kmath/linear/MatrixFeature { + public static final field INSTANCE Lkscience/kmath/linear/LFeature; +} + +public final class kscience/kmath/linear/LinearAlgebraKt { + public static final fun asMatrix (Lkscience/kmath/structures/Buffer;)Lkscience/kmath/linear/VirtualMatrix; + public static final fun asPoint (Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/structures/Buffer; +} + +public abstract interface class kscience/kmath/linear/LinearSolver { + public abstract fun inverse (Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public abstract fun solve (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public abstract fun solve (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; +} + +public final class kscience/kmath/linear/LinearSolver$DefaultImpls { + public static fun solve (Lkscience/kmath/linear/LinearSolver;Lkscience/kmath/nd/Structure2D;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; +} + +public final class kscience/kmath/linear/LupDecomposition : kscience/kmath/linear/DeterminantFeature, kscience/kmath/linear/LupDecompositionFeature { + public fun (Lkscience/kmath/linear/MatrixContext;Lkscience/kmath/operations/Field;Lkscience/kmath/nd/Structure2D;[IZ)V + public final fun getContext ()Lkscience/kmath/linear/MatrixContext; + public fun getDeterminant ()Ljava/lang/Object; + public final fun getElementContext ()Lkscience/kmath/operations/Field; + public fun getL ()Lkscience/kmath/nd/Structure2D; + public final fun getLu ()Lkscience/kmath/nd/Structure2D; + public fun getP ()Lkscience/kmath/nd/Structure2D; + public final fun getPivot ()[I + public fun getU ()Lkscience/kmath/nd/Structure2D; +} + +public abstract interface class kscience/kmath/linear/LupDecompositionFeature : kscience/kmath/linear/MatrixFeature { + public abstract fun getL ()Lkscience/kmath/nd/Structure2D; + public abstract fun getP ()Lkscience/kmath/nd/Structure2D; + public abstract fun getU ()Lkscience/kmath/nd/Structure2D; +} + +public final class kscience/kmath/linear/LupDecompositionKt { + public static final fun abs (Lkscience/kmath/linear/GenericMatrixContext;Ljava/lang/Comparable;)Ljava/lang/Comparable; + public static final fun inverseWithLup (Lkscience/kmath/linear/RealMatrixContext;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static final fun lup (Lkscience/kmath/linear/MatrixContext;Lkotlin/jvm/functions/Function2;Lkscience/kmath/operations/Field;Lkscience/kmath/nd/Structure2D;Lkotlin/jvm/functions/Function1;)Lkscience/kmath/linear/LupDecomposition; + public static final fun lup (Lkscience/kmath/linear/MatrixContext;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/linear/LupDecomposition; + public static final fun solveWithLup (Lkscience/kmath/linear/LupDecomposition;Lkotlin/jvm/functions/Function2;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static final fun solveWithLup (Lkscience/kmath/linear/RealMatrixContext;Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; +} + +public final class kscience/kmath/linear/MatrixBuilder { + public fun (II)V + public final fun getColumns ()I + public final fun getRows ()I + public final fun invoke ([Ljava/lang/Object;)Lkscience/kmath/nd/Structure2D; +} + +public final class kscience/kmath/linear/MatrixBuilderKt { + public static final fun build (Lkscience/kmath/nd/Structure2D$Companion;II)Lkscience/kmath/linear/MatrixBuilder; + public static final fun column (Lkscience/kmath/nd/Structure2D$Companion;[Ljava/lang/Object;)Lkscience/kmath/nd/Structure2D; + public static final fun row (Lkscience/kmath/nd/Structure2D$Companion;[Ljava/lang/Object;)Lkscience/kmath/nd/Structure2D; +} + +public abstract interface class kscience/kmath/linear/MatrixContext : kscience/kmath/operations/SpaceOperations { + public static final field Companion Lkscience/kmath/linear/MatrixContext$Companion; + public abstract fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public abstract fun dot (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public abstract fun dot (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public abstract fun point (ILkotlin/jvm/functions/Function1;)Lkscience/kmath/structures/Buffer; + public abstract fun produce (IILkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/Structure2D; + public abstract fun times (Ljava/lang/Object;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public abstract fun times (Lkscience/kmath/nd/Structure2D;Ljava/lang/Object;)Lkscience/kmath/nd/Structure2D; +} + +public final class kscience/kmath/linear/MatrixContext$Companion { + public final fun buffered (Lkscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;)Lkscience/kmath/linear/GenericMatrixContext; + public static synthetic fun buffered$default (Lkscience/kmath/linear/MatrixContext$Companion;Lkscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkscience/kmath/linear/GenericMatrixContext; +} + +public final class kscience/kmath/linear/MatrixContext$DefaultImpls { + public static fun binaryOperation (Lkscience/kmath/linear/MatrixContext;Ljava/lang/String;Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static fun binaryOperationFunction (Lkscience/kmath/linear/MatrixContext;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun div (Lkscience/kmath/linear/MatrixContext;Lkscience/kmath/nd/Structure2D;Ljava/lang/Number;)Lkscience/kmath/nd/Structure2D; + public static fun minus (Lkscience/kmath/linear/MatrixContext;Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static fun plus (Lkscience/kmath/linear/MatrixContext;Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static fun point (Lkscience/kmath/linear/MatrixContext;ILkotlin/jvm/functions/Function1;)Lkscience/kmath/structures/Buffer; + public static fun symbol (Lkscience/kmath/linear/MatrixContext;Ljava/lang/String;)Lkscience/kmath/nd/Structure2D; + public static fun times (Lkscience/kmath/linear/MatrixContext;Ljava/lang/Number;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static fun times (Lkscience/kmath/linear/MatrixContext;Ljava/lang/Object;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static fun times (Lkscience/kmath/linear/MatrixContext;Lkscience/kmath/nd/Structure2D;Ljava/lang/Number;)Lkscience/kmath/nd/Structure2D; + public static fun unaryMinus (Lkscience/kmath/linear/MatrixContext;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static fun unaryOperation (Lkscience/kmath/linear/MatrixContext;Ljava/lang/String;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static fun unaryOperationFunction (Lkscience/kmath/linear/MatrixContext;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lkscience/kmath/linear/MatrixContext;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; +} + +public abstract interface class kscience/kmath/linear/MatrixFeature { +} + +public final class kscience/kmath/linear/MatrixFeaturesKt { + public static final fun DeterminantFeature (Ljava/lang/Object;)Lkscience/kmath/linear/DeterminantFeature; +} + +public final class kscience/kmath/linear/MatrixWrapper : kscience/kmath/nd/Structure2D { + public fun elements ()Lkotlin/sequences/Sequence; + public fun equals (Ljava/lang/Object;)Z + public fun get (II)Ljava/lang/Object; + public fun get ([I)Ljava/lang/Object; + public fun getColNum ()I + public fun getColumns ()Lkscience/kmath/structures/Buffer; + public fun getDimension ()I + public fun getFeature (Lkotlin/reflect/KClass;)Ljava/lang/Object; + public final fun getFeatures ()Ljava/util/Set; + public final fun getOrigin ()Lkscience/kmath/nd/Structure2D; + public fun getRowNum ()I + public fun getRows ()Lkscience/kmath/structures/Buffer; + public fun getShape ()[I + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class kscience/kmath/linear/MatrixWrapperKt { + public static final fun getOrigin (Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static final fun one (Lkscience/kmath/linear/GenericMatrixContext;II)Lkscience/kmath/nd/Structure2D; + public static final fun plus (Lkscience/kmath/nd/Structure2D;Ljava/util/Collection;)Lkscience/kmath/linear/MatrixWrapper; + public static final fun plus (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/linear/MatrixFeature;)Lkscience/kmath/linear/MatrixWrapper; + public static final fun square (Lkscience/kmath/nd/Structure2D$Companion;[Ljava/lang/Object;)Lkscience/kmath/nd/Structure2D; + public static final fun transpose (Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public static final fun zero (Lkscience/kmath/linear/GenericMatrixContext;II)Lkscience/kmath/nd/Structure2D; +} + +public final class kscience/kmath/linear/OrthogonalFeature : kscience/kmath/linear/MatrixFeature { + public static final field INSTANCE Lkscience/kmath/linear/OrthogonalFeature; +} + +public abstract interface class kscience/kmath/linear/QRDecompositionFeature : kscience/kmath/linear/MatrixFeature { + public abstract fun getQ ()Lkscience/kmath/nd/Structure2D; + public abstract fun getR ()Lkscience/kmath/nd/Structure2D; +} + +public final class kscience/kmath/linear/RealMatrixContext : kscience/kmath/linear/MatrixContext { + public static final field INSTANCE Lkscience/kmath/linear/RealMatrixContext; + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun add (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/linear/BufferMatrix; + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun div (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun div (Lkscience/kmath/nd/Structure2D;Ljava/lang/Number;)Lkscience/kmath/nd/Structure2D; + public fun dot (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/linear/BufferMatrix; + public synthetic fun dot (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public fun dot (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun minus (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun multiply (Lkscience/kmath/nd/Structure2D;Ljava/lang/Number;)Lkscience/kmath/linear/BufferMatrix; + public final fun one (II)Lkscience/kmath/nd/Structure2D; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun plus (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public fun point (ILkotlin/jvm/functions/Function1;)Lkscience/kmath/structures/Buffer; + public fun produce (IILkotlin/jvm/functions/Function2;)Lkscience/kmath/linear/BufferMatrix; + public synthetic fun produce (IILkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/Structure2D; + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun symbol (Ljava/lang/String;)Lkscience/kmath/nd/Structure2D; + public fun times (DLkscience/kmath/nd/Structure2D;)Lkscience/kmath/linear/BufferMatrix; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Ljava/lang/Number;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public synthetic fun times (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public synthetic fun times (Ljava/lang/Object;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public fun times (Lkscience/kmath/nd/Structure2D;D)Lkscience/kmath/linear/BufferMatrix; + public fun times (Lkscience/kmath/nd/Structure2D;Ljava/lang/Number;)Lkscience/kmath/nd/Structure2D; + public synthetic fun times (Lkscience/kmath/nd/Structure2D;Ljava/lang/Object;)Lkscience/kmath/nd/Structure2D; + public final fun toBufferMatrix (Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/linear/BufferMatrix; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryPlus (Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/nd/Structure2D; +} + +public final class kscience/kmath/linear/RealMatrixContextKt { + public static final fun getReal (Lkscience/kmath/linear/MatrixContext$Companion;)Lkscience/kmath/linear/RealMatrixContext; +} + +public abstract interface class kscience/kmath/linear/SingularValueDecompositionFeature : kscience/kmath/linear/MatrixFeature { + public abstract fun getS ()Lkscience/kmath/nd/Structure2D; + public abstract fun getSingularValues ()Lkscience/kmath/structures/Buffer; + public abstract fun getU ()Lkscience/kmath/nd/Structure2D; + public abstract fun getV ()Lkscience/kmath/nd/Structure2D; +} + +public final class kscience/kmath/linear/TransposedFeature : kscience/kmath/linear/MatrixFeature { + public fun (Lkscience/kmath/nd/Structure2D;)V + public final fun getOriginal ()Lkscience/kmath/nd/Structure2D; +} + +public final class kscience/kmath/linear/UFeature : kscience/kmath/linear/MatrixFeature { + public static final field INSTANCE Lkscience/kmath/linear/UFeature; +} + +public final class kscience/kmath/linear/UnitFeature : kscience/kmath/linear/DiagonalFeature { + public static final field INSTANCE Lkscience/kmath/linear/UnitFeature; +} + +public abstract interface class kscience/kmath/linear/VectorSpace : kscience/kmath/operations/Space { + public static final field Companion Lkscience/kmath/linear/VectorSpace$Companion; + public abstract fun add (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public abstract fun getSize ()I + public abstract fun getSpace ()Lkscience/kmath/operations/Space; + public abstract fun getZero ()Lkscience/kmath/structures/Buffer; + public abstract fun multiply (Lkscience/kmath/structures/Buffer;Ljava/lang/Number;)Lkscience/kmath/structures/Buffer; + public abstract fun produce (Lkotlin/jvm/functions/Function2;)Lkscience/kmath/structures/Buffer; +} + +public final class kscience/kmath/linear/VectorSpace$Companion { + public final fun buffered (ILkscience/kmath/operations/Space;Lkotlin/jvm/functions/Function2;)Lkscience/kmath/linear/BufferVectorSpace; + public static synthetic fun buffered$default (Lkscience/kmath/linear/VectorSpace$Companion;ILkscience/kmath/operations/Space;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkscience/kmath/linear/BufferVectorSpace; + public final fun real (I)Lkscience/kmath/linear/BufferVectorSpace; +} + +public final class kscience/kmath/linear/VectorSpace$DefaultImpls { + public static fun add (Lkscience/kmath/linear/VectorSpace;Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public static fun binaryOperation (Lkscience/kmath/linear/VectorSpace;Ljava/lang/String;Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public static fun binaryOperationFunction (Lkscience/kmath/linear/VectorSpace;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun div (Lkscience/kmath/linear/VectorSpace;Lkscience/kmath/structures/Buffer;Ljava/lang/Number;)Lkscience/kmath/structures/Buffer; + public static fun getZero (Lkscience/kmath/linear/VectorSpace;)Lkscience/kmath/structures/Buffer; + public static fun minus (Lkscience/kmath/linear/VectorSpace;Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public static fun multiply (Lkscience/kmath/linear/VectorSpace;Lkscience/kmath/structures/Buffer;Ljava/lang/Number;)Lkscience/kmath/structures/Buffer; + public static fun plus (Lkscience/kmath/linear/VectorSpace;Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public static fun symbol (Lkscience/kmath/linear/VectorSpace;Ljava/lang/String;)Lkscience/kmath/structures/Buffer; + public static fun times (Lkscience/kmath/linear/VectorSpace;Ljava/lang/Number;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public static fun times (Lkscience/kmath/linear/VectorSpace;Lkscience/kmath/structures/Buffer;Ljava/lang/Number;)Lkscience/kmath/structures/Buffer; + public static fun unaryMinus (Lkscience/kmath/linear/VectorSpace;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public static fun unaryOperation (Lkscience/kmath/linear/VectorSpace;Ljava/lang/String;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public static fun unaryOperationFunction (Lkscience/kmath/linear/VectorSpace;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lkscience/kmath/linear/VectorSpace;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; +} + +public final class kscience/kmath/linear/VirtualMatrix : kscience/kmath/nd/Structure2D { + public fun (IILkotlin/jvm/functions/Function2;)V + public fun elements ()Lkotlin/sequences/Sequence; + public fun equals (Ljava/lang/Object;)Z + public fun get (II)Ljava/lang/Object; + public fun get ([I)Ljava/lang/Object; + public fun getColNum ()I + public fun getColumns ()Lkscience/kmath/structures/Buffer; + public fun getDimension ()I + public fun getFeature (Lkotlin/reflect/KClass;)Ljava/lang/Object; + public final fun getGenerator ()Lkotlin/jvm/functions/Function2; + public fun getRowNum ()I + public fun getRows ()Lkscience/kmath/structures/Buffer; + public fun getShape ()[I + public fun hashCode ()I +} + +public final class kscience/kmath/linear/ZeroFeature : kscience/kmath/linear/DiagonalFeature { + public static final field INSTANCE Lkscience/kmath/linear/ZeroFeature; +} + +public final class kscience/kmath/misc/CumulativeKt { + public static final fun cumulative (Ljava/lang/Iterable;Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Ljava/lang/Iterable; + public static final fun cumulative (Ljava/util/Iterator;Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Ljava/util/Iterator; + public static final fun cumulative (Ljava/util/List;Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Ljava/util/List; + public static final fun cumulative (Lkotlin/sequences/Sequence;Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence; + public static final fun cumulativeSum (Ljava/lang/Iterable;Lkscience/kmath/operations/Space;)Ljava/lang/Iterable; + public static final fun cumulativeSum (Ljava/util/List;Lkscience/kmath/operations/Space;)Ljava/util/List; + public static final fun cumulativeSum (Lkotlin/sequences/Sequence;Lkscience/kmath/operations/Space;)Lkotlin/sequences/Sequence; + public static final fun cumulativeSumOfDouble (Ljava/lang/Iterable;)Ljava/lang/Iterable; + public static final fun cumulativeSumOfDouble (Ljava/util/List;)Ljava/util/List; + public static final fun cumulativeSumOfDouble (Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence; + public static final fun cumulativeSumOfInt (Ljava/lang/Iterable;)Ljava/lang/Iterable; + public static final fun cumulativeSumOfInt (Ljava/util/List;)Ljava/util/List; + public static final fun cumulativeSumOfInt (Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence; + public static final fun cumulativeSumOfLong (Ljava/lang/Iterable;)Ljava/lang/Iterable; + public static final fun cumulativeSumOfLong (Ljava/util/List;)Ljava/util/List; + public static final fun cumulativeSumOfLong (Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence; +} + +public abstract interface annotation class kscience/kmath/misc/UnstableKMathAPI : java/lang/annotation/Annotation { +} + +public abstract interface class kscience/kmath/nd/BufferNDAlgebra : kscience/kmath/nd/NDAlgebra { + public abstract fun combine (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lkscience/kmath/nd/NDBuffer; + public abstract fun getBuffer (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/structures/Buffer; + public abstract fun getBufferFactory ()Lkotlin/jvm/functions/Function2; + public abstract fun getStrides ()Lkscience/kmath/nd/Strides; + public abstract fun map (Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/NDBuffer; + public abstract fun mapIndexed (Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lkscience/kmath/nd/NDBuffer; + public abstract fun produce (Lkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/NDBuffer; +} + +public final class kscience/kmath/nd/BufferNDAlgebra$DefaultImpls { + public static fun combine (Lkscience/kmath/nd/BufferNDAlgebra;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lkscience/kmath/nd/NDBuffer; + public static fun getBuffer (Lkscience/kmath/nd/BufferNDAlgebra;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/structures/Buffer; + public static fun invoke (Lkscience/kmath/nd/BufferNDAlgebra;Lkotlin/jvm/functions/Function1;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun map (Lkscience/kmath/nd/BufferNDAlgebra;Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/NDBuffer; + public static fun mapIndexed (Lkscience/kmath/nd/BufferNDAlgebra;Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lkscience/kmath/nd/NDBuffer; + public static fun produce (Lkscience/kmath/nd/BufferNDAlgebra;Lkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/NDBuffer; +} + +public final class kscience/kmath/nd/BufferNDAlgebraKt { + public static final fun field (Lkscience/kmath/nd/NDAlgebra$Companion;Lkscience/kmath/operations/Field;Lkotlin/jvm/functions/Function2;[I)Lkscience/kmath/nd/BufferedNDField; + public static final fun ndField (Lkscience/kmath/operations/Field;Lkotlin/jvm/functions/Function2;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static final fun ndRing (Lkscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static final fun ndSpace (Lkscience/kmath/operations/Space;Lkotlin/jvm/functions/Function2;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static final fun ring (Lkscience/kmath/nd/NDAlgebra$Companion;Lkscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;[I)Lkscience/kmath/nd/BufferedNDRing; + public static final fun space (Lkscience/kmath/nd/NDAlgebra$Companion;Lkscience/kmath/operations/Space;Lkotlin/jvm/functions/Function2;[I)Lkscience/kmath/nd/BufferedNDSpace; +} + +public class kscience/kmath/nd/BufferedNDField : kscience/kmath/nd/BufferedNDRing, kscience/kmath/nd/NDField { + public fun ([ILkscience/kmath/operations/Field;Lkotlin/jvm/functions/Function2;)V + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun div (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun div (Ljava/lang/Number;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun div (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun div (Ljava/lang/Object;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun div (Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public fun div (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun divide (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; +} + +public class kscience/kmath/nd/BufferedNDRing : kscience/kmath/nd/BufferedNDSpace, kscience/kmath/nd/NDRing { + public fun ([ILkscience/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 ()Lkscience/kmath/nd/NDBuffer; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun times (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Ljava/lang/Object;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun times (Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public fun times (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; +} + +public class kscience/kmath/nd/BufferedNDSpace : kscience/kmath/nd/BufferNDAlgebra, kscience/kmath/nd/NDSpace { + public fun ([ILkscience/kmath/operations/Space;Lkotlin/jvm/functions/Function2;)V + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun add (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public fun combine (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun combine (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lkscience/kmath/nd/NDStructure; + public synthetic fun div (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun div (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public fun getBuffer (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/structures/Buffer; + public final fun getBufferFactory ()Lkotlin/jvm/functions/Function2; + public synthetic fun getElementContext ()Ljava/lang/Object; + public final fun getElementContext ()Lkscience/kmath/operations/Space; + public final fun getShape ()[I + public fun getStrides ()Lkscience/kmath/nd/Strides; + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero ()Lkscience/kmath/nd/NDBuffer; + public fun invoke (Lkotlin/jvm/functions/Function1;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun map (Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun map (Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/NDStructure; + public fun mapIndexed (Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun mapIndexed (Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lkscience/kmath/nd/NDStructure; + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun minus (Ljava/lang/Object;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun minus (Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public fun minus (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun multiply (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun plus (Ljava/lang/Object;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun plus (Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public fun plus (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun produce (Lkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun produce (Lkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/NDStructure; + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun symbol (Ljava/lang/String;)Lkscience/kmath/nd/NDStructure; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Ljava/lang/Number;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun times (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun times (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryPlus (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; +} + +public final class kscience/kmath/nd/ComplexNDField : kscience/kmath/nd/BufferedNDField, kscience/kmath/operations/ExtendedField, kscience/kmath/operations/RingWithNumbers { + public fun ([I)V + public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; + public fun acos (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun acosh (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; + public fun asin (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun asinh (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; + public fun atan (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun atanh (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; + public fun cos (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun cosh (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; + public fun exp (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun getOne ()Ljava/lang/Object; + public fun getOne ()Lkscience/kmath/nd/NDBuffer; + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero ()Lkscience/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;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object; + public fun ln (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun minus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun minus (Ljava/lang/Number;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun minus (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun number (Ljava/lang/Number;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun plus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun plus (Ljava/lang/Number;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun plus (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public synthetic fun pow (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun pow (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun power (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperation (Ljava/lang/String;Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; + public fun sin (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun sinh (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun sqrt (Ljava/lang/Object;)Ljava/lang/Object; + public fun sqrt (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; + public fun tan (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun tanh (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + +public final class kscience/kmath/nd/ComplexNDFieldKt { + public static final fun complex (Lkscience/kmath/nd/NDAlgebra$Companion;[I)Lkscience/kmath/nd/ComplexNDField; + public static final fun nd (Lkscience/kmath/operations/ComplexField;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static final fun produceInline (Lkscience/kmath/nd/BufferedNDField;Lkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/NDBuffer; +} + +public final class kscience/kmath/nd/DefaultStrides : kscience/kmath/nd/Strides { + public static final field Companion Lkscience/kmath/nd/DefaultStrides$Companion; + public synthetic fun ([ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun equals (Ljava/lang/Object;)Z + public fun getLinearSize ()I + public fun getShape ()[I + public fun getStrides ()Ljava/util/List; + public fun hashCode ()I + public fun index (I)[I + public fun indices ()Lkotlin/sequences/Sequence; + public fun offset ([I)I +} + +public final class kscience/kmath/nd/DefaultStrides$Companion { + public final fun invoke ([I)Lkscience/kmath/nd/Strides; +} + +public final class kscience/kmath/nd/MutableNDBuffer : kscience/kmath/nd/NDBuffer, kscience/kmath/nd/MutableNDStructure { + public fun (Lkscience/kmath/nd/Strides;Lkscience/kmath/structures/MutableBuffer;)V + public synthetic fun getBuffer ()Lkscience/kmath/structures/Buffer; + public fun getBuffer ()Lkscience/kmath/structures/MutableBuffer; + public fun set ([ILjava/lang/Object;)V +} + +public abstract interface class kscience/kmath/nd/MutableNDStructure : kscience/kmath/nd/NDStructure { + public abstract fun set ([ILjava/lang/Object;)V +} + +public final class kscience/kmath/nd/MutableNDStructure$DefaultImpls { + public static fun getDimension (Lkscience/kmath/nd/MutableNDStructure;)I + public static fun getFeature (Lkscience/kmath/nd/MutableNDStructure;Lkotlin/reflect/KClass;)Ljava/lang/Object; +} + +public abstract interface class kscience/kmath/nd/NDAlgebra { + public static final field Companion Lkscience/kmath/nd/NDAlgebra$Companion; + public abstract fun combine (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lkscience/kmath/nd/NDStructure; + public abstract fun getElementContext ()Ljava/lang/Object; + public abstract fun getShape ()[I + public abstract fun invoke (Lkotlin/jvm/functions/Function1;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public abstract fun map (Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/NDStructure; + public abstract fun mapIndexed (Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lkscience/kmath/nd/NDStructure; + public abstract fun produce (Lkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/NDStructure; +} + +public final class kscience/kmath/nd/NDAlgebra$Companion { +} + +public final class kscience/kmath/nd/NDAlgebra$DefaultImpls { + public static fun invoke (Lkscience/kmath/nd/NDAlgebra;Lkotlin/jvm/functions/Function1;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; +} + +public class kscience/kmath/nd/NDBuffer : kscience/kmath/nd/NDStructure { + public fun (Lkscience/kmath/nd/Strides;Lkscience/kmath/structures/Buffer;)V + public fun elements ()Lkotlin/sequences/Sequence; + public fun equals (Ljava/lang/Object;)Z + public fun get ([I)Ljava/lang/Object; + public fun getBuffer ()Lkscience/kmath/structures/Buffer; + public fun getDimension ()I + public fun getFeature (Lkotlin/reflect/KClass;)Ljava/lang/Object; + public fun getShape ()[I + public final fun getStrides ()Lkscience/kmath/nd/Strides; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public abstract interface class kscience/kmath/nd/NDField : kscience/kmath/nd/NDRing, kscience/kmath/operations/Field { + public abstract fun div (Ljava/lang/Object;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public abstract fun div (Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public abstract fun divide (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; +} + +public final class kscience/kmath/nd/NDField$DefaultImpls { + public static fun add (Lkscience/kmath/nd/NDField;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun binaryOperation (Lkscience/kmath/nd/NDField;Ljava/lang/String;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun binaryOperationFunction (Lkscience/kmath/nd/NDField;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun div (Lkscience/kmath/nd/NDField;Ljava/lang/Number;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun div (Lkscience/kmath/nd/NDField;Ljava/lang/Object;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun div (Lkscience/kmath/nd/NDField;Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public static fun div (Lkscience/kmath/nd/NDField;Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public static fun div (Lkscience/kmath/nd/NDField;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun divide (Lkscience/kmath/nd/NDField;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun invoke (Lkscience/kmath/nd/NDField;Lkotlin/jvm/functions/Function1;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun minus (Lkscience/kmath/nd/NDField;Ljava/lang/Object;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun minus (Lkscience/kmath/nd/NDField;Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public static fun minus (Lkscience/kmath/nd/NDField;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun multiply (Lkscience/kmath/nd/NDField;Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public static fun multiply (Lkscience/kmath/nd/NDField;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun plus (Lkscience/kmath/nd/NDField;Ljava/lang/Object;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun plus (Lkscience/kmath/nd/NDField;Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public static fun plus (Lkscience/kmath/nd/NDField;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun symbol (Lkscience/kmath/nd/NDField;Ljava/lang/String;)Lkscience/kmath/nd/NDStructure; + public static fun times (Lkscience/kmath/nd/NDField;Ljava/lang/Number;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun times (Lkscience/kmath/nd/NDField;Ljava/lang/Object;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun times (Lkscience/kmath/nd/NDField;Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public static fun times (Lkscience/kmath/nd/NDField;Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public static fun times (Lkscience/kmath/nd/NDField;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun unaryMinus (Lkscience/kmath/nd/NDField;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun unaryOperation (Lkscience/kmath/nd/NDField;Ljava/lang/String;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun unaryOperationFunction (Lkscience/kmath/nd/NDField;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lkscience/kmath/nd/NDField;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; +} + +public abstract interface class kscience/kmath/nd/NDRing : kscience/kmath/nd/NDSpace, kscience/kmath/operations/Ring { + public static final field Companion Lkscience/kmath/nd/NDRing$Companion; + public abstract fun multiply (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public abstract fun times (Ljava/lang/Object;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public abstract fun times (Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; +} + +public final class kscience/kmath/nd/NDRing$Companion { +} + +public final class kscience/kmath/nd/NDRing$DefaultImpls { + public static fun add (Lkscience/kmath/nd/NDRing;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun binaryOperation (Lkscience/kmath/nd/NDRing;Ljava/lang/String;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun binaryOperationFunction (Lkscience/kmath/nd/NDRing;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun div (Lkscience/kmath/nd/NDRing;Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public static fun invoke (Lkscience/kmath/nd/NDRing;Lkotlin/jvm/functions/Function1;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun minus (Lkscience/kmath/nd/NDRing;Ljava/lang/Object;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun minus (Lkscience/kmath/nd/NDRing;Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public static fun minus (Lkscience/kmath/nd/NDRing;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun multiply (Lkscience/kmath/nd/NDRing;Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public static fun multiply (Lkscience/kmath/nd/NDRing;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun plus (Lkscience/kmath/nd/NDRing;Ljava/lang/Object;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun plus (Lkscience/kmath/nd/NDRing;Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public static fun plus (Lkscience/kmath/nd/NDRing;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun symbol (Lkscience/kmath/nd/NDRing;Ljava/lang/String;)Lkscience/kmath/nd/NDStructure; + public static fun times (Lkscience/kmath/nd/NDRing;Ljava/lang/Number;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun times (Lkscience/kmath/nd/NDRing;Ljava/lang/Object;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun times (Lkscience/kmath/nd/NDRing;Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public static fun times (Lkscience/kmath/nd/NDRing;Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public static fun times (Lkscience/kmath/nd/NDRing;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun unaryMinus (Lkscience/kmath/nd/NDRing;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun unaryOperation (Lkscience/kmath/nd/NDRing;Ljava/lang/String;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun unaryOperationFunction (Lkscience/kmath/nd/NDRing;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lkscience/kmath/nd/NDRing;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; +} + +public abstract interface class kscience/kmath/nd/NDSpace : kscience/kmath/nd/NDAlgebra, kscience/kmath/operations/Space { + public static final field Companion Lkscience/kmath/nd/NDSpace$Companion; + public abstract fun add (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public abstract fun minus (Ljava/lang/Object;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public abstract fun minus (Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public abstract fun multiply (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public abstract fun plus (Ljava/lang/Object;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public abstract fun plus (Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; +} + +public final class kscience/kmath/nd/NDSpace$Companion { +} + +public final class kscience/kmath/nd/NDSpace$DefaultImpls { + public static fun add (Lkscience/kmath/nd/NDSpace;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun binaryOperation (Lkscience/kmath/nd/NDSpace;Ljava/lang/String;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun binaryOperationFunction (Lkscience/kmath/nd/NDSpace;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun div (Lkscience/kmath/nd/NDSpace;Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public static fun invoke (Lkscience/kmath/nd/NDSpace;Lkotlin/jvm/functions/Function1;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun minus (Lkscience/kmath/nd/NDSpace;Ljava/lang/Object;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun minus (Lkscience/kmath/nd/NDSpace;Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public static fun minus (Lkscience/kmath/nd/NDSpace;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun multiply (Lkscience/kmath/nd/NDSpace;Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public static fun plus (Lkscience/kmath/nd/NDSpace;Ljava/lang/Object;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun plus (Lkscience/kmath/nd/NDSpace;Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public static fun plus (Lkscience/kmath/nd/NDSpace;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun symbol (Lkscience/kmath/nd/NDSpace;Ljava/lang/String;)Lkscience/kmath/nd/NDStructure; + public static fun times (Lkscience/kmath/nd/NDSpace;Ljava/lang/Number;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun times (Lkscience/kmath/nd/NDSpace;Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public static fun unaryMinus (Lkscience/kmath/nd/NDSpace;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun unaryOperation (Lkscience/kmath/nd/NDSpace;Ljava/lang/String;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public static fun unaryOperationFunction (Lkscience/kmath/nd/NDSpace;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lkscience/kmath/nd/NDSpace;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; +} + +public abstract interface class kscience/kmath/nd/NDStructure { + public static final field Companion Lkscience/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 getFeature (Lkotlin/reflect/KClass;)Ljava/lang/Object; + public abstract fun getShape ()[I + public abstract fun hashCode ()I +} + +public final class kscience/kmath/nd/NDStructure$Companion { + public final fun auto (Lkotlin/reflect/KClass;Lkscience/kmath/nd/Strides;Lkotlin/jvm/functions/Function1;)Lkscience/kmath/nd/NDBuffer; + public final fun auto (Lkotlin/reflect/KClass;[ILkotlin/jvm/functions/Function1;)Lkscience/kmath/nd/NDBuffer; + public final fun build (Lkscience/kmath/nd/Strides;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;)Lkscience/kmath/nd/NDBuffer; + public final fun build ([ILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;)Lkscience/kmath/nd/NDBuffer; + public static synthetic fun build$default (Lkscience/kmath/nd/NDStructure$Companion;Lkscience/kmath/nd/Strides;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkscience/kmath/nd/NDBuffer; + public static synthetic fun build$default (Lkscience/kmath/nd/NDStructure$Companion;[ILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkscience/kmath/nd/NDBuffer; + public final fun contentEquals (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Z +} + +public final class kscience/kmath/nd/NDStructure$DefaultImpls { + public static fun getDimension (Lkscience/kmath/nd/NDStructure;)I + public static fun getFeature (Lkscience/kmath/nd/NDStructure;Lkotlin/reflect/KClass;)Ljava/lang/Object; +} + +public final class kscience/kmath/nd/NDStructureKt { + public static final fun get (Lkscience/kmath/nd/NDStructure;[I)Ljava/lang/Object; + public static final fun mapInPlace (Lkscience/kmath/nd/MutableNDStructure;Lkotlin/jvm/functions/Function2;)V +} + +public final class kscience/kmath/nd/RealNDField : kscience/kmath/nd/BufferedNDField, kscience/kmath/operations/ExtendedField, kscience/kmath/operations/RingWithNumbers { + public fun ([I)V + public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; + public fun acos (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun acosh (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; + public fun asin (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun asinh (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; + public fun atan (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun atanh (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public fun combine (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun combine (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lkscience/kmath/nd/NDStructure; + public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; + public fun cos (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun cosh (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; + public fun exp (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun getBuffer (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/structures/Buffer; + public fun getBuffer-JVEF3vg (Lkscience/kmath/nd/NDStructure;)[D + public synthetic fun getOne ()Ljava/lang/Object; + public fun getOne ()Lkscience/kmath/nd/NDBuffer; + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero ()Lkscience/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;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object; + public fun ln (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public fun map (Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun map (Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/NDStructure; + public fun mapIndexed (Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun mapIndexed (Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lkscience/kmath/nd/NDStructure; + public synthetic fun minus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun minus (Ljava/lang/Number;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun minus (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun number (Ljava/lang/Number;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun plus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun plus (Ljava/lang/Number;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun plus (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public synthetic fun pow (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun pow (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun power (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDBuffer; + public fun produce (Lkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun produce (Lkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/NDStructure; + public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperation (Ljava/lang/String;Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; + public fun sin (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun sinh (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun sqrt (Ljava/lang/Object;)Ljava/lang/Object; + public fun sqrt (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; + public fun tan (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun tanh (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDBuffer; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + +public final class kscience/kmath/nd/RealNDFieldKt { + public static final fun nd (Lkscience/kmath/operations/RealField;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static final fun real (Lkscience/kmath/nd/NDAlgebra$Companion;[I)Lkscience/kmath/nd/RealNDField; +} + +public final class kscience/kmath/nd/ShapeMismatchException : java/lang/RuntimeException { + public fun ([I[I)V + public final fun getActual ()[I + public final fun getExpected ()[I +} + +public final class kscience/kmath/nd/ShortNDRing : kscience/kmath/nd/BufferedNDRing, kscience/kmath/operations/RingWithNumbers { + public fun ([I)V + public synthetic fun getOne ()Ljava/lang/Object; + public fun getOne ()Lkscience/kmath/nd/NDBuffer; + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero ()Lkscience/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;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + 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;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun minus (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun number (Ljava/lang/Number;)Lkscience/kmath/nd/NDBuffer; + public synthetic fun plus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun plus (Ljava/lang/Number;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun plus (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperation (Ljava/lang/String;Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; +} + +public final class kscience/kmath/nd/ShortNDRingKt { + public static final fun nd (Lkscience/kmath/operations/ShortRing;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static final fun produceInline (Lkscience/kmath/nd/BufferedNDRing;Lkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/NDBuffer; +} + +public abstract interface class kscience/kmath/nd/Strides { + public abstract fun getLinearSize ()I + public abstract fun getShape ()[I + public abstract fun getStrides ()Ljava/util/List; + public abstract fun index (I)[I + public abstract fun indices ()Lkotlin/sequences/Sequence; + public abstract fun offset ([I)I +} + +public final class kscience/kmath/nd/Strides$DefaultImpls { + public static fun indices (Lkscience/kmath/nd/Strides;)Lkotlin/sequences/Sequence; +} + +public abstract interface class kscience/kmath/nd/Structure1D : kscience/kmath/nd/NDStructure, kscience/kmath/structures/Buffer { + public abstract fun get ([I)Ljava/lang/Object; + public abstract fun getDimension ()I + public abstract fun iterator ()Ljava/util/Iterator; +} + +public final class kscience/kmath/nd/Structure1D$DefaultImpls { + public static fun contentEquals (Lkscience/kmath/nd/Structure1D;Lkscience/kmath/structures/Buffer;)Z + public static fun get (Lkscience/kmath/nd/Structure1D;[I)Ljava/lang/Object; + public static fun getDimension (Lkscience/kmath/nd/Structure1D;)I + public static fun getFeature (Lkscience/kmath/nd/Structure1D;Lkotlin/reflect/KClass;)Ljava/lang/Object; + public static fun iterator (Lkscience/kmath/nd/Structure1D;)Ljava/util/Iterator; +} + +public final class kscience/kmath/nd/Structure1DKt { + public static final fun as1D (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/Structure1D; + public static final fun asND (Lkscience/kmath/structures/Buffer;)Lkscience/kmath/nd/Structure1D; +} + +public abstract interface class kscience/kmath/nd/Structure2D : kscience/kmath/nd/NDStructure { + public static final field Companion Lkscience/kmath/nd/Structure2D$Companion; + public abstract fun elements ()Lkotlin/sequences/Sequence; + public abstract fun get (II)Ljava/lang/Object; + public abstract fun get ([I)Ljava/lang/Object; + public abstract fun getColNum ()I + public abstract fun getColumns ()Lkscience/kmath/structures/Buffer; + public abstract fun getRowNum ()I + public abstract fun getRows ()Lkscience/kmath/structures/Buffer; + public abstract fun getShape ()[I +} + +public final class kscience/kmath/nd/Structure2D$Companion { + public final fun real (IILkotlin/jvm/functions/Function2;)Lkscience/kmath/linear/BufferMatrix; +} + +public final class kscience/kmath/nd/Structure2D$DefaultImpls { + public static fun elements (Lkscience/kmath/nd/Structure2D;)Lkotlin/sequences/Sequence; + public static fun get (Lkscience/kmath/nd/Structure2D;[I)Ljava/lang/Object; + public static fun getColumns (Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/structures/Buffer; + public static fun getDimension (Lkscience/kmath/nd/Structure2D;)I + public static fun getFeature (Lkscience/kmath/nd/Structure2D;Lkotlin/reflect/KClass;)Ljava/lang/Object; + public static fun getRows (Lkscience/kmath/nd/Structure2D;)Lkscience/kmath/structures/Buffer; + public static fun getShape (Lkscience/kmath/nd/Structure2D;)[I +} + +public final class kscience/kmath/nd/Structure2DKt { + public static final fun as2D (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/Structure2D; +} + +public abstract interface class kscience/kmath/operations/Algebra { + public abstract fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public abstract fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public abstract fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + +public final class kscience/kmath/operations/Algebra$DefaultImpls { + public static fun binaryOperation (Lkscience/kmath/operations/Algebra;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperationFunction (Lkscience/kmath/operations/Algebra;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun symbol (Lkscience/kmath/operations/Algebra;Ljava/lang/String;)Ljava/lang/Object; + public static fun unaryOperation (Lkscience/kmath/operations/Algebra;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperationFunction (Lkscience/kmath/operations/Algebra;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + +public final class kscience/kmath/operations/AlgebraExtensionsKt { + public static final fun abs (Lkscience/kmath/operations/Space;Ljava/lang/Comparable;)Ljava/lang/Comparable; + public static final fun average (Lkscience/kmath/operations/Space;Ljava/lang/Iterable;)Ljava/lang/Object; + public static final fun average (Lkscience/kmath/operations/Space;Lkotlin/sequences/Sequence;)Ljava/lang/Object; + public static final fun averageWith (Ljava/lang/Iterable;Lkscience/kmath/operations/Space;)Ljava/lang/Object; + public static final fun averageWith (Lkotlin/sequences/Sequence;Lkscience/kmath/operations/Space;)Ljava/lang/Object; + public static final fun power (Lkscience/kmath/operations/Field;Ljava/lang/Object;I)Ljava/lang/Object; + public static final fun power (Lkscience/kmath/operations/Ring;Ljava/lang/Object;I)Ljava/lang/Object; + public static final fun sum (Lkscience/kmath/operations/Space;Ljava/lang/Iterable;)Ljava/lang/Object; + public static final fun sum (Lkscience/kmath/operations/Space;Lkotlin/sequences/Sequence;)Ljava/lang/Object; + public static final fun sumWith (Ljava/lang/Iterable;Lkscience/kmath/operations/Space;)Ljava/lang/Object; + public static final fun sumWith (Lkotlin/sequences/Sequence;Lkscience/kmath/operations/Space;)Ljava/lang/Object; +} + +public final class kscience/kmath/operations/AlgebraKt { + public static final fun invoke (Lkscience/kmath/operations/Algebra;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; +} + +public final class kscience/kmath/operations/BigInt : java/lang/Comparable { + public static final field BASE J + public static final field BASE_SIZE I + public static final field Companion Lkscience/kmath/operations/BigInt$Companion; + public final fun abs ()Lkscience/kmath/operations/BigInt; + public final fun and (Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public synthetic fun compareTo (Ljava/lang/Object;)I + public fun compareTo (Lkscience/kmath/operations/BigInt;)I + public final fun div (I)Lkscience/kmath/operations/BigInt; + public final fun div (Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public final fun div-WZ4Q5Ns (I)Lkscience/kmath/operations/BigInt; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public final fun minus (Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public final fun modPow (Lkscience/kmath/operations/BigInt;Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public final fun or (Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public final fun plus (Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public final fun rem (I)I + public final fun rem (Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public final fun shl (I)Lkscience/kmath/operations/BigInt; + public final fun shr (I)Lkscience/kmath/operations/BigInt; + public final fun times (I)Lkscience/kmath/operations/BigInt; + public final fun times (Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public final fun times-WZ4Q5Ns (I)Lkscience/kmath/operations/BigInt; + public fun toString ()Ljava/lang/String; + public final fun unaryMinus ()Lkscience/kmath/operations/BigInt; +} + +public final class kscience/kmath/operations/BigInt$Companion { + public final fun getONE ()Lkscience/kmath/operations/BigInt; + public final fun getZERO ()Lkscience/kmath/operations/BigInt; +} + +public final class kscience/kmath/operations/BigIntField : kscience/kmath/operations/Field, kscience/kmath/operations/RingWithNumbers { + public static final field INSTANCE Lkscience/kmath/operations/BigIntField; + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun add (Lkscience/kmath/operations/BigInt;Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;Lkscience/kmath/operations/BigInt;Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun div (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun div (Ljava/lang/Number;Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + 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 (Lkscience/kmath/operations/BigInt;Ljava/lang/Number;)Lkscience/kmath/operations/BigInt; + public fun div (Lkscience/kmath/operations/BigInt;Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun divide (Lkscience/kmath/operations/BigInt;Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public synthetic fun getOne ()Ljava/lang/Object; + public fun getOne ()Lkscience/kmath/operations/BigInt; + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero ()Lkscience/kmath/operations/BigInt; + 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;Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + 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;Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + 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 fun minus (Lkscience/kmath/operations/BigInt;Ljava/lang/Number;)Lkscience/kmath/operations/BigInt; + public fun minus (Lkscience/kmath/operations/BigInt;Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply (Lkscience/kmath/operations/BigInt;Ljava/lang/Number;)Lkscience/kmath/operations/BigInt; + public fun multiply (Lkscience/kmath/operations/BigInt;Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun number (Ljava/lang/Number;)Lkscience/kmath/operations/BigInt; + public synthetic fun plus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun plus (Ljava/lang/Number;Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + 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 fun plus (Lkscience/kmath/operations/BigInt;Ljava/lang/Number;)Lkscience/kmath/operations/BigInt; + public fun plus (Lkscience/kmath/operations/BigInt;Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperation (Ljava/lang/String;Lkscience/kmath/operations/BigInt;Ljava/lang/Number;)Lkscience/kmath/operations/BigInt; + public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun symbol (Ljava/lang/String;)Lkscience/kmath/operations/BigInt; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Ljava/lang/Number;Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + 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 fun times (Lkscience/kmath/operations/BigInt;Ljava/lang/Number;)Lkscience/kmath/operations/BigInt; + public fun times (Lkscience/kmath/operations/BigInt;Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public final fun unaryMinus (Ljava/lang/String;)Lkscience/kmath/operations/BigInt; + public fun unaryMinus (Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; + public final fun unaryPlus (Ljava/lang/String;)Lkscience/kmath/operations/BigInt; + public fun unaryPlus (Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; +} + +public final class kscience/kmath/operations/BigIntKt { + public static final fun abs (Lkscience/kmath/operations/BigInt;)Lkscience/kmath/operations/BigInt; + public static final fun bigInt (Lkscience/kmath/nd/NDAlgebra$Companion;[I)Lkscience/kmath/nd/BufferedNDRing; + public static final fun bigInt (Lkscience/kmath/structures/Buffer$Companion;ILkotlin/jvm/functions/Function1;)Lkscience/kmath/structures/Buffer; + public static final fun bigInt (Lkscience/kmath/structures/MutableBuffer$Companion;ILkotlin/jvm/functions/Function1;)Lkscience/kmath/structures/MutableBuffer; + public static final fun parseBigInteger (Ljava/lang/String;)Lkscience/kmath/operations/BigInt; + public static final fun toBigInt (I)Lkscience/kmath/operations/BigInt; + public static final fun toBigInt (J)Lkscience/kmath/operations/BigInt; + public static final fun toBigInt-LpG4sQ0 ([IB)Lkscience/kmath/operations/BigInt; + public static final fun toBigInt-VKZWuLQ (J)Lkscience/kmath/operations/BigInt; + public static final fun toBigInt-WZ4Q5Ns (I)Lkscience/kmath/operations/BigInt; +} + +public final class kscience/kmath/operations/ByteRing : kscience/kmath/operations/Norm, kscience/kmath/operations/NumericAlgebra, kscience/kmath/operations/Ring { + public static final field INSTANCE Lkscience/kmath/operations/ByteRing; + public fun add (BB)Ljava/lang/Byte; + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;BB)Ljava/lang/Byte; + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public fun div (BLjava/lang/Number;)Ljava/lang/Byte; + public synthetic fun div (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun getOne ()Ljava/lang/Byte; + public synthetic fun getOne ()Ljava/lang/Object; + public fun getZero ()Ljava/lang/Byte; + public synthetic fun getZero ()Ljava/lang/Object; + public fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;B)Ljava/lang/Byte; + public synthetic fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public fun minus (BB)Ljava/lang/Byte; + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply (BB)Ljava/lang/Byte; + public fun multiply (BLjava/lang/Number;)Ljava/lang/Byte; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun norm (B)Ljava/lang/Byte; + public synthetic fun norm (Ljava/lang/Object;)Ljava/lang/Object; + public fun number (Ljava/lang/Number;)Ljava/lang/Byte; + public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun plus (BB)Ljava/lang/Byte; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun rightSideNumberOperation (Ljava/lang/String;BLjava/lang/Number;)Ljava/lang/Byte; + public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public fun symbol (Ljava/lang/String;)Ljava/lang/Byte; + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun times (BB)Ljava/lang/Byte; + public fun times (BLjava/lang/Number;)Ljava/lang/Byte; + public fun times (Ljava/lang/Number;B)Ljava/lang/Byte; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + 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 fun unaryMinus (B)Ljava/lang/Byte; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;B)Ljava/lang/Byte; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public fun unaryPlus (B)Ljava/lang/Byte; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; +} + +public final class kscience/kmath/operations/Complex : java/lang/Comparable, kscience/kmath/operations/FieldElement { + public static final field Companion Lkscience/kmath/operations/Complex$Companion; + public fun (DD)V + public fun (Ljava/lang/Number;Ljava/lang/Number;)V + public synthetic fun compareTo (Ljava/lang/Object;)I + public fun compareTo (Lkscience/kmath/operations/Complex;)I + public final fun component1 ()D + public final fun component2 ()D + public final fun copy (DD)Lkscience/kmath/operations/Complex; + public static synthetic fun copy$default (Lkscience/kmath/operations/Complex;DDILjava/lang/Object;)Lkscience/kmath/operations/Complex; + public fun div (Ljava/lang/Number;)Lkscience/kmath/operations/Complex; + public synthetic fun div (Ljava/lang/Number;)Lkscience/kmath/operations/FieldElement; + public synthetic fun div (Ljava/lang/Number;)Lkscience/kmath/operations/RingElement; + public synthetic fun div (Ljava/lang/Number;)Lkscience/kmath/operations/SpaceElement; + public synthetic fun div (Ljava/lang/Object;)Lkscience/kmath/operations/FieldElement; + public fun div (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public fun equals (Ljava/lang/Object;)Z + public synthetic fun getContext ()Ljava/lang/Object; + public fun getContext ()Lkscience/kmath/operations/ComplexField; + public synthetic fun getContext ()Lkscience/kmath/operations/Field; + public final fun getIm ()D + public final fun getRe ()D + public fun hashCode ()I + public synthetic fun minus (Ljava/lang/Object;)Lkscience/kmath/operations/FieldElement; + public synthetic fun minus (Ljava/lang/Object;)Lkscience/kmath/operations/RingElement; + public synthetic fun minus (Ljava/lang/Object;)Lkscience/kmath/operations/SpaceElement; + public fun minus (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun plus (Ljava/lang/Object;)Lkscience/kmath/operations/FieldElement; + public synthetic fun plus (Ljava/lang/Object;)Lkscience/kmath/operations/RingElement; + public synthetic fun plus (Ljava/lang/Object;)Lkscience/kmath/operations/SpaceElement; + public fun plus (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public fun times (Ljava/lang/Number;)Lkscience/kmath/operations/Complex; + public synthetic fun times (Ljava/lang/Number;)Lkscience/kmath/operations/FieldElement; + public synthetic fun times (Ljava/lang/Number;)Lkscience/kmath/operations/RingElement; + public synthetic fun times (Ljava/lang/Number;)Lkscience/kmath/operations/SpaceElement; + public synthetic fun times (Ljava/lang/Object;)Lkscience/kmath/operations/FieldElement; + public synthetic fun times (Ljava/lang/Object;)Lkscience/kmath/operations/RingElement; + public fun times (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public fun toString ()Ljava/lang/String; + public synthetic fun unwrap ()Ljava/lang/Object; + public fun unwrap ()Lkscience/kmath/operations/Complex; + public synthetic fun wrap (Ljava/lang/Object;)Ljava/lang/Object; + public fun wrap (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; +} + +public final class kscience/kmath/operations/Complex$Companion : kscience/kmath/memory/MemorySpec { + public fun getObjectSize ()I + public synthetic fun read (Lkscience/kmath/memory/MemoryReader;I)Ljava/lang/Object; + public fun read (Lkscience/kmath/memory/MemoryReader;I)Lkscience/kmath/operations/Complex; + public synthetic fun write (Lkscience/kmath/memory/MemoryWriter;ILjava/lang/Object;)V + public fun write (Lkscience/kmath/memory/MemoryWriter;ILkscience/kmath/operations/Complex;)V +} + +public final class kscience/kmath/operations/ComplexField : kscience/kmath/operations/ExtendedField, kscience/kmath/operations/Norm, kscience/kmath/operations/RingWithNumbers { + public static final field INSTANCE Lkscience/kmath/operations/ComplexField; + public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; + public fun acos (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun acosh (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun add (Lkscience/kmath/operations/Complex;Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; + public fun asin (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun asinh (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; + public fun atan (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun atanh (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;Lkscience/kmath/operations/Complex;Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; + public fun cos (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun cosh (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun div (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun div (Ljava/lang/Number;Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + 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 (Lkscience/kmath/operations/Complex;Ljava/lang/Number;)Lkscience/kmath/operations/Complex; + public fun div (Lkscience/kmath/operations/Complex;Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun divide (Lkscience/kmath/operations/Complex;Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; + public fun exp (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public final fun getI ()Lkscience/kmath/operations/Complex; + public synthetic fun getOne ()Ljava/lang/Object; + public fun getOne ()Lkscience/kmath/operations/Complex; + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero ()Lkscience/kmath/operations/Complex; + 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;Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object; + public fun ln (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public final fun minus (DLkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun minus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun minus (Ljava/lang/Number;Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + 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 final fun minus (Lkscience/kmath/operations/Complex;D)Lkscience/kmath/operations/Complex; + public fun minus (Lkscience/kmath/operations/Complex;Ljava/lang/Number;)Lkscience/kmath/operations/Complex; + public fun minus (Lkscience/kmath/operations/Complex;Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply (Lkscience/kmath/operations/Complex;Ljava/lang/Number;)Lkscience/kmath/operations/Complex; + public fun multiply (Lkscience/kmath/operations/Complex;Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun norm (Ljava/lang/Object;)Ljava/lang/Object; + public fun norm (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun number (Ljava/lang/Number;)Lkscience/kmath/operations/Complex; + public final fun plus (DLkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun plus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun plus (Ljava/lang/Number;Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + 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 final fun plus (Lkscience/kmath/operations/Complex;D)Lkscience/kmath/operations/Complex; + public fun plus (Lkscience/kmath/operations/Complex;Ljava/lang/Number;)Lkscience/kmath/operations/Complex; + public fun plus (Lkscience/kmath/operations/Complex;Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun pow (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun pow (Lkscience/kmath/operations/Complex;Ljava/lang/Number;)Lkscience/kmath/operations/Complex; + public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun power (Lkscience/kmath/operations/Complex;Ljava/lang/Number;)Lkscience/kmath/operations/Complex; + public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperation (Ljava/lang/String;Lkscience/kmath/operations/Complex;Ljava/lang/Number;)Lkscience/kmath/operations/Complex; + public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; + public fun sin (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun sinh (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun sqrt (Ljava/lang/Object;)Ljava/lang/Object; + public fun sqrt (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun symbol (Ljava/lang/String;)Lkscience/kmath/operations/Complex; + public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; + public fun tan (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun tanh (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public final fun times (DLkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Ljava/lang/Number;Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + 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 fun times (Lkscience/kmath/operations/Complex;Ljava/lang/Number;)Lkscience/kmath/operations/Complex; + public fun times (Lkscience/kmath/operations/Complex;Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryPlus (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; +} + +public final class kscience/kmath/operations/ComplexKt { + public static final fun complex (Lkscience/kmath/structures/Buffer$Companion;ILkotlin/jvm/functions/Function1;)Lkscience/kmath/structures/Buffer; + public static final fun complex (Lkscience/kmath/structures/MutableBuffer$Companion;ILkotlin/jvm/functions/Function1;)Lkscience/kmath/structures/MutableBuffer; + public static final fun getConjugate (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public static final fun getR (Lkscience/kmath/operations/Complex;)D + public static final fun getReciprocal (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex; + public static final fun getTheta (Lkscience/kmath/operations/Complex;)D + public static final fun toComplex (Ljava/lang/Number;)Lkscience/kmath/operations/Complex; +} + +public abstract interface class kscience/kmath/operations/ExponentialOperations : kscience/kmath/operations/Algebra { + public static final field Companion Lkscience/kmath/operations/ExponentialOperations$Companion; + public static final field EXP_OPERATION Ljava/lang/String; + public static final field LN_OPERATION Ljava/lang/String; + public abstract fun exp (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun ln (Ljava/lang/Object;)Ljava/lang/Object; +} + +public final class kscience/kmath/operations/ExponentialOperations$Companion { + public static final field EXP_OPERATION Ljava/lang/String; + public static final field LN_OPERATION Ljava/lang/String; +} + +public final class kscience/kmath/operations/ExponentialOperations$DefaultImpls { + public static fun binaryOperation (Lkscience/kmath/operations/ExponentialOperations;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperationFunction (Lkscience/kmath/operations/ExponentialOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun symbol (Lkscience/kmath/operations/ExponentialOperations;Ljava/lang/String;)Ljava/lang/Object; + public static fun unaryOperation (Lkscience/kmath/operations/ExponentialOperations;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperationFunction (Lkscience/kmath/operations/ExponentialOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + +public abstract interface class kscience/kmath/operations/ExtendedField : kscience/kmath/operations/ExtendedFieldOperations, kscience/kmath/operations/Field, kscience/kmath/operations/NumericAlgebra { + public abstract fun acosh (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun asinh (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun atanh (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun cosh (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public abstract fun sinh (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun tanh (Ljava/lang/Object;)Ljava/lang/Object; +} + +public final class kscience/kmath/operations/ExtendedField$DefaultImpls { + public static fun acosh (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Object;)Ljava/lang/Object; + public static fun asinh (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Object;)Ljava/lang/Object; + public static fun atanh (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperation (Lkscience/kmath/operations/ExtendedField;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperationFunction (Lkscience/kmath/operations/ExtendedField;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun cosh (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Object;)Ljava/lang/Object; + public static fun div (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public static fun div (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun div (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun leftSideNumberOperation (Lkscience/kmath/operations/ExtendedField;Ljava/lang/String;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public static fun leftSideNumberOperationFunction (Lkscience/kmath/operations/ExtendedField;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun minus (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun plus (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun pow (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun rightSideNumberOperation (Lkscience/kmath/operations/ExtendedField;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun rightSideNumberOperationFunction (Lkscience/kmath/operations/ExtendedField;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun sinh (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Object;)Ljava/lang/Object; + public static fun sqrt (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Object;)Ljava/lang/Object; + public static fun symbol (Lkscience/kmath/operations/ExtendedField;Ljava/lang/String;)Ljava/lang/Object; + public static fun tan (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Object;)Ljava/lang/Object; + public static fun tanh (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Object;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryMinus (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperation (Lkscience/kmath/operations/ExtendedField;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperationFunction (Lkscience/kmath/operations/ExtendedField;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lkscience/kmath/operations/ExtendedField;Ljava/lang/Object;)Ljava/lang/Object; +} + +public abstract interface class kscience/kmath/operations/ExtendedFieldOperations : kscience/kmath/operations/ExponentialOperations, kscience/kmath/operations/FieldOperations, kscience/kmath/operations/HyperbolicOperations, kscience/kmath/operations/PowerOperations, kscience/kmath/operations/TrigonometricOperations { + public abstract fun tan (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun tanh (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + +public final class kscience/kmath/operations/ExtendedFieldOperations$DefaultImpls { + public static fun binaryOperation (Lkscience/kmath/operations/ExtendedFieldOperations;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperationFunction (Lkscience/kmath/operations/ExtendedFieldOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun div (Lkscience/kmath/operations/ExtendedFieldOperations;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun div (Lkscience/kmath/operations/ExtendedFieldOperations;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun minus (Lkscience/kmath/operations/ExtendedFieldOperations;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun plus (Lkscience/kmath/operations/ExtendedFieldOperations;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun pow (Lkscience/kmath/operations/ExtendedFieldOperations;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun sqrt (Lkscience/kmath/operations/ExtendedFieldOperations;Ljava/lang/Object;)Ljava/lang/Object; + public static fun symbol (Lkscience/kmath/operations/ExtendedFieldOperations;Ljava/lang/String;)Ljava/lang/Object; + public static fun tan (Lkscience/kmath/operations/ExtendedFieldOperations;Ljava/lang/Object;)Ljava/lang/Object; + public static fun tanh (Lkscience/kmath/operations/ExtendedFieldOperations;Ljava/lang/Object;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/ExtendedFieldOperations;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/ExtendedFieldOperations;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/ExtendedFieldOperations;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryMinus (Lkscience/kmath/operations/ExtendedFieldOperations;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperation (Lkscience/kmath/operations/ExtendedFieldOperations;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperationFunction (Lkscience/kmath/operations/ExtendedFieldOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lkscience/kmath/operations/ExtendedFieldOperations;Ljava/lang/Object;)Ljava/lang/Object; +} + +public abstract interface class kscience/kmath/operations/Field : kscience/kmath/operations/FieldOperations, kscience/kmath/operations/Ring { + public abstract fun div (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; +} + +public final class kscience/kmath/operations/Field$DefaultImpls { + public static fun binaryOperation (Lkscience/kmath/operations/Field;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperationFunction (Lkscience/kmath/operations/Field;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun div (Lkscience/kmath/operations/Field;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public static fun div (Lkscience/kmath/operations/Field;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun div (Lkscience/kmath/operations/Field;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun minus (Lkscience/kmath/operations/Field;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun plus (Lkscience/kmath/operations/Field;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun symbol (Lkscience/kmath/operations/Field;Ljava/lang/String;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/Field;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/Field;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/Field;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryMinus (Lkscience/kmath/operations/Field;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperation (Lkscience/kmath/operations/Field;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperationFunction (Lkscience/kmath/operations/Field;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lkscience/kmath/operations/Field;Ljava/lang/Object;)Ljava/lang/Object; +} + +public abstract interface class kscience/kmath/operations/FieldElement : kscience/kmath/operations/RingElement { + public abstract fun div (Ljava/lang/Object;)Lkscience/kmath/operations/FieldElement; + public abstract fun getContext ()Lkscience/kmath/operations/Field; +} + +public final class kscience/kmath/operations/FieldElement$DefaultImpls { + public static fun div (Lkscience/kmath/operations/FieldElement;Ljava/lang/Number;)Lkscience/kmath/operations/FieldElement; + public static fun div (Lkscience/kmath/operations/FieldElement;Ljava/lang/Object;)Lkscience/kmath/operations/FieldElement; + public static fun minus (Lkscience/kmath/operations/FieldElement;Ljava/lang/Object;)Lkscience/kmath/operations/FieldElement; + public static fun plus (Lkscience/kmath/operations/FieldElement;Ljava/lang/Object;)Lkscience/kmath/operations/FieldElement; + public static fun times (Lkscience/kmath/operations/FieldElement;Ljava/lang/Number;)Lkscience/kmath/operations/FieldElement; + public static fun times (Lkscience/kmath/operations/FieldElement;Ljava/lang/Object;)Lkscience/kmath/operations/FieldElement; +} + +public abstract interface class kscience/kmath/operations/FieldOperations : kscience/kmath/operations/RingOperations { + public static final field Companion Lkscience/kmath/operations/FieldOperations$Companion; + public static final field DIV_OPERATION Ljava/lang/String; + public abstract fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public abstract fun div (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; +} + +public final class kscience/kmath/operations/FieldOperations$Companion { + public static final field DIV_OPERATION Ljava/lang/String; +} + +public final class kscience/kmath/operations/FieldOperations$DefaultImpls { + public static fun binaryOperation (Lkscience/kmath/operations/FieldOperations;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperationFunction (Lkscience/kmath/operations/FieldOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun div (Lkscience/kmath/operations/FieldOperations;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun div (Lkscience/kmath/operations/FieldOperations;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun minus (Lkscience/kmath/operations/FieldOperations;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun plus (Lkscience/kmath/operations/FieldOperations;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun symbol (Lkscience/kmath/operations/FieldOperations;Ljava/lang/String;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/FieldOperations;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/FieldOperations;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/FieldOperations;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryMinus (Lkscience/kmath/operations/FieldOperations;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperation (Lkscience/kmath/operations/FieldOperations;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperationFunction (Lkscience/kmath/operations/FieldOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lkscience/kmath/operations/FieldOperations;Ljava/lang/Object;)Ljava/lang/Object; +} + +public final class kscience/kmath/operations/FloatField : kscience/kmath/operations/ExtendedField, kscience/kmath/operations/Norm { + public static final field INSTANCE Lkscience/kmath/operations/FloatField; + public fun acos (F)Ljava/lang/Float; + public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; + public fun acosh (F)Ljava/lang/Float; + public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun add (FF)Ljava/lang/Float; + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun asin (F)Ljava/lang/Float; + public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; + public fun asinh (F)Ljava/lang/Float; + public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun atan (F)Ljava/lang/Float; + public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; + public fun atanh (F)Ljava/lang/Float; + public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;FF)Ljava/lang/Float; + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public fun cos (F)Ljava/lang/Float; + public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; + public fun cosh (F)Ljava/lang/Float; + public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun div (FF)Ljava/lang/Float; + public fun div (FLjava/lang/Number;)Ljava/lang/Float; + public fun div (Ljava/lang/Number;F)Ljava/lang/Float; + public synthetic fun div (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + 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 divide (FF)Ljava/lang/Float; + public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun exp (F)Ljava/lang/Float; + public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; + public fun getOne ()Ljava/lang/Float; + public synthetic fun getOne ()Ljava/lang/Object; + public fun getZero ()Ljava/lang/Float; + public synthetic fun getZero ()Ljava/lang/Object; + public fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;F)Ljava/lang/Float; + public synthetic fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public fun ln (F)Ljava/lang/Float; + public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object; + public fun minus (FF)Ljava/lang/Float; + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply (FF)Ljava/lang/Float; + public fun multiply (FLjava/lang/Number;)Ljava/lang/Float; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun norm (F)Ljava/lang/Float; + public synthetic fun norm (Ljava/lang/Object;)Ljava/lang/Object; + public fun number (Ljava/lang/Number;)Ljava/lang/Float; + public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun plus (FF)Ljava/lang/Float; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun pow (FLjava/lang/Number;)Ljava/lang/Float; + public synthetic fun pow (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun power (FLjava/lang/Number;)Ljava/lang/Float; + public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperation (Ljava/lang/String;FLjava/lang/Number;)Ljava/lang/Float; + public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public fun sin (F)Ljava/lang/Float; + public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; + public fun sinh (F)Ljava/lang/Float; + public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun sqrt (F)Ljava/lang/Float; + public synthetic fun sqrt (Ljava/lang/Object;)Ljava/lang/Object; + public fun symbol (Ljava/lang/String;)Ljava/lang/Float; + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun tan (F)Ljava/lang/Float; + public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; + public fun tanh (F)Ljava/lang/Float; + public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun times (FF)Ljava/lang/Float; + public fun times (FLjava/lang/Number;)Ljava/lang/Float; + public fun times (Ljava/lang/Number;F)Ljava/lang/Float; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + 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 fun unaryMinus (F)Ljava/lang/Float; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;F)Ljava/lang/Float; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public fun unaryPlus (F)Ljava/lang/Float; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; +} + +public abstract interface class kscience/kmath/operations/HyperbolicOperations : kscience/kmath/operations/Algebra { + public static final field ACOSH_OPERATION Ljava/lang/String; + public static final field ASINH_OPERATION Ljava/lang/String; + public static final field ATANH_OPERATION Ljava/lang/String; + public static final field COSH_OPERATION Ljava/lang/String; + public static final field Companion Lkscience/kmath/operations/HyperbolicOperations$Companion; + public static final field SINH_OPERATION Ljava/lang/String; + public static final field TANH_OPERATION Ljava/lang/String; + public abstract fun acosh (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun asinh (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun atanh (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun cosh (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun sinh (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun tanh (Ljava/lang/Object;)Ljava/lang/Object; +} + +public final class kscience/kmath/operations/HyperbolicOperations$Companion { + public static final field ACOSH_OPERATION Ljava/lang/String; + public static final field ASINH_OPERATION Ljava/lang/String; + public static final field ATANH_OPERATION Ljava/lang/String; + public static final field COSH_OPERATION Ljava/lang/String; + public static final field SINH_OPERATION Ljava/lang/String; + public static final field TANH_OPERATION Ljava/lang/String; +} + +public final class kscience/kmath/operations/HyperbolicOperations$DefaultImpls { + public static fun binaryOperation (Lkscience/kmath/operations/HyperbolicOperations;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperationFunction (Lkscience/kmath/operations/HyperbolicOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun symbol (Lkscience/kmath/operations/HyperbolicOperations;Ljava/lang/String;)Ljava/lang/Object; + public static fun unaryOperation (Lkscience/kmath/operations/HyperbolicOperations;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperationFunction (Lkscience/kmath/operations/HyperbolicOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + +public final class kscience/kmath/operations/IntRing : kscience/kmath/operations/Norm, kscience/kmath/operations/NumericAlgebra, kscience/kmath/operations/Ring { + public static final field INSTANCE Lkscience/kmath/operations/IntRing; + public fun add (II)Ljava/lang/Integer; + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;II)Ljava/lang/Integer; + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public fun div (ILjava/lang/Number;)Ljava/lang/Integer; + public synthetic fun div (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun getOne ()Ljava/lang/Integer; + public synthetic fun getOne ()Ljava/lang/Object; + public fun getZero ()Ljava/lang/Integer; + public synthetic fun getZero ()Ljava/lang/Object; + public fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;I)Ljava/lang/Integer; + public synthetic fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public fun minus (II)Ljava/lang/Integer; + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply (II)Ljava/lang/Integer; + public fun multiply (ILjava/lang/Number;)Ljava/lang/Integer; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun norm (I)Ljava/lang/Integer; + public synthetic fun norm (Ljava/lang/Object;)Ljava/lang/Object; + public fun number (Ljava/lang/Number;)Ljava/lang/Integer; + public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun plus (II)Ljava/lang/Integer; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun rightSideNumberOperation (Ljava/lang/String;ILjava/lang/Number;)Ljava/lang/Integer; + public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public fun symbol (Ljava/lang/String;)Ljava/lang/Integer; + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun times (II)Ljava/lang/Integer; + public fun times (ILjava/lang/Number;)Ljava/lang/Integer; + public fun times (Ljava/lang/Number;I)Ljava/lang/Integer; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + 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 fun unaryMinus (I)Ljava/lang/Integer; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;I)Ljava/lang/Integer; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public fun unaryPlus (I)Ljava/lang/Integer; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; +} + +public final class kscience/kmath/operations/JBigDecimalField : kscience/kmath/operations/JBigDecimalFieldBase { + public static final field Companion Lkscience/kmath/operations/JBigDecimalField$Companion; + public fun ()V + public fun (Ljava/math/MathContext;)V + public synthetic fun (Ljava/math/MathContext;ILkotlin/jvm/internal/DefaultConstructorMarker;)V +} + +public final class kscience/kmath/operations/JBigDecimalField$Companion : kscience/kmath/operations/JBigDecimalFieldBase { +} + +public abstract class kscience/kmath/operations/JBigDecimalFieldBase : kscience/kmath/operations/Field, kscience/kmath/operations/NumericAlgebra, kscience/kmath/operations/PowerOperations { + public fun ()V + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun add (Ljava/math/BigDecimal;Ljava/math/BigDecimal;)Ljava/math/BigDecimal; + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;Ljava/math/BigDecimal;Ljava/math/BigDecimal;)Ljava/math/BigDecimal; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun div (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun div (Ljava/lang/Number;Ljava/math/BigDecimal;)Ljava/math/BigDecimal; + 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/math/BigDecimal;Ljava/lang/Number;)Ljava/math/BigDecimal; + public fun div (Ljava/math/BigDecimal;Ljava/math/BigDecimal;)Ljava/math/BigDecimal; + public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun divide (Ljava/math/BigDecimal;Ljava/math/BigDecimal;)Ljava/math/BigDecimal; + public synthetic fun getOne ()Ljava/lang/Object; + public fun getOne ()Ljava/math/BigDecimal; + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero ()Ljava/math/BigDecimal; + 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;Ljava/math/BigDecimal;)Ljava/math/BigDecimal; + public fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun minus (Ljava/math/BigDecimal;Ljava/math/BigDecimal;)Ljava/math/BigDecimal; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply (Ljava/math/BigDecimal;Ljava/lang/Number;)Ljava/math/BigDecimal; + public fun multiply (Ljava/math/BigDecimal;Ljava/math/BigDecimal;)Ljava/math/BigDecimal; + public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun number (Ljava/lang/Number;)Ljava/math/BigDecimal; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun plus (Ljava/math/BigDecimal;Ljava/math/BigDecimal;)Ljava/math/BigDecimal; + public synthetic fun pow (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun pow (Ljava/math/BigDecimal;Ljava/lang/Number;)Ljava/math/BigDecimal; + public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun power (Ljava/math/BigDecimal;Ljava/lang/Number;)Ljava/math/BigDecimal; + public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperation (Ljava/lang/String;Ljava/math/BigDecimal;Ljava/lang/Number;)Ljava/math/BigDecimal; + public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun sqrt (Ljava/lang/Object;)Ljava/lang/Object; + public fun sqrt (Ljava/math/BigDecimal;)Ljava/math/BigDecimal; + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun symbol (Ljava/lang/String;)Ljava/math/BigDecimal; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Ljava/lang/Number;Ljava/math/BigDecimal;)Ljava/math/BigDecimal; + 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 fun times (Ljava/math/BigDecimal;Ljava/lang/Number;)Ljava/math/BigDecimal; + public fun times (Ljava/math/BigDecimal;Ljava/math/BigDecimal;)Ljava/math/BigDecimal; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (Ljava/math/BigDecimal;)Ljava/math/BigDecimal; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;Ljava/math/BigDecimal;)Ljava/math/BigDecimal; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryPlus (Ljava/math/BigDecimal;)Ljava/math/BigDecimal; +} + +public final class kscience/kmath/operations/JBigIntegerField : kscience/kmath/operations/Field, kscience/kmath/operations/NumericAlgebra { + public static final field INSTANCE Lkscience/kmath/operations/JBigIntegerField; + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun add (Ljava/math/BigInteger;Ljava/math/BigInteger;)Ljava/math/BigInteger; + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;Ljava/math/BigInteger;Ljava/math/BigInteger;)Ljava/math/BigInteger; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun div (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun div (Ljava/lang/Number;Ljava/math/BigInteger;)Ljava/math/BigInteger; + 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/math/BigInteger;Ljava/lang/Number;)Ljava/math/BigInteger; + public fun div (Ljava/math/BigInteger;Ljava/math/BigInteger;)Ljava/math/BigInteger; + public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun divide (Ljava/math/BigInteger;Ljava/math/BigInteger;)Ljava/math/BigInteger; + public synthetic fun getOne ()Ljava/lang/Object; + public fun getOne ()Ljava/math/BigInteger; + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero ()Ljava/math/BigInteger; + 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;Ljava/math/BigInteger;)Ljava/math/BigInteger; + public fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun minus (Ljava/math/BigInteger;Ljava/math/BigInteger;)Ljava/math/BigInteger; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply (Ljava/math/BigInteger;Ljava/lang/Number;)Ljava/math/BigInteger; + public fun multiply (Ljava/math/BigInteger;Ljava/math/BigInteger;)Ljava/math/BigInteger; + public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun number (Ljava/lang/Number;)Ljava/math/BigInteger; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun plus (Ljava/math/BigInteger;Ljava/math/BigInteger;)Ljava/math/BigInteger; + public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperation (Ljava/lang/String;Ljava/math/BigInteger;Ljava/lang/Number;)Ljava/math/BigInteger; + public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun symbol (Ljava/lang/String;)Ljava/math/BigInteger; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Ljava/lang/Number;Ljava/math/BigInteger;)Ljava/math/BigInteger; + 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 fun times (Ljava/math/BigInteger;Ljava/lang/Number;)Ljava/math/BigInteger; + public fun times (Ljava/math/BigInteger;Ljava/math/BigInteger;)Ljava/math/BigInteger; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (Ljava/math/BigInteger;)Ljava/math/BigInteger; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;Ljava/math/BigInteger;)Ljava/math/BigInteger; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryPlus (Ljava/math/BigInteger;)Ljava/math/BigInteger; +} + +public abstract interface annotation class kscience/kmath/operations/KMathContext : java/lang/annotation/Annotation { +} + +public final class kscience/kmath/operations/LongRing : kscience/kmath/operations/Norm, kscience/kmath/operations/NumericAlgebra, kscience/kmath/operations/Ring { + public static final field INSTANCE Lkscience/kmath/operations/LongRing; + public fun add (JJ)Ljava/lang/Long; + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;JJ)Ljava/lang/Long; + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public fun div (JLjava/lang/Number;)Ljava/lang/Long; + public synthetic fun div (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun getOne ()Ljava/lang/Long; + public synthetic fun getOne ()Ljava/lang/Object; + public fun getZero ()Ljava/lang/Long; + public synthetic fun getZero ()Ljava/lang/Object; + public fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;J)Ljava/lang/Long; + public synthetic fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public fun minus (JJ)Ljava/lang/Long; + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply (JJ)Ljava/lang/Long; + public fun multiply (JLjava/lang/Number;)Ljava/lang/Long; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun norm (J)Ljava/lang/Long; + public synthetic fun norm (Ljava/lang/Object;)Ljava/lang/Object; + public fun number (Ljava/lang/Number;)Ljava/lang/Long; + public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun plus (JJ)Ljava/lang/Long; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun rightSideNumberOperation (Ljava/lang/String;JLjava/lang/Number;)Ljava/lang/Long; + public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public fun symbol (Ljava/lang/String;)Ljava/lang/Long; + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun times (JJ)Ljava/lang/Long; + public fun times (JLjava/lang/Number;)Ljava/lang/Long; + public fun times (Ljava/lang/Number;J)Ljava/lang/Long; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + 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 fun unaryMinus (J)Ljava/lang/Long; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;J)Ljava/lang/Long; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public fun unaryPlus (J)Ljava/lang/Long; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; +} + +public abstract interface class kscience/kmath/operations/MathElement { + public abstract fun getContext ()Ljava/lang/Object; +} + +public abstract interface class kscience/kmath/operations/MathWrapper { + public abstract fun unwrap ()Ljava/lang/Object; + public abstract fun wrap (Ljava/lang/Object;)Ljava/lang/Object; +} + +public abstract interface class kscience/kmath/operations/Norm { + public abstract fun norm (Ljava/lang/Object;)Ljava/lang/Object; +} + +public abstract interface class kscience/kmath/operations/NumericAlgebra : kscience/kmath/operations/Algebra { + public abstract fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public abstract fun number (Ljava/lang/Number;)Ljava/lang/Object; + public abstract fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public abstract fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; +} + +public final class kscience/kmath/operations/NumericAlgebra$DefaultImpls { + public static fun binaryOperation (Lkscience/kmath/operations/NumericAlgebra;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperationFunction (Lkscience/kmath/operations/NumericAlgebra;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun leftSideNumberOperation (Lkscience/kmath/operations/NumericAlgebra;Ljava/lang/String;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public static fun leftSideNumberOperationFunction (Lkscience/kmath/operations/NumericAlgebra;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun rightSideNumberOperation (Lkscience/kmath/operations/NumericAlgebra;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun rightSideNumberOperationFunction (Lkscience/kmath/operations/NumericAlgebra;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun symbol (Lkscience/kmath/operations/NumericAlgebra;Ljava/lang/String;)Ljava/lang/Object; + public static fun unaryOperation (Lkscience/kmath/operations/NumericAlgebra;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperationFunction (Lkscience/kmath/operations/NumericAlgebra;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + +public final class kscience/kmath/operations/OptionalOperationsKt { + public static final fun acos (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; + public static final fun acosh (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; + public static final fun asin (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; + public static final fun asinh (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; + public static final fun atan (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; + public static final fun atanh (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; + public static final fun cos (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; + public static final fun cosh (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; + public static final fun exp (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; + public static final fun ln (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; + public static final fun norm (Lkscience/kmath/operations/MathElement;)Ljava/lang/Object; + public static final fun pow (Lkscience/kmath/operations/MathElement;D)Lkscience/kmath/operations/MathElement; + public static final fun sin (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; + public static final fun sinh (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; + public static final fun sqr (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; + public static final fun sqrt (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; + public static final fun tan (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; + public static final fun tanh (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; +} + +public abstract interface class kscience/kmath/operations/PowerOperations : kscience/kmath/operations/Algebra { + public static final field Companion Lkscience/kmath/operations/PowerOperations$Companion; + public static final field POW_OPERATION Ljava/lang/String; + public static final field SQRT_OPERATION Ljava/lang/String; + public abstract fun pow (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public abstract fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public abstract fun sqrt (Ljava/lang/Object;)Ljava/lang/Object; +} + +public final class kscience/kmath/operations/PowerOperations$Companion { + public static final field POW_OPERATION Ljava/lang/String; + public static final field SQRT_OPERATION Ljava/lang/String; +} + +public final class kscience/kmath/operations/PowerOperations$DefaultImpls { + public static fun binaryOperation (Lkscience/kmath/operations/PowerOperations;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperationFunction (Lkscience/kmath/operations/PowerOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun pow (Lkscience/kmath/operations/PowerOperations;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun sqrt (Lkscience/kmath/operations/PowerOperations;Ljava/lang/Object;)Ljava/lang/Object; + public static fun symbol (Lkscience/kmath/operations/PowerOperations;Ljava/lang/String;)Ljava/lang/Object; + public static fun unaryOperation (Lkscience/kmath/operations/PowerOperations;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperationFunction (Lkscience/kmath/operations/PowerOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + +public final class kscience/kmath/operations/Real : kscience/kmath/operations/FieldElement { + public static final field Companion Lkscience/kmath/operations/Real$Companion; + public static final synthetic fun box-impl (D)Lkscience/kmath/operations/Real; + public static fun constructor-impl (D)D + public synthetic fun div (Ljava/lang/Number;)Lkscience/kmath/operations/FieldElement; + public synthetic fun div (Ljava/lang/Number;)Lkscience/kmath/operations/RingElement; + public synthetic fun div (Ljava/lang/Number;)Lkscience/kmath/operations/SpaceElement; + public synthetic fun div (Ljava/lang/Object;)Lkscience/kmath/operations/FieldElement; + public fun div-qF3TpSg (D)D + public static fun div-qF3TpSg (DD)D + public static fun div-qF3TpSg (DLjava/lang/Number;)D + public fun div-qF3TpSg (Ljava/lang/Number;)D + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (DLjava/lang/Object;)Z + public static final fun equals-impl0 (DD)Z + public synthetic fun getContext ()Ljava/lang/Object; + public synthetic fun getContext ()Lkscience/kmath/operations/Field; + public fun getContext ()Lkscience/kmath/operations/RealField; + public static fun getContext-impl (D)Lkscience/kmath/operations/RealField; + public final fun getValue ()D + public fun hashCode ()I + public static fun hashCode-impl (D)I + public synthetic fun minus (Ljava/lang/Object;)Lkscience/kmath/operations/FieldElement; + public synthetic fun minus (Ljava/lang/Object;)Lkscience/kmath/operations/RingElement; + public synthetic fun minus (Ljava/lang/Object;)Lkscience/kmath/operations/SpaceElement; + public fun minus-qF3TpSg (D)D + public static fun minus-qF3TpSg (DD)D + public synthetic fun plus (Ljava/lang/Object;)Lkscience/kmath/operations/FieldElement; + public synthetic fun plus (Ljava/lang/Object;)Lkscience/kmath/operations/RingElement; + public synthetic fun plus (Ljava/lang/Object;)Lkscience/kmath/operations/SpaceElement; + public fun plus-qF3TpSg (D)D + public static fun plus-qF3TpSg (DD)D + public synthetic fun times (Ljava/lang/Number;)Lkscience/kmath/operations/FieldElement; + public synthetic fun times (Ljava/lang/Number;)Lkscience/kmath/operations/RingElement; + public synthetic fun times (Ljava/lang/Number;)Lkscience/kmath/operations/SpaceElement; + public synthetic fun times (Ljava/lang/Object;)Lkscience/kmath/operations/FieldElement; + public synthetic fun times (Ljava/lang/Object;)Lkscience/kmath/operations/RingElement; + public fun times-qF3TpSg (D)D + public static fun times-qF3TpSg (DD)D + public static fun times-qF3TpSg (DLjava/lang/Number;)D + public fun times-qF3TpSg (Ljava/lang/Number;)D + public fun toString ()Ljava/lang/String; + public static fun toString-impl (D)Ljava/lang/String; + public final synthetic fun unbox-impl ()D + public fun unwrap ()Ljava/lang/Double; + public synthetic fun unwrap ()Ljava/lang/Object; + public static fun unwrap-impl (D)Ljava/lang/Double; + public synthetic fun wrap (Ljava/lang/Object;)Ljava/lang/Object; + public fun wrap-qF3TpSg (D)D + public static fun wrap-qF3TpSg (DD)D +} + +public final class kscience/kmath/operations/Real$Companion { +} + +public final class kscience/kmath/operations/RealField : kscience/kmath/operations/ExtendedField, kscience/kmath/operations/Norm { + public static final field INSTANCE Lkscience/kmath/operations/RealField; + public fun acos (D)Ljava/lang/Double; + public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; + public fun acosh (D)Ljava/lang/Double; + public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun add (DD)Ljava/lang/Double; + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun asin (D)Ljava/lang/Double; + public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; + public fun asinh (D)Ljava/lang/Double; + public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun atan (D)Ljava/lang/Double; + public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; + public fun atanh (D)Ljava/lang/Double; + public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;DD)Ljava/lang/Double; + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public fun cos (D)Ljava/lang/Double; + public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; + public fun cosh (D)Ljava/lang/Double; + public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun div (DD)Ljava/lang/Double; + public fun div (DLjava/lang/Number;)Ljava/lang/Double; + public fun div (Ljava/lang/Number;D)Ljava/lang/Double; + public synthetic fun div (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + 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 divide (DD)Ljava/lang/Double; + public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun exp (D)Ljava/lang/Double; + public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; + public fun getOne ()Ljava/lang/Double; + public synthetic fun getOne ()Ljava/lang/Object; + public fun getZero ()Ljava/lang/Double; + public synthetic fun getZero ()Ljava/lang/Object; + public fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;D)Ljava/lang/Double; + public synthetic fun leftSideNumberOperation (Ljava/lang/String;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public fun ln (D)Ljava/lang/Double; + public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object; + public fun minus (DD)Ljava/lang/Double; + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply (DD)Ljava/lang/Double; + public fun multiply (DLjava/lang/Number;)Ljava/lang/Double; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun norm (D)Ljava/lang/Double; + public synthetic fun norm (Ljava/lang/Object;)Ljava/lang/Object; + public fun number (Ljava/lang/Number;)Ljava/lang/Double; + public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun plus (DD)Ljava/lang/Double; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun pow (DLjava/lang/Number;)Ljava/lang/Double; + public synthetic fun pow (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun power (DLjava/lang/Number;)Ljava/lang/Double; + public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperation (Ljava/lang/String;DLjava/lang/Number;)Ljava/lang/Double; + public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public fun sin (D)Ljava/lang/Double; + public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; + public fun sinh (D)Ljava/lang/Double; + public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun sqrt (D)Ljava/lang/Double; + public synthetic fun sqrt (Ljava/lang/Object;)Ljava/lang/Object; + public fun symbol (Ljava/lang/String;)Ljava/lang/Double; + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun tan (D)Ljava/lang/Double; + public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; + public fun tanh (D)Ljava/lang/Double; + public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun times (DD)Ljava/lang/Double; + public fun times (DLjava/lang/Number;)Ljava/lang/Double; + public fun times (Ljava/lang/Number;D)Ljava/lang/Double; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + 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 fun unaryMinus (D)Ljava/lang/Double; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;D)Ljava/lang/Double; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public fun unaryPlus (D)Ljava/lang/Double; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; +} + +public abstract interface class kscience/kmath/operations/Ring : kscience/kmath/operations/RingOperations, kscience/kmath/operations/Space { + public abstract fun getOne ()Ljava/lang/Object; +} + +public final class kscience/kmath/operations/Ring$DefaultImpls { + public static fun binaryOperation (Lkscience/kmath/operations/Ring;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperationFunction (Lkscience/kmath/operations/Ring;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun div (Lkscience/kmath/operations/Ring;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun minus (Lkscience/kmath/operations/Ring;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun plus (Lkscience/kmath/operations/Ring;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun symbol (Lkscience/kmath/operations/Ring;Ljava/lang/String;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/Ring;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/Ring;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/Ring;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryMinus (Lkscience/kmath/operations/Ring;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperation (Lkscience/kmath/operations/Ring;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperationFunction (Lkscience/kmath/operations/Ring;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lkscience/kmath/operations/Ring;Ljava/lang/Object;)Ljava/lang/Object; +} + +public abstract interface class kscience/kmath/operations/RingElement : kscience/kmath/operations/SpaceElement { + public abstract fun times (Ljava/lang/Object;)Lkscience/kmath/operations/RingElement; +} + +public final class kscience/kmath/operations/RingElement$DefaultImpls { + public static fun div (Lkscience/kmath/operations/RingElement;Ljava/lang/Number;)Lkscience/kmath/operations/RingElement; + public static fun minus (Lkscience/kmath/operations/RingElement;Ljava/lang/Object;)Lkscience/kmath/operations/RingElement; + public static fun plus (Lkscience/kmath/operations/RingElement;Ljava/lang/Object;)Lkscience/kmath/operations/RingElement; + public static fun times (Lkscience/kmath/operations/RingElement;Ljava/lang/Number;)Lkscience/kmath/operations/RingElement; + public static fun times (Lkscience/kmath/operations/RingElement;Ljava/lang/Object;)Lkscience/kmath/operations/RingElement; +} + +public abstract interface class kscience/kmath/operations/RingOperations : kscience/kmath/operations/SpaceOperations { + public static final field Companion Lkscience/kmath/operations/RingOperations$Companion; + public static final field TIMES_OPERATION Ljava/lang/String; + public abstract fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public abstract fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun times (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; +} + +public final class kscience/kmath/operations/RingOperations$Companion { + public static final field TIMES_OPERATION Ljava/lang/String; +} + +public final class kscience/kmath/operations/RingOperations$DefaultImpls { + public static fun binaryOperation (Lkscience/kmath/operations/RingOperations;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperationFunction (Lkscience/kmath/operations/RingOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun div (Lkscience/kmath/operations/RingOperations;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun minus (Lkscience/kmath/operations/RingOperations;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun plus (Lkscience/kmath/operations/RingOperations;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun symbol (Lkscience/kmath/operations/RingOperations;Ljava/lang/String;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/RingOperations;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/RingOperations;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/RingOperations;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryMinus (Lkscience/kmath/operations/RingOperations;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperation (Lkscience/kmath/operations/RingOperations;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperationFunction (Lkscience/kmath/operations/RingOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lkscience/kmath/operations/RingOperations;Ljava/lang/Object;)Ljava/lang/Object; +} + +public abstract interface class kscience/kmath/operations/RingWithNumbers : kscience/kmath/operations/NumericAlgebra, kscience/kmath/operations/Ring { + public abstract fun minus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun minus (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public abstract fun number (Ljava/lang/Number;)Ljava/lang/Object; + public abstract fun plus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun plus (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; +} + +public final class kscience/kmath/operations/RingWithNumbers$DefaultImpls { + public static fun binaryOperation (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperationFunction (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun div (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun leftSideNumberOperation (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/String;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public static fun leftSideNumberOperationFunction (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun minus (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public static fun minus (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun minus (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun number (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/Number;)Ljava/lang/Object; + public static fun plus (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public static fun plus (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun plus (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun rightSideNumberOperation (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun rightSideNumberOperationFunction (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun symbol (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/String;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryMinus (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperation (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperationFunction (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lkscience/kmath/operations/RingWithNumbers;Ljava/lang/Object;)Ljava/lang/Object; +} + +public final class kscience/kmath/operations/ShortRing : kscience/kmath/operations/Norm, kscience/kmath/operations/NumericAlgebra, kscience/kmath/operations/Ring { + public static final field INSTANCE Lkscience/kmath/operations/ShortRing; + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun add (SS)Ljava/lang/Short; + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;SS)Ljava/lang/Short; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun div (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun div (SLjava/lang/Number;)Ljava/lang/Short; + public synthetic fun getOne ()Ljava/lang/Object; + public fun getOne ()Ljava/lang/Short; + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero ()Ljava/lang/Short; + 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;S)Ljava/lang/Short; + public fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun minus (SS)Ljava/lang/Short; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply (SLjava/lang/Number;)Ljava/lang/Short; + public fun multiply (SS)Ljava/lang/Short; + public synthetic fun norm (Ljava/lang/Object;)Ljava/lang/Object; + public fun norm (S)Ljava/lang/Short; + public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun number (Ljava/lang/Number;)Ljava/lang/Short; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun plus (SS)Ljava/lang/Short; + public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperation (Ljava/lang/String;SLjava/lang/Number;)Ljava/lang/Short; + public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun symbol (Ljava/lang/String;)Ljava/lang/Short; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Ljava/lang/Number;S)Ljava/lang/Short; + 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 fun times (SLjava/lang/Number;)Ljava/lang/Short; + public fun times (SS)Ljava/lang/Short; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (S)Ljava/lang/Short; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;S)Ljava/lang/Short; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryPlus (S)Ljava/lang/Short; +} + +public abstract interface class kscience/kmath/operations/Space : kscience/kmath/operations/SpaceOperations { + public abstract fun getZero ()Ljava/lang/Object; +} + +public final class kscience/kmath/operations/Space$DefaultImpls { + public static fun binaryOperation (Lkscience/kmath/operations/Space;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperationFunction (Lkscience/kmath/operations/Space;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun div (Lkscience/kmath/operations/Space;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun minus (Lkscience/kmath/operations/Space;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun plus (Lkscience/kmath/operations/Space;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun symbol (Lkscience/kmath/operations/Space;Ljava/lang/String;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/Space;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/Space;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun unaryMinus (Lkscience/kmath/operations/Space;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperation (Lkscience/kmath/operations/Space;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperationFunction (Lkscience/kmath/operations/Space;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lkscience/kmath/operations/Space;Ljava/lang/Object;)Ljava/lang/Object; +} + +public abstract interface class kscience/kmath/operations/SpaceElement : kscience/kmath/operations/MathElement, kscience/kmath/operations/MathWrapper { + public abstract fun div (Ljava/lang/Number;)Lkscience/kmath/operations/SpaceElement; + public abstract fun minus (Ljava/lang/Object;)Lkscience/kmath/operations/SpaceElement; + public abstract fun plus (Ljava/lang/Object;)Lkscience/kmath/operations/SpaceElement; + public abstract fun times (Ljava/lang/Number;)Lkscience/kmath/operations/SpaceElement; +} + +public final class kscience/kmath/operations/SpaceElement$DefaultImpls { + public static fun div (Lkscience/kmath/operations/SpaceElement;Ljava/lang/Number;)Lkscience/kmath/operations/SpaceElement; + public static fun minus (Lkscience/kmath/operations/SpaceElement;Ljava/lang/Object;)Lkscience/kmath/operations/SpaceElement; + public static fun plus (Lkscience/kmath/operations/SpaceElement;Ljava/lang/Object;)Lkscience/kmath/operations/SpaceElement; + public static fun times (Lkscience/kmath/operations/SpaceElement;Ljava/lang/Number;)Lkscience/kmath/operations/SpaceElement; +} + +public abstract interface class kscience/kmath/operations/SpaceOperations : kscience/kmath/operations/Algebra { + public static final field Companion Lkscience/kmath/operations/SpaceOperations$Companion; + public static final field MINUS_OPERATION Ljava/lang/String; + public static final field PLUS_OPERATION Ljava/lang/String; + public abstract fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public abstract fun div (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public abstract fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public abstract fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun times (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public abstract fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public abstract fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; +} + +public final class kscience/kmath/operations/SpaceOperations$Companion { + public static final field MINUS_OPERATION Ljava/lang/String; + public static final field PLUS_OPERATION Ljava/lang/String; +} + +public final class kscience/kmath/operations/SpaceOperations$DefaultImpls { + public static fun binaryOperation (Lkscience/kmath/operations/SpaceOperations;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperationFunction (Lkscience/kmath/operations/SpaceOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun div (Lkscience/kmath/operations/SpaceOperations;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun minus (Lkscience/kmath/operations/SpaceOperations;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun plus (Lkscience/kmath/operations/SpaceOperations;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun symbol (Lkscience/kmath/operations/SpaceOperations;Ljava/lang/String;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/SpaceOperations;Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public static fun times (Lkscience/kmath/operations/SpaceOperations;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public static fun unaryMinus (Lkscience/kmath/operations/SpaceOperations;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperation (Lkscience/kmath/operations/SpaceOperations;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperationFunction (Lkscience/kmath/operations/SpaceOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lkscience/kmath/operations/SpaceOperations;Ljava/lang/Object;)Ljava/lang/Object; +} + +public abstract interface class kscience/kmath/operations/TrigonometricOperations : kscience/kmath/operations/Algebra { + public static final field ACOS_OPERATION Ljava/lang/String; + public static final field ASIN_OPERATION Ljava/lang/String; + public static final field ATAN_OPERATION Ljava/lang/String; + public static final field COS_OPERATION Ljava/lang/String; + public static final field Companion Lkscience/kmath/operations/TrigonometricOperations$Companion; + public static final field SIN_OPERATION Ljava/lang/String; + public static final field TAN_OPERATION Ljava/lang/String; + public abstract fun acos (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun asin (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun atan (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun cos (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun sin (Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun tan (Ljava/lang/Object;)Ljava/lang/Object; +} + +public final class kscience/kmath/operations/TrigonometricOperations$Companion { + public static final field ACOS_OPERATION Ljava/lang/String; + public static final field ASIN_OPERATION Ljava/lang/String; + public static final field ATAN_OPERATION Ljava/lang/String; + public static final field COS_OPERATION Ljava/lang/String; + public static final field SIN_OPERATION Ljava/lang/String; + public static final field TAN_OPERATION Ljava/lang/String; +} + +public final class kscience/kmath/operations/TrigonometricOperations$DefaultImpls { + public static fun binaryOperation (Lkscience/kmath/operations/TrigonometricOperations;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperationFunction (Lkscience/kmath/operations/TrigonometricOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun symbol (Lkscience/kmath/operations/TrigonometricOperations;Ljava/lang/String;)Ljava/lang/Object; + public static fun unaryOperation (Lkscience/kmath/operations/TrigonometricOperations;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperationFunction (Lkscience/kmath/operations/TrigonometricOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + +public final class kscience/kmath/structures/ArrayBuffer : kscience/kmath/structures/MutableBuffer { + public fun ([Ljava/lang/Object;)V + public fun contentEquals (Lkscience/kmath/structures/Buffer;)Z + public fun copy ()Lkscience/kmath/structures/MutableBuffer; + public fun get (I)Ljava/lang/Object; + public fun getSize ()I + public fun iterator ()Ljava/util/Iterator; + public fun set (ILjava/lang/Object;)V +} + +public abstract interface class kscience/kmath/structures/Buffer { + public static final field Companion Lkscience/kmath/structures/Buffer$Companion; + public abstract fun contentEquals (Lkscience/kmath/structures/Buffer;)Z + public abstract fun get (I)Ljava/lang/Object; + public abstract fun getSize ()I + public abstract fun iterator ()Ljava/util/Iterator; +} + +public final class kscience/kmath/structures/Buffer$Companion { + public final fun auto (Lkotlin/reflect/KClass;ILkotlin/jvm/functions/Function1;)Lkscience/kmath/structures/Buffer; + public final fun boxing (ILkotlin/jvm/functions/Function1;)Lkscience/kmath/structures/Buffer; + public final fun real-4n5bU9U (ILkotlin/jvm/functions/Function1;)[D +} + +public final class kscience/kmath/structures/Buffer$DefaultImpls { + public static fun contentEquals (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Z +} + +public final class kscience/kmath/structures/BuffersKt { + public static final fun ListBuffer (ILkotlin/jvm/functions/Function1;)Ljava/util/List; + public static final fun asBuffer (Ljava/util/List;)Ljava/util/List; + public static final fun asBuffer ([Ljava/lang/Object;)Lkscience/kmath/structures/ArrayBuffer; + public static final fun asIterable (Lkscience/kmath/structures/Buffer;)Ljava/lang/Iterable; + public static final fun asReadOnly (Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public static final fun asSequence (Lkscience/kmath/structures/Buffer;)Lkotlin/sequences/Sequence; + public static final fun getIndices (Lkscience/kmath/structures/Buffer;)Lkotlin/ranges/IntRange; + public static final fun toList (Lkscience/kmath/structures/Buffer;)Ljava/util/List; +} + +public abstract interface class kscience/kmath/structures/FlaggedBuffer : kscience/kmath/structures/Buffer { + public abstract fun getFlag (I)B +} + +public final class kscience/kmath/structures/FlaggedBuffer$DefaultImpls { + public static fun contentEquals (Lkscience/kmath/structures/FlaggedBuffer;Lkscience/kmath/structures/Buffer;)Z +} + +public final class kscience/kmath/structures/FlaggedBufferKt { + public static final fun forEachValid (Lkscience/kmath/structures/FlaggedRealBuffer;Lkotlin/jvm/functions/Function1;)V + public static final fun hasFlag (Lkscience/kmath/structures/FlaggedBuffer;ILkscience/kmath/structures/ValueFlag;)Z + public static final fun isMissing (Lkscience/kmath/structures/FlaggedBuffer;I)Z + public static final fun isValid (Lkscience/kmath/structures/FlaggedBuffer;I)Z +} + +public final class kscience/kmath/structures/FlaggedRealBuffer : kscience/kmath/structures/Buffer, kscience/kmath/structures/FlaggedBuffer { + public fun ([D[B)V + public fun contentEquals (Lkscience/kmath/structures/Buffer;)Z + public fun get (I)Ljava/lang/Double; + public synthetic fun get (I)Ljava/lang/Object; + public fun getFlag (I)B + public final fun getFlags ()[B + public fun getSize ()I + public final fun getValues ()[D + public fun iterator ()Ljava/util/Iterator; +} + +public final class kscience/kmath/structures/FloatBuffer : kscience/kmath/structures/MutableBuffer { + public static final synthetic fun box-impl ([F)Lkscience/kmath/structures/FloatBuffer; + public static fun constructor-impl ([F)[F + public fun contentEquals (Lkscience/kmath/structures/Buffer;)Z + public static fun contentEquals-impl ([FLkscience/kmath/structures/Buffer;)Z + public fun copy ()Lkscience/kmath/structures/MutableBuffer; + public static fun copy-impl ([F)Lkscience/kmath/structures/MutableBuffer; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl ([FLjava/lang/Object;)Z + public static final fun equals-impl0 ([F[F)Z + public fun get (I)Ljava/lang/Float; + public synthetic fun get (I)Ljava/lang/Object; + public static fun get-impl ([FI)Ljava/lang/Float; + public final fun getArray ()[F + public fun getSize ()I + public static fun getSize-impl ([F)I + public fun hashCode ()I + public static fun hashCode-impl ([F)I + public synthetic fun iterator ()Ljava/util/Iterator; + public fun iterator ()Lkotlin/collections/FloatIterator; + public static fun iterator-impl ([F)Lkotlin/collections/FloatIterator; + public fun set (IF)V + public synthetic fun set (ILjava/lang/Object;)V + public static fun set-impl ([FIF)V + public fun toString ()Ljava/lang/String; + public static fun toString-impl ([F)Ljava/lang/String; + public final synthetic fun unbox-impl ()[F +} + +public final class kscience/kmath/structures/FloatBufferKt { + public static final fun FloatBuffer (ILkotlin/jvm/functions/Function1;)[F + public static final fun FloatBuffer ([F)[F + public static final fun asBuffer ([F)[F + public static final fun getArray (Lkscience/kmath/structures/MutableBuffer;)[F +} + +public final class kscience/kmath/structures/IntBuffer : kscience/kmath/structures/MutableBuffer { + public static final synthetic fun box-impl ([I)Lkscience/kmath/structures/IntBuffer; + public static fun constructor-impl ([I)[I + public fun contentEquals (Lkscience/kmath/structures/Buffer;)Z + public static fun contentEquals-impl ([ILkscience/kmath/structures/Buffer;)Z + public fun copy ()Lkscience/kmath/structures/MutableBuffer; + public static fun copy-impl ([I)Lkscience/kmath/structures/MutableBuffer; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl ([ILjava/lang/Object;)Z + public static final fun equals-impl0 ([I[I)Z + public fun get (I)Ljava/lang/Integer; + public synthetic fun get (I)Ljava/lang/Object; + public static fun get-impl ([II)Ljava/lang/Integer; + public final fun getArray ()[I + public fun getSize ()I + public static fun getSize-impl ([I)I + public fun hashCode ()I + public static fun hashCode-impl ([I)I + public synthetic fun iterator ()Ljava/util/Iterator; + public fun iterator ()Lkotlin/collections/IntIterator; + public static fun iterator-impl ([I)Lkotlin/collections/IntIterator; + public fun set (II)V + public synthetic fun set (ILjava/lang/Object;)V + public static fun set-impl ([III)V + public fun toString ()Ljava/lang/String; + public static fun toString-impl ([I)Ljava/lang/String; + public final synthetic fun unbox-impl ()[I +} + +public final class kscience/kmath/structures/IntBufferKt { + public static final fun IntBuffer (ILkotlin/jvm/functions/Function1;)[I + public static final fun IntBuffer ([I)[I + public static final fun asBuffer ([I)[I + public static final fun getArray (Lkscience/kmath/structures/MutableBuffer;)[I +} + +public final class kscience/kmath/structures/ListBuffer : kscience/kmath/structures/Buffer { + public static final synthetic fun box-impl (Ljava/util/List;)Lkscience/kmath/structures/ListBuffer; + public static fun constructor-impl (Ljava/util/List;)Ljava/util/List; + public fun contentEquals (Lkscience/kmath/structures/Buffer;)Z + public static fun contentEquals-impl (Ljava/util/List;Lkscience/kmath/structures/Buffer;)Z + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Ljava/util/List;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Ljava/util/List;Ljava/util/List;)Z + public fun get (I)Ljava/lang/Object; + public static fun get-impl (Ljava/util/List;I)Ljava/lang/Object; + public final fun getList ()Ljava/util/List; + public fun getSize ()I + public static fun getSize-impl (Ljava/util/List;)I + public fun hashCode ()I + public static fun hashCode-impl (Ljava/util/List;)I + public fun iterator ()Ljava/util/Iterator; + public static fun iterator-impl (Ljava/util/List;)Ljava/util/Iterator; + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Ljava/util/List;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Ljava/util/List; +} + +public final class kscience/kmath/structures/LongBuffer : kscience/kmath/structures/MutableBuffer { + public static final synthetic fun box-impl ([J)Lkscience/kmath/structures/LongBuffer; + public static fun constructor-impl ([J)[J + public fun contentEquals (Lkscience/kmath/structures/Buffer;)Z + public static fun contentEquals-impl ([JLkscience/kmath/structures/Buffer;)Z + public fun copy ()Lkscience/kmath/structures/MutableBuffer; + public static fun copy-impl ([J)Lkscience/kmath/structures/MutableBuffer; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl ([JLjava/lang/Object;)Z + public static final fun equals-impl0 ([J[J)Z + public fun get (I)Ljava/lang/Long; + public synthetic fun get (I)Ljava/lang/Object; + public static fun get-impl ([JI)Ljava/lang/Long; + public final fun getArray ()[J + public fun getSize ()I + public static fun getSize-impl ([J)I + public fun hashCode ()I + public static fun hashCode-impl ([J)I + public synthetic fun iterator ()Ljava/util/Iterator; + public fun iterator ()Lkotlin/collections/LongIterator; + public static fun iterator-impl ([J)Lkotlin/collections/LongIterator; + public fun set (IJ)V + public synthetic fun set (ILjava/lang/Object;)V + public static fun set-impl ([JIJ)V + public fun toString ()Ljava/lang/String; + public static fun toString-impl ([J)Ljava/lang/String; + public final synthetic fun unbox-impl ()[J +} + +public final class kscience/kmath/structures/LongBufferKt { + public static final fun LongBuffer (ILkotlin/jvm/functions/Function1;)[J + public static final fun LongBuffer ([J)[J + public static final fun asBuffer ([J)[J + public static final fun getArray (Lkscience/kmath/structures/MutableBuffer;)[J +} + +public class kscience/kmath/structures/MemoryBuffer : kscience/kmath/structures/Buffer { + public static final field Companion Lkscience/kmath/structures/MemoryBuffer$Companion; + public fun (Lkscience/kmath/memory/Memory;Lkscience/kmath/memory/MemorySpec;)V + public fun contentEquals (Lkscience/kmath/structures/Buffer;)Z + public fun get (I)Ljava/lang/Object; + protected final fun getMemory ()Lkscience/kmath/memory/Memory; + public fun getSize ()I + protected final fun getSpec ()Lkscience/kmath/memory/MemorySpec; + public fun iterator ()Ljava/util/Iterator; +} + +public final class kscience/kmath/structures/MemoryBuffer$Companion { + public final fun create (Lkscience/kmath/memory/MemorySpec;I)Lkscience/kmath/structures/MemoryBuffer; + public final fun create (Lkscience/kmath/memory/MemorySpec;ILkotlin/jvm/functions/Function1;)Lkscience/kmath/structures/MemoryBuffer; +} + +public abstract interface class kscience/kmath/structures/MutableBuffer : kscience/kmath/structures/Buffer { + public static final field Companion Lkscience/kmath/structures/MutableBuffer$Companion; + public abstract fun copy ()Lkscience/kmath/structures/MutableBuffer; + public abstract fun set (ILjava/lang/Object;)V +} + +public final class kscience/kmath/structures/MutableBuffer$Companion { + public final fun auto (Lkotlin/reflect/KClass;ILkotlin/jvm/functions/Function1;)Lkscience/kmath/structures/MutableBuffer; + public final fun boxing (ILkotlin/jvm/functions/Function1;)Lkscience/kmath/structures/MutableBuffer; + public final fun real-4n5bU9U (ILkotlin/jvm/functions/Function1;)[D +} + +public final class kscience/kmath/structures/MutableBuffer$DefaultImpls { + public static fun contentEquals (Lkscience/kmath/structures/MutableBuffer;Lkscience/kmath/structures/Buffer;)Z +} + +public final class kscience/kmath/structures/MutableListBuffer : kscience/kmath/structures/MutableBuffer { + public static final synthetic fun box-impl (Ljava/util/List;)Lkscience/kmath/structures/MutableListBuffer; + public static fun constructor-impl (Ljava/util/List;)Ljava/util/List; + public fun contentEquals (Lkscience/kmath/structures/Buffer;)Z + public static fun contentEquals-impl (Ljava/util/List;Lkscience/kmath/structures/Buffer;)Z + public fun copy ()Lkscience/kmath/structures/MutableBuffer; + public static fun copy-impl (Ljava/util/List;)Lkscience/kmath/structures/MutableBuffer; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Ljava/util/List;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Ljava/util/List;Ljava/util/List;)Z + public fun get (I)Ljava/lang/Object; + public static fun get-impl (Ljava/util/List;I)Ljava/lang/Object; + public final fun getList ()Ljava/util/List; + public fun getSize ()I + public static fun getSize-impl (Ljava/util/List;)I + public fun hashCode ()I + public static fun hashCode-impl (Ljava/util/List;)I + public fun iterator ()Ljava/util/Iterator; + public static fun iterator-impl (Ljava/util/List;)Ljava/util/Iterator; + public fun set (ILjava/lang/Object;)V + public static fun set-impl (Ljava/util/List;ILjava/lang/Object;)V + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Ljava/util/List;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Ljava/util/List; +} + +public final class kscience/kmath/structures/MutableMemoryBuffer : kscience/kmath/structures/MemoryBuffer, kscience/kmath/structures/MutableBuffer { + public static final field Companion Lkscience/kmath/structures/MutableMemoryBuffer$Companion; + public fun (Lkscience/kmath/memory/Memory;Lkscience/kmath/memory/MemorySpec;)V + public fun copy ()Lkscience/kmath/structures/MutableBuffer; + public fun set (ILjava/lang/Object;)V +} + +public final class kscience/kmath/structures/MutableMemoryBuffer$Companion { + public final fun create (Lkscience/kmath/memory/MemorySpec;I)Lkscience/kmath/structures/MutableMemoryBuffer; + public final fun create (Lkscience/kmath/memory/MemorySpec;ILkotlin/jvm/functions/Function1;)Lkscience/kmath/structures/MutableMemoryBuffer; +} + +public final class kscience/kmath/structures/ReadOnlyBuffer : kscience/kmath/structures/Buffer { + public static final synthetic fun box-impl (Lkscience/kmath/structures/MutableBuffer;)Lkscience/kmath/structures/ReadOnlyBuffer; + public static fun constructor-impl (Lkscience/kmath/structures/MutableBuffer;)Lkscience/kmath/structures/MutableBuffer; + public fun contentEquals (Lkscience/kmath/structures/Buffer;)Z + public static fun contentEquals-impl (Lkscience/kmath/structures/MutableBuffer;Lkscience/kmath/structures/Buffer;)Z + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Lkscience/kmath/structures/MutableBuffer;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Lkscience/kmath/structures/MutableBuffer;Lkscience/kmath/structures/MutableBuffer;)Z + public fun get (I)Ljava/lang/Object; + public static fun get-impl (Lkscience/kmath/structures/MutableBuffer;I)Ljava/lang/Object; + public final fun getBuffer ()Lkscience/kmath/structures/MutableBuffer; + public fun getSize ()I + public static fun getSize-impl (Lkscience/kmath/structures/MutableBuffer;)I + public fun hashCode ()I + public static fun hashCode-impl (Lkscience/kmath/structures/MutableBuffer;)I + public fun iterator ()Ljava/util/Iterator; + public static fun iterator-impl (Lkscience/kmath/structures/MutableBuffer;)Ljava/util/Iterator; + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Lkscience/kmath/structures/MutableBuffer;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Lkscience/kmath/structures/MutableBuffer; +} + +public final class kscience/kmath/structures/RealBuffer : kscience/kmath/structures/MutableBuffer { + public static final synthetic fun box-impl ([D)Lkscience/kmath/structures/RealBuffer; + public static fun constructor-impl ([D)[D + public fun contentEquals (Lkscience/kmath/structures/Buffer;)Z + public static fun contentEquals-impl ([DLkscience/kmath/structures/Buffer;)Z + public synthetic fun copy ()Lkscience/kmath/structures/MutableBuffer; + public fun copy-H8_hoUg ()[D + public static fun copy-H8_hoUg ([D)[D + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl ([DLjava/lang/Object;)Z + public static final fun equals-impl0 ([D[D)Z + public fun get (I)Ljava/lang/Double; + public synthetic fun get (I)Ljava/lang/Object; + public static fun get-impl ([DI)Ljava/lang/Double; + public final fun getArray ()[D + public fun getSize ()I + public static fun getSize-impl ([D)I + public fun hashCode ()I + public static fun hashCode-impl ([D)I + public synthetic fun iterator ()Ljava/util/Iterator; + public fun iterator ()Lkotlin/collections/DoubleIterator; + public static fun iterator-impl ([D)Lkotlin/collections/DoubleIterator; + public fun set (ID)V + public synthetic fun set (ILjava/lang/Object;)V + public static fun set-impl ([DID)V + public fun toString ()Ljava/lang/String; + public static fun toString-impl ([D)Ljava/lang/String; + public final synthetic fun unbox-impl ()[D +} + +public final class kscience/kmath/structures/RealBufferField : kscience/kmath/operations/ExtendedField { + public fun (I)V + public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; + public fun acos-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun acosh-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun add-4n5bU9U (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)[D + public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; + public fun asin-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun asinh-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; + public fun atan-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun atanh-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; + public fun cos-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun cosh-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun div (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun div (Ljava/lang/Number;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + 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 (Lkscience/kmath/structures/Buffer;Ljava/lang/Number;)Lkscience/kmath/structures/Buffer; + public fun div (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun divide-4n5bU9U (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)[D + public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; + public fun exp-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun getOne ()Ljava/lang/Object; + public fun getOne ()Lkscience/kmath/structures/Buffer; + public final fun getSize ()I + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero ()Lkscience/kmath/structures/Buffer; + 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;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object; + public fun ln-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun minus (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply-4n5bU9U (Lkscience/kmath/structures/Buffer;Ljava/lang/Number;)[D + public fun multiply-4n5bU9U (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)[D + public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun number (Ljava/lang/Number;)Lkscience/kmath/structures/Buffer; + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun plus (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public synthetic fun pow (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun pow (Lkscience/kmath/structures/Buffer;Ljava/lang/Number;)Lkscience/kmath/structures/Buffer; + public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun power-4n5bU9U (Lkscience/kmath/structures/Buffer;Ljava/lang/Number;)[D + public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun rightSideNumberOperation (Ljava/lang/String;Lkscience/kmath/structures/Buffer;Ljava/lang/Number;)Lkscience/kmath/structures/Buffer; + public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; + public fun sin-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun sinh-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun sqrt (Ljava/lang/Object;)Ljava/lang/Object; + public fun sqrt (Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun symbol (Ljava/lang/String;)Lkscience/kmath/structures/Buffer; + public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; + public fun tan-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun tanh-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Ljava/lang/Number;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + 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 fun times (Lkscience/kmath/structures/Buffer;Ljava/lang/Number;)Lkscience/kmath/structures/Buffer; + public fun times (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryPlus (Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; +} + +public final class kscience/kmath/structures/RealBufferFieldOperations : kscience/kmath/operations/ExtendedFieldOperations { + public static final field INSTANCE Lkscience/kmath/structures/RealBufferFieldOperations; + public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; + public fun acos-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun acosh-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun add-4n5bU9U (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)[D + public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; + public fun asin-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun asinh-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; + public fun atan-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun atanh-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; + public fun cos-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun cosh-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + 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 (Lkscience/kmath/structures/Buffer;Ljava/lang/Number;)Lkscience/kmath/structures/Buffer; + public fun div (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun divide-4n5bU9U (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)[D + public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; + public fun exp-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object; + public fun ln-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun minus (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply-4n5bU9U (Lkscience/kmath/structures/Buffer;Ljava/lang/Number;)[D + public fun multiply-4n5bU9U (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)[D + public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun plus (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public synthetic fun pow (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun pow (Lkscience/kmath/structures/Buffer;Ljava/lang/Number;)Lkscience/kmath/structures/Buffer; + public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun power-4n5bU9U (Lkscience/kmath/structures/Buffer;Ljava/lang/Number;)[D + public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; + public fun sin-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun sinh-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun sqrt (Ljava/lang/Object;)Ljava/lang/Object; + public fun sqrt (Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun symbol (Ljava/lang/String;)Lkscience/kmath/structures/Buffer; + public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; + public fun tan-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun tanh-JVEF3vg (Lkscience/kmath/structures/Buffer;)[D + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Ljava/lang/Number;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + 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 fun times (Lkscience/kmath/structures/Buffer;Ljava/lang/Number;)Lkscience/kmath/structures/Buffer; + public fun times (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryPlus (Lkscience/kmath/structures/Buffer;)Lkscience/kmath/structures/Buffer; +} + +public final class kscience/kmath/structures/RealBufferKt { + public static final fun RealBuffer (ILkotlin/jvm/functions/Function1;)[D + public static final fun RealBuffer ([D)[D + public static final fun asBuffer ([D)[D + public static final fun contentEquals-KRld2r8 ([D[D)Z + public static final fun getArray (Lkscience/kmath/structures/MutableBuffer;)[D +} + +public final class kscience/kmath/structures/ShortBuffer : kscience/kmath/structures/MutableBuffer { + public static final synthetic fun box-impl ([S)Lkscience/kmath/structures/ShortBuffer; + public static fun constructor-impl ([S)[S + public fun contentEquals (Lkscience/kmath/structures/Buffer;)Z + public static fun contentEquals-impl ([SLkscience/kmath/structures/Buffer;)Z + public fun copy ()Lkscience/kmath/structures/MutableBuffer; + public static fun copy-impl ([S)Lkscience/kmath/structures/MutableBuffer; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl ([SLjava/lang/Object;)Z + public static final fun equals-impl0 ([S[S)Z + public synthetic fun get (I)Ljava/lang/Object; + public fun get (I)Ljava/lang/Short; + public static fun get-impl ([SI)Ljava/lang/Short; + public final fun getArray ()[S + public fun getSize ()I + public static fun getSize-impl ([S)I + public fun hashCode ()I + public static fun hashCode-impl ([S)I + public synthetic fun iterator ()Ljava/util/Iterator; + public fun iterator ()Lkotlin/collections/ShortIterator; + public static fun iterator-impl ([S)Lkotlin/collections/ShortIterator; + public synthetic fun set (ILjava/lang/Object;)V + public fun set (IS)V + public static fun set-impl ([SIS)V + public fun toString ()Ljava/lang/String; + public static fun toString-impl ([S)Ljava/lang/String; + public final synthetic fun unbox-impl ()[S +} + +public final class kscience/kmath/structures/ShortBufferKt { + public static final fun ShortBuffer (ILkotlin/jvm/functions/Function1;)[S + public static final fun ShortBuffer ([S)[S + public static final fun asBuffer ([S)[S + public static final fun getArray (Lkscience/kmath/structures/MutableBuffer;)[S +} + +public final class kscience/kmath/structures/ValueFlag : java/lang/Enum { + public static final field MISSING Lkscience/kmath/structures/ValueFlag; + public static final field NAN Lkscience/kmath/structures/ValueFlag; + public static final field NEGATIVE_INFINITY Lkscience/kmath/structures/ValueFlag; + public static final field POSITIVE_INFINITY Lkscience/kmath/structures/ValueFlag; + public final fun getMask ()B + public static fun valueOf (Ljava/lang/String;)Lkscience/kmath/structures/ValueFlag; + public static fun values ()[Lkscience/kmath/structures/ValueFlag; +} + +public final class kscience/kmath/structures/VirtualBuffer : kscience/kmath/structures/Buffer { + public fun (ILkotlin/jvm/functions/Function1;)V + public fun contentEquals (Lkscience/kmath/structures/Buffer;)Z + public fun get (I)Ljava/lang/Object; + public fun getSize ()I + public fun iterator ()Ljava/util/Iterator; +} + diff --git a/kmath-coroutines/build.gradle.kts b/kmath-coroutines/build.gradle.kts index e108c2755..d1d5a96cc 100644 --- a/kmath-coroutines/build.gradle.kts +++ b/kmath-coroutines/build.gradle.kts @@ -16,3 +16,7 @@ kotlin.sourceSets { } } } + +readme{ + maturity = ru.mipt.npm.gradle.Maturity.EXPERIMENTAL +} \ No newline at end of file diff --git a/kmath-ejml/build.gradle.kts b/kmath-ejml/build.gradle.kts index fa4aa3e39..ecf76a022 100644 --- a/kmath-ejml/build.gradle.kts +++ b/kmath-ejml/build.gradle.kts @@ -6,3 +6,7 @@ dependencies { implementation("org.ejml:ejml-simple:0.39") implementation(project(":kmath-core")) } + +readme{ + maturity = ru.mipt.npm.gradle.Maturity.PROTOTYPE +} \ No newline at end of file diff --git a/kmath-functions/README.md b/kmath-functions/README.md index 993baafc4..3e3d96fe9 100644 --- a/kmath-functions/README.md +++ b/kmath-functions/README.md @@ -2,10 +2,10 @@ Functions and interpolations: - - [piecewise](src/commonMain/kotlin/kscience/kmath/functions/Piecewise.kt) : Piecewise functions. - - [polynomials](src/commonMain/kotlin/kscience/kmath/functions/Polynomial.kt) : Polynomial functions. - - [linear interpolation](src/commonMain/kotlin/kscience/kmath/interpolation/LinearInterpolator.kt) : Linear XY interpolator. - - [spline interpolation](src/commonMain/kotlin/kscience/kmath/interpolation/SplineInterpolator.kt) : Cubic spline XY interpolator. + - [piecewise](Piecewise functions.) : src/commonMain/kotlin/kscience/kmath/functions/Piecewise.kt + - [polynomials](Polynomial functions.) : src/commonMain/kotlin/kscience/kmath/functions/Polynomial.kt + - [linear interpolation](Linear XY interpolator.) : src/commonMain/kotlin/kscience/kmath/interpolation/LinearInterpolator.kt + - [spline interpolation](Cubic spline XY interpolator.) : src/commonMain/kotlin/kscience/kmath/interpolation/SplineInterpolator.kt > #### Artifact: diff --git a/kmath-geometry/build.gradle.kts b/kmath-geometry/build.gradle.kts index 00abcb934..e27496a41 100644 --- a/kmath-geometry/build.gradle.kts +++ b/kmath-geometry/build.gradle.kts @@ -5,3 +5,7 @@ kotlin.sourceSets.commonMain { api(project(":kmath-core")) } } + +readme{ + maturity = ru.mipt.npm.gradle.Maturity.PROTOTYPE +} diff --git a/kmath-kotlingrad/build.gradle.kts b/kmath-kotlingrad/build.gradle.kts index 3925a744c..bb76f096b 100644 --- a/kmath-kotlingrad/build.gradle.kts +++ b/kmath-kotlingrad/build.gradle.kts @@ -7,3 +7,7 @@ dependencies { implementation("com.github.breandan:kotlingrad:0.4.0") api(project(":kmath-ast")) } + +readme{ + maturity = ru.mipt.npm.gradle.Maturity.PROTOTYPE +} \ No newline at end of file diff --git a/kmath-memory/api/kmath-memory.api b/kmath-memory/api/kmath-memory.api new file mode 100644 index 000000000..88b6be1d4 --- /dev/null +++ b/kmath-memory/api/kmath-memory.api @@ -0,0 +1,72 @@ +public final class kscience/kmath/memory/ByteBufferMemory : kscience/kmath/memory/Memory { + public fun (Ljava/nio/ByteBuffer;II)V + public synthetic fun (Ljava/nio/ByteBuffer;IIILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun copy ()Lkscience/kmath/memory/Memory; + public final fun getBuffer ()Ljava/nio/ByteBuffer; + public fun getSize ()I + public final fun getStartOffset ()I + public fun reader ()Lkscience/kmath/memory/MemoryReader; + public fun view (II)Lkscience/kmath/memory/Memory; + public fun writer ()Lkscience/kmath/memory/MemoryWriter; +} + +public final class kscience/kmath/memory/ByteBufferMemoryKt { + public static final fun allocate (Lkscience/kmath/memory/Memory$Companion;I)Lkscience/kmath/memory/Memory; + public static final fun asMemory (Ljava/nio/ByteBuffer;II)Lkscience/kmath/memory/Memory; + public static synthetic fun asMemory$default (Ljava/nio/ByteBuffer;IIILjava/lang/Object;)Lkscience/kmath/memory/Memory; + public static final fun readAsMemory (Ljava/nio/file/Path;JJLkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static synthetic fun readAsMemory$default (Ljava/nio/file/Path;JJLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/Object; + public static final fun wrap (Lkscience/kmath/memory/Memory$Companion;[B)Lkscience/kmath/memory/Memory; +} + +public abstract interface class kscience/kmath/memory/Memory { + public static final field Companion Lkscience/kmath/memory/Memory$Companion; + public abstract fun copy ()Lkscience/kmath/memory/Memory; + public abstract fun getSize ()I + public abstract fun reader ()Lkscience/kmath/memory/MemoryReader; + public abstract fun view (II)Lkscience/kmath/memory/Memory; + public abstract fun writer ()Lkscience/kmath/memory/MemoryWriter; +} + +public final class kscience/kmath/memory/Memory$Companion { +} + +public final class kscience/kmath/memory/MemoryKt { + public static final fun read (Lkscience/kmath/memory/Memory;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static final fun write (Lkscience/kmath/memory/Memory;Lkotlin/jvm/functions/Function1;)V +} + +public abstract interface class kscience/kmath/memory/MemoryReader { + public abstract fun getMemory ()Lkscience/kmath/memory/Memory; + public abstract fun readByte (I)B + public abstract fun readDouble (I)D + public abstract fun readFloat (I)F + public abstract fun readInt (I)I + public abstract fun readLong (I)J + public abstract fun readShort (I)S + public abstract fun release ()V +} + +public abstract interface class kscience/kmath/memory/MemorySpec { + public abstract fun getObjectSize ()I + public abstract fun read (Lkscience/kmath/memory/MemoryReader;I)Ljava/lang/Object; + public abstract fun write (Lkscience/kmath/memory/MemoryWriter;ILjava/lang/Object;)V +} + +public final class kscience/kmath/memory/MemorySpecKt { + public static final fun read (Lkscience/kmath/memory/MemoryReader;Lkscience/kmath/memory/MemorySpec;I)Ljava/lang/Object; + public static final fun write (Lkscience/kmath/memory/MemoryWriter;Lkscience/kmath/memory/MemorySpec;ILjava/lang/Object;)V + public static final fun writeArray (Lkscience/kmath/memory/MemoryWriter;Lkscience/kmath/memory/MemorySpec;I[Ljava/lang/Object;)V +} + +public abstract interface class kscience/kmath/memory/MemoryWriter { + public abstract fun getMemory ()Lkscience/kmath/memory/Memory; + public abstract fun release ()V + public abstract fun writeByte (IB)V + public abstract fun writeDouble (ID)V + public abstract fun writeFloat (IF)V + public abstract fun writeInt (II)V + public abstract fun writeLong (IJ)V + public abstract fun writeShort (IS)V +} + diff --git a/kmath-memory/build.gradle.kts b/kmath-memory/build.gradle.kts index 9f92cca92..fe7b591de 100644 --- a/kmath-memory/build.gradle.kts +++ b/kmath-memory/build.gradle.kts @@ -2,3 +2,10 @@ plugins { id("ru.mipt.npm.mpp") id("ru.mipt.npm.native") } + +readme{ + description = """ + An API and basic implementation for arranging objects in a continous memory block. + """.trimIndent() + maturity = ru.mipt.npm.gradle.Maturity.DEVELOPMENT +} \ No newline at end of file diff --git a/kmath-stat/build.gradle.kts b/kmath-stat/build.gradle.kts index 186aff944..9aba34361 100644 --- a/kmath-stat/build.gradle.kts +++ b/kmath-stat/build.gradle.kts @@ -16,3 +16,7 @@ kotlin.sourceSets { } } } + +readme{ + maturity = ru.mipt.npm.gradle.Maturity.EXPERIMENTAL +} \ No newline at end of file diff --git a/kmath-viktor/api/kmath-viktor.api b/kmath-viktor/api/kmath-viktor.api new file mode 100644 index 000000000..afd17feb1 --- /dev/null +++ b/kmath-viktor/api/kmath-viktor.api @@ -0,0 +1,189 @@ +public final class kscience/kmath/viktor/ViktorBuffer : kscience/kmath/structures/MutableBuffer { + public static final synthetic fun box-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;)Lkscience/kmath/viktor/ViktorBuffer; + public static fun constructor-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;)Lorg/jetbrains/bio/viktor/F64FlatArray; + public fun contentEquals (Lkscience/kmath/structures/Buffer;)Z + public static fun contentEquals-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;Lkscience/kmath/structures/Buffer;)Z + public fun copy ()Lkscience/kmath/structures/MutableBuffer; + public static fun copy-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;)Lkscience/kmath/structures/MutableBuffer; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Lorg/jetbrains/bio/viktor/F64FlatArray;Lorg/jetbrains/bio/viktor/F64FlatArray;)Z + public fun get (I)Ljava/lang/Double; + public synthetic fun get (I)Ljava/lang/Object; + public static fun get-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;I)Ljava/lang/Double; + public final fun getFlatArray ()Lorg/jetbrains/bio/viktor/F64FlatArray; + public fun getSize ()I + public static fun getSize-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;)I + public fun hashCode ()I + public static fun hashCode-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;)I + public fun iterator ()Ljava/util/Iterator; + public static fun iterator-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;)Ljava/util/Iterator; + public fun set (ID)V + public synthetic fun set (ILjava/lang/Object;)V + public static fun set-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;ID)V + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Lorg/jetbrains/bio/viktor/F64FlatArray;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Lorg/jetbrains/bio/viktor/F64FlatArray; +} + +public final class kscience/kmath/viktor/ViktorNDField : kscience/kmath/nd/NDField, kscience/kmath/operations/ExtendedField, kscience/kmath/operations/RingWithNumbers { + public fun ([I)V + public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; + public fun acos-02gLDOA (Lkscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun acosh (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public synthetic fun add (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun add-frQ_39w (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; + public fun asin-02gLDOA (Lkscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun asinh (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; + public fun atan-02gLDOA (Lkscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun atanh (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun binaryOperation (Ljava/lang/String;Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun combine (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lkscience/kmath/nd/NDStructure; + public fun combine-C8Lp-Ak (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; + public fun cos-02gLDOA (Lkscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; + public fun cosh (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun div (DLkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun div (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun div (Ljava/lang/Number;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + 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;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun div (Lkscience/kmath/nd/NDStructure;D)Lkscience/kmath/nd/NDStructure; + public fun div (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public synthetic fun div (Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public fun div (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun divide (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; + public fun exp-02gLDOA (Lkscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun getElementContext ()Ljava/lang/Object; + public fun getElementContext ()Lkscience/kmath/operations/RealField; + public final fun getF64Buffer (Lkscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun getOne ()Ljava/lang/Object; + public fun getOne-hHuhEO0 ()Lorg/jetbrains/bio/viktor/F64Array; + public fun getShape ()[I + public synthetic fun getZero ()Ljava/lang/Object; + public fun getZero-hHuhEO0 ()Lorg/jetbrains/bio/viktor/F64Array; + public fun invoke (Lkotlin/jvm/functions/Function1;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + 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;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun leftSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object; + public fun ln-02gLDOA (Lkscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun map (Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/NDStructure; + public fun map-frQ_39w (Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function2;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun mapIndexed (Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lkscience/kmath/nd/NDStructure; + public fun mapIndexed-frQ_39w (Lkscience/kmath/nd/NDStructure;Lkotlin/jvm/functions/Function3;)Lorg/jetbrains/bio/viktor/F64Array; + public fun minus (DLkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun minus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun minus (Ljava/lang/Number;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + 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;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun minus (Lkscience/kmath/nd/NDStructure;D)Lkscience/kmath/nd/NDStructure; + public fun minus (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public synthetic fun minus (Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public synthetic fun minus (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun minus-frQ_39w (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public synthetic fun multiply (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public fun multiply (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun multiply-frQ_39w (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; + public fun number-02gLDOA (Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array; + public fun plus (DLkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun plus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun plus (Ljava/lang/Number;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + 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;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun plus (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public synthetic fun plus (Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public synthetic fun plus (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun plus-frQ_39w (Lkscience/kmath/nd/NDStructure;D)Lorg/jetbrains/bio/viktor/F64Array; + public fun plus-frQ_39w (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun pow (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun pow (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; + public fun power-frQ_39w (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun produce (Lkotlin/jvm/functions/Function2;)Lkscience/kmath/nd/NDStructure; + public fun produce-02gLDOA (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;Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; + public fun sin-02gLDOA (Lkscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object; + public fun sinh (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun sqrt (Ljava/lang/Object;)Ljava/lang/Object; + public fun sqrt (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun symbol (Ljava/lang/String;)Ljava/lang/Object; + public fun symbol (Ljava/lang/String;)Lkscience/kmath/nd/NDStructure; + public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; + public fun tan (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; + public fun tanh (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun times (DLkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Ljava/lang/Number;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + 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;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun times (Lkscience/kmath/nd/NDStructure;D)Lkscience/kmath/nd/NDStructure; + public synthetic fun times (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lkscience/kmath/nd/NDStructure; + public synthetic fun times (Lkscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lkscience/kmath/nd/NDStructure; + public fun times (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun times-frQ_39w (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array; + public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryMinus (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryOperation (Ljava/lang/String;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; + public fun unaryPlus (Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; +} + +public final class kscience/kmath/viktor/ViktorNDStructure : kscience/kmath/nd/MutableNDStructure { + public static final synthetic fun box-impl (Lorg/jetbrains/bio/viktor/F64Array;)Lkscience/kmath/viktor/ViktorNDStructure; + 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; + public fun equals (Ljava/lang/Object;)Z + public static fun equals-impl (Lorg/jetbrains/bio/viktor/F64Array;Ljava/lang/Object;)Z + public static final fun equals-impl0 (Lorg/jetbrains/bio/viktor/F64Array;Lorg/jetbrains/bio/viktor/F64Array;)Z + public fun get ([I)Ljava/lang/Double; + public synthetic fun get ([I)Ljava/lang/Object; + public static fun get-impl (Lorg/jetbrains/bio/viktor/F64Array;[I)Ljava/lang/Double; + public fun getDimension ()I + public static fun getDimension-impl (Lorg/jetbrains/bio/viktor/F64Array;)I + public final fun getF64Buffer ()Lorg/jetbrains/bio/viktor/F64Array; + public fun getFeature (Lkotlin/reflect/KClass;)Ljava/lang/Object; + public static fun getFeature-impl (Lorg/jetbrains/bio/viktor/F64Array;Lkotlin/reflect/KClass;)Ljava/lang/Object; + public fun getShape ()[I + public static fun getShape-impl (Lorg/jetbrains/bio/viktor/F64Array;)[I + public fun hashCode ()I + public static fun hashCode-impl (Lorg/jetbrains/bio/viktor/F64Array;)I + public fun set ([ID)V + public synthetic fun set ([ILjava/lang/Object;)V + public static fun set-impl (Lorg/jetbrains/bio/viktor/F64Array;[ID)V + public fun toString ()Ljava/lang/String; + public static fun toString-impl (Lorg/jetbrains/bio/viktor/F64Array;)Ljava/lang/String; + public final synthetic fun unbox-impl ()Lorg/jetbrains/bio/viktor/F64Array; +} + +public final class kscience/kmath/viktor/ViktorNDStructureKt { + public static final fun ViktorNDField ([I)Lkscience/kmath/viktor/ViktorNDField; + 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 3e5c5912c..3c042174f 100644 --- a/kmath-viktor/build.gradle.kts +++ b/kmath-viktor/build.gradle.kts @@ -8,3 +8,7 @@ dependencies { api(project(":kmath-core")) api("org.jetbrains.bio:viktor:1.0.1") } + +readme{ + maturity = ru.mipt.npm.gradle.Maturity.DEVELOPMENT +} \ No newline at end of file From 730678b2fc5aaba5ad3b3fba32fc77ae4b72f160 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 31 Jan 2021 20:02:11 +0300 Subject: [PATCH 22/23] Add safety checks for kmath-for-real buffer operations. --- .../kotlin/kscience/kmath/real/RealVector.kt | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealVector.kt b/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealVector.kt index 596692782..ee2a960a1 100644 --- a/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealVector.kt +++ b/kmath-for-real/src/commonMain/kotlin/kscience/kmath/real/RealVector.kt @@ -29,8 +29,10 @@ public inline fun RealVector.map(transform: (Double) -> Double): RealVector = public inline fun RealVector.mapIndexed(transform: (index: Int, value: Double) -> Double): RealVector = Buffer.real(size) { transform(it, get(it)) } -public operator fun RealVector.plus(other: RealVector): RealVector = - mapIndexed { index, value -> value + other[index] } +public operator fun RealVector.plus(other: RealVector): RealVector { + require(size == other.size){"Vector size $size expected but ${other.size} found"} + return mapIndexed { index, value -> value + other[index] } +} public operator fun RealVector.plus(number: Number): RealVector = map { it + number.toDouble() } @@ -38,22 +40,28 @@ public operator fun Number.plus(vector: RealVector): RealVector = vector + this public operator fun RealVector.unaryMinus(): Buffer = map { -it } -public operator fun RealVector.minus(other: RealVector): RealVector = - mapIndexed { index, value -> value - other[index] } +public operator fun RealVector.minus(other: RealVector): RealVector { + require(size == other.size){"Vector size $size expected but ${other.size} found"} + return mapIndexed { index, value -> value - other[index] } +} public operator fun RealVector.minus(number: Number): RealVector = map { it - number.toDouble() } public operator fun Number.minus(vector: RealVector): RealVector = vector.map { toDouble() - it } -public operator fun RealVector.times(other: RealVector): RealVector = - mapIndexed { index, value -> value * other[index] } +public operator fun RealVector.times(other: RealVector): RealVector { + require(size == other.size){"Vector size $size expected but ${other.size} found"} + return mapIndexed { index, value -> value * other[index] } +} public operator fun RealVector.times(number: Number): RealVector = map { it * number.toDouble() } public operator fun Number.times(vector: RealVector): RealVector = vector * this -public operator fun RealVector.div(other: RealVector): RealVector = - mapIndexed { index, value -> value / other[index] } +public operator fun RealVector.div(other: RealVector): RealVector { + require(size == other.size){"Vector size $size expected but ${other.size} found"} + return mapIndexed { index, value -> value / other[index] } +} public operator fun RealVector.div(number: Number): RealVector = map { it / number.toDouble() } From 8f101c5cd0b60af6f9df527f5b9c545bc304de04 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Mon, 1 Feb 2021 12:34:30 +0300 Subject: [PATCH 23/23] Fix symbol delegate after build work-around for https://youtrack.jetbrains.com/issue/KT-4012 --- kmath-core/api/kmath-core.api | 6 ------ .../kscience/kmath/expressions/Expression.kt | 14 +++----------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/kmath-core/api/kmath-core.api b/kmath-core/api/kmath-core.api index ab0555932..92165f795 100644 --- a/kmath-core/api/kmath-core.api +++ b/kmath-core/api/kmath-core.api @@ -488,15 +488,9 @@ public final class kscience/kmath/expressions/StringSymbol : kscience/kmath/expr } public abstract interface class kscience/kmath/expressions/Symbol { - public static final field Companion Lkscience/kmath/expressions/Symbol$Companion; public abstract fun getIdentity ()Ljava/lang/String; } -public final class kscience/kmath/expressions/Symbol$Companion : kotlin/properties/ReadOnlyProperty { - public synthetic fun getValue (Ljava/lang/Object;Lkotlin/reflect/KProperty;)Ljava/lang/Object; - public fun getValue (Ljava/lang/Object;Lkotlin/reflect/KProperty;)Lkscience/kmath/expressions/Symbol; -} - public abstract interface class kscience/kmath/expressions/SymbolIndexer { public abstract fun get (Ljava/util/List;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; public abstract fun get (Lkscience/kmath/nd/Structure2D;Lkscience/kmath/expressions/Symbol;Lkscience/kmath/expressions/Symbol;)Ljava/lang/Object; diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/expressions/Expression.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/expressions/Expression.kt index 63bbc9312..c53d64871 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/expressions/Expression.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/expressions/Expression.kt @@ -3,7 +3,6 @@ package kscience.kmath.expressions import kscience.kmath.operations.Algebra import kotlin.jvm.JvmName import kotlin.properties.ReadOnlyProperty -import kotlin.reflect.KProperty /** * A marker interface for a symbol. A symbol mus have an identity @@ -13,13 +12,6 @@ public interface Symbol { * Identity object for the symbol. Two symbols with the same identity are considered to be the same symbol. */ public val identity: String - - public companion object : ReadOnlyProperty { - //TODO deprecate and replace by top level function after fix of https://youtrack.jetbrains.com/issue/KT-40121 - override fun getValue(thisRef: Any?, property: KProperty<*>): Symbol { - return StringSymbol(property.name) - } - } } /** @@ -103,9 +95,9 @@ public fun ExpressionAlgebra.bind(symbol: Symbol): E = /** * A delegate to create a symbol with a string identity in this scope */ -public val symbol: ReadOnlyProperty get() = Symbol -//TODO does not work directly on native due to https://youtrack.jetbrains.com/issue/KT-40121 - +public val symbol: ReadOnlyProperty = ReadOnlyProperty { thisRef, property -> + StringSymbol(property.name) +} /** * Bind a symbol by name inside the [ExpressionAlgebra]