forked from kscience/kmath
cleanup
This commit is contained in:
parent
9c353f4a0d
commit
6aa5b547b5
@ -32,6 +32,7 @@
|
|||||||
- Number multiplication and division in main Algebra chain
|
- Number multiplication and division in main Algebra chain
|
||||||
- `contentEquals` from Buffer. It moved to the companion.
|
- `contentEquals` from Buffer. It moved to the companion.
|
||||||
- MSTExpression
|
- MSTExpression
|
||||||
|
- Expression algebra builders
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Ring inherits RingOperations, not GroupOperations
|
- Ring inherits RingOperations, not GroupOperations
|
||||||
|
@ -45,13 +45,6 @@ public abstract interface class space/kscience/kmath/expressions/ExpressionAlgeb
|
|||||||
public abstract fun const (Ljava/lang/Object;)Ljava/lang/Object;
|
public abstract fun const (Ljava/lang/Object;)Ljava/lang/Object;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class space/kscience/kmath/expressions/ExpressionBuildersKt {
|
|
||||||
public static final fun extendedFieldExpression (Lspace/kscience/kmath/operations/ExtendedField;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression;
|
|
||||||
public static final fun fieldExpression (Lspace/kscience/kmath/operations/Field;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression;
|
|
||||||
public static final fun ringExpression (Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression;
|
|
||||||
public static final fun spaceExpression (Lspace/kscience/kmath/operations/Ring;Lkotlin/jvm/functions/Function1;)Lspace/kscience/kmath/expressions/Expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final class space/kscience/kmath/expressions/ExpressionKt {
|
public final class space/kscience/kmath/expressions/ExpressionKt {
|
||||||
public static final fun binding (Lspace/kscience/kmath/expressions/ExpressionAlgebra;)Lkotlin/properties/ReadOnlyProperty;
|
public static final fun binding (Lspace/kscience/kmath/expressions/ExpressionAlgebra;)Lkotlin/properties/ReadOnlyProperty;
|
||||||
public static final fun callByString (Lspace/kscience/kmath/expressions/Expression;[Lkotlin/Pair;)Ljava/lang/Object;
|
public static final fun callByString (Lspace/kscience/kmath/expressions/Expression;[Lkotlin/Pair;)Ljava/lang/Object;
|
||||||
@ -705,7 +698,11 @@ public final class space/kscience/kmath/misc/Symbol$Companion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final class space/kscience/kmath/misc/SymbolKt {
|
public final class space/kscience/kmath/misc/SymbolKt {
|
||||||
|
public static final fun get (Ljava/util/Map;Ljava/lang/String;)Ljava/lang/Object;
|
||||||
|
public static final fun get (Ljava/util/Map;Lspace/kscience/kmath/misc/Symbol;)Ljava/lang/Object;
|
||||||
public static final fun getSymbol ()Lkotlin/properties/ReadOnlyProperty;
|
public static final fun getSymbol ()Lkotlin/properties/ReadOnlyProperty;
|
||||||
|
public static final fun set (Ljava/util/Map;Ljava/lang/String;Ljava/lang/Object;)V
|
||||||
|
public static final fun set (Ljava/util/Map;Lspace/kscience/kmath/misc/Symbol;Ljava/lang/Object;)V
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract interface annotation class space/kscience/kmath/misc/UnstableKMathAPI : java/lang/annotation/Annotation {
|
public abstract interface annotation class space/kscience/kmath/misc/UnstableKMathAPI : java/lang/annotation/Annotation {
|
||||||
@ -1209,7 +1206,6 @@ public abstract interface class space/kscience/kmath/operations/ExtendedField :
|
|||||||
public fun acosh (Ljava/lang/Object;)Ljava/lang/Object;
|
public fun acosh (Ljava/lang/Object;)Ljava/lang/Object;
|
||||||
public fun asinh (Ljava/lang/Object;)Ljava/lang/Object;
|
public fun asinh (Ljava/lang/Object;)Ljava/lang/Object;
|
||||||
public fun atanh (Ljava/lang/Object;)Ljava/lang/Object;
|
public fun atanh (Ljava/lang/Object;)Ljava/lang/Object;
|
||||||
public fun bindSymbol (Ljava/lang/String;)Ljava/lang/Object;
|
|
||||||
public fun cosh (Ljava/lang/Object;)Ljava/lang/Object;
|
public fun cosh (Ljava/lang/Object;)Ljava/lang/Object;
|
||||||
public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2;
|
public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2;
|
||||||
public fun sinh (Ljava/lang/Object;)Ljava/lang/Object;
|
public fun sinh (Ljava/lang/Object;)Ljava/lang/Object;
|
||||||
|
@ -33,12 +33,12 @@ public interface SymbolIndexer {
|
|||||||
|
|
||||||
public operator fun DoubleArray.get(symbol: Symbol): Double {
|
public operator fun DoubleArray.get(symbol: Symbol): Double {
|
||||||
require(size == symbols.size) { "The input array size for indexer should be ${symbols.size} but $size found" }
|
require(size == symbols.size) { "The input array size for indexer should be ${symbols.size} but $size found" }
|
||||||
return get(this@SymbolIndexer.indexOf(symbol))
|
return get(indexOf(symbol))
|
||||||
}
|
}
|
||||||
|
|
||||||
public operator fun <T> Point<T>.get(symbol: Symbol): T {
|
public operator fun <T> Point<T>.get(symbol: Symbol): T {
|
||||||
require(size == symbols.size) { "The input buffer size for indexer should be ${symbols.size} but $size found" }
|
require(size == symbols.size) { "The input buffer size for indexer should be ${symbols.size} but $size found" }
|
||||||
return get(this@SymbolIndexer.indexOf(symbol))
|
return get(indexOf(symbol))
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun DoubleArray.toMap(): Map<Symbol, Double> {
|
public fun DoubleArray.toMap(): Map<Symbol, Double> {
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2018-2021 KMath contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package space.kscience.kmath.expressions
|
|
||||||
|
|
||||||
import space.kscience.kmath.operations.ExtendedField
|
|
||||||
import space.kscience.kmath.operations.Field
|
|
||||||
import space.kscience.kmath.operations.Ring
|
|
||||||
import kotlin.contracts.InvocationKind
|
|
||||||
import kotlin.contracts.contract
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a functional expression with this [Ring].
|
|
||||||
*/
|
|
||||||
public inline fun <T> Ring<T>.spaceExpression(block: FunctionalExpressionGroup<T, Ring<T>>.() -> Expression<T>): Expression<T> {
|
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
|
||||||
return FunctionalExpressionGroup(this).block()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a functional expression with this [Ring].
|
|
||||||
*/
|
|
||||||
public inline fun <T> Ring<T>.ringExpression(block: FunctionalExpressionRing<T, Ring<T>>.() -> Expression<T>): Expression<T> {
|
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
|
||||||
return FunctionalExpressionRing(this).block()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a functional expression with this [Field].
|
|
||||||
*/
|
|
||||||
public inline fun <T> Field<T>.fieldExpression(block: FunctionalExpressionField<T, Field<T>>.() -> Expression<T>): Expression<T> {
|
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
|
||||||
return FunctionalExpressionField(this).block()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a functional expression with this [ExtendedField].
|
|
||||||
*/
|
|
||||||
public inline fun <T> ExtendedField<T>.extendedFieldExpression(block: FunctionalExpressionExtendedField<T, ExtendedField<T>>.() -> Expression<T>): Expression<T> {
|
|
||||||
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
|
||||||
return FunctionalExpressionExtendedField(this).block()
|
|
||||||
}
|
|
@ -32,10 +32,33 @@ public value class StringSymbol(override val identity: String) : Symbol {
|
|||||||
override fun toString(): String = identity
|
override fun toString(): String = identity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 { _, property ->
|
public val symbol: ReadOnlyProperty<Any?, Symbol> = ReadOnlyProperty { _, property ->
|
||||||
StringSymbol(property.name)
|
StringSymbol(property.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ger a value from a [String]-keyed map by a [Symbol]
|
||||||
|
*/
|
||||||
|
public operator fun <T> Map<String, T>.get(symbol: Symbol): T? = get(symbol.identity)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a value of [String]-keyed map by a [Symbol]
|
||||||
|
*/
|
||||||
|
public operator fun <T> MutableMap<String, T>.set(symbol: Symbol, value: T){
|
||||||
|
set(symbol.identity, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a value from a [Symbol]-keyed map by a [String]
|
||||||
|
*/
|
||||||
|
public operator fun <T> Map<Symbol, T>.get(string: String): T? = get(StringSymbol(string))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a value of [String]-keyed map by a [Symbol]
|
||||||
|
*/
|
||||||
|
public operator fun <T> MutableMap<Symbol, T>.set(string: String, value: T){
|
||||||
|
set(StringSymbol(string), value)
|
||||||
|
}
|
@ -44,9 +44,9 @@ public interface Algebra<T> {
|
|||||||
/**
|
/**
|
||||||
* Dynamically dispatches an unary operation with the certain name.
|
* Dynamically dispatches an unary operation with the certain name.
|
||||||
*
|
*
|
||||||
* This function must follow two properties:
|
* This function must has two features:
|
||||||
*
|
*
|
||||||
* 1. In case if operation is not defined in the structure, the function throws [kotlin.IllegalStateException].
|
* 1. In case operation is not defined in the structure, the function throws [kotlin.IllegalStateException].
|
||||||
* 2. This function is symmetric with second `unaryOperation` overload:
|
* 2. This function is symmetric with second `unaryOperation` overload:
|
||||||
* i.e. `unaryOperationFunction(a)(b) == unaryOperation(a, b)`.
|
* i.e. `unaryOperationFunction(a)(b) == unaryOperation(a, b)`.
|
||||||
*
|
*
|
||||||
|
@ -97,14 +97,12 @@ public interface NumericAlgebra<T> : Algebra<T> {
|
|||||||
/**
|
/**
|
||||||
* The π mathematical constant.
|
* The π mathematical constant.
|
||||||
*/
|
*/
|
||||||
public val <T> NumericAlgebra<T>.pi: T
|
public val <T> NumericAlgebra<T>.pi: T get() = bindSymbolOrNull("pi") ?: number(PI)
|
||||||
get() = bindSymbolOrNull("pi") ?: number(PI)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The *e* mathematical constant.
|
* The *e* mathematical constant.
|
||||||
*/
|
*/
|
||||||
public val <T> NumericAlgebra<T>.e: T
|
public val <T> NumericAlgebra<T>.e: T get() = number(E)
|
||||||
get() = number(E)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scale by scalar operations
|
* Scale by scalar operations
|
||||||
|
@ -49,12 +49,6 @@ public interface ExtendedField<T> : ExtendedFieldOperations<T>, Field<T>, Numeri
|
|||||||
public override fun acosh(arg: T): T = ln(arg + sqrt((arg - one) * (arg + one)))
|
public override fun acosh(arg: T): T = ln(arg + sqrt((arg - one) * (arg + one)))
|
||||||
public override fun atanh(arg: T): T = (ln(arg + one) - ln(one - arg)) / 2.0
|
public override fun atanh(arg: T): T = (ln(arg + one) - ln(one - arg)) / 2.0
|
||||||
|
|
||||||
public override fun bindSymbol(value: String): T = when (value) {
|
|
||||||
"pi" -> pi
|
|
||||||
"e" -> e
|
|
||||||
else -> super<ExtendedFieldOperations>.bindSymbol(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
public override fun rightSideNumberOperationFunction(operation: String): (left: T, right: Number) -> T =
|
public override fun rightSideNumberOperationFunction(operation: String): (left: T, right: Number) -> T =
|
||||||
when (operation) {
|
when (operation) {
|
||||||
PowerOperations.POW_OPERATION -> ::power
|
PowerOperations.POW_OPERATION -> ::power
|
||||||
|
Loading…
Reference in New Issue
Block a user