From 522f39cef3f75efe11d5e323a3ada955da9d6f7a Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 10 Mar 2021 22:09:19 +0300 Subject: [PATCH] replace Space by Group --- CHANGELOG.md | 1 + .../space/kscience/kmath/ast/MstAlgebra.kt | 34 +-- .../space/kscience/kmath/ast/MstExpression.kt | 10 +- .../TestESTreeConsistencyWithInterpreter.kt | 4 +- .../kotlin/space/kscience/kmath/ast/parser.kt | 8 +- .../asm/TestAsmConsistencyWithInterpreter.kt | 4 +- kmath-core/api/kmath-core.api | 260 +++++++++--------- .../FunctionalExpressionAlgebra.kt | 20 +- .../kmath/expressions/expressionBuilders.kt | 8 +- .../kscience/kmath/linear/MatrixContext.kt | 2 +- .../kscience/kmath/linear/VectorSpace.kt | 14 +- .../space/kscience/kmath/misc/cumulative.kt | 8 +- .../kscience/kmath/nd/BufferNDAlgebra.kt | 14 +- .../space/kscience/kmath/nd/NDAlgebra.kt | 20 +- .../kscience/kmath/operations/Algebra.kt | 11 +- .../kmath/operations/AlgebraElements.kt | 6 +- .../kmath/operations/NumericAlgebra.kt | 2 +- .../kmath/operations/algebraExtensions.kt | 30 +- .../kscience/kmath/testutils/SpaceVerifier.kt | 4 +- .../space/kscience/kmath/chains/flowExtra.kt | 10 +- .../kscience/kmath/functions/Polynomial.kt | 4 +- .../kscience/kmath/geometry/GeometrySpace.kt | 4 +- .../space/kscience/kmath/histogram/Counter.kt | 4 +- .../kmath/histogram/IndexedHistogramSpace.kt | 4 +- .../kmath/histogram/TreeHistogramSpace.kt | 4 +- .../kmath/histogram/UnivariateHistogram.kt | 4 +- .../kmath/kotlingrad/ScalarsAdapters.kt | 8 +- .../kscience/kmath/nd4j/Nd4jArrayAlgebra.kt | 6 +- .../kscience/kmath/stat/SamplerAlgebra.kt | 6 +- .../space/kscience/kmath/stat/Statistic.kt | 2 +- 30 files changed, 258 insertions(+), 258 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 595cd3bbc..a172eb69a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Changed - Exponential operations merged with hyperbolic functions +- Space is replaced by Group. Space is reserved for vector spaces. ### Deprecated diff --git a/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/MstAlgebra.kt b/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/MstAlgebra.kt index 047ee187d..a65027147 100644 --- a/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/MstAlgebra.kt +++ b/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/MstAlgebra.kt @@ -18,22 +18,22 @@ public object MstAlgebra : NumericAlgebra { } /** - * [Space] over [MST] nodes. + * [Group] over [MST] nodes. */ -public object MstSpace : Space, NumericAlgebra, ScaleOperations { +public object MstGroup : Group, NumericAlgebra, ScaleOperations { public override val zero: MST.Numeric = number(0.0) public override fun number(value: Number): MST.Numeric = MstAlgebra.number(value) public override fun bindSymbol(value: String): MST.Symbolic = MstAlgebra.bindSymbol(value) - public override fun add(a: MST, b: MST): MST.Binary = binaryOperationFunction(SpaceOperations.PLUS_OPERATION)(a, b) + public override fun add(a: MST, b: MST): MST.Binary = binaryOperationFunction(GroupOperations.PLUS_OPERATION)(a, b) public override operator fun MST.unaryPlus(): MST.Unary = - unaryOperationFunction(SpaceOperations.PLUS_OPERATION)(this) + unaryOperationFunction(GroupOperations.PLUS_OPERATION)(this) public override operator fun MST.unaryMinus(): MST.Unary = - unaryOperationFunction(SpaceOperations.MINUS_OPERATION)(this) + unaryOperationFunction(GroupOperations.MINUS_OPERATION)(this) public override operator fun MST.minus(b: MST): MST.Binary = - binaryOperationFunction(SpaceOperations.MINUS_OPERATION)(this, b) + binaryOperationFunction(GroupOperations.MINUS_OPERATION)(this, b) public override fun scale(a: MST, value: Double): MST.Binary = binaryOperationFunction(RingOperations.TIMES_OPERATION)(a, number(value)) @@ -50,25 +50,25 @@ public object MstSpace : Space, NumericAlgebra, ScaleOperations { */ @OptIn(UnstableKMathAPI::class) public object MstRing : Ring, NumbersAddOperations, ScaleOperations { - public override val zero: MST.Numeric = MstSpace.zero + public override val zero: MST.Numeric = MstGroup.zero public override val one: MST.Numeric = number(1.0) - public override fun number(value: Number): MST.Numeric = MstSpace.number(value) - public override fun bindSymbol(value: String): MST.Symbolic = MstSpace.bindSymbol(value) - public override fun add(a: MST, b: MST): MST.Binary = MstSpace.add(a, b) + public override fun number(value: Number): MST.Numeric = MstGroup.number(value) + public override fun bindSymbol(value: String): MST.Symbolic = MstGroup.bindSymbol(value) + public override fun add(a: MST, b: MST): MST.Binary = MstGroup.add(a, b) public override fun scale(a: MST, value: Double): MST.Binary = - MstSpace.binaryOperationFunction(RingOperations.TIMES_OPERATION)(a, MstSpace.number(value)) + MstGroup.binaryOperationFunction(RingOperations.TIMES_OPERATION)(a, MstGroup.number(value)) public override fun multiply(a: MST, b: MST): MST.Binary = binaryOperationFunction(RingOperations.TIMES_OPERATION)(a, b) - public override operator fun MST.unaryPlus(): MST.Unary = MstSpace { +this@unaryPlus } - public override operator fun MST.unaryMinus(): MST.Unary = MstSpace { -this@unaryMinus } - public override operator fun MST.minus(b: MST): MST.Binary = MstSpace { this@minus - b } + public override operator fun MST.unaryPlus(): MST.Unary = MstGroup { +this@unaryPlus } + public override operator fun MST.unaryMinus(): MST.Unary = MstGroup { -this@unaryMinus } + public override operator fun MST.minus(b: MST): MST.Binary = MstGroup { this@minus - b } public override fun binaryOperationFunction(operation: String): (left: MST, right: MST) -> MST.Binary = - MstSpace.binaryOperationFunction(operation) + MstGroup.binaryOperationFunction(operation) public override fun unaryOperationFunction(operation: String): (arg: MST) -> MST.Unary = MstAlgebra.unaryOperationFunction(operation) @@ -88,7 +88,7 @@ public object MstField : Field, NumbersAddOperations, ScaleOperations< public override fun add(a: MST, b: MST): MST.Binary = MstRing.add(a, b) public override fun scale(a: MST, value: Double): MST.Binary = - MstSpace.binaryOperationFunction(RingOperations.TIMES_OPERATION)(a, MstSpace.number(value)) + MstGroup.binaryOperationFunction(RingOperations.TIMES_OPERATION)(a, MstGroup.number(value)) public override fun multiply(a: MST, b: MST): MST.Binary = MstRing.multiply(a, b) public override fun divide(a: MST, b: MST): MST.Binary = @@ -129,7 +129,7 @@ public object MstExtendedField : ExtendedField, NumericAlgebra { public override fun add(a: MST, b: MST): MST.Binary = MstField.add(a, b) public override fun scale(a: MST, value: Double): MST = - binaryOperation(SpaceOperations.PLUS_OPERATION, a, number(value)) + binaryOperation(GroupOperations.PLUS_OPERATION, a, number(value)) public override fun multiply(a: MST, b: MST): MST.Binary = MstField.multiply(a, b) public override fun divide(a: MST, b: MST): MST.Binary = MstField.divide(a, b) diff --git a/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/MstExpression.kt b/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/MstExpression.kt index 412dde32c..3a598fb8c 100644 --- a/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/MstExpression.kt +++ b/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/MstExpression.kt @@ -54,13 +54,13 @@ public inline fun , E : Algebra> A.mst( ): MstExpression = MstExpression(this, mstAlgebra.block()) /** - * Builds [MstExpression] over [Space]. + * Builds [MstExpression] over [Group]. * * @author Alexander Nozik */ -public inline fun > A.mstInSpace(block: MstSpace.() -> MST): MstExpression { +public inline fun > A.mstInSpace(block: MstGroup.() -> MST): MstExpression { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } - return MstExpression(this, MstSpace.block()) + return MstExpression(this, MstGroup.block()) } /** @@ -94,11 +94,11 @@ public inline fun > A.mstInExtendedField(b } /** - * Builds [MstExpression] over [FunctionalExpressionSpace]. + * Builds [MstExpression] over [FunctionalExpressionGroup]. * * @author Alexander Nozik */ -public inline fun > FunctionalExpressionSpace.mstInSpace(block: MstSpace.() -> MST): MstExpression { +public inline fun > FunctionalExpressionGroup.mstInSpace(block: MstGroup.() -> MST): MstExpression { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return algebra.mstInSpace(block) } diff --git a/kmath-ast/src/jsTest/kotlin/space/kscience/kmath/estree/TestESTreeConsistencyWithInterpreter.kt b/kmath-ast/src/jsTest/kotlin/space/kscience/kmath/estree/TestESTreeConsistencyWithInterpreter.kt index c91cc4daf..34e9dd945 100644 --- a/kmath-ast/src/jsTest/kotlin/space/kscience/kmath/estree/TestESTreeConsistencyWithInterpreter.kt +++ b/kmath-ast/src/jsTest/kotlin/space/kscience/kmath/estree/TestESTreeConsistencyWithInterpreter.kt @@ -12,7 +12,7 @@ import kotlin.test.assertEquals internal class TestESTreeConsistencyWithInterpreter { @Test fun mstSpace() { - val res1 = MstSpace.mstInSpace { + val res1 = MstGroup.mstInSpace { binaryOperationFunction("+")( unaryOperationFunction("+")( number(3.toByte()) - (number(2.toByte()) + (scale( @@ -25,7 +25,7 @@ internal class TestESTreeConsistencyWithInterpreter { ) + bindSymbol("x") + zero }("x" to MST.Numeric(2)) - val res2 = MstSpace.mstInSpace { + val res2 = MstGroup.mstInSpace { binaryOperationFunction("+")( unaryOperationFunction("+")( number(3.toByte()) - (number(2.toByte()) + (scale( diff --git a/kmath-ast/src/jvmMain/kotlin/space/kscience/kmath/ast/parser.kt b/kmath-ast/src/jvmMain/kotlin/space/kscience/kmath/ast/parser.kt index be4aff34f..9a38ce81a 100644 --- a/kmath-ast/src/jvmMain/kotlin/space/kscience/kmath/ast/parser.kt +++ b/kmath-ast/src/jvmMain/kotlin/space/kscience/kmath/ast/parser.kt @@ -14,9 +14,9 @@ import com.github.h0tk3y.betterParse.lexer.regexToken import com.github.h0tk3y.betterParse.parser.ParseResult import com.github.h0tk3y.betterParse.parser.Parser import space.kscience.kmath.operations.FieldOperations +import space.kscience.kmath.operations.GroupOperations import space.kscience.kmath.operations.PowerOperations import space.kscience.kmath.operations.RingOperations -import space.kscience.kmath.operations.SpaceOperations /** * better-parse implementation of grammar defined in the ArithmeticsEvaluator.g4. @@ -55,7 +55,7 @@ public object ArithmeticsEvaluator : Grammar() { .or(binaryFunction) .or(unaryFunction) .or(singular) - .or(-minus and parser(ArithmeticsEvaluator::term) map { MST.Unary(SpaceOperations.MINUS_OPERATION, it) }) + .or(-minus and parser(ArithmeticsEvaluator::term) map { MST.Unary(GroupOperations.MINUS_OPERATION, it) }) .or(-lpar and parser(ArithmeticsEvaluator::subSumChain) and -rpar) private val powChain: Parser by leftAssociative(term = term, operator = pow) { a, _, b -> @@ -77,9 +77,9 @@ public object ArithmeticsEvaluator : Grammar() { operator = plus or minus use TokenMatch::type ) { a, op, b -> if (op == plus) - MST.Binary(SpaceOperations.PLUS_OPERATION, a, b) + MST.Binary(GroupOperations.PLUS_OPERATION, a, b) else - MST.Binary(SpaceOperations.MINUS_OPERATION, a, b) + MST.Binary(GroupOperations.MINUS_OPERATION, a, b) } override val rootParser: Parser by subSumChain diff --git a/kmath-ast/src/jvmTest/kotlin/space/kscience/kmath/asm/TestAsmConsistencyWithInterpreter.kt b/kmath-ast/src/jvmTest/kotlin/space/kscience/kmath/asm/TestAsmConsistencyWithInterpreter.kt index 5c6297f3f..4be2ee331 100644 --- a/kmath-ast/src/jvmTest/kotlin/space/kscience/kmath/asm/TestAsmConsistencyWithInterpreter.kt +++ b/kmath-ast/src/jvmTest/kotlin/space/kscience/kmath/asm/TestAsmConsistencyWithInterpreter.kt @@ -12,7 +12,7 @@ import kotlin.test.assertEquals internal class TestAsmConsistencyWithInterpreter { @Test fun mstSpace() { - val res1 = MstSpace.mstInSpace { + val res1 = MstGroup.mstInSpace { binaryOperationFunction("+")( unaryOperationFunction("+")( number(3.toByte()) - (number(2.toByte()) + (scale( @@ -25,7 +25,7 @@ internal class TestAsmConsistencyWithInterpreter { ) + bindSymbol("x") + zero }("x" to MST.Numeric(2)) - val res2 = MstSpace.mstInSpace { + val res2 = MstGroup.mstInSpace { binaryOperationFunction("+")( unaryOperationFunction("+")( number(3.toByte()) - (number(2.toByte()) + (scale( diff --git a/kmath-core/api/kmath-core.api b/kmath-core/api/kmath-core.api index da4725428..eae91c985 100644 --- a/kmath-core/api/kmath-core.api +++ b/kmath-core/api/kmath-core.api @@ -52,7 +52,7 @@ public final class space/kscience/kmath/expressions/ExpressionBuildersKt { public static final fun extendedFieldExpression (Lspace/kscience/kmath/operations/ExtendedField;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression; public static final fun fieldExpression (Lspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression; public static final fun ringExpression (Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression; - public static final fun spaceExpression (Lspace/kscience/kmath/operations/Space;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression; + public static final fun spaceExpression (Lspace/kscience/kmath/operations/Group;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression; } public final class space/kscience/kmath/expressions/ExpressionKt { @@ -91,7 +91,7 @@ public final class space/kscience/kmath/expressions/FunctionalExpressionAlgebraK public static final fun expressionInExtendedField (Lspace/kscience/kmath/operations/ExtendedField;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression; public static final fun expressionInField (Lspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression; public static final fun expressionInRing (Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression; - public static final fun expressionInSpace (Lspace/kscience/kmath/operations/Space;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression; + public static final fun expressionInSpace (Lspace/kscience/kmath/operations/Group;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression; } public class space/kscience/kmath/expressions/FunctionalExpressionExtendedField : space/kscience/kmath/expressions/FunctionalExpressionField, space/kscience/kmath/operations/ExtendedField { @@ -165,22 +165,8 @@ public class space/kscience/kmath/expressions/FunctionalExpressionField : space/ public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; } -public class space/kscience/kmath/expressions/FunctionalExpressionRing : space/kscience/kmath/expressions/FunctionalExpressionSpace, space/kscience/kmath/operations/Ring { - public fun (Lspace/kscience/kmath/operations/Ring;)V - public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; - public synthetic fun getOne ()Ljava/lang/Object; - public fun getOne ()Lspace/kscience/kmath/expressions/Expression; - public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun multiply (Lspace/kscience/kmath/expressions/Expression;Lspace/kscience/kmath/expressions/Expression;)Lspace/kscience/kmath/expressions/Expression; - public synthetic fun times (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public final fun times (Ljava/lang/Object;Lspace/kscience/kmath/expressions/Expression;)Lspace/kscience/kmath/expressions/Expression; - public final fun times (Lspace/kscience/kmath/expressions/Expression;Ljava/lang/Object;)Lspace/kscience/kmath/expressions/Expression; - public fun times (Lspace/kscience/kmath/expressions/Expression;Lspace/kscience/kmath/expressions/Expression;)Lspace/kscience/kmath/expressions/Expression; - public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; -} - -public class space/kscience/kmath/expressions/FunctionalExpressionSpace : space/kscience/kmath/expressions/FunctionalExpressionAlgebra, space/kscience/kmath/operations/Space { - public fun (Lspace/kscience/kmath/operations/Space;)V +public class space/kscience/kmath/expressions/FunctionalExpressionGroup : space/kscience/kmath/expressions/FunctionalExpressionAlgebra, space/kscience/kmath/operations/Group { + public fun (Lspace/kscience/kmath/operations/Group;)V public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun add (Lspace/kscience/kmath/expressions/Expression;Lspace/kscience/kmath/expressions/Expression;)Lspace/kscience/kmath/expressions/Expression; public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; @@ -201,6 +187,20 @@ public class space/kscience/kmath/expressions/FunctionalExpressionSpace : space/ public fun unaryPlus (Lspace/kscience/kmath/expressions/Expression;)Lspace/kscience/kmath/expressions/Expression; } +public class space/kscience/kmath/expressions/FunctionalExpressionRing : space/kscience/kmath/expressions/FunctionalExpressionGroup, space/kscience/kmath/operations/Ring { + public fun (Lspace/kscience/kmath/operations/Ring;)V + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun getOne ()Ljava/lang/Object; + public fun getOne ()Lspace/kscience/kmath/expressions/Expression; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply (Lspace/kscience/kmath/expressions/Expression;Lspace/kscience/kmath/expressions/Expression;)Lspace/kscience/kmath/expressions/Expression; + public synthetic fun times (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public final fun times (Ljava/lang/Object;Lspace/kscience/kmath/expressions/Expression;)Lspace/kscience/kmath/expressions/Expression; + public final fun times (Lspace/kscience/kmath/expressions/Expression;Ljava/lang/Object;)Lspace/kscience/kmath/expressions/Expression; + public fun times (Lspace/kscience/kmath/expressions/Expression;Lspace/kscience/kmath/expressions/Expression;)Lspace/kscience/kmath/expressions/Expression; + public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1; +} + public final class space/kscience/kmath/expressions/SimpleAutoDiffExpression : space/kscience/kmath/expressions/FirstDerivativeExpression { public fun (Lspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function1;)V public fun derivativeOrNull (Lspace/kscience/kmath/expressions/Symbol;)Lspace/kscience/kmath/expressions/Expression; @@ -490,7 +490,7 @@ public final class space/kscience/kmath/linear/BufferMatrixContext : space/kscie public final class space/kscience/kmath/linear/BufferMatrixContext$Companion { } -public final class space/kscience/kmath/linear/BufferVectorSpace : space/kscience/kmath/linear/VectorSpace { +public final class space/kscience/kmath/linear/BufferVectorGroup : space/kscience/kmath/linear/VectorSpace { public fun (ILspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;)V public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun add (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; @@ -625,7 +625,7 @@ public final class space/kscience/kmath/linear/MatrixBuilderKt { public static final fun row (Lspace/kscience/kmath/nd/Structure2D$Companion;[Ljava/lang/Object;)Lspace/kscience/kmath/nd/Structure2D; } -public abstract interface class space/kscience/kmath/linear/MatrixContext : space/kscience/kmath/operations/SpaceOperations { +public abstract interface class space/kscience/kmath/linear/MatrixContext : space/kscience/kmath/operations/GroupOperations { public static final field Companion Lspace/kscience/kmath/linear/MatrixContext$Companion; public abstract fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; public abstract fun dot (Lspace/kscience/kmath/nd/Structure2D;Lspace/kscience/kmath/nd/Structure2D;)Lspace/kscience/kmath/nd/Structure2D; @@ -763,7 +763,7 @@ public final class space/kscience/kmath/linear/UnitFeature : space/kscience/kmat public static final field INSTANCE Lspace/kscience/kmath/linear/UnitFeature; } -public abstract interface class space/kscience/kmath/linear/VectorSpace : space/kscience/kmath/operations/Space { +public abstract interface class space/kscience/kmath/linear/VectorSpace : space/kscience/kmath/operations/Group { public static final field Companion Lspace/kscience/kmath/linear/VectorSpace$Companion; public abstract fun add (Lspace/kscience/kmath/structures/Buffer;Lspace/kscience/kmath/structures/Buffer;)Lspace/kscience/kmath/structures/Buffer; public abstract fun getAlgebra ()Lspace/kscience/kmath/operations/Ring; @@ -775,9 +775,9 @@ public abstract interface class space/kscience/kmath/linear/VectorSpace : space/ } public final class space/kscience/kmath/linear/VectorSpace$Companion { - public final fun buffered (ILspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/linear/BufferVectorSpace; - public static synthetic fun buffered$default (Lspace/kscience/kmath/linear/VectorSpace$Companion;ILspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lspace/kscience/kmath/linear/BufferVectorSpace; - public final fun real (I)Lspace/kscience/kmath/linear/BufferVectorSpace; + public final fun buffered (ILspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/linear/BufferVectorGroup; + public static synthetic fun buffered$default (Lspace/kscience/kmath/linear/VectorSpace$Companion;ILspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lspace/kscience/kmath/linear/BufferVectorGroup; + public final fun real (I)Lspace/kscience/kmath/linear/BufferVectorGroup; } public final class space/kscience/kmath/linear/VectorSpace$DefaultImpls { @@ -820,9 +820,9 @@ public final class space/kscience/kmath/misc/CumulativeKt { 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;Lspace/kscience/kmath/operations/Space;)Ljava/lang/Iterable; - public static final fun cumulativeSum (Ljava/util/List;Lspace/kscience/kmath/operations/Space;)Ljava/util/List; - public static final fun cumulativeSum (Lkotlin/sequences/Sequence;Lspace/kscience/kmath/operations/Space;)Lkotlin/sequences/Sequence; + public static final fun cumulativeSum (Ljava/lang/Iterable;Lspace/kscience/kmath/operations/Group;)Ljava/lang/Iterable; + public static final fun cumulativeSum (Ljava/util/List;Lspace/kscience/kmath/operations/Group;)Ljava/util/List; + public static final fun cumulativeSum (Lkotlin/sequences/Sequence;Lspace/kscience/kmath/operations/Group;)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; @@ -860,9 +860,9 @@ public final class space/kscience/kmath/nd/BufferNDAlgebraKt { public static final fun field (Lspace/kscience/kmath/nd/NDAlgebra$Companion;Lspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function2;[I)Lspace/kscience/kmath/nd/BufferedNDField; public static final fun ndField (Lspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function2;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ndRing (Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; - public static final fun ndSpace (Lspace/kscience/kmath/operations/Space;Lkotlin/jvm/functions/Function2;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; + public static final fun ndSpace (Lspace/kscience/kmath/operations/Group;Lkotlin/jvm/functions/Function2;[ILkotlin/jvm/functions/Function1;)Ljava/lang/Object; public static final fun ring (Lspace/kscience/kmath/nd/NDAlgebra$Companion;Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;[I)Lspace/kscience/kmath/nd/BufferedNDRing; - public static final fun space (Lspace/kscience/kmath/nd/NDAlgebra$Companion;Lspace/kscience/kmath/operations/Space;Lkotlin/jvm/functions/Function2;[I)Lspace/kscience/kmath/nd/BufferedNDSpace; + public static final fun space (Lspace/kscience/kmath/nd/NDAlgebra$Companion;Lspace/kscience/kmath/operations/Group;Lkotlin/jvm/functions/Function2;[I)Lspace/kscience/kmath/nd/BufferedNDGroup; } public class space/kscience/kmath/nd/BufferedNDField : space/kscience/kmath/nd/BufferedNDRing, space/kscience/kmath/nd/NDField { @@ -892,21 +892,8 @@ public class space/kscience/kmath/nd/BufferedNDField : space/kscience/kmath/nd/B public fun times (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lspace/kscience/kmath/nd/NDStructure; } -public class space/kscience/kmath/nd/BufferedNDRing : space/kscience/kmath/nd/BufferedNDSpace, space/kscience/kmath/nd/NDRing { - public fun ([ILspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;)V - public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; - public synthetic fun getOne ()Ljava/lang/Object; - public fun getOne ()Lspace/kscience/kmath/nd/NDBuffer; - public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun multiply (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public synthetic fun times (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public fun times (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public fun times (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public fun times (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; -} - -public class space/kscience/kmath/nd/BufferedNDSpace : space/kscience/kmath/nd/BufferNDAlgebra, space/kscience/kmath/nd/NDSpace { - public fun ([ILspace/kscience/kmath/operations/Space;Lkotlin/jvm/functions/Function2;)V +public class space/kscience/kmath/nd/BufferedNDGroup : space/kscience/kmath/nd/BufferNDAlgebra, space/kscience/kmath/nd/NDGroup { + public fun ([ILspace/kscience/kmath/operations/Group;Lkotlin/jvm/functions/Function2;)V public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public fun add (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; @@ -919,7 +906,7 @@ public class space/kscience/kmath/nd/BufferedNDSpace : space/kscience/kmath/nd/B public fun getBuffer (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/structures/Buffer; public final fun getBufferFactory ()Lkotlin/jvm/functions/Function2; public synthetic fun getElementContext ()Lspace/kscience/kmath/operations/Algebra; - public final fun getElementContext ()Lspace/kscience/kmath/operations/Space; + public final fun getElementContext ()Lspace/kscience/kmath/operations/Group; public final fun getShape ()[I public fun getStrides ()Lspace/kscience/kmath/nd/Strides; public synthetic fun getZero ()Ljava/lang/Object; @@ -948,6 +935,19 @@ public class space/kscience/kmath/nd/BufferedNDSpace : space/kscience/kmath/nd/B public fun unaryPlus (Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; } +public class space/kscience/kmath/nd/BufferedNDRing : space/kscience/kmath/nd/BufferedNDGroup, space/kscience/kmath/nd/NDRing { + public fun ([ILspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function2;)V + public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public synthetic fun getOne ()Ljava/lang/Object; + public fun getOne ()Lspace/kscience/kmath/nd/NDBuffer; + public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun multiply (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public synthetic fun times (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public fun times (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public fun times (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; + public fun times (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; +} + public final class space/kscience/kmath/nd/DefaultStrides : space/kscience/kmath/nd/Strides { public static final field Companion Lspace/kscience/kmath/nd/DefaultStrides$Companion; public synthetic fun ([ILkotlin/jvm/internal/DefaultConstructorMarker;)V @@ -1050,7 +1050,36 @@ public final class space/kscience/kmath/nd/NDField$DefaultImpls { public static fun unaryPlus (Lspace/kscience/kmath/nd/NDField;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; } -public abstract interface class space/kscience/kmath/nd/NDRing : space/kscience/kmath/nd/NDSpace, space/kscience/kmath/operations/Ring { +public abstract interface class space/kscience/kmath/nd/NDGroup : space/kscience/kmath/nd/NDAlgebra, space/kscience/kmath/operations/Group { + public static final field Companion Lspace/kscience/kmath/nd/NDGroup$Companion; + public abstract fun add (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public abstract fun minus (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public abstract fun minus (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; + public abstract fun plus (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public abstract fun plus (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; +} + +public final class space/kscience/kmath/nd/NDGroup$Companion { +} + +public final class space/kscience/kmath/nd/NDGroup$DefaultImpls { + public static fun add (Lspace/kscience/kmath/nd/NDGroup;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public static fun binaryOperation (Lspace/kscience/kmath/nd/NDGroup;Ljava/lang/String;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public static fun binaryOperationFunction (Lspace/kscience/kmath/nd/NDGroup;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun bindSymbol (Lspace/kscience/kmath/nd/NDGroup;Ljava/lang/String;)Lspace/kscience/kmath/nd/NDStructure; + public static fun invoke (Lspace/kscience/kmath/nd/NDGroup;Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public static fun minus (Lspace/kscience/kmath/nd/NDGroup;Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public static fun minus (Lspace/kscience/kmath/nd/NDGroup;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; + public static fun minus (Lspace/kscience/kmath/nd/NDGroup;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public static fun plus (Lspace/kscience/kmath/nd/NDGroup;Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public static fun plus (Lspace/kscience/kmath/nd/NDGroup;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; + public static fun plus (Lspace/kscience/kmath/nd/NDGroup;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public static fun unaryOperation (Lspace/kscience/kmath/nd/NDGroup;Ljava/lang/String;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; + public static fun unaryOperationFunction (Lspace/kscience/kmath/nd/NDGroup;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lspace/kscience/kmath/nd/NDGroup;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; +} + +public abstract interface class space/kscience/kmath/nd/NDRing : space/kscience/kmath/nd/NDGroup, space/kscience/kmath/operations/Ring { public static final field Companion Lspace/kscience/kmath/nd/NDRing$Companion; public abstract fun multiply (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; public abstract fun times (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; @@ -1081,35 +1110,6 @@ public final class space/kscience/kmath/nd/NDRing$DefaultImpls { public static fun unaryPlus (Lspace/kscience/kmath/nd/NDRing;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; } -public abstract interface class space/kscience/kmath/nd/NDSpace : space/kscience/kmath/nd/NDAlgebra, space/kscience/kmath/operations/Space { - public static final field Companion Lspace/kscience/kmath/nd/NDSpace$Companion; - public abstract fun add (Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public abstract fun minus (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public abstract fun minus (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public abstract fun plus (Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public abstract fun plus (Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; -} - -public final class space/kscience/kmath/nd/NDSpace$Companion { -} - -public final class space/kscience/kmath/nd/NDSpace$DefaultImpls { - public static fun add (Lspace/kscience/kmath/nd/NDSpace;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun binaryOperation (Lspace/kscience/kmath/nd/NDSpace;Ljava/lang/String;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun binaryOperationFunction (Lspace/kscience/kmath/nd/NDSpace;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; - public static fun bindSymbol (Lspace/kscience/kmath/nd/NDSpace;Ljava/lang/String;)Lspace/kscience/kmath/nd/NDStructure; - public static fun invoke (Lspace/kscience/kmath/nd/NDSpace;Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun minus (Lspace/kscience/kmath/nd/NDSpace;Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun minus (Lspace/kscience/kmath/nd/NDSpace;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public static fun minus (Lspace/kscience/kmath/nd/NDSpace;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun plus (Lspace/kscience/kmath/nd/NDSpace;Ljava/lang/Object;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun plus (Lspace/kscience/kmath/nd/NDSpace;Lspace/kscience/kmath/nd/NDStructure;Ljava/lang/Object;)Lspace/kscience/kmath/nd/NDStructure; - public static fun plus (Lspace/kscience/kmath/nd/NDSpace;Lspace/kscience/kmath/nd/NDStructure;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun unaryOperation (Lspace/kscience/kmath/nd/NDSpace;Ljava/lang/String;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; - public static fun unaryOperationFunction (Lspace/kscience/kmath/nd/NDSpace;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; - public static fun unaryPlus (Lspace/kscience/kmath/nd/NDSpace;Lspace/kscience/kmath/nd/NDStructure;)Lspace/kscience/kmath/nd/NDStructure; -} - public abstract interface class space/kscience/kmath/nd/NDStructure { public static final field Companion Lspace/kscience/kmath/nd/NDStructure$Companion; public abstract fun elements ()Lkotlin/sequences/Sequence; @@ -1333,17 +1333,17 @@ public final class space/kscience/kmath/operations/AlgebraElementsKt { } public final class space/kscience/kmath/operations/AlgebraExtensionsKt { - public static final fun abs (Lspace/kscience/kmath/operations/Space;Ljava/lang/Comparable;)Ljava/lang/Comparable; - public static final fun average (Lspace/kscience/kmath/operations/Space;Ljava/lang/Iterable;)Ljava/lang/Object; - public static final fun average (Lspace/kscience/kmath/operations/Space;Lkotlin/sequences/Sequence;)Ljava/lang/Object; - public static final fun averageWith (Ljava/lang/Iterable;Lspace/kscience/kmath/operations/Space;)Ljava/lang/Object; - public static final fun averageWith (Lkotlin/sequences/Sequence;Lspace/kscience/kmath/operations/Space;)Ljava/lang/Object; + public static final fun abs (Lspace/kscience/kmath/operations/Group;Ljava/lang/Comparable;)Ljava/lang/Comparable; + public static final fun average (Lspace/kscience/kmath/operations/Group;Ljava/lang/Iterable;)Ljava/lang/Object; + public static final fun average (Lspace/kscience/kmath/operations/Group;Lkotlin/sequences/Sequence;)Ljava/lang/Object; + public static final fun averageWith (Ljava/lang/Iterable;Lspace/kscience/kmath/operations/Group;)Ljava/lang/Object; + public static final fun averageWith (Lkotlin/sequences/Sequence;Lspace/kscience/kmath/operations/Group;)Ljava/lang/Object; public static final fun power (Lspace/kscience/kmath/operations/Field;Ljava/lang/Object;I)Ljava/lang/Object; public static final fun power (Lspace/kscience/kmath/operations/Ring;Ljava/lang/Object;I)Ljava/lang/Object; - public static final fun sum (Lspace/kscience/kmath/operations/Space;Ljava/lang/Iterable;)Ljava/lang/Object; - public static final fun sum (Lspace/kscience/kmath/operations/Space;Lkotlin/sequences/Sequence;)Ljava/lang/Object; - public static final fun sumWith (Ljava/lang/Iterable;Lspace/kscience/kmath/operations/Space;)Ljava/lang/Object; - public static final fun sumWith (Lkotlin/sequences/Sequence;Lspace/kscience/kmath/operations/Space;)Ljava/lang/Object; + public static final fun sum (Lspace/kscience/kmath/operations/Group;Ljava/lang/Iterable;)Ljava/lang/Object; + public static final fun sum (Lspace/kscience/kmath/operations/Group;Lkotlin/sequences/Sequence;)Ljava/lang/Object; + public static final fun sumWith (Ljava/lang/Iterable;Lspace/kscience/kmath/operations/Group;)Ljava/lang/Object; + public static final fun sumWith (Lkotlin/sequences/Sequence;Lspace/kscience/kmath/operations/Group;)Ljava/lang/Object; } public final class space/kscience/kmath/operations/AlgebraKt { @@ -1735,6 +1735,50 @@ public final class space/kscience/kmath/operations/FloatField : space/kscience/k public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; } +public abstract interface class space/kscience/kmath/operations/Group : space/kscience/kmath/operations/GroupOperations { + public abstract fun getZero ()Ljava/lang/Object; +} + +public final class space/kscience/kmath/operations/Group$DefaultImpls { + public static fun binaryOperation (Lspace/kscience/kmath/operations/Group;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperationFunction (Lspace/kscience/kmath/operations/Group;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun bindSymbol (Lspace/kscience/kmath/operations/Group;Ljava/lang/String;)Ljava/lang/Object; + public static fun minus (Lspace/kscience/kmath/operations/Group;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun plus (Lspace/kscience/kmath/operations/Group;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperation (Lspace/kscience/kmath/operations/Group;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperationFunction (Lspace/kscience/kmath/operations/Group;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lspace/kscience/kmath/operations/Group;Ljava/lang/Object;)Ljava/lang/Object; +} + +public abstract interface class space/kscience/kmath/operations/GroupOperations : space/kscience/kmath/operations/Algebra { + public static final field Companion Lspace/kscience/kmath/operations/GroupOperations$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 minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public abstract fun plus (Ljava/lang/Object;Ljava/lang/Object;)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 space/kscience/kmath/operations/GroupOperations$Companion { + public static final field MINUS_OPERATION Ljava/lang/String; + public static final field PLUS_OPERATION Ljava/lang/String; +} + +public final class space/kscience/kmath/operations/GroupOperations$DefaultImpls { + public static fun binaryOperation (Lspace/kscience/kmath/operations/GroupOperations;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun binaryOperationFunction (Lspace/kscience/kmath/operations/GroupOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; + public static fun bindSymbol (Lspace/kscience/kmath/operations/GroupOperations;Ljava/lang/String;)Ljava/lang/Object; + public static fun minus (Lspace/kscience/kmath/operations/GroupOperations;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun plus (Lspace/kscience/kmath/operations/GroupOperations;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperation (Lspace/kscience/kmath/operations/GroupOperations;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; + public static fun unaryOperationFunction (Lspace/kscience/kmath/operations/GroupOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; + public static fun unaryPlus (Lspace/kscience/kmath/operations/GroupOperations;Ljava/lang/Object;)Ljava/lang/Object; +} + public final class space/kscience/kmath/operations/IntRing : space/kscience/kmath/operations/Norm, space/kscience/kmath/operations/NumericAlgebra, space/kscience/kmath/operations/Ring { public static final field INSTANCE Lspace/kscience/kmath/operations/IntRing; public fun add (II)Ljava/lang/Integer; @@ -2078,7 +2122,7 @@ public final class space/kscience/kmath/operations/RealField : space/kscience/km public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; } -public abstract interface class space/kscience/kmath/operations/Ring : space/kscience/kmath/operations/RingOperations, space/kscience/kmath/operations/Space { +public abstract interface class space/kscience/kmath/operations/Ring : space/kscience/kmath/operations/Group, space/kscience/kmath/operations/RingOperations { public abstract fun getOne ()Ljava/lang/Object; } @@ -2094,7 +2138,7 @@ public final class space/kscience/kmath/operations/Ring$DefaultImpls { public static fun unaryPlus (Lspace/kscience/kmath/operations/Ring;Ljava/lang/Object;)Ljava/lang/Object; } -public abstract interface class space/kscience/kmath/operations/RingOperations : space/kscience/kmath/operations/SpaceOperations { +public abstract interface class space/kscience/kmath/operations/RingOperations : space/kscience/kmath/operations/GroupOperations { public static final field Companion Lspace/kscience/kmath/operations/RingOperations$Companion; public static final field TIMES_OPERATION Ljava/lang/String; public abstract fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2; @@ -2176,50 +2220,6 @@ public final class space/kscience/kmath/operations/ShortRing : space/kscience/km public fun unaryPlus (S)Ljava/lang/Short; } -public abstract interface class space/kscience/kmath/operations/Space : space/kscience/kmath/operations/SpaceOperations { - public abstract fun getZero ()Ljava/lang/Object; -} - -public final class space/kscience/kmath/operations/Space$DefaultImpls { - public static fun binaryOperation (Lspace/kscience/kmath/operations/Space;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public static fun binaryOperationFunction (Lspace/kscience/kmath/operations/Space;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; - public static fun bindSymbol (Lspace/kscience/kmath/operations/Space;Ljava/lang/String;)Ljava/lang/Object; - public static fun minus (Lspace/kscience/kmath/operations/Space;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public static fun plus (Lspace/kscience/kmath/operations/Space;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public static fun unaryOperation (Lspace/kscience/kmath/operations/Space;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; - public static fun unaryOperationFunction (Lspace/kscience/kmath/operations/Space;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; - public static fun unaryPlus (Lspace/kscience/kmath/operations/Space;Ljava/lang/Object;)Ljava/lang/Object; -} - -public abstract interface class space/kscience/kmath/operations/SpaceOperations : space/kscience/kmath/operations/Algebra { - public static final field Companion Lspace/kscience/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 minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public abstract fun plus (Ljava/lang/Object;Ljava/lang/Object;)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 space/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 space/kscience/kmath/operations/SpaceOperations$DefaultImpls { - public static fun binaryOperation (Lspace/kscience/kmath/operations/SpaceOperations;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public static fun binaryOperationFunction (Lspace/kscience/kmath/operations/SpaceOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function2; - public static fun bindSymbol (Lspace/kscience/kmath/operations/SpaceOperations;Ljava/lang/String;)Ljava/lang/Object; - public static fun minus (Lspace/kscience/kmath/operations/SpaceOperations;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public static fun plus (Lspace/kscience/kmath/operations/SpaceOperations;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; - public static fun unaryOperation (Lspace/kscience/kmath/operations/SpaceOperations;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object; - public static fun unaryOperationFunction (Lspace/kscience/kmath/operations/SpaceOperations;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; - public static fun unaryPlus (Lspace/kscience/kmath/operations/SpaceOperations;Ljava/lang/Object;)Ljava/lang/Object; -} - public abstract interface class space/kscience/kmath/operations/TrigonometricOperations : space/kscience/kmath/operations/Algebra { public static final field ACOS_OPERATION Ljava/lang/String; public static final field ASIN_OPERATION Ljava/lang/String; diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/FunctionalExpressionAlgebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/FunctionalExpressionAlgebra.kt index 3c23d0ecf..880f13a3e 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/FunctionalExpressionAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/FunctionalExpressionAlgebra.kt @@ -41,21 +41,21 @@ public abstract class FunctionalExpressionAlgebra>( } /** - * A context class for [Expression] construction for [Space] algebras. + * A context class for [Expression] construction for [Group] algebras. */ -public open class FunctionalExpressionSpace>( +public open class FunctionalExpressionGroup>( algebra: A, -) : FunctionalExpressionAlgebra(algebra), Space> { +) : FunctionalExpressionAlgebra(algebra), Group> { public override val zero: Expression get() = const(algebra.zero) override fun Expression.unaryMinus(): Expression = - unaryOperation(SpaceOperations.MINUS_OPERATION, this) + unaryOperation(GroupOperations.MINUS_OPERATION, this) /** * Builds an Expression of addition of two another expressions. */ public override fun add(a: Expression, b: Expression): Expression = - binaryOperation(SpaceOperations.PLUS_OPERATION, a, b) + binaryOperation(GroupOperations.PLUS_OPERATION, a, b) // /** // * Builds an Expression of multiplication of expression by number. @@ -79,7 +79,7 @@ public open class FunctionalExpressionSpace>( public open class FunctionalExpressionRing>( algebra: A, -) : FunctionalExpressionSpace(algebra), Ring> { +) : FunctionalExpressionGroup(algebra), Ring> { public override val one: Expression get() = const(algebra.one) /** @@ -92,10 +92,10 @@ public open class FunctionalExpressionRing>( public operator fun T.times(arg: Expression): Expression = arg * this public override fun unaryOperationFunction(operation: String): (arg: Expression) -> Expression = - super.unaryOperationFunction(operation) + super.unaryOperationFunction(operation) public override fun binaryOperationFunction(operation: String): (left: Expression, right: Expression) -> Expression = - super.binaryOperationFunction(operation) + super.binaryOperationFunction(operation) } public open class FunctionalExpressionField>( @@ -159,8 +159,8 @@ public open class FunctionalExpressionExtendedField>( super.binaryOperationFunction(operation) } -public inline fun > A.expressionInSpace(block: FunctionalExpressionSpace.() -> Expression): Expression = - FunctionalExpressionSpace(this).block() +public inline fun > A.expressionInSpace(block: FunctionalExpressionGroup.() -> Expression): Expression = + FunctionalExpressionGroup(this).block() public inline fun > A.expressionInRing(block: FunctionalExpressionRing.() -> Expression): Expression = FunctionalExpressionRing(this).block() diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/expressionBuilders.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/expressionBuilders.kt index 0ef6803d6..fbf080032 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/expressionBuilders.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/expressionBuilders.kt @@ -2,18 +2,18 @@ package space.kscience.kmath.expressions import space.kscience.kmath.operations.ExtendedField import space.kscience.kmath.operations.Field +import space.kscience.kmath.operations.Group import space.kscience.kmath.operations.Ring -import space.kscience.kmath.operations.Space import kotlin.contracts.InvocationKind import kotlin.contracts.contract /** - * Creates a functional expression with this [Space]. + * Creates a functional expression with this [Group]. */ -public inline fun Space.spaceExpression(block: FunctionalExpressionSpace>.() -> Expression): Expression { +public inline fun Group.spaceExpression(block: FunctionalExpressionGroup>.() -> Expression): Expression { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } - return FunctionalExpressionSpace(this).block() + return FunctionalExpressionGroup(this).block() } /** diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/MatrixContext.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/MatrixContext.kt index 639d77e85..b8937885a 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/MatrixContext.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/MatrixContext.kt @@ -13,7 +13,7 @@ import kotlin.reflect.KClass * @param T the type of items in the matrices. * @param M the type of operated matrices. */ -public interface MatrixContext> : SpaceOperations> { +public interface MatrixContext> : GroupOperations> { /** * Produces a matrix with this context and given dimensions. */ diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/VectorSpace.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/VectorSpace.kt index fd3144d24..570c87b81 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/VectorSpace.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/VectorSpace.kt @@ -1,8 +1,8 @@ package space.kscience.kmath.linear +import space.kscience.kmath.operations.Group import space.kscience.kmath.operations.RealField import space.kscience.kmath.operations.Ring -import space.kscience.kmath.operations.Space import space.kscience.kmath.operations.invoke import space.kscience.kmath.structures.Buffer import space.kscience.kmath.structures.BufferFactory @@ -11,7 +11,7 @@ import space.kscience.kmath.structures.BufferFactory * A linear space for vectors. * Could be used on any point-like structure */ -public interface VectorSpace> : Space> { +public interface VectorSpace> : Group> { public val size: Int public val algebra: A override val zero: Point get() = produce { algebra.zero } @@ -27,13 +27,13 @@ public interface VectorSpace> : Space> { //TODO add basis public companion object { - private val realSpaceCache: MutableMap> = hashMapOf() + private val realSpaceCache: MutableMap> = hashMapOf() /** * Non-boxing double vector space */ - public fun real(size: Int): BufferVectorSpace = realSpaceCache.getOrPut(size) { - BufferVectorSpace( + public fun real(size: Int): BufferVectorGroup = realSpaceCache.getOrPut(size) { + BufferVectorGroup( size, RealField, Buffer.Companion::auto @@ -47,7 +47,7 @@ public interface VectorSpace> : Space> { size: Int, space: A, bufferFactory: BufferFactory = Buffer.Companion::boxing, - ): BufferVectorSpace = BufferVectorSpace(size, space, bufferFactory) + ): BufferVectorGroup = BufferVectorGroup(size, space, bufferFactory) /** * Automatic buffered vector, unboxed if it is possible @@ -58,7 +58,7 @@ public interface VectorSpace> : Space> { } -public class BufferVectorSpace>( +public class BufferVectorGroup>( override val size: Int, override val algebra: A, public val bufferFactory: BufferFactory, diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/cumulative.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/cumulative.kt index 380723095..b50e095cf 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/cumulative.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/cumulative.kt @@ -1,6 +1,6 @@ package space.kscience.kmath.misc -import space.kscience.kmath.operations.Space +import space.kscience.kmath.operations.Group import space.kscience.kmath.operations.invoke import kotlin.jvm.JvmName @@ -37,7 +37,7 @@ public fun List.cumulative(initial: R, operation: (R, T) -> R): List Iterable.cumulativeSum(space: Space): Iterable = +public fun Iterable.cumulativeSum(space: Group): Iterable = space { cumulative(zero) { element: T, sum: T -> sum + element } } @JvmName("cumulativeSumOfDouble") @@ -49,7 +49,7 @@ public fun Iterable.cumulativeSum(): Iterable = cumulative(0) { elemen @JvmName("cumulativeSumOfLong") public fun Iterable.cumulativeSum(): Iterable = cumulative(0L) { element, sum -> sum + element } -public fun Sequence.cumulativeSum(space: Space): Sequence = +public fun Sequence.cumulativeSum(space: Group): Sequence = space { cumulative(zero) { element: T, sum: T -> sum + element } } @JvmName("cumulativeSumOfDouble") @@ -61,7 +61,7 @@ public fun Sequence.cumulativeSum(): Sequence = cumulative(0) { elemen @JvmName("cumulativeSumOfLong") public fun Sequence.cumulativeSum(): Sequence = cumulative(0L) { element, sum -> sum + element } -public fun List.cumulativeSum(space: Space): List = +public fun List.cumulativeSum(space: Group): List = space { cumulative(zero) { element: T, sum: T -> sum + element } } @JvmName("cumulativeSumOfDouble") diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/BufferNDAlgebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/BufferNDAlgebra.kt index ff9c911ac..58d1ea7b1 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/BufferNDAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/BufferNDAlgebra.kt @@ -52,11 +52,11 @@ public interface BufferNDAlgebra> : NDAlgebra { } } -public open class BufferedNDSpace>( +public open class BufferedNDGroup>( final override val shape: IntArray, final override val elementContext: A, final override val bufferFactory: BufferFactory, -) : NDSpace, BufferNDAlgebra { +) : NDGroup, BufferNDAlgebra { override val strides: Strides = DefaultStrides(shape) override val zero: NDBuffer by lazy { produce { zero } } override fun NDStructure.unaryMinus(): NDStructure = produce { -get(it) } @@ -66,7 +66,7 @@ public open class BufferedNDRing>( shape: IntArray, elementContext: R, bufferFactory: BufferFactory, -) : BufferedNDSpace(shape, elementContext, bufferFactory), NDRing { +) : BufferedNDGroup(shape, elementContext, bufferFactory), NDRing { override val one: NDBuffer by lazy { produce { one } } } @@ -80,16 +80,16 @@ public open class BufferedNDField>( } // space factories -public fun > NDAlgebra.Companion.space( +public fun > NDAlgebra.Companion.space( space: A, bufferFactory: BufferFactory, vararg shape: Int, -): BufferedNDSpace = BufferedNDSpace(shape, space, bufferFactory) +): BufferedNDGroup = BufferedNDGroup(shape, space, bufferFactory) -public inline fun , R> A.ndSpace( +public inline fun , R> A.ndSpace( noinline bufferFactory: BufferFactory, vararg shape: Int, - action: BufferedNDSpace.() -> R, + action: BufferedNDGroup.() -> R, ): R { contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) } return NDAlgebra.space(this, bufferFactory, *shape).run(action) diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/NDAlgebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/NDAlgebra.kt index 6b6e887dc..e3ffae74b 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/NDAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/NDAlgebra.kt @@ -54,7 +54,7 @@ public interface NDAlgebra> { * Element-wise invocation of function working on [T] on a [NDStructure]. */ public operator fun Function1.invoke(structure: NDStructure): NDStructure = - structure.map() { value -> this@invoke(value) } + structure.map { value -> this@invoke(value) } public companion object } @@ -89,7 +89,7 @@ internal fun > NDAlgebra.checkShape(element: NDStructure< * @param N the type of ND structure. * @param S the type of space of structure elements. */ -public interface NDSpace> : Space>, NDAlgebra { +public interface NDGroup> : Group>, NDAlgebra { /** * Element-wise addition. * @@ -127,7 +127,7 @@ public interface NDSpace> : Space>, NDAlgebra.minus(arg: T): NDStructure = this.map() { 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. @@ -136,7 +136,7 @@ public interface NDSpace> : Space>, NDAlgebra): NDStructure = arg.map() { 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. @@ -145,7 +145,7 @@ public interface NDSpace> : Space>, NDAlgebra): NDStructure = arg.map() { value -> add(-this@minus, value) } + public operator fun T.minus(arg: NDStructure): NDStructure = arg.map { value -> add(-this@minus, value) } public companion object } @@ -157,7 +157,7 @@ public interface NDSpace> : Space>, NDAlgebra> : Ring>, NDSpace { +public interface NDRing> : Ring>, NDGroup { /** * Element-wise multiplication. * @@ -177,7 +177,7 @@ public interface NDRing> : Ring>, NDSpace { * @param arg the multiplier. * @return the product. */ - public operator fun NDStructure.times(arg: T): NDStructure = this.map() { 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. @@ -186,7 +186,7 @@ public interface NDRing> : Ring>, NDSpace { * @param arg the multiplier. * @return the product. */ - public operator fun T.times(arg: NDStructure): NDStructure = arg.map() { value -> multiply(this@times, value) } + public operator fun T.times(arg: NDStructure): NDStructure = arg.map { value -> multiply(this@times, value) } public companion object } @@ -217,7 +217,7 @@ public interface NDField> : Field>, NDRing, * @param arg the divisor. * @return the quotient. */ - public operator fun NDStructure.div(arg: T): NDStructure = this.map() { value -> divide(arg, value) } + public operator fun NDStructure.div(arg: T): NDStructure = this.map { value -> divide(arg, value) } /** * Divides an element by an ND structure of it. @@ -226,7 +226,7 @@ public interface NDField> : Field>, NDRing, * @param arg the divisor. * @return the quotient. */ - public operator fun T.div(arg: NDStructure): NDStructure = arg.map() { divide(it, this@div) } + public operator fun T.div(arg: NDStructure): NDStructure = arg.map { divide(it, this@div) } // @ThreadLocal // public companion object { diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt index 2163f61b2..0198700f2 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt @@ -105,7 +105,7 @@ public inline operator fun , R> A.invoke(block: A.() -> R): R = r * * @param T the type of element of this semispace. */ -public interface SpaceOperations : Algebra { +public interface GroupOperations : Algebra { /** * Addition of two elements. * @@ -177,12 +177,11 @@ public interface SpaceOperations : Algebra { } /** - * Represents linear space with neutral element, i.e. algebraic structure with associative, binary operation [add] and - * scalar multiplication [multiply]. + * Represents linear space with neutral element, i.e. algebraic structure with associative, binary operation [add]. * * @param T the type of element of this semispace. */ -public interface Space : SpaceOperations { +public interface Group : GroupOperations { /** * The neutral element of addition. */ @@ -195,7 +194,7 @@ public interface Space : SpaceOperations { * * @param T the type of element of this semiring. */ -public interface RingOperations : SpaceOperations { +public interface RingOperations : GroupOperations { /** * Multiplies two elements. * @@ -231,7 +230,7 @@ public interface RingOperations : SpaceOperations { * * @param T the type of element of this ring. */ -public interface Ring : Space, RingOperations { +public interface Ring : Group, RingOperations { /** * neutral operation for multiplication */ diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/AlgebraElements.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/AlgebraElements.kt index 1fb4f6750..3e42ac094 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/AlgebraElements.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/AlgebraElements.kt @@ -49,7 +49,7 @@ public operator fun , S : NumbersAddOperations> T.mi * @param b the augend. * @return the sum. */ -public operator fun , S : Space> T.plus(b: T): T = +public operator fun , S : Group> T.plus(b: T): T = context.add(this, b) ///** @@ -80,14 +80,14 @@ public operator fun , F : Field> T.div(b: T): T = /** - * The element of [Space]. + * The element of [Group]. * * @param T the type of space operation results. * @param I self type of the element. Needed for static type checking. * @param S the type of space. */ @UnstableKMathAPI -public interface SpaceElement, S : Space> : AlgebraElement +public interface SpaceElement, S : Group> : AlgebraElement /** * The element of [Ring]. diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/NumericAlgebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/NumericAlgebra.kt index 5f6ec869a..bd5f5951f 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/NumericAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/NumericAlgebra.kt @@ -127,7 +127,7 @@ public interface ScaleOperations : Algebra { * TODO to be removed and replaced by extensions after multiple receivers are there */ @UnstableKMathAPI -public interface NumbersAddOperations : Space, NumericAlgebra { +public interface NumbersAddOperations : Group, NumericAlgebra { /** * Addition of element and scalar. * diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/algebraExtensions.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/algebraExtensions.kt index 66b16b6f6..52a0dec6f 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/algebraExtensions.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/algebraExtensions.kt @@ -1,49 +1,49 @@ package space.kscience.kmath.operations /** - * Returns the sum of all elements in the iterable in this [Space]. + * Returns the sum of all elements in the iterable in this [Group]. * * @receiver the algebra that provides addition. * @param data the iterable to sum up. * @return the sum. */ -public fun Space.sum(data: Iterable): T = data.fold(zero) { left, right -> add(left, right) } +public fun Group.sum(data: Iterable): T = data.fold(zero) { left, right -> add(left, right) } /** - * Returns the sum of all elements in the sequence in this [Space]. + * Returns the sum of all elements in the sequence in this [Group]. * * @receiver the algebra that provides addition. * @param data the sequence to sum up. * @return the sum. */ -public fun Space.sum(data: Sequence): T = data.fold(zero) { left, right -> add(left, right) } +public fun Group.sum(data: Sequence): T = data.fold(zero) { left, right -> add(left, right) } /** - * Returns an average value of elements in the iterable in this [Space]. + * Returns an average value of elements in the iterable in this [Group]. * * @receiver the algebra that provides addition and division. * @param data the iterable to find average. * @return the average value. * @author Iaroslav Postovalov */ -public fun S.average(data: Iterable): T where S : Space, S : ScaleOperations = +public fun S.average(data: Iterable): T where S : Group, S : ScaleOperations = sum(data) / data.count() /** - * Returns an average value of elements in the sequence in this [Space]. + * Returns an average value of elements in the sequence in this [Group]. * * @receiver the algebra that provides addition and division. * @param data the sequence to find average. * @return the average value. * @author Iaroslav Postovalov */ -public fun S.average(data: Sequence): T where S : Space, S : ScaleOperations = +public fun S.average(data: Sequence): T where S : Group, S : ScaleOperations = sum(data) / data.count() /** * Absolute of the comparable [value] */ -public fun > Space.abs(value: T): T = if (value > zero) value else -value +public fun > Group.abs(value: T): T = if (value > zero) value else -value /** * Returns the sum of all elements in the iterable in provided space. @@ -52,7 +52,7 @@ public fun > Space.abs(value: T): T = if (value > zero) val * @param space the algebra that provides addition. * @return the sum. */ -public fun Iterable.sumWith(space: Space): T = space.sum(this) +public fun Iterable.sumWith(space: Group): T = space.sum(this) /** * Returns the sum of all elements in the sequence in provided space. @@ -61,28 +61,28 @@ public fun Iterable.sumWith(space: Space): T = space.sum(this) * @param space the algebra that provides addition. * @return the sum. */ -public fun Sequence.sumWith(space: Space): T = space.sum(this) +public fun Sequence.sumWith(space: Group): T = space.sum(this) /** - * Returns an average value of elements in the iterable in this [Space]. + * Returns an average value of elements in the iterable in this [Group]. * * @receiver the iterable to find average. * @param space the algebra that provides addition and division. * @return the average value. * @author Iaroslav Postovalov */ -public fun Iterable.averageWith(space: S): T where S : Space, S : ScaleOperations = +public fun Iterable.averageWith(space: S): T where S : Group, S : ScaleOperations = space.average(this) /** - * Returns an average value of elements in the sequence in this [Space]. + * Returns an average value of elements in the sequence in this [Group]. * * @receiver the sequence to find average. * @param space the algebra that provides addition and division. * @return the average value. * @author Iaroslav Postovalov */ -public fun Sequence.averageWith(space: S): T where S : Space, S : ScaleOperations = +public fun Sequence.averageWith(space: S): T where S : Group, S : ScaleOperations = space.average(this) //TODO optimized power operation diff --git a/kmath-core/src/commonTest/kotlin/space/kscience/kmath/testutils/SpaceVerifier.kt b/kmath-core/src/commonTest/kotlin/space/kscience/kmath/testutils/SpaceVerifier.kt index 6ea75156b..a9cd4454c 100644 --- a/kmath-core/src/commonTest/kotlin/space/kscience/kmath/testutils/SpaceVerifier.kt +++ b/kmath-core/src/commonTest/kotlin/space/kscience/kmath/testutils/SpaceVerifier.kt @@ -1,7 +1,7 @@ package space.kscience.kmath.testutils +import space.kscience.kmath.operations.Group import space.kscience.kmath.operations.ScaleOperations -import space.kscience.kmath.operations.Space import space.kscience.kmath.operations.invoke import kotlin.test.assertEquals import kotlin.test.assertNotEquals @@ -12,7 +12,7 @@ internal open class SpaceVerifier( val b: T, val c: T, val x: Number, -) : AlgebraicVerifier> where S : Space, S : ScaleOperations { +) : AlgebraicVerifier> where S : Group, S : ScaleOperations { override fun verify() { algebra { assertEquals(a + b + c, a + (b + c), "Addition in $algebra is not associative.") diff --git a/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/chains/flowExtra.kt b/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/chains/flowExtra.kt index eff813bee..81b4327fc 100644 --- a/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/chains/flowExtra.kt +++ b/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/chains/flowExtra.kt @@ -5,16 +5,16 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.runningReduce import kotlinx.coroutines.flow.scan +import space.kscience.kmath.operations.Group +import space.kscience.kmath.operations.GroupOperations import space.kscience.kmath.operations.ScaleOperations -import space.kscience.kmath.operations.Space -import space.kscience.kmath.operations.SpaceOperations import space.kscience.kmath.operations.invoke -public fun Flow.cumulativeSum(space: SpaceOperations): Flow = - space { runningReduce { sum, element -> sum + element } } +public fun Flow.cumulativeSum(group: GroupOperations): Flow = + group { runningReduce { sum, element -> sum + element } } @ExperimentalCoroutinesApi -public fun Flow.mean(algebra: S): Flow where S : Space, S : ScaleOperations = algebra { +public fun Flow.mean(algebra: S): Flow where S : Group, S : ScaleOperations = algebra { data class Accumulator(var sum: T, var num: Int) scan(Accumulator(zero, 0)) { sum, element -> diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt index 9141fa7b9..049909fe1 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt @@ -1,8 +1,8 @@ package space.kscience.kmath.functions +import space.kscience.kmath.operations.Group import space.kscience.kmath.operations.Ring import space.kscience.kmath.operations.ScaleOperations -import space.kscience.kmath.operations.Space import space.kscience.kmath.operations.invoke import kotlin.contracts.InvocationKind import kotlin.contracts.contract @@ -44,7 +44,7 @@ public fun > Polynomial.asFunction(ring: C): (T) -> T = */ public class PolynomialSpace( private val ring: C, -) : Space>, ScaleOperations> where C : Ring, C : ScaleOperations { +) : Group>, ScaleOperations> where C : Ring, C : ScaleOperations { public override val zero: Polynomial = Polynomial(emptyList()) override fun Polynomial.unaryMinus(): Polynomial = with(ring) { diff --git a/kmath-geometry/src/commonMain/kotlin/space/kscience/kmath/geometry/GeometrySpace.kt b/kmath-geometry/src/commonMain/kotlin/space/kscience/kmath/geometry/GeometrySpace.kt index 392156e9f..808bd692f 100644 --- a/kmath-geometry/src/commonMain/kotlin/space/kscience/kmath/geometry/GeometrySpace.kt +++ b/kmath-geometry/src/commonMain/kotlin/space/kscience/kmath/geometry/GeometrySpace.kt @@ -1,10 +1,10 @@ package space.kscience.kmath.geometry -import space.kscience.kmath.operations.Space +import space.kscience.kmath.operations.Group public interface Vector -public interface GeometrySpace : Space { +public interface GeometrySpace : Group { /** * L2 distance */ diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Counter.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Counter.kt index 55e8c0631..d5f3965d9 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Counter.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Counter.kt @@ -2,8 +2,8 @@ package space.kscience.kmath.histogram import kotlinx.atomicfu.atomic import kotlinx.atomicfu.getAndUpdate +import space.kscience.kmath.operations.Group import space.kscience.kmath.operations.RealField -import space.kscience.kmath.operations.Space /** * Common representation for atomic counters @@ -36,7 +36,7 @@ public class LongCounter : Counter { override val value: Long get() = innerValue.value } -public class ObjectCounter(public val space: Space) : Counter { +public class ObjectCounter(public val space: Group) : Counter { private val innerValue = atomic(space.zero) override fun add(delta: T) { diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt index b82644481..19128b2ac 100644 --- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt +++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/IndexedHistogramSpace.kt @@ -6,8 +6,8 @@ import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.nd.NDField import space.kscience.kmath.nd.NDStructure import space.kscience.kmath.nd.Strides +import space.kscience.kmath.operations.Group import space.kscience.kmath.operations.ScaleOperations -import space.kscience.kmath.operations.Space import space.kscience.kmath.operations.SpaceElement import space.kscience.kmath.operations.invoke @@ -43,7 +43,7 @@ public class IndexedHistogram, V : Any>( * A space for producing histograms with values in a NDStructure */ public interface IndexedHistogramSpace, V : Any> - : Space>, ScaleOperations> { + : Group>, ScaleOperations> { //public val valueSpace: Space public val strides: Strides public val histogramValueSpace: NDField //= NDAlgebra.space(valueSpace, Buffer.Companion::boxing, *shape), diff --git a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt index 85e82f515..b2071fa02 100644 --- a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt +++ b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/TreeHistogramSpace.kt @@ -2,8 +2,8 @@ package space.kscience.kmath.histogram import space.kscience.kmath.domains.UnivariateDomain import space.kscience.kmath.misc.UnstableKMathAPI +import space.kscience.kmath.operations.Group import space.kscience.kmath.operations.ScaleOperations -import space.kscience.kmath.operations.Space import space.kscience.kmath.structures.Buffer import java.util.* import kotlin.math.abs @@ -37,7 +37,7 @@ public class TreeHistogram( @UnstableKMathAPI public class TreeHistogramSpace( public val binFactory: (Double) -> UnivariateDomain, -) : Space, ScaleOperations { +) : Group, ScaleOperations { private class BinCounter(val domain: UnivariateDomain, val counter: Counter = Counter.real()) : ClosedFloatingPointRange by domain.range diff --git a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt index 96e3d41ae..03bd096d9 100644 --- a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt +++ b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt @@ -2,7 +2,7 @@ package space.kscience.kmath.histogram import space.kscience.kmath.domains.UnivariateDomain import space.kscience.kmath.misc.UnstableKMathAPI -import space.kscience.kmath.operations.Space +import space.kscience.kmath.operations.Group import space.kscience.kmath.operations.SpaceElement import space.kscience.kmath.structures.Buffer import space.kscience.kmath.structures.asSequence @@ -30,7 +30,7 @@ public class UnivariateBin( @OptIn(UnstableKMathAPI::class) public interface UnivariateHistogram : Histogram, - SpaceElement> { + SpaceElement> { public operator fun get(value: Double): UnivariateBin? public override operator fun get(point: Buffer): UnivariateBin? = get(point[0]) diff --git a/kmath-kotlingrad/src/main/kotlin/space/kscience/kmath/kotlingrad/ScalarsAdapters.kt b/kmath-kotlingrad/src/main/kotlin/space/kscience/kmath/kotlingrad/ScalarsAdapters.kt index 6ca6bc113..82b801f91 100644 --- a/kmath-kotlingrad/src/main/kotlin/space/kscience/kmath/kotlingrad/ScalarsAdapters.kt +++ b/kmath-kotlingrad/src/main/kotlin/space/kscience/kmath/kotlingrad/ScalarsAdapters.kt @@ -102,8 +102,8 @@ public fun > MST.toSFun(): SFun = when (this) { is MST.Symbolic -> toSVar() is MST.Unary -> when (operation) { - SpaceOperations.PLUS_OPERATION -> +value.toSFun() - SpaceOperations.MINUS_OPERATION -> -value.toSFun() + GroupOperations.PLUS_OPERATION -> +value.toSFun() + GroupOperations.MINUS_OPERATION -> -value.toSFun() TrigonometricOperations.SIN_OPERATION -> sin(value.toSFun()) TrigonometricOperations.COS_OPERATION -> cos(value.toSFun()) TrigonometricOperations.TAN_OPERATION -> tan(value.toSFun()) @@ -114,8 +114,8 @@ public fun > MST.toSFun(): SFun = when (this) { } is MST.Binary -> when (operation) { - SpaceOperations.PLUS_OPERATION -> left.toSFun() + right.toSFun() - SpaceOperations.MINUS_OPERATION -> left.toSFun() - right.toSFun() + GroupOperations.PLUS_OPERATION -> left.toSFun() + right.toSFun() + GroupOperations.MINUS_OPERATION -> left.toSFun() - right.toSFun() RingOperations.TIMES_OPERATION -> left.toSFun() * right.toSFun() FieldOperations.DIV_OPERATION -> left.toSFun() / right.toSFun() PowerOperations.POW_OPERATION -> left.toSFun() pow (right as MST.Numeric).toSConst() diff --git a/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebra.kt b/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebra.kt index dea74abdc..d8ce1052a 100644 --- a/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebra.kt +++ b/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebra.kt @@ -70,12 +70,12 @@ public interface Nd4jArrayAlgebra> : NDAlgebra { } /** - * Represents [NDSpace] over [Nd4jArrayStructure]. + * Represents [NDGroup] over [Nd4jArrayStructure]. * * @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 Nd4JArrayGroup> : NDGroup, Nd4jArrayAlgebra { public override val zero: Nd4jArrayStructure get() = Nd4j.zeros(*shape).wrap() @@ -100,7 +100,7 @@ public interface Nd4jArraySpace> : NDSpace, Nd4jArrayAlgeb * @param R the type of ring of structure elements. */ @OptIn(UnstableKMathAPI::class) -public interface Nd4jArrayRing> : NDRing, Nd4jArraySpace { +public interface Nd4jArrayRing> : NDRing, Nd4JArrayGroup { public override val one: Nd4jArrayStructure get() = Nd4j.ones(*shape).wrap() diff --git a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/SamplerAlgebra.kt b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/SamplerAlgebra.kt index ca2fd58cc..c5ec99dae 100644 --- a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/SamplerAlgebra.kt +++ b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/SamplerAlgebra.kt @@ -4,8 +4,8 @@ import space.kscience.kmath.chains.Chain import space.kscience.kmath.chains.ConstantChain import space.kscience.kmath.chains.map import space.kscience.kmath.chains.zip +import space.kscience.kmath.operations.Group import space.kscience.kmath.operations.ScaleOperations -import space.kscience.kmath.operations.Space import space.kscience.kmath.operations.invoke public class BasicSampler(public val chainBuilder: (RandomGenerator) -> Chain) : Sampler { @@ -19,8 +19,8 @@ public class ConstantSampler(public val value: T) : Sampler { /** * A space for samplers. Allows to perform simple operations on distributions */ -public class SamplerSpace(public val algebra: S) : Space>, - ScaleOperations> where S : Space, S : ScaleOperations { +public class SamplerSpace(public val algebra: S) : Group>, + ScaleOperations> where S : Group, S : ScaleOperations { public override val zero: Sampler = ConstantSampler(algebra.zero) diff --git a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Statistic.kt b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Statistic.kt index 4a3103d1b..a9f7cd3e4 100644 --- a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Statistic.kt +++ b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Statistic.kt @@ -66,7 +66,7 @@ public fun ComposableStatistic.flow( * Arithmetic mean */ public class Mean( - private val space: Space, + private val space: Group, private val division: (sum: T, count: Int) -> T, ) : ComposableStatistic, T> { public override suspend fun computeIntermediate(data: Buffer): Pair =