Merge branch 'dev' into gsl-experiment

This commit is contained in:
Iaroslav Postovalov 2021-02-07 02:46:24 +07:00
commit a5cdf7c297
No known key found for this signature in database
GPG Key ID: 46E15E4A31B3BCD7
19 changed files with 216 additions and 320 deletions

View File

@ -39,6 +39,7 @@
- Capitalization of LUP in many names changed to Lup. - 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 - Refactored `NDStructure` algebra to be more simple, preferring under-the-hood conversion to explicit NDStructure types
- Refactor histograms. They are marked as prototype - Refactor histograms. They are marked as prototype
- Refactor AlgebraElement
### Deprecated ### Deprecated
@ -47,6 +48,7 @@
- Support of `legacy` JS backend (we will support only IR) - Support of `legacy` JS backend (we will support only IR)
- `toGrid` method. - `toGrid` method.
- Public visibility of `BufferAccessor2D` - Public visibility of `BufferAccessor2D`
- `Real` class
### Fixed ### Fixed
- `symbol` method in `MstExtendedField` (https://github.com/mipt-npm/kmath/pull/140) - `symbol` method in `MstExtendedField` (https://github.com/mipt-npm/kmath/pull/140)

View File

@ -4,7 +4,7 @@ plugins {
id("ru.mipt.npm.project") id("ru.mipt.npm.project")
} }
internal val kmathVersion: String by extra("0.2.0-dev-6") internal val kmathVersion: String by extra("0.2.0-dev-7")
internal val bintrayRepo: String by extra("kscience") internal val bintrayRepo: String by extra("kscience")
internal val githubProject: String by extra("kmath") internal val githubProject: String by extra("kmath")
@ -37,4 +37,4 @@ readme {
ksciencePublish { ksciencePublish {
spaceRepo = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven" spaceRepo = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven"
} }

View File

@ -286,37 +286,19 @@ public final class kscience/kmath/expressions/SimpleAutoDiffExtendedField : ksci
public fun atan (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; public fun atan (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue;
public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object; public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object;
public fun atanh (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; 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 synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object;
public fun cos (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; public fun cos (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue;
public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object; public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object;
public fun cosh (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; 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 synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object;
public fun exp (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; 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 synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object;
public fun ln (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; 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 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 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 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 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 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 fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2;
public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object;
public fun sin (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; 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 fun tan (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue;
public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object; public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object;
public fun tanh (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue; 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 fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1;
public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object;
public fun unaryPlus (Lkscience/kmath/expressions/AutoDiffValue;)Lkscience/kmath/expressions/AutoDiffValue;
} }
public class kscience/kmath/expressions/SimpleAutoDiffField : kscience/kmath/expressions/ExpressionAlgebra, kscience/kmath/operations/Field, kscience/kmath/operations/RingWithNumbers { public class kscience/kmath/expressions/SimpleAutoDiffField : kscience/kmath/expressions/ExpressionAlgebra, kscience/kmath/operations/Field, kscience/kmath/operations/RingWithNumbers {
@ -1524,6 +1494,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 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 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 abs (Lkscience/kmath/operations/Space;Ljava/lang/Comparable;)Ljava/lang/Comparable;
public static final fun average (Lkscience/kmath/operations/Space;Ljava/lang/Iterable;)Ljava/lang/Object; public static final fun average (Lkscience/kmath/operations/Space;Ljava/lang/Iterable;)Ljava/lang/Object;
@ -1708,39 +1692,13 @@ public final class kscience/kmath/operations/Complex : java/lang/Comparable, ksc
public final fun component2 ()D public final fun component2 ()D
public final fun copy (DD)Lkscience/kmath/operations/Complex; 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 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 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 fun getContext ()Lkscience/kmath/operations/ComplexField;
public synthetic fun getContext ()Lkscience/kmath/operations/Field;
public final fun getIm ()D public final fun getIm ()D
public final fun getRe ()D public final fun getRe ()D
public fun hashCode ()I 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 fun toString ()Ljava/lang/String;
public synthetic fun unwrap ()Ljava/lang/Object;
public fun unwrap ()Lkscience/kmath/operations/Complex;
public synthetic fun wrap (Ljava/lang/Object;)Ljava/lang/Object;
public fun wrap (Lkscience/kmath/operations/Complex;)Lkscience/kmath/operations/Complex;
} }
public final class kscience/kmath/operations/Complex$Companion : kscience/kmath/memory/MemorySpec { public final class kscience/kmath/operations/Complex$Companion : kscience/kmath/memory/MemorySpec {
@ -1975,17 +1933,6 @@ public final class kscience/kmath/operations/Field$DefaultImpls {
} }
public abstract interface class kscience/kmath/operations/FieldElement : kscience/kmath/operations/RingElement { public abstract interface class kscience/kmath/operations/FieldElement : kscience/kmath/operations/RingElement {
public abstract fun div (Ljava/lang/Object;)Lkscience/kmath/operations/FieldElement;
public abstract fun getContext ()Lkscience/kmath/operations/Field;
}
public final class kscience/kmath/operations/FieldElement$DefaultImpls {
public static fun div (Lkscience/kmath/operations/FieldElement;Ljava/lang/Number;)Lkscience/kmath/operations/FieldElement;
public static fun div (Lkscience/kmath/operations/FieldElement;Ljava/lang/Object;)Lkscience/kmath/operations/FieldElement;
public static fun minus (Lkscience/kmath/operations/FieldElement;Ljava/lang/Object;)Lkscience/kmath/operations/FieldElement;
public static fun plus (Lkscience/kmath/operations/FieldElement;Ljava/lang/Object;)Lkscience/kmath/operations/FieldElement;
public static fun times (Lkscience/kmath/operations/FieldElement;Ljava/lang/Number;)Lkscience/kmath/operations/FieldElement;
public static fun times (Lkscience/kmath/operations/FieldElement;Ljava/lang/Object;)Lkscience/kmath/operations/FieldElement;
} }
public abstract interface class kscience/kmath/operations/FieldOperations : kscience/kmath/operations/RingOperations { public abstract interface class kscience/kmath/operations/FieldOperations : kscience/kmath/operations/RingOperations {
@ -2357,15 +2304,6 @@ public final class kscience/kmath/operations/LongRing : kscience/kmath/operation
public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object; 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 interface class kscience/kmath/operations/Norm {
public abstract fun norm (Ljava/lang/Object;)Ljava/lang/Object; public abstract fun norm (Ljava/lang/Object;)Ljava/lang/Object;
} }
@ -2391,24 +2329,24 @@ public final class kscience/kmath/operations/NumericAlgebra$DefaultImpls {
} }
public final class kscience/kmath/operations/OptionalOperationsKt { public final class kscience/kmath/operations/OptionalOperationsKt {
public static final fun acos (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/MathElement;)Lkscience/kmath/operations/MathElement; public static final fun acosh (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement;
public static final fun asin (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; public static final fun asin (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement;
public static final fun asinh (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; public static final fun asinh (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement;
public static final fun atan (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; public static final fun atan (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement;
public static final fun atanh (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; public static final fun atanh (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement;
public static final fun cos (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; public static final fun cos (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement;
public static final fun cosh (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; public static final fun cosh (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement;
public static final fun exp (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; public static final fun exp (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement;
public static final fun ln (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; public static final fun ln (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement;
public static final fun norm (Lkscience/kmath/operations/MathElement;)Ljava/lang/Object; public static final fun norm (Lkscience/kmath/operations/AlgebraElement;)Ljava/lang/Object;
public static final fun pow (Lkscience/kmath/operations/MathElement;D)Lkscience/kmath/operations/MathElement; public static final fun pow (Lkscience/kmath/operations/AlgebraElement;D)Lkscience/kmath/operations/AlgebraElement;
public static final fun sin (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; public static final fun sin (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement;
public static final fun sinh (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; public static final fun sinh (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement;
public static final fun sqr (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; public static final fun sqr (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement;
public static final fun sqrt (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; public static final fun sqrt (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement;
public static final fun tan (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; public static final fun tan (Lkscience/kmath/operations/AlgebraElement;)Lkscience/kmath/operations/AlgebraElement;
public static final fun tanh (Lkscience/kmath/operations/MathElement;)Lkscience/kmath/operations/MathElement; 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 { public abstract interface class kscience/kmath/operations/PowerOperations : kscience/kmath/operations/Algebra {
@ -2435,61 +2373,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 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 final class kscience/kmath/operations/RealField : kscience/kmath/operations/ExtendedField, kscience/kmath/operations/Norm {
public static final field INSTANCE Lkscience/kmath/operations/RealField; public static final field INSTANCE Lkscience/kmath/operations/RealField;
public fun acos (D)Ljava/lang/Double; public fun acos (D)Ljava/lang/Double;
@ -2599,15 +2482,6 @@ public final class kscience/kmath/operations/Ring$DefaultImpls {
} }
public abstract interface class kscience/kmath/operations/RingElement : kscience/kmath/operations/SpaceElement { public abstract interface class kscience/kmath/operations/RingElement : kscience/kmath/operations/SpaceElement {
public abstract fun times (Ljava/lang/Object;)Lkscience/kmath/operations/RingElement;
}
public final class kscience/kmath/operations/RingElement$DefaultImpls {
public static fun div (Lkscience/kmath/operations/RingElement;Ljava/lang/Number;)Lkscience/kmath/operations/RingElement;
public static fun minus (Lkscience/kmath/operations/RingElement;Ljava/lang/Object;)Lkscience/kmath/operations/RingElement;
public static fun plus (Lkscience/kmath/operations/RingElement;Ljava/lang/Object;)Lkscience/kmath/operations/RingElement;
public static fun times (Lkscience/kmath/operations/RingElement;Ljava/lang/Number;)Lkscience/kmath/operations/RingElement;
public static fun times (Lkscience/kmath/operations/RingElement;Ljava/lang/Object;)Lkscience/kmath/operations/RingElement;
} }
public abstract interface class kscience/kmath/operations/RingOperations : kscience/kmath/operations/SpaceOperations { public abstract interface class kscience/kmath/operations/RingOperations : kscience/kmath/operations/SpaceOperations {
@ -2738,18 +2612,7 @@ public final class kscience/kmath/operations/Space$DefaultImpls {
public static fun unaryPlus (Lkscience/kmath/operations/Space;Ljava/lang/Object;)Ljava/lang/Object; 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 interface class kscience/kmath/operations/SpaceElement : kscience/kmath/operations/AlgebraElement {
public abstract fun div (Ljava/lang/Number;)Lkscience/kmath/operations/SpaceElement;
public abstract fun minus (Ljava/lang/Object;)Lkscience/kmath/operations/SpaceElement;
public abstract fun plus (Ljava/lang/Object;)Lkscience/kmath/operations/SpaceElement;
public abstract fun times (Ljava/lang/Number;)Lkscience/kmath/operations/SpaceElement;
}
public final class kscience/kmath/operations/SpaceElement$DefaultImpls {
public static fun div (Lkscience/kmath/operations/SpaceElement;Ljava/lang/Number;)Lkscience/kmath/operations/SpaceElement;
public static fun minus (Lkscience/kmath/operations/SpaceElement;Ljava/lang/Object;)Lkscience/kmath/operations/SpaceElement;
public static fun plus (Lkscience/kmath/operations/SpaceElement;Ljava/lang/Object;)Lkscience/kmath/operations/SpaceElement;
public static fun times (Lkscience/kmath/operations/SpaceElement;Ljava/lang/Number;)Lkscience/kmath/operations/SpaceElement;
} }
public abstract interface class kscience/kmath/operations/SpaceOperations : kscience/kmath/operations/Algebra { public abstract interface class kscience/kmath/operations/SpaceOperations : kscience/kmath/operations/Algebra {
@ -2850,7 +2713,7 @@ public final class kscience/kmath/structures/Buffer$DefaultImpls {
public static fun contentEquals (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Z public static fun contentEquals (Lkscience/kmath/structures/Buffer;Lkscience/kmath/structures/Buffer;)Z
} }
public final class kscience/kmath/structures/BuffersKt { public final class kscience/kmath/structures/BufferKt {
public static final fun ListBuffer (ILkotlin/jvm/functions/Function1;)Ljava/util/List; public static final fun ListBuffer (ILkotlin/jvm/functions/Function1;)Ljava/util/List;
public static final fun asBuffer (Ljava/util/List;)Ljava/util/List; public static final fun asBuffer (Ljava/util/List;)Ljava/util/List;
public static final fun asBuffer ([Ljava/lang/Object;)Lkscience/kmath/structures/ArrayBuffer; public static final fun asBuffer ([Ljava/lang/Object;)Lkscience/kmath/structures/ArrayBuffer;

View File

@ -95,7 +95,7 @@ public fun <T, E> ExpressionAlgebra<T, E>.bind(symbol: Symbol): E =
/** /**
* A delegate to create a symbol with a string identity in this scope * A delegate to create a symbol with a string identity in this scope
*/ */
public val symbol: ReadOnlyProperty<Any?, Symbol> = ReadOnlyProperty { thisRef, property -> public val symbol: ReadOnlyProperty<Any?, Symbol> = ReadOnlyProperty { _, property ->
StringSymbol(property.name) StringSymbol(property.name)
} }

View File

@ -162,7 +162,7 @@ public interface SpaceOperations<T> : Algebra<T> {
* @param k the multiplicand. * @param k the multiplicand.
* @return the product. * @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. * Division of this element by scalar.

View File

@ -1,11 +1,14 @@
package kscience.kmath.operations package kscience.kmath.operations
import kscience.kmath.misc.UnstableKMathAPI
/** /**
* The generic mathematics elements which is able to store its context * The generic mathematics elements which is able to store its context
* *
* @param C the type of mathematical context for this element. * @param C the type of mathematical context for this element.
* @param T the type wrapped by this wrapper.
*/ */
public interface MathElement<C> { public interface AlgebraElement<T, C : Algebra<T>> {
/** /**
* The context this element belongs to. * The context this element belongs to.
*/ */
@ -13,22 +16,67 @@ public interface MathElement<C> {
} }
/** /**
* Represents element that can be wrapped to its "primitive" value. * Divides this element by number.
* *
* @param T the type wrapped by this wrapper. * @param k the divisor.
* @param I the type of this wrapper. * @return the quotient.
*/ */
public interface MathWrapper<T, I> { public operator fun <T : AlgebraElement<T, S>, S : Space<T>> T.div(k: Number): T =
/** context.multiply(this, 1.0 / k.toDouble())
* Unwraps [I] to [T].
*/ /**
public fun unwrap(): T * Multiplies this element by number.
*
* @param k the multiplicand.
* @return the product.
*/
public operator fun <T : AlgebraElement<T, S>, S : Space<T>> 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 <T : AlgebraElement<T, S>, S : Space<T>> 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 <T : AlgebraElement<T, S>, S : Space<T>> T.plus(b: T): T =
context.add(this, b)
/**
* Number times element
*/
public operator fun <T : AlgebraElement<T, S>, S : Space<T>> Number.times(element: T): T =
element.times(this)
/**
* Multiplies this element by another one.
*
* @param b the multiplicand.
* @return the product.
*/
public operator fun <T : AlgebraElement<T, R>, R : Ring<T>> 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 <T : AlgebraElement<T, F>, F : Field<T>> T.div(b: T): T =
context.divide(this, b)
/**
* Wraps [T] to [I].
*/
public fun T.wrap(): I
}
/** /**
* The element of [Space]. * The element of [Space].
@ -37,39 +85,8 @@ public interface MathWrapper<T, I> {
* @param I self type of the element. Needed for static type checking. * @param I self type of the element. Needed for static type checking.
* @param S the type of space. * @param S the type of space.
*/ */
public interface SpaceElement<T, I : SpaceElement<T, I, S>, S : Space<T>> : MathElement<S>, MathWrapper<T, I> { @UnstableKMathAPI
/** public interface SpaceElement<T : SpaceElement<T, S>, S : Space<T>> : AlgebraElement<T, S>
* 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()
}
/** /**
* The element of [Ring]. * The element of [Ring].
@ -78,15 +95,8 @@ public interface SpaceElement<T, I : SpaceElement<T, I, S>, S : Space<T>> : Math
* @param I self type of the element. Needed for static type checking. * @param I self type of the element. Needed for static type checking.
* @param R the type of ring. * @param R the type of ring.
*/ */
public interface RingElement<T, I : RingElement<T, I, R>, R : Ring<T>> : SpaceElement<T, I, R> { @UnstableKMathAPI
/** public interface RingElement<T : RingElement<T, R>, R : Ring<T>> : SpaceElement<T, R>
* 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()
}
/** /**
* The element of [Field]. * The element of [Field].
@ -95,14 +105,5 @@ public interface RingElement<T, I : RingElement<T, I, R>, R : Ring<T>> : SpaceEl
* @param I self type of the element. Needed for static type checking. * @param I self type of the element. Needed for static type checking.
* @param F the type of field. * @param F the type of field.
*/ */
public interface FieldElement<T, I : FieldElement<T, I, F>, F : Field<T>> : RingElement<T, I, F> { @UnstableKMathAPI
override val context: F public interface FieldElement<T : FieldElement<T, F>, F : Field<T>> : RingElement<T, 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()
}

View File

@ -167,16 +167,15 @@ public object ComplexField : ExtendedField<Complex>, Norm<Complex, Complex>, Rin
* @property re The real part. * @property re The real part.
* @property im The imaginary part. * @property im The imaginary part.
*/ */
public data class Complex(val re: Double, val im: Double) : FieldElement<Complex, Complex, ComplexField>, @OptIn(UnstableKMathAPI::class)
Comparable<Complex> { public data class Complex(
val re: Double,
val im: Double,
) : FieldElement<Complex, ComplexField>, Comparable<Complex> {
public constructor(re: Number, im: Number) : this(re.toDouble(), im.toDouble()) public constructor(re: Number, im: Number) : this(re.toDouble(), im.toDouble())
override val context: ComplexField get() = ComplexField 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 compareTo(other: Complex): Int = r.compareTo(other.r)
override fun toString(): String { override fun toString(): String {

View File

@ -1,5 +1,7 @@
package kscience.kmath.operations package kscience.kmath.operations
import kscience.kmath.misc.UnstableKMathAPI
/** /**
* A container for trigonometric operations for specific type. * A container for trigonometric operations for specific type.
* *
@ -72,32 +74,38 @@ public interface TrigonometricOperations<T> : Algebra<T> {
/** /**
* Computes the sine of [arg]. * Computes the sine of [arg].
*/ */
public fun <T : MathElement<out TrigonometricOperations<T>>> sin(arg: T): T = arg.context.sin(arg) @UnstableKMathAPI
public fun <T : AlgebraElement<T, out TrigonometricOperations<T>>> sin(arg: T): T = arg.context.sin(arg)
/** /**
* Computes the cosine of [arg]. * Computes the cosine of [arg].
*/ */
public fun <T : MathElement<out TrigonometricOperations<T>>> cos(arg: T): T = arg.context.cos(arg) @UnstableKMathAPI
public fun <T : AlgebraElement<T, out TrigonometricOperations<T>>> cos(arg: T): T = arg.context.cos(arg)
/** /**
* Computes the tangent of [arg]. * Computes the tangent of [arg].
*/ */
public fun <T : MathElement<out TrigonometricOperations<T>>> tan(arg: T): T = arg.context.tan(arg) @UnstableKMathAPI
public fun <T : AlgebraElement<T, out TrigonometricOperations<T>>> tan(arg: T): T = arg.context.tan(arg)
/** /**
* Computes the inverse sine of [arg]. * Computes the inverse sine of [arg].
*/ */
public fun <T : MathElement<out TrigonometricOperations<T>>> asin(arg: T): T = arg.context.asin(arg) @UnstableKMathAPI
public fun <T : AlgebraElement<T, out TrigonometricOperations<T>>> asin(arg: T): T = arg.context.asin(arg)
/** /**
* Computes the inverse cosine of [arg]. * Computes the inverse cosine of [arg].
*/ */
public fun <T : MathElement<out TrigonometricOperations<T>>> acos(arg: T): T = arg.context.acos(arg) @UnstableKMathAPI
public fun <T : AlgebraElement<T, out TrigonometricOperations<T>>> acos(arg: T): T = arg.context.acos(arg)
/** /**
* Computes the inverse tangent of [arg]. * Computes the inverse tangent of [arg].
*/ */
public fun <T : MathElement<out TrigonometricOperations<T>>> atan(arg: T): T = arg.context.atan(arg) @UnstableKMathAPI
public fun <T : AlgebraElement<T, out TrigonometricOperations<T>>> atan(arg: T): T = arg.context.atan(arg)
/** /**
* A container for hyperbolic trigonometric operations for specific type. * A container for hyperbolic trigonometric operations for specific type.
@ -171,32 +179,38 @@ public interface HyperbolicOperations<T> : Algebra<T> {
/** /**
* Computes the hyperbolic sine of [arg]. * Computes the hyperbolic sine of [arg].
*/ */
public fun <T : MathElement<out HyperbolicOperations<T>>> sinh(arg: T): T = arg.context.sinh(arg) @UnstableKMathAPI
public fun <T : AlgebraElement<T, out HyperbolicOperations<T>>> sinh(arg: T): T = arg.context.sinh(arg)
/** /**
* Computes the hyperbolic cosine of [arg]. * Computes the hyperbolic cosine of [arg].
*/ */
public fun <T : MathElement<out HyperbolicOperations<T>>> cosh(arg: T): T = arg.context.cosh(arg) @UnstableKMathAPI
public fun <T : AlgebraElement<T, out HyperbolicOperations<T>>> cosh(arg: T): T = arg.context.cosh(arg)
/** /**
* Computes the hyperbolic tangent of [arg]. * Computes the hyperbolic tangent of [arg].
*/ */
public fun <T : MathElement<out HyperbolicOperations<T>>> tanh(arg: T): T = arg.context.tanh(arg) @UnstableKMathAPI
public fun <T : AlgebraElement<T, out HyperbolicOperations<T>>> tanh(arg: T): T = arg.context.tanh(arg)
/** /**
* Computes the inverse hyperbolic sine of [arg]. * Computes the inverse hyperbolic sine of [arg].
*/ */
public fun <T : MathElement<out HyperbolicOperations<T>>> asinh(arg: T): T = arg.context.asinh(arg) @UnstableKMathAPI
public fun <T : AlgebraElement<T, out HyperbolicOperations<T>>> asinh(arg: T): T = arg.context.asinh(arg)
/** /**
* Computes the inverse hyperbolic cosine of [arg]. * Computes the inverse hyperbolic cosine of [arg].
*/ */
public fun <T : MathElement<out HyperbolicOperations<T>>> acosh(arg: T): T = arg.context.acosh(arg) @UnstableKMathAPI
public fun <T : AlgebraElement<T, out HyperbolicOperations<T>>> acosh(arg: T): T = arg.context.acosh(arg)
/** /**
* Computes the inverse hyperbolic tangent of [arg]. * Computes the inverse hyperbolic tangent of [arg].
*/ */
public fun <T : MathElement<out HyperbolicOperations<T>>> atanh(arg: T): T = arg.context.atanh(arg) @UnstableKMathAPI
public fun <T : AlgebraElement<T, out HyperbolicOperations<T>>> atanh(arg: T): T = arg.context.atanh(arg)
/** /**
* A context extension to include power operations based on exponentiation. * A context extension to include power operations based on exponentiation.
@ -239,17 +253,20 @@ public interface PowerOperations<T> : Algebra<T> {
* @param power the exponent. * @param power the exponent.
* @return the base raised to the power. * @return the base raised to the power.
*/ */
public infix fun <T : MathElement<out PowerOperations<T>>> T.pow(power: Double): T = context.power(this, power) @UnstableKMathAPI
public infix fun <T : AlgebraElement<T, out PowerOperations<T>>> T.pow(power: Double): T = context.power(this, power)
/** /**
* Computes the square root of the value [arg]. * Computes the square root of the value [arg].
*/ */
public fun <T : MathElement<out PowerOperations<T>>> sqrt(arg: T): T = arg pow 0.5 @UnstableKMathAPI
public fun <T : AlgebraElement<T, out PowerOperations<T>>> sqrt(arg: T): T = arg pow 0.5
/** /**
* Computes the square of the value [arg]. * Computes the square of the value [arg].
*/ */
public fun <T : MathElement<out PowerOperations<T>>> sqr(arg: T): T = arg pow 2.0 @UnstableKMathAPI
public fun <T : AlgebraElement<T, out PowerOperations<T>>> sqr(arg: T): T = arg pow 2.0
/** /**
* A container for operations related to `exp` and `ln` functions. * A container for operations related to `exp` and `ln` functions.
@ -283,12 +300,14 @@ public interface ExponentialOperations<T> : Algebra<T> {
/** /**
* The identifier of exponential function. * The identifier of exponential function.
*/ */
public fun <T : MathElement<out ExponentialOperations<T>>> exp(arg: T): T = arg.context.exp(arg) @UnstableKMathAPI
public fun <T : AlgebraElement<T, out ExponentialOperations<T>>> exp(arg: T): T = arg.context.exp(arg)
/** /**
* The identifier of natural logarithm. * The identifier of natural logarithm.
*/ */
public fun <T : MathElement<out ExponentialOperations<T>>> ln(arg: T): T = arg.context.ln(arg) @UnstableKMathAPI
public fun <T : AlgebraElement<T, out ExponentialOperations<T>>> ln(arg: T): T = arg.context.ln(arg)
/** /**
* A container for norm functional on element. * A container for norm functional on element.
@ -306,4 +325,5 @@ public interface Norm<in T : Any, out R> {
/** /**
* Computes the norm of [arg] (i.e. absolute value or vector length). * Computes the norm of [arg] (i.e. absolute value or vector length).
*/ */
public fun <T : MathElement<out Norm<T, R>>, R> norm(arg: T): R = arg.context.norm(arg) @UnstableKMathAPI
public fun <T : AlgebraElement<T, out Norm<T, R>>, R> norm(arg: T): R = arg.context.norm(arg)

View File

@ -52,23 +52,6 @@ public interface ExtendedField<T> : ExtendedFieldOperations<T>, Field<T>, 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<Double, Real, RealField> {
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. * A field for [Double] without boxing. Does not produce appropriate field element.
*/ */

View File

@ -1,11 +1,13 @@
package kscience.kmath.geometry package kscience.kmath.geometry
import kscience.kmath.linear.Point import kscience.kmath.linear.Point
import kscience.kmath.misc.UnstableKMathAPI
import kscience.kmath.operations.SpaceElement import kscience.kmath.operations.SpaceElement
import kscience.kmath.operations.invoke import kscience.kmath.operations.invoke
import kotlin.math.sqrt import kotlin.math.sqrt
public interface Vector2D : Point<Double>, Vector, SpaceElement<Vector2D, Vector2D, Euclidean2DSpace> { @OptIn(UnstableKMathAPI::class)
public interface Vector2D : Point<Double>, Vector, SpaceElement<Vector2D, Euclidean2DSpace> {
public val x: Double public val x: Double
public val y: Double public val y: Double
public override val context: Euclidean2DSpace get() = Euclidean2DSpace public override val context: Euclidean2DSpace get() = Euclidean2DSpace
@ -18,8 +20,6 @@ public interface Vector2D : Point<Double>, Vector, SpaceElement<Vector2D, Vector
} }
public override operator fun iterator(): Iterator<Double> = listOf(x, y).iterator() public override operator fun iterator(): Iterator<Double> = listOf(x, y).iterator()
public override fun unwrap(): Vector2D = this
public override fun Vector2D.wrap(): Vector2D = this
} }
public val Vector2D.r: Double public val Vector2D.r: Double

View File

@ -1,11 +1,13 @@
package kscience.kmath.geometry package kscience.kmath.geometry
import kscience.kmath.linear.Point import kscience.kmath.linear.Point
import kscience.kmath.misc.UnstableKMathAPI
import kscience.kmath.operations.SpaceElement import kscience.kmath.operations.SpaceElement
import kscience.kmath.operations.invoke import kscience.kmath.operations.invoke
import kotlin.math.sqrt import kotlin.math.sqrt
public interface Vector3D : Point<Double>, Vector, SpaceElement<Vector3D, Vector3D, Euclidean3DSpace> { @OptIn(UnstableKMathAPI::class)
public interface Vector3D : Point<Double>, Vector, SpaceElement<Vector3D, Euclidean3DSpace> {
public val x: Double public val x: Double
public val y: Double public val y: Double
public val z: Double public val z: Double
@ -20,8 +22,6 @@ public interface Vector3D : Point<Double>, Vector, SpaceElement<Vector3D, Vector
} }
public override operator fun iterator(): Iterator<Double> = listOf(x, y, z).iterator() public override operator fun iterator(): Iterator<Double> = listOf(x, y, z).iterator()
public override fun unwrap(): Vector3D = this
public override fun Vector3D.wrap(): Vector3D = this
} }
@Suppress("FunctionName") @Suppress("FunctionName")

View File

@ -8,7 +8,7 @@ import kscience.kmath.operations.invoke
import kscience.kmath.structures.* import kscience.kmath.structures.*
import kotlin.math.floor import kotlin.math.floor
public data class BinDefinition<T : Comparable<T>>( public data class MultivariateBinDefinition<T : Comparable<T>>(
public val space: SpaceOperations<Point<T>>, public val space: SpaceOperations<Point<T>>,
public val center: Point<T>, public val center: Point<T>,
public val sizes: Point<T>, public val sizes: Point<T>,
@ -23,8 +23,9 @@ public data class BinDefinition<T : Comparable<T>>(
public class MultivariateBin<T : Comparable<T>>( public class MultivariateBin<T : Comparable<T>>(
public val definition: BinDefinition<T>, public val definition: MultivariateBinDefinition<T>,
public override val value: Number, public val count: Long,
public override val value: Double,
) : Bin<T> { ) : Bin<T> {
public override val dimension: Int public override val dimension: Int
get() = definition.center.size 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" } 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 * Get internal [NDStructure] bin index for given axis
*/ */
@ -68,11 +68,15 @@ public class RealHistogram(
private fun getIndex(point: Buffer<out Double>): IntArray = IntArray(dimension) { getIndex(it, point[it]) } private fun getIndex(point: Buffer<out Double>): 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<out Double>): Long = getValue(getIndex(point)) public fun getCount(point: Buffer<out Double>): Long = getCount(getIndex(point))
private fun getBinDefinition(index: IntArray): BinDefinition<Double> { private fun getValue(index: IntArray): Double = values[index].sum()
public fun getValue(point: Buffer<out Double>): Double = getValue(getIndex(point))
private fun getBinDefinition(index: IntArray): MultivariateBinDefinition<Double> {
val center = index.mapIndexed { axis, i -> val center = index.mapIndexed { axis, i ->
when (i) { when (i) {
0 -> Double.NEGATIVE_INFINITY 0 -> Double.NEGATIVE_INFINITY
@ -81,14 +85,14 @@ public class RealHistogram(
} }
}.asBuffer() }.asBuffer()
return BinDefinition(RealBufferFieldOperations, center, binSize) return MultivariateBinDefinition(RealBufferFieldOperations, center, binSize)
} }
public fun getBinDefinition(point: Buffer<out Double>): BinDefinition<Double> = getBinDefinition(getIndex(point)) public fun getBinDefinition(point: Buffer<out Double>): MultivariateBinDefinition<Double> = getBinDefinition(getIndex(point))
public override operator fun get(point: Buffer<out Double>): MultivariateBin<Double>? { public override operator fun get(point: Buffer<out Double>): MultivariateBin<Double>? {
val index = getIndex(point) val index = getIndex(point)
return MultivariateBin(getBinDefinition(index), getValue(index)) return MultivariateBin(getBinDefinition(index), getCount(index),getValue(index))
} }
// fun put(point: Point<out Double>){ // fun put(point: Point<out Double>){
@ -103,8 +107,8 @@ public class RealHistogram(
} }
public override operator fun iterator(): Iterator<MultivariateBin<Double>> = public override operator fun iterator(): Iterator<MultivariateBin<Double>> =
values.elements().map { (index, value) -> strides.indices().map { index->
MultivariateBin(getBinDefinition(index), value.sum()) MultivariateBin(getBinDefinition(index), counts[index].sum(), values[index].sum())
}.iterator() }.iterator()
/** /**

View File

@ -2,6 +2,7 @@ package kscience.kmath.histogram
import kscience.kmath.linear.Point import kscience.kmath.linear.Point
import kscience.kmath.misc.UnstableKMathAPI import kscience.kmath.misc.UnstableKMathAPI
import kscience.kmath.operations.SpaceElement
import kscience.kmath.structures.Buffer import kscience.kmath.structures.Buffer
import kscience.kmath.structures.asBuffer import kscience.kmath.structures.asBuffer
import kscience.kmath.structures.asSequence import kscience.kmath.structures.asSequence
@ -38,9 +39,10 @@ public class UnivariateBin(
/** /**
* Univariate histogram with log(n) bin search speed * 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<Double, UnivariateBin> = TreeMap(), protected val bins: TreeMap<Double, UnivariateBin> = TreeMap(),
) : Histogram<Double, UnivariateBin> { ) : Histogram<Double, UnivariateBin>, SpaceElement<UnivariateHistogram, UnivariateHistogramSpace> {
public operator fun get(value: Double): UnivariateBin? { public operator fun get(value: Double): UnivariateBin? {
// check ceiling entry and return it if it is what needed // 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] * 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 = public fun uniformBuilder(binSize: Double, start: Double = 0.0): UnivariateHistogramBuilder =
UnivariateHistogramBuilder { value -> UnivariateHistogramSpace { value ->
val center = start + binSize * floor((value - start) / binSize + 0.5) val center = start + binSize * floor((value - start) / binSize + 0.5)
UnivariateBin(center, binSize) UnivariateBin(center, binSize)
} }.builder()
/** /**
* Build and fill a [UnivariateHistogram]. Returns a read-only histogram. * Build and fill a [UnivariateHistogram]. Returns a read-only histogram.
@ -84,7 +86,7 @@ public abstract class UnivariateHistogram(
public fun customBuilder(borders: DoubleArray): UnivariateHistogramBuilder { public fun customBuilder(borders: DoubleArray): UnivariateHistogramBuilder {
val sorted = borders.sortedArray() val sorted = borders.sortedArray()
return UnivariateHistogramBuilder { value -> return UnivariateHistogramSpace { value ->
when { when {
value < sorted.first() -> UnivariateBin( value < sorted.first() -> UnivariateBin(
Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY,
@ -103,7 +105,7 @@ public abstract class UnivariateHistogram(
UnivariateBin((left + right) / 2, (right - left)) UnivariateBin((left + right) / 2, (right - left))
} }
} }
} }.builder()
} }
/** /**
@ -116,11 +118,11 @@ public abstract class UnivariateHistogram(
} }
} }
public class UnivariateHistogramBuilder( public class UnivariateHistogramBuilder internal constructor(
private val factory: (Double) -> UnivariateBin, override val context: UnivariateHistogramSpace,
) : UnivariateHistogram(), MutableHistogram<Double, UnivariateBin> { ) : UnivariateHistogram(), MutableHistogram<Double, UnivariateBin> {
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 } synchronized(this) { bins[it.position] = it }
} }
@ -128,7 +130,7 @@ public class UnivariateHistogramBuilder(
* Thread safe put operation * Thread safe put operation
*/ */
public fun put(value: Double, weight: Double = 1.0) { public fun put(value: Double, weight: Double = 1.0) {
(get(value) ?: createBin(value)).apply{ (get(value) ?: createBin(value)).apply {
counter.increment() counter.increment()
weightCounter.add(weight) weightCounter.add(weight)
} }
@ -141,8 +143,8 @@ public class UnivariateHistogramBuilder(
/** /**
* Put several items into a single bin * Put several items into a single bin
*/ */
public fun putMany(value: Double, count: Int, weight: Double = count.toDouble()){ public fun putMany(value: Double, count: Int, weight: Double = count.toDouble()) {
(get(value) ?: createBin(value)).apply{ (get(value) ?: createBin(value)).apply {
counter.add(count.toLong()) counter.add(count.toLong())
weightCounter.add(weight) weightCounter.add(weight)
} }

View File

@ -0,0 +1,25 @@
package kscience.kmath.histogram
import kscience.kmath.operations.Space
public class UnivariateHistogramSpace(public val binFactory: (Double) -> UnivariateBin) : Space<UnivariateHistogram> {
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 { }
}

View File

@ -83,7 +83,7 @@ public interface RandomGenerator {
/** /**
* Implements [RandomGenerator] by delegating all operations to [Random]. * Implements [RandomGenerator] by delegating all operations to [Random].
*/ */
public inline class DefaultGenerator(public val random: Random = Random) : RandomGenerator { public class DefaultGenerator(public val random: Random = Random) : RandomGenerator {
public override fun nextBoolean(): Boolean = random.nextBoolean() public override fun nextBoolean(): Boolean = random.nextBoolean()
public override fun nextDouble(): Double = random.nextDouble() public override fun nextDouble(): Double = random.nextDouble()
public override fun nextInt(): Int = random.nextInt() public override fun nextInt(): Int = random.nextInt()

View File

@ -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;D)Lkscience/kmath/nd/NDStructure;
public fun minus (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)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;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 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/Number;)Ljava/lang/Object;
public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)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 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 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;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;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 fun plus-frQ_39w (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lorg/jetbrains/bio/viktor/F64Array;
public synthetic fun pow (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; public 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;Ljava/lang/Object;)Ljava/lang/Object;
public synthetic fun times (Ljava/lang/Object;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure; 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 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 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 (Lkscience/kmath/nd/NDStructure;Lkscience/kmath/nd/NDStructure;)Lkscience/kmath/nd/NDStructure;
public fun times-frQ_39w (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array; public fun times-frQ_39w (Lkscience/kmath/nd/NDStructure;Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array;

View File

@ -8,8 +8,8 @@ pluginManagement {
maven("https://dl.bintray.com/kotlin/kotlinx") maven("https://dl.bintray.com/kotlin/kotlinx")
} }
val toolsVersion = "0.7.4" val toolsVersion = "0.7.5"
val kotlinVersion = "1.4.30-RC" val kotlinVersion = "1.4.30"
plugins { plugins {
id("kotlinx.benchmark") version "0.2.0-dev-20" id("kotlinx.benchmark") version "0.2.0-dev-20"