diff --git a/CHANGELOG.md b/CHANGELOG.md index 68a1829d9..f5dce8ad9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ - 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 +- Refactor AlgebraElement ### Deprecated @@ -46,6 +47,7 @@ - Support of `legacy` JS backend (we will support only IR) - `toGrid` method. - Public visibility of `BufferAccessor2D` +- `Real` class ### Fixed - `symbol` method in `MstExtendedField` (https://github.com/mipt-npm/kmath/pull/140) diff --git a/build.gradle.kts b/build.gradle.kts index 41f762a5f..ddce63678 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -37,4 +37,4 @@ readme { ksciencePublish { spaceRepo = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven" -} +} \ No newline at end of file diff --git a/kmath-core/api/kmath-core.api b/kmath-core/api/kmath-core.api index 92165f795..790259192 100644 --- a/kmath-core/api/kmath-core.api +++ b/kmath-core/api/kmath-core.api @@ -286,37 +286,19 @@ public final class kscience/kmath/expressions/SimpleAutoDiffExtendedField : ksci 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; @@ -329,19 +311,7 @@ public final class kscience/kmath/expressions/SimpleAutoDiffExtendedField : ksci 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 { @@ -1519,6 +1489,20 @@ public final class kscience/kmath/operations/Algebra$DefaultImpls { public static fun unaryOperationFunction (Lkscience/kmath/operations/Algebra;Ljava/lang/String;)Lkotlin/jvm/functions/Function1; } +public abstract interface class kscience/kmath/operations/AlgebraElement { + public abstract fun getContext ()Lkscience/kmath/operations/Algebra; +} + +public final class kscience/kmath/operations/AlgebraElementsKt { + public static final fun div (Lkscience/kmath/operations/AlgebraElement;Ljava/lang/Number;)Lkscience/kmath/operations/AlgebraElement; + public static final fun div (Lkscience/kmath/operations/AlgebraElement;Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun minus (Lkscience/kmath/operations/AlgebraElement;Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun plus (Lkscience/kmath/operations/AlgebraElement;Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun times (Ljava/lang/Number;Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun times (Lkscience/kmath/operations/AlgebraElement;Ljava/lang/Number;)Lkscience/kmath/operations/AlgebraElement; + public static final fun times (Lkscience/kmath/operations/AlgebraElement;Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; +} + 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; @@ -1703,39 +1687,13 @@ public final class kscience/kmath/operations/Complex : java/lang/Comparable, ksc 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 synthetic fun getContext ()Lkscience/kmath/operations/Algebra; 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 { @@ -1970,17 +1928,6 @@ public final class kscience/kmath/operations/Field$DefaultImpls { } 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 { @@ -2352,15 +2299,6 @@ public final class kscience/kmath/operations/LongRing : kscience/kmath/operation 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; } @@ -2386,24 +2324,24 @@ public final class kscience/kmath/operations/NumericAlgebra$DefaultImpls { } 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 static final fun acos (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun acosh (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun asin (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun asinh (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun atan (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun atanh (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun cos (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun cosh (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun exp (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun ln (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun norm (Lkscience/kmath/operations/AlgebraElement;)Ljava/lang/Object; + public static final fun pow (Lkscience/kmath/operations/AlgebraElement;D)Lkscience/kmath/operations/AlgebraElement; + public static final fun sin (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun sinh (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun sqr (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun sqrt (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun tan (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; + public static final fun tanh (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement; } public abstract interface class kscience/kmath/operations/PowerOperations : kscience/kmath/operations/Algebra { @@ -2430,61 +2368,6 @@ public final class kscience/kmath/operations/PowerOperations$DefaultImpls { 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; @@ -2594,15 +2477,6 @@ public final class kscience/kmath/operations/Ring$DefaultImpls { } 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 { @@ -2733,18 +2607,7 @@ public final class kscience/kmath/operations/Space$DefaultImpls { 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/SpaceElement : kscience/kmath/operations/AlgebraElement { } public abstract interface class kscience/kmath/operations/SpaceOperations : kscience/kmath/operations/Algebra { diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Algebra.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Algebra.kt index e7eb2770d..f3a87d644 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Algebra.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Algebra.kt @@ -162,7 +162,7 @@ public interface SpaceOperations : Algebra { * @param k the multiplicand. * @return the product. */ - public operator fun T.times(k: Number): T = multiply(this, k.toDouble()) + public operator fun T.times(k: Number): T = multiply(this, k) /** * Division of this element by scalar. diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/AlgebraElements.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/AlgebraElements.kt index aa572d894..eb55678b9 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/AlgebraElements.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/AlgebraElements.kt @@ -1,11 +1,14 @@ package kscience.kmath.operations +import kscience.kmath.misc.UnstableKMathAPI + /** * The generic mathematics elements which is able to store its context * * @param C the type of mathematical context for this element. + * @param T the type wrapped by this wrapper. */ -public interface MathElement { +public interface AlgebraElement> { /** * The context this element belongs to. */ @@ -13,22 +16,67 @@ public interface MathElement { } /** - * Represents element that can be wrapped to its "primitive" value. + * Divides this element by number. * - * @param T the type wrapped by this wrapper. - * @param I the type of this wrapper. + * @param k the divisor. + * @return the quotient. */ -public interface MathWrapper { - /** - * Unwraps [I] to [T]. - */ - public fun unwrap(): T +public operator fun , S : Space> T.div(k: Number): T = + context.multiply(this, 1.0 / k.toDouble()) + +/** + * Multiplies this element by number. + * + * @param k the multiplicand. + * @return the product. + */ +public operator fun , S : Space> T.times(k: Number): T = + context.multiply(this, k.toDouble()) + +/** + * Subtracts element from this one. + * + * @param b the subtrahend. + * @return the difference. + */ +public operator fun , S : Space> T.minus(b: T): T = + context.add(this, context.multiply(b, -1.0)) + +/** + * Adds element to this one. + * + * @param b the augend. + * @return the sum. + */ +public operator fun , S : Space> T.plus(b: T): T = + context.add(this, b) + +/** + * Number times element + */ +public operator fun , S : Space> Number.times(element: T): T = + element.times(this) + + +/** + * Multiplies this element by another one. + * + * @param b the multiplicand. + * @return the product. + */ +public operator fun , R : Ring> T.times(b: T): T = + context.multiply(this, b) + + +/** + * Divides this element by another one. + * + * @param b the divisor. + * @return the quotient. + */ +public operator fun , F : Field> T.div(b: T): T = + context.divide(this, b) - /** - * Wraps [T] to [I]. - */ - public fun T.wrap(): I -} /** * The element of [Space]. @@ -37,39 +85,8 @@ public interface MathWrapper { * @param I self type of the element. Needed for static type checking. * @param S the type of space. */ -public interface SpaceElement, S : Space> : MathElement, MathWrapper { - /** - * Adds element to this one. - * - * @param b the augend. - * @return the sum. - */ - public operator fun plus(b: T): I = context.add(unwrap(), b).wrap() - - /** - * Subtracts element from this one. - * - * @param b the subtrahend. - * @return the difference. - */ - public operator fun minus(b: T): I = context.add(unwrap(), context.multiply(b, -1.0)).wrap() - - /** - * Multiplies this element by number. - * - * @param k the multiplicand. - * @return the product. - */ - public operator fun times(k: Number): I = context.multiply(unwrap(), k.toDouble()).wrap() - - /** - * Divides this element by number. - * - * @param k the divisor. - * @return the quotient. - */ - public operator fun div(k: Number): I = context.multiply(unwrap(), 1.0 / k.toDouble()).wrap() -} +@UnstableKMathAPI +public interface SpaceElement, S : Space> : AlgebraElement /** * The element of [Ring]. @@ -78,15 +95,8 @@ public interface SpaceElement, S : Space> : Math * @param I self type of the element. Needed for static type checking. * @param R the type of ring. */ -public interface RingElement, R : Ring> : SpaceElement { - /** - * Multiplies this element by another one. - * - * @param b the multiplicand. - * @return the product. - */ - public operator fun times(b: T): I = context.multiply(unwrap(), b).wrap() -} +@UnstableKMathAPI +public interface RingElement, R : Ring> : SpaceElement /** * The element of [Field]. @@ -95,14 +105,5 @@ public interface RingElement, R : Ring> : SpaceEl * @param I self type of the element. Needed for static type checking. * @param F the type of field. */ -public interface FieldElement, F : Field> : RingElement { - override val context: F - - /** - * Divides this element by another one. - * - * @param b the divisor. - * @return the quotient. - */ - public operator fun div(b: T): I = context.divide(unwrap(), b).wrap() -} +@UnstableKMathAPI +public interface FieldElement, F : Field> : RingElement \ No newline at end of file diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Complex.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Complex.kt index c6409c015..3102a0422 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Complex.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Complex.kt @@ -167,16 +167,15 @@ public object ComplexField : ExtendedField, Norm, Rin * @property re The real part. * @property im The imaginary part. */ -public data class Complex(val re: Double, val im: Double) : FieldElement, - Comparable { +@OptIn(UnstableKMathAPI::class) +public data class Complex( + val re: Double, + val im: Double, +) : FieldElement, Comparable { public constructor(re: Number, im: Number) : this(re.toDouble(), im.toDouble()) override val context: ComplexField get() = ComplexField - override fun unwrap(): Complex = this - - override fun Complex.wrap(): Complex = this - override fun compareTo(other: Complex): Int = r.compareTo(other.r) override fun toString(): String { diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/OptionalOperations.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/OptionalOperations.kt index f31d61ae1..3d809e6a5 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/OptionalOperations.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/OptionalOperations.kt @@ -1,5 +1,7 @@ package kscience.kmath.operations +import kscience.kmath.misc.UnstableKMathAPI + /** * A container for trigonometric operations for specific type. * @@ -72,32 +74,38 @@ public interface TrigonometricOperations : Algebra { /** * Computes the sine of [arg]. */ -public fun >> sin(arg: T): T = arg.context.sin(arg) +@UnstableKMathAPI +public fun >> sin(arg: T): T = arg.context.sin(arg) /** * Computes the cosine of [arg]. */ -public fun >> cos(arg: T): T = arg.context.cos(arg) +@UnstableKMathAPI +public fun >> cos(arg: T): T = arg.context.cos(arg) /** * Computes the tangent of [arg]. */ -public fun >> tan(arg: T): T = arg.context.tan(arg) +@UnstableKMathAPI +public fun >> tan(arg: T): T = arg.context.tan(arg) /** * Computes the inverse sine of [arg]. */ -public fun >> asin(arg: T): T = arg.context.asin(arg) +@UnstableKMathAPI +public fun >> asin(arg: T): T = arg.context.asin(arg) /** * Computes the inverse cosine of [arg]. */ -public fun >> acos(arg: T): T = arg.context.acos(arg) +@UnstableKMathAPI +public fun >> acos(arg: T): T = arg.context.acos(arg) /** * Computes the inverse tangent of [arg]. */ -public fun >> atan(arg: T): T = arg.context.atan(arg) +@UnstableKMathAPI +public fun >> atan(arg: T): T = arg.context.atan(arg) /** * A container for hyperbolic trigonometric operations for specific type. @@ -171,32 +179,38 @@ public interface HyperbolicOperations : Algebra { /** * Computes the hyperbolic sine of [arg]. */ -public fun >> sinh(arg: T): T = arg.context.sinh(arg) +@UnstableKMathAPI +public fun >> sinh(arg: T): T = arg.context.sinh(arg) /** * Computes the hyperbolic cosine of [arg]. */ -public fun >> cosh(arg: T): T = arg.context.cosh(arg) +@UnstableKMathAPI +public fun >> cosh(arg: T): T = arg.context.cosh(arg) /** * Computes the hyperbolic tangent of [arg]. */ -public fun >> tanh(arg: T): T = arg.context.tanh(arg) +@UnstableKMathAPI +public fun >> tanh(arg: T): T = arg.context.tanh(arg) /** * Computes the inverse hyperbolic sine of [arg]. */ -public fun >> asinh(arg: T): T = arg.context.asinh(arg) +@UnstableKMathAPI +public fun >> asinh(arg: T): T = arg.context.asinh(arg) /** * Computes the inverse hyperbolic cosine of [arg]. */ -public fun >> acosh(arg: T): T = arg.context.acosh(arg) +@UnstableKMathAPI +public fun >> acosh(arg: T): T = arg.context.acosh(arg) /** * Computes the inverse hyperbolic tangent of [arg]. */ -public fun >> atanh(arg: T): T = arg.context.atanh(arg) +@UnstableKMathAPI +public fun >> atanh(arg: T): T = arg.context.atanh(arg) /** * A context extension to include power operations based on exponentiation. @@ -239,17 +253,20 @@ public interface PowerOperations : Algebra { * @param power the exponent. * @return the base raised to the power. */ -public infix fun >> T.pow(power: Double): T = context.power(this, power) +@UnstableKMathAPI +public infix fun >> T.pow(power: Double): T = context.power(this, power) /** * Computes the square root of the value [arg]. */ -public fun >> sqrt(arg: T): T = arg pow 0.5 +@UnstableKMathAPI +public fun >> sqrt(arg: T): T = arg pow 0.5 /** * Computes the square of the value [arg]. */ -public fun >> sqr(arg: T): T = arg pow 2.0 +@UnstableKMathAPI +public fun >> sqr(arg: T): T = arg pow 2.0 /** * A container for operations related to `exp` and `ln` functions. @@ -283,12 +300,14 @@ public interface ExponentialOperations : Algebra { /** * The identifier of exponential function. */ -public fun >> exp(arg: T): T = arg.context.exp(arg) +@UnstableKMathAPI +public fun >> exp(arg: T): T = arg.context.exp(arg) /** * The identifier of natural logarithm. */ -public fun >> ln(arg: T): T = arg.context.ln(arg) +@UnstableKMathAPI +public fun >> ln(arg: T): T = arg.context.ln(arg) /** * A container for norm functional on element. @@ -306,4 +325,5 @@ public interface Norm { /** * Computes the norm of [arg] (i.e. absolute value or vector length). */ -public fun >, R> norm(arg: T): R = arg.context.norm(arg) +@UnstableKMathAPI +public fun >, R> norm(arg: T): R = arg.context.norm(arg) diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/AlgebraExtensions.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/algebraExtensions.kt similarity index 100% rename from kmath-core/src/commonMain/kotlin/kscience/kmath/operations/AlgebraExtensions.kt rename to kmath-core/src/commonMain/kotlin/kscience/kmath/operations/algebraExtensions.kt diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/numbers.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/numbers.kt index 0440d74e8..a5c4cfff9 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/numbers.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/numbers.kt @@ -52,23 +52,6 @@ public interface ExtendedField : ExtendedFieldOperations, Field, Numeri } } -/** - * Real field element wrapping double. - * - * @property value the [Double] value wrapped by this [Real]. - * - * TODO inline does not work due to compiler bug. Waiting for fix for KT-27586 - */ -public inline class Real(public val value: Double) : FieldElement { - public override val context: RealField - get() = RealField - - public override fun unwrap(): Double = value - public override fun Double.wrap(): Real = Real(value) - - public companion object -} - /** * A field for [Double] without boxing. Does not produce appropriate field element. */ diff --git a/kmath-geometry/src/commonMain/kotlin/kscience/kmath/geometry/Euclidean2DSpace.kt b/kmath-geometry/src/commonMain/kotlin/kscience/kmath/geometry/Euclidean2DSpace.kt index c2a883a64..7714dc939 100644 --- a/kmath-geometry/src/commonMain/kotlin/kscience/kmath/geometry/Euclidean2DSpace.kt +++ b/kmath-geometry/src/commonMain/kotlin/kscience/kmath/geometry/Euclidean2DSpace.kt @@ -1,11 +1,13 @@ package kscience.kmath.geometry import kscience.kmath.linear.Point +import kscience.kmath.misc.UnstableKMathAPI import kscience.kmath.operations.SpaceElement import kscience.kmath.operations.invoke import kotlin.math.sqrt -public interface Vector2D : Point, Vector, SpaceElement { +@OptIn(UnstableKMathAPI::class) +public interface Vector2D : Point, Vector, SpaceElement { public val x: Double public val y: Double public override val context: Euclidean2DSpace get() = Euclidean2DSpace @@ -18,8 +20,6 @@ public interface Vector2D : Point, Vector, SpaceElement = listOf(x, y).iterator() - public override fun unwrap(): Vector2D = this - public override fun Vector2D.wrap(): Vector2D = this } public val Vector2D.r: Double diff --git a/kmath-geometry/src/commonMain/kotlin/kscience/kmath/geometry/Euclidean3DSpace.kt b/kmath-geometry/src/commonMain/kotlin/kscience/kmath/geometry/Euclidean3DSpace.kt index e0052d791..00daa2d75 100644 --- a/kmath-geometry/src/commonMain/kotlin/kscience/kmath/geometry/Euclidean3DSpace.kt +++ b/kmath-geometry/src/commonMain/kotlin/kscience/kmath/geometry/Euclidean3DSpace.kt @@ -1,11 +1,13 @@ package kscience.kmath.geometry import kscience.kmath.linear.Point +import kscience.kmath.misc.UnstableKMathAPI import kscience.kmath.operations.SpaceElement import kscience.kmath.operations.invoke import kotlin.math.sqrt -public interface Vector3D : Point, Vector, SpaceElement { +@OptIn(UnstableKMathAPI::class) +public interface Vector3D : Point, Vector, SpaceElement { public val x: Double public val y: Double public val z: Double @@ -20,8 +22,6 @@ public interface Vector3D : Point, Vector, SpaceElement = listOf(x, y, z).iterator() - public override fun unwrap(): Vector3D = this - public override fun Vector3D.wrap(): Vector3D = this } @Suppress("FunctionName") 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 11eb77735..21d873806 100644 --- a/kmath-histograms/src/commonMain/kotlin/kscience/kmath/histogram/RealHistogram.kt +++ b/kmath-histograms/src/commonMain/kotlin/kscience/kmath/histogram/RealHistogram.kt @@ -8,7 +8,7 @@ import kscience.kmath.operations.invoke import kscience.kmath.structures.* import kotlin.math.floor -public data class BinDefinition>( +public data class MultivariateBinDefinition>( public val space: SpaceOperations>, public val center: Point, public val sizes: Point, @@ -23,8 +23,9 @@ public data class BinDefinition>( public class MultivariateBin>( - public val definition: BinDefinition, - public override val value: Number, + public val definition: MultivariateBinDefinition, + public val count: Long, + public override val value: Double, ) : Bin { public override val dimension: Int get() = definition.center.size @@ -56,7 +57,6 @@ public class RealHistogram( require(!(0 until dimension).any { upper[it] - lower[it] < 0 }) { "Range for one of axis is not strictly positive" } } - /** * Get internal [NDStructure] bin index for given axis */ @@ -68,11 +68,15 @@ public class RealHistogram( private fun getIndex(point: Buffer): IntArray = IntArray(dimension) { getIndex(it, point[it]) } - private fun getValue(index: IntArray): Long = counts[index].sum() + private fun getCount(index: IntArray): Long = counts[index].sum() - public fun getValue(point: Buffer): Long = getValue(getIndex(point)) + public fun getCount(point: Buffer): Long = getCount(getIndex(point)) - private fun getBinDefinition(index: IntArray): BinDefinition { + private fun getValue(index: IntArray): Double = values[index].sum() + + public fun getValue(point: Buffer): Double = getValue(getIndex(point)) + + private fun getBinDefinition(index: IntArray): MultivariateBinDefinition { val center = index.mapIndexed { axis, i -> when (i) { 0 -> Double.NEGATIVE_INFINITY @@ -81,14 +85,14 @@ public class RealHistogram( } }.asBuffer() - return BinDefinition(RealBufferFieldOperations, center, binSize) + return MultivariateBinDefinition(RealBufferFieldOperations, center, binSize) } - public fun getBinDefinition(point: Buffer): BinDefinition = getBinDefinition(getIndex(point)) + public fun getBinDefinition(point: Buffer): MultivariateBinDefinition = getBinDefinition(getIndex(point)) public override operator fun get(point: Buffer): MultivariateBin? { val index = getIndex(point) - return MultivariateBin(getBinDefinition(index), getValue(index)) + return MultivariateBin(getBinDefinition(index), getCount(index),getValue(index)) } // fun put(point: Point){ @@ -103,8 +107,8 @@ public class RealHistogram( } public override operator fun iterator(): Iterator> = - values.elements().map { (index, value) -> - MultivariateBin(getBinDefinition(index), value.sum()) + strides.indices().map { index-> + MultivariateBin(getBinDefinition(index), counts[index].sum(), values[index].sum()) }.iterator() /** 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 049f61d5a..10aa9f8ca 100644 --- a/kmath-histograms/src/jvmMain/kotlin/kscience/kmath/histogram/UnivariateHistogram.kt +++ b/kmath-histograms/src/jvmMain/kotlin/kscience/kmath/histogram/UnivariateHistogram.kt @@ -2,6 +2,7 @@ package kscience.kmath.histogram import kscience.kmath.linear.Point import kscience.kmath.misc.UnstableKMathAPI +import kscience.kmath.operations.SpaceElement import kscience.kmath.structures.Buffer import kscience.kmath.structures.asBuffer import kscience.kmath.structures.asSequence @@ -38,9 +39,10 @@ public class UnivariateBin( /** * Univariate histogram with log(n) bin search speed */ -public abstract class UnivariateHistogram( +@OptIn(UnstableKMathAPI::class) +public abstract class UnivariateHistogram protected constructor( protected val bins: TreeMap = TreeMap(), -) : Histogram { +) : Histogram, SpaceElement { public operator fun get(value: Double): UnivariateBin? { // check ceiling entry and return it if it is what needed @@ -64,10 +66,10 @@ public abstract class UnivariateHistogram( * 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 -> + UnivariateHistogramSpace { value -> val center = start + binSize * floor((value - start) / binSize + 0.5) UnivariateBin(center, binSize) - } + }.builder() /** * Build and fill a [UnivariateHistogram]. Returns a read-only histogram. @@ -84,7 +86,7 @@ public abstract class UnivariateHistogram( public fun customBuilder(borders: DoubleArray): UnivariateHistogramBuilder { val sorted = borders.sortedArray() - return UnivariateHistogramBuilder { value -> + return UnivariateHistogramSpace { value -> when { value < sorted.first() -> UnivariateBin( Double.NEGATIVE_INFINITY, @@ -103,7 +105,7 @@ public abstract class UnivariateHistogram( UnivariateBin((left + right) / 2, (right - left)) } } - } + }.builder() } /** @@ -116,11 +118,11 @@ public abstract class UnivariateHistogram( } } -public class UnivariateHistogramBuilder( - private val factory: (Double) -> UnivariateBin, +public class UnivariateHistogramBuilder internal constructor( + override val context: UnivariateHistogramSpace, ) : UnivariateHistogram(), MutableHistogram { - private fun createBin(value: Double): UnivariateBin = factory(value).also { + private fun createBin(value: Double): UnivariateBin = context.binFactory(value).also { synchronized(this) { bins[it.position] = it } } @@ -128,7 +130,7 @@ public class UnivariateHistogramBuilder( * Thread safe put operation */ public fun put(value: Double, weight: Double = 1.0) { - (get(value) ?: createBin(value)).apply{ + (get(value) ?: createBin(value)).apply { counter.increment() weightCounter.add(weight) } @@ -141,8 +143,8 @@ public class UnivariateHistogramBuilder( /** * Put several items into a single bin */ - public fun putMany(value: Double, count: Int, weight: Double = count.toDouble()){ - (get(value) ?: createBin(value)).apply{ + public fun putMany(value: Double, count: Int, weight: Double = count.toDouble()) { + (get(value) ?: createBin(value)).apply { counter.add(count.toLong()) weightCounter.add(weight) } diff --git a/kmath-histograms/src/jvmMain/kotlin/kscience/kmath/histogram/UnivariateHistogramSpace.kt b/kmath-histograms/src/jvmMain/kotlin/kscience/kmath/histogram/UnivariateHistogramSpace.kt new file mode 100644 index 000000000..0deeb0a97 --- /dev/null +++ b/kmath-histograms/src/jvmMain/kotlin/kscience/kmath/histogram/UnivariateHistogramSpace.kt @@ -0,0 +1,25 @@ +package kscience.kmath.histogram + +import kscience.kmath.operations.Space + +public class UnivariateHistogramSpace(public val binFactory: (Double) -> UnivariateBin) : Space { + + public fun builder(): UnivariateHistogramBuilder = UnivariateHistogramBuilder(this) + + public fun produce(builder: UnivariateHistogramBuilder.() -> Unit): UnivariateHistogram = builder().apply(builder) + + override fun add( + a: UnivariateHistogram, + b: UnivariateHistogram, + ): UnivariateHistogram { + require(a.context == this){"Histogram $a does not belong to this context"} + require(b.context == this){"Histogram $b does not belong to this context"} + TODO() + } + + override fun multiply(a: UnivariateHistogram, k: Number): UnivariateHistogram { + TODO("Not yet implemented") + } + + override val zero: UnivariateHistogram = produce { } +} \ No newline at end of file diff --git a/kmath-viktor/api/kmath-viktor.api b/kmath-viktor/api/kmath-viktor.api index afd17feb1..cbfaeb8d5 100644 --- a/kmath-viktor/api/kmath-viktor.api +++ b/kmath-viktor/api/kmath-viktor.api @@ -93,7 +93,6 @@ public final class kscience/kmath/viktor/ViktorNDField : kscience/kmath/nd/NDFie 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; @@ -110,7 +109,6 @@ public final class kscience/kmath/viktor/ViktorNDField : kscience/kmath/nd/NDFie 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; @@ -141,7 +139,6 @@ public final class kscience/kmath/viktor/ViktorNDField : kscience/kmath/nd/NDFie 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;