Dev #280

Merged
altavir merged 99 commits from dev into master 2021-04-16 19:45:55 +03:00
40 changed files with 457 additions and 1240 deletions
Showing only changes of commit e2ceb64d36 - Show all commits

View File

@ -7,6 +7,8 @@
- Basic integration API - Basic integration API
- Basic MPP distributions and samplers - Basic MPP distributions and samplers
- bindSymbolOrNull - bindSymbolOrNull
- Blocking chains and Statistics
- Multiplatform integration
### Changed ### Changed
- Exponential operations merged with hyperbolic functions - Exponential operations merged with hyperbolic functions
@ -29,6 +31,7 @@
- MSTExpression - MSTExpression
### Fixed ### Fixed
- Ring inherits RingOperations, not GroupOperations
### Security ### Security

View File

@ -114,7 +114,10 @@ kotlin.sourceSets.all {
} }
tasks.withType<KotlinCompile> { tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11" kotlinOptions{
jvmTarget = "11"
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all"
}
} }
readme { readme {

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@ import space.kscience.kmath.linear.Point
import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.misc.UnstableKMathAPI
@UnstableKMathAPI @UnstableKMathAPI
public inline class UnivariateDomain(public val range: ClosedFloatingPointRange<Double>) : DoubleDomain { public class UnivariateDomain(public val range: ClosedFloatingPointRange<Double>) : DoubleDomain {
public override val dimension: Int get() = 1 public override val dimension: Int get() = 1
public operator fun contains(d: Double): Boolean = range.contains(d) public operator fun contains(d: Double): Boolean = range.contains(d)

View File

@ -44,7 +44,7 @@ public abstract class FunctionalExpressionAlgebra<T, A : Algebra<T>>(
} }
/** /**
* A context class for [Expression] construction for [Group] algebras. * A context class for [Expression] construction for [Ring] algebras.
*/ */
public open class FunctionalExpressionGroup<T, A : Group<T>>( public open class FunctionalExpressionGroup<T, A : Group<T>>(
algebra: A, algebra: A,
@ -168,7 +168,7 @@ public open class FunctionalExpressionExtendedField<T, A : ExtendedField<T>>(
public override fun bindSymbol(value: String): Expression<T> = super<FunctionalExpressionField>.bindSymbol(value) public override fun bindSymbol(value: String): Expression<T> = super<FunctionalExpressionField>.bindSymbol(value)
} }
public inline fun <T, A : Group<T>> A.expressionInSpace(block: FunctionalExpressionGroup<T, A>.() -> Expression<T>): Expression<T> = public inline fun <T, A : Ring<T>> A.expressionInSpace(block: FunctionalExpressionGroup<T, A>.() -> Expression<T>): Expression<T> =
FunctionalExpressionGroup(this).block() FunctionalExpressionGroup(this).block()
public inline fun <T, A : Ring<T>> A.expressionInRing(block: FunctionalExpressionRing<T, A>.() -> Expression<T>): Expression<T> = public inline fun <T, A : Ring<T>> A.expressionInRing(block: FunctionalExpressionRing<T, A>.() -> Expression<T>): Expression<T> =

View File

@ -19,7 +19,7 @@ public object MstAlgebra : NumericAlgebra<MST> {
} }
/** /**
* [Group] over [MST] nodes. * [Ring] over [MST] nodes.
*/ */
public object MstGroup : Group<MST>, NumericAlgebra<MST>, ScaleOperations<MST> { public object MstGroup : Group<MST>, NumericAlgebra<MST>, ScaleOperations<MST> {
public override val zero: MST.Numeric = number(0.0) public override val zero: MST.Numeric = number(0.0)

View File

@ -5,6 +5,7 @@ import space.kscience.kmath.misc.Symbol
import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.misc.UnstableKMathAPI
import space.kscience.kmath.nd.Structure2D import space.kscience.kmath.nd.Structure2D
import space.kscience.kmath.structures.BufferFactory import space.kscience.kmath.structures.BufferFactory
import kotlin.jvm.JvmInline
/** /**
* An environment to easy transform indexed variables to symbols and back. * An environment to easy transform indexed variables to symbols and back.
@ -53,7 +54,8 @@ public interface SymbolIndexer {
} }
@UnstableKMathAPI @UnstableKMathAPI
public inline class SimpleSymbolIndexer(override val symbols: List<Symbol>) : SymbolIndexer @JvmInline
public value class SimpleSymbolIndexer(override val symbols: List<Symbol>) : SymbolIndexer
/** /**
* Execute the block with symbol indexer based on given symbol order * Execute the block with symbol indexer based on given symbol order

View File

@ -2,16 +2,15 @@ package space.kscience.kmath.expressions
import space.kscience.kmath.operations.ExtendedField import space.kscience.kmath.operations.ExtendedField
import space.kscience.kmath.operations.Field import space.kscience.kmath.operations.Field
import space.kscience.kmath.operations.Group
import space.kscience.kmath.operations.Ring import space.kscience.kmath.operations.Ring
import kotlin.contracts.InvocationKind import kotlin.contracts.InvocationKind
import kotlin.contracts.contract import kotlin.contracts.contract
/** /**
* Creates a functional expression with this [Group]. * Creates a functional expression with this [Ring].
*/ */
public inline fun <T> Group<T>.spaceExpression(block: FunctionalExpressionGroup<T, Group<T>>.() -> Expression<T>): Expression<T> { public inline fun <T> Ring<T>.spaceExpression(block: FunctionalExpressionGroup<T, Ring<T>>.() -> Expression<T>): Expression<T> {
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
return FunctionalExpressionGroup(this).block() return FunctionalExpressionGroup(this).block()
} }

View File

@ -1,5 +1,6 @@
package space.kscience.kmath.misc package space.kscience.kmath.misc
import kotlin.jvm.JvmInline
import kotlin.properties.ReadOnlyProperty import kotlin.properties.ReadOnlyProperty
/** /**
@ -21,7 +22,8 @@ public interface Symbol {
/** /**
* A [Symbol] with a [String] identity * A [Symbol] with a [String] identity
*/ */
public inline class StringSymbol(override val identity: String) : Symbol { @JvmInline
public value class StringSymbol(override val identity: String) : Symbol {
override fun toString(): String = identity override fun toString(): String = identity
} }

View File

@ -1,6 +1,6 @@
package space.kscience.kmath.misc package space.kscience.kmath.misc
import space.kscience.kmath.operations.Group import space.kscience.kmath.operations.Ring
import space.kscience.kmath.operations.invoke import space.kscience.kmath.operations.invoke
import kotlin.jvm.JvmName import kotlin.jvm.JvmName
@ -37,7 +37,7 @@ public fun <T, R> List<T>.cumulative(initial: R, operation: (R, T) -> R): List<R
/** /**
* Cumulative sum with custom space * Cumulative sum with custom space
*/ */
public fun <T> Iterable<T>.cumulativeSum(group: Group<T>): Iterable<T> = public fun <T> Iterable<T>.cumulativeSum(group: Ring<T>): Iterable<T> =
group { cumulative(zero) { element: T, sum: T -> sum + element } } group { cumulative(zero) { element: T, sum: T -> sum + element } }
@JvmName("cumulativeSumOfDouble") @JvmName("cumulativeSumOfDouble")
@ -49,7 +49,7 @@ public fun Iterable<Int>.cumulativeSum(): Iterable<Int> = cumulative(0) { elemen
@JvmName("cumulativeSumOfLong") @JvmName("cumulativeSumOfLong")
public fun Iterable<Long>.cumulativeSum(): Iterable<Long> = cumulative(0L) { element, sum -> sum + element } public fun Iterable<Long>.cumulativeSum(): Iterable<Long> = cumulative(0L) { element, sum -> sum + element }
public fun <T> Sequence<T>.cumulativeSum(group: Group<T>): Sequence<T> = public fun <T> Sequence<T>.cumulativeSum(group: Ring<T>): Sequence<T> =
group { cumulative(zero) { element: T, sum: T -> sum + element } } group { cumulative(zero) { element: T, sum: T -> sum + element } }
@JvmName("cumulativeSumOfDouble") @JvmName("cumulativeSumOfDouble")
@ -61,7 +61,7 @@ public fun Sequence<Int>.cumulativeSum(): Sequence<Int> = cumulative(0) { elemen
@JvmName("cumulativeSumOfLong") @JvmName("cumulativeSumOfLong")
public fun Sequence<Long>.cumulativeSum(): Sequence<Long> = cumulative(0L) { element, sum -> sum + element } public fun Sequence<Long>.cumulativeSum(): Sequence<Long> = cumulative(0L) { element, sum -> sum + element }
public fun <T> List<T>.cumulativeSum(group: Group<T>): List<T> = public fun <T> List<T>.cumulativeSum(group: Ring<T>): List<T> =
group { cumulative(zero) { element: T, sum: T -> sum + element } } group { cumulative(zero) { element: T, sum: T -> sum + element } }
@JvmName("cumulativeSumOfDouble") @JvmName("cumulativeSumOfDouble")

View File

@ -80,13 +80,13 @@ public open class BufferedFieldND<T, R : Field<T>>(
} }
// group factories // group factories
public fun <T, A : Group<T>> AlgebraND.Companion.group( public fun <T, A : Ring<T>> AlgebraND.Companion.group(
space: A, space: A,
bufferFactory: BufferFactory<T>, bufferFactory: BufferFactory<T>,
vararg shape: Int, vararg shape: Int,
): BufferedGroupND<T, A> = BufferedGroupND(shape, space, bufferFactory) ): BufferedGroupND<T, A> = BufferedGroupND(shape, space, bufferFactory)
public inline fun <T, A : Group<T>, R> A.ndGroup( public inline fun <T, A : Ring<T>, R> A.ndGroup(
noinline bufferFactory: BufferFactory<T>, noinline bufferFactory: BufferFactory<T>,
vararg shape: Int, vararg shape: Int,
action: BufferedGroupND<T, A>.() -> R, action: BufferedGroupND<T, A>.() -> R,

View File

@ -2,6 +2,7 @@ package space.kscience.kmath.nd
import space.kscience.kmath.structures.Buffer import space.kscience.kmath.structures.Buffer
import space.kscience.kmath.structures.asSequence import space.kscience.kmath.structures.asSequence
import kotlin.jvm.JvmInline
/** /**
* A structure that is guaranteed to be one-dimensional * A structure that is guaranteed to be one-dimensional
@ -22,7 +23,8 @@ public interface Structure1D<T> : StructureND<T>, Buffer<T> {
/** /**
* A 1D wrapper for nd-structure * A 1D wrapper for nd-structure
*/ */
private inline class Structure1DWrapper<T>(val structure: StructureND<T>) : Structure1D<T> { @JvmInline
private value class Structure1DWrapper<T>(val structure: StructureND<T>) : Structure1D<T> {
override val shape: IntArray get() = structure.shape override val shape: IntArray get() = structure.shape
override val size: Int get() = structure.shape[0] override val size: Int get() = structure.shape[0]
@ -34,7 +36,8 @@ private inline class Structure1DWrapper<T>(val structure: StructureND<T>) : Stru
/** /**
* A structure wrapper for buffer * A structure wrapper for buffer
*/ */
private inline class Buffer1DWrapper<T>(val buffer: Buffer<T>) : Structure1D<T> { @JvmInline
private value class Buffer1DWrapper<T>(val buffer: Buffer<T>) : Structure1D<T> {
override val shape: IntArray get() = intArrayOf(buffer.size) override val shape: IntArray get() = intArrayOf(buffer.size)
override val size: Int get() = buffer.size override val size: Int get() = buffer.size

View File

@ -3,6 +3,7 @@ package space.kscience.kmath.nd
import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.misc.UnstableKMathAPI
import space.kscience.kmath.structures.Buffer import space.kscience.kmath.structures.Buffer
import space.kscience.kmath.structures.VirtualBuffer import space.kscience.kmath.structures.VirtualBuffer
import kotlin.jvm.JvmInline
import kotlin.reflect.KClass import kotlin.reflect.KClass
/** /**
@ -60,7 +61,8 @@ public interface Structure2D<T> : StructureND<T> {
/** /**
* A 2D wrapper for nd-structure * A 2D wrapper for nd-structure
*/ */
private inline class Structure2DWrapper<T>(val structure: StructureND<T>) : Structure2D<T> { @JvmInline
private value class Structure2DWrapper<T>(val structure: StructureND<T>) : Structure2D<T> {
override val shape: IntArray get() = structure.shape override val shape: IntArray get() = structure.shape
override val rowNum: Int get() = shape[0] override val rowNum: Int get() = shape[0]

View File

@ -50,7 +50,7 @@ public operator fun <T : AlgebraElement<T, S>, S : NumbersAddOperations<T>> T.mi
* @param b the addend. * @param b the addend.
* @return the sum. * @return the sum.
*/ */
public operator fun <T : AlgebraElement<T, S>, S : Group<T>> T.plus(b: T): T = public operator fun <T : AlgebraElement<T, S>, S : Ring<T>> T.plus(b: T): T =
context.add(this, b) context.add(this, b)
///** ///**
@ -88,7 +88,7 @@ public operator fun <T : AlgebraElement<T, F>, F : Field<T>> T.div(b: T): T =
* @param S the type of space. * @param S the type of space.
*/ */
@UnstableKMathAPI @UnstableKMathAPI
public interface SpaceElement<T : SpaceElement<T, S>, S : Group<T>> : AlgebraElement<T, S> public interface GroupElement<T : GroupElement<T, S>, S : Group<T>> : AlgebraElement<T, S>
/** /**
* The element of [Ring]. * The element of [Ring].
@ -98,7 +98,7 @@ public interface SpaceElement<T : SpaceElement<T, S>, S : Group<T>> : AlgebraEle
* @param R the type of ring. * @param R the type of ring.
*/ */
@UnstableKMathAPI @UnstableKMathAPI
public interface RingElement<T : RingElement<T, R>, R : Ring<T>> : SpaceElement<T, R> public interface RingElement<T : RingElement<T, R>, R : Ring<T>> : GroupElement<T, R>
/** /**
* The element of [Field]. * The element of [Field].

View File

@ -440,7 +440,7 @@ public fun String.parseBigInteger(): BigInt? {
var res = BigInt.ZERO var res = BigInt.ZERO
var digitValue = BigInt.ONE var digitValue = BigInt.ONE
val sPositiveUpper = sPositive.toUpperCase() val sPositiveUpper = sPositive.uppercase()
if (sPositiveUpper.startsWith("0X")) { // hex representation if (sPositiveUpper.startsWith("0X")) { // hex representation
val sHex = sPositiveUpper.substring(2) val sHex = sPositiveUpper.substring(2)
@ -456,7 +456,7 @@ public fun String.parseBigInteger(): BigInt? {
if (ch !in '0'..'9') { if (ch !in '0'..'9') {
return null return null
} }
res += digitValue * (ch.toInt() - '0'.toInt()) res += digitValue * (ch.code - '0'.code)
digitValue *= 10.toBigInt() digitValue *= 10.toBigInt()
} }

View File

@ -147,7 +147,7 @@ public interface ScaleOperations<T> : Algebra<T> {
* TODO to be removed and replaced by extensions after multiple receivers are there * TODO to be removed and replaced by extensions after multiple receivers are there
*/ */
@UnstableKMathAPI @UnstableKMathAPI
public interface NumbersAddOperations<T> : Group<T>, NumericAlgebra<T> { public interface NumbersAddOperations<T> : Ring<T>, NumericAlgebra<T> {
/** /**
* Addition of element and scalar. * Addition of element and scalar.
* *

View File

@ -1,53 +1,53 @@
package space.kscience.kmath.operations package space.kscience.kmath.operations
/** /**
* Returns the sum of all elements in the iterable in this [Group]. * Returns the sum of all elements in the iterable in this [Ring].
* *
* @receiver the algebra that provides addition. * @receiver the algebra that provides addition.
* @param data the iterable to sum up. * @param data the iterable to sum up.
* @return the sum. * @return the sum.
*/ */
public fun <T> Group<T>.sum(data: Iterable<T>): T = data.fold(zero) { left, right -> public fun <T> Ring<T>.sum(data: Iterable<T>): T = data.fold(zero) { left, right ->
add(left, right) add(left, right)
} }
/** /**
* Returns the sum of all elements in the sequence in this [Group]. * Returns the sum of all elements in the sequence in this [Ring].
* *
* @receiver the algebra that provides addition. * @receiver the algebra that provides addition.
* @param data the sequence to sum up. * @param data the sequence to sum up.
* @return the sum. * @return the sum.
*/ */
public fun <T> Group<T>.sum(data: Sequence<T>): T = data.fold(zero) { left, right -> public fun <T> Ring<T>.sum(data: Sequence<T>): T = data.fold(zero) { left, right ->
add(left, right) add(left, right)
} }
/** /**
* Returns an average value of elements in the iterable in this [Group]. * Returns an average value of elements in the iterable in this [Ring].
* *
* @receiver the algebra that provides addition and division. * @receiver the algebra that provides addition and division.
* @param data the iterable to find average. * @param data the iterable to find average.
* @return the average value. * @return the average value.
* @author Iaroslav Postovalov * @author Iaroslav Postovalov
*/ */
public fun <T, S> S.average(data: Iterable<T>): T where S : Group<T>, S : ScaleOperations<T> = public fun <T, S> S.average(data: Iterable<T>): T where S : Ring<T>, S : ScaleOperations<T> =
sum(data) / data.count() sum(data) / data.count()
/** /**
* Returns an average value of elements in the sequence in this [Group]. * Returns an average value of elements in the sequence in this [Ring].
* *
* @receiver the algebra that provides addition and division. * @receiver the algebra that provides addition and division.
* @param data the sequence to find average. * @param data the sequence to find average.
* @return the average value. * @return the average value.
* @author Iaroslav Postovalov * @author Iaroslav Postovalov
*/ */
public fun <T, S> S.average(data: Sequence<T>): T where S : Group<T>, S : ScaleOperations<T> = public fun <T, S> S.average(data: Sequence<T>): T where S : Ring<T>, S : ScaleOperations<T> =
sum(data) / data.count() sum(data) / data.count()
/** /**
* Absolute of the comparable [value] * Absolute of the comparable [value]
*/ */
public fun <T : Comparable<T>> Group<T>.abs(value: T): T = if (value > zero) value else -value public fun <T : Comparable<T>> Ring<T>.abs(value: T): T = if (value > zero) value else -value
/** /**
* Returns the sum of all elements in the iterable in provided space. * Returns the sum of all elements in the iterable in provided space.
@ -56,7 +56,7 @@ public fun <T : Comparable<T>> Group<T>.abs(value: T): T = if (value > zero) val
* @param group the algebra that provides addition. * @param group the algebra that provides addition.
* @return the sum. * @return the sum.
*/ */
public fun <T> Iterable<T>.sumWith(group: Group<T>): T = group.sum(this) public fun <T> Iterable<T>.sumWith(group: Ring<T>): T = group.sum(this)
/** /**
* Returns the sum of all elements in the sequence in provided space. * Returns the sum of all elements in the sequence in provided space.
@ -65,28 +65,28 @@ public fun <T> Iterable<T>.sumWith(group: Group<T>): T = group.sum(this)
* @param group the algebra that provides addition. * @param group the algebra that provides addition.
* @return the sum. * @return the sum.
*/ */
public fun <T> Sequence<T>.sumWith(group: Group<T>): T = group.sum(this) public fun <T> Sequence<T>.sumWith(group: Ring<T>): T = group.sum(this)
/** /**
* Returns an average value of elements in the iterable in this [Group]. * Returns an average value of elements in the iterable in this [Ring].
* *
* @receiver the iterable to find average. * @receiver the iterable to find average.
* @param space the algebra that provides addition and division. * @param space the algebra that provides addition and division.
* @return the average value. * @return the average value.
* @author Iaroslav Postovalov * @author Iaroslav Postovalov
*/ */
public fun <T, S> Iterable<T>.averageWith(space: S): T where S : Group<T>, S : ScaleOperations<T> = public fun <T, S> Iterable<T>.averageWith(space: S): T where S : Ring<T>, S : ScaleOperations<T> =
space.average(this) space.average(this)
/** /**
* Returns an average value of elements in the sequence in this [Group]. * Returns an average value of elements in the sequence in this [Ring].
* *
* @receiver the sequence to find average. * @receiver the sequence to find average.
* @param space the algebra that provides addition and division. * @param space the algebra that provides addition and division.
* @return the average value. * @return the average value.
* @author Iaroslav Postovalov * @author Iaroslav Postovalov
*/ */
public fun <T, S> Sequence<T>.averageWith(space: S): T where S : Group<T>, S : ScaleOperations<T> = public fun <T, S> Sequence<T>.averageWith(space: S): T where S : Ring<T>, S : ScaleOperations<T> =
space.average(this) space.average(this)
//TODO optimized power operation //TODO optimized power operation

View File

@ -1,5 +1,6 @@
package space.kscience.kmath.structures package space.kscience.kmath.structures
import kotlin.jvm.JvmInline
import kotlin.reflect.KClass import kotlin.reflect.KClass
/** /**
@ -187,9 +188,8 @@ public interface MutableBuffer<T> : Buffer<T> {
* @param T the type of elements contained in the buffer. * @param T the type of elements contained in the buffer.
* @property list The underlying list. * @property list The underlying list.
*/ */
public inline class ListBuffer<T>(public val list: List<T>) : Buffer<T> { public class ListBuffer<T>(public val list: List<T>) : Buffer<T> {
override val size: Int override val size: Int get() = list.size
get() = list.size
override operator fun get(index: Int): T = list[index] override operator fun get(index: Int): T = list[index]
override operator fun iterator(): Iterator<T> = list.iterator() override operator fun iterator(): Iterator<T> = list.iterator()
@ -206,7 +206,8 @@ public fun <T> List<T>.asBuffer(): ListBuffer<T> = ListBuffer(this)
* @param T the type of elements contained in the buffer. * @param T the type of elements contained in the buffer.
* @property list The underlying list. * @property list The underlying list.
*/ */
public inline class MutableListBuffer<T>(public val list: MutableList<T>) : MutableBuffer<T> { @JvmInline
public value class MutableListBuffer<T>(public val list: MutableList<T>) : MutableBuffer<T> {
override val size: Int override val size: Int
get() = list.size get() = list.size
@ -257,7 +258,8 @@ public fun <T> Array<T>.asBuffer(): ArrayBuffer<T> = ArrayBuffer(this)
* @param T the type of elements contained in the buffer. * @param T the type of elements contained in the buffer.
* @property buffer The underlying buffer. * @property buffer The underlying buffer.
*/ */
public inline class ReadOnlyBuffer<T>(public val buffer: MutableBuffer<T>) : Buffer<T> { @JvmInline
public value class ReadOnlyBuffer<T>(public val buffer: MutableBuffer<T>) : Buffer<T> {
override val size: Int get() = buffer.size override val size: Int get() = buffer.size
override operator fun get(index: Int): T = buffer[index] override operator fun get(index: Int): T = buffer[index]

View File

@ -1,12 +1,14 @@
package space.kscience.kmath.structures package space.kscience.kmath.structures
import kotlin.jvm.JvmInline
/** /**
* Specialized [MutableBuffer] implementation over [DoubleArray]. * Specialized [MutableBuffer] implementation over [DoubleArray].
* *
* @property array the underlying array. * @property array the underlying array.
*/ */
@Suppress("OVERRIDE_BY_INLINE") @JvmInline
public inline class DoubleBuffer(public val array: DoubleArray) : MutableBuffer<Double> { public value class DoubleBuffer(public val array: DoubleArray) : MutableBuffer<Double> {
override val size: Int get() = array.size override val size: Int get() = array.size
override operator fun get(index: Int): Double = array[index] override operator fun get(index: Int): Double = array[index]

View File

@ -1,12 +1,15 @@
package space.kscience.kmath.structures package space.kscience.kmath.structures
import kotlin.jvm.JvmInline
/** /**
* Specialized [MutableBuffer] implementation over [FloatArray]. * Specialized [MutableBuffer] implementation over [FloatArray].
* *
* @property array the underlying array. * @property array the underlying array.
* @author Iaroslav Postovalov * @author Iaroslav Postovalov
*/ */
public inline class FloatBuffer(public val array: FloatArray) : MutableBuffer<Float> { @JvmInline
public value class FloatBuffer(public val array: FloatArray) : MutableBuffer<Float> {
override val size: Int get() = array.size override val size: Int get() = array.size
override operator fun get(index: Int): Float = array[index] override operator fun get(index: Int): Float = array[index]

View File

@ -1,11 +1,14 @@
package space.kscience.kmath.structures package space.kscience.kmath.structures
import kotlin.jvm.JvmInline
/** /**
* Specialized [MutableBuffer] implementation over [IntArray]. * Specialized [MutableBuffer] implementation over [IntArray].
* *
* @property array the underlying array. * @property array the underlying array.
*/ */
public inline class IntBuffer(public val array: IntArray) : MutableBuffer<Int> { @JvmInline
public value class IntBuffer(public val array: IntArray) : MutableBuffer<Int> {
override val size: Int get() = array.size override val size: Int get() = array.size
override operator fun get(index: Int): Int = array[index] override operator fun get(index: Int): Int = array[index]

View File

@ -1,11 +1,14 @@
package space.kscience.kmath.structures package space.kscience.kmath.structures
import kotlin.jvm.JvmInline
/** /**
* Specialized [MutableBuffer] implementation over [LongArray]. * Specialized [MutableBuffer] implementation over [LongArray].
* *
* @property array the underlying array. * @property array the underlying array.
*/ */
public inline class LongBuffer(public val array: LongArray) : MutableBuffer<Long> { @JvmInline
public value class LongBuffer(public val array: LongArray) : MutableBuffer<Long> {
override val size: Int get() = array.size override val size: Int get() = array.size
override operator fun get(index: Int): Long = array[index] override operator fun get(index: Int): Long = array[index]

View File

@ -1,11 +1,14 @@
package space.kscience.kmath.structures package space.kscience.kmath.structures
import kotlin.jvm.JvmInline
/** /**
* Specialized [MutableBuffer] implementation over [ShortArray]. * Specialized [MutableBuffer] implementation over [ShortArray].
* *
* @property array the underlying array. * @property array the underlying array.
*/ */
public inline class ShortBuffer(public val array: ShortArray) : MutableBuffer<Short> { @JvmInline
public value class ShortBuffer(public val array: ShortArray) : MutableBuffer<Short> {
public override val size: Int get() = array.size public override val size: Int get() = array.size
public override operator fun get(index: Int): Short = array[index] public override operator fun get(index: Int): Short = array[index]

View File

@ -53,12 +53,18 @@ public fun <T> Buffer<T>.toMutableList(): MutableList<T> = when (this) {
public inline fun <reified T> Buffer<T>.toTypedArray(): Array<T> = Array(size, ::get) public inline fun <reified T> Buffer<T>.toTypedArray(): Array<T> = Array(size, ::get)
/** /**
* Create a new buffer from this one with the given mapping function. * Create a new buffer from this one with the given mapping function and using [Buffer.Companion.auto] buffer factory.
* Provided [BufferFactory] is used to construct the new buffer.
*/ */
public inline fun <T : Any, reified R : Any> Buffer<T>.map( public inline fun <T : Any, reified R : Any> Buffer<T>.map(block: (T) -> R): Buffer<R> =
bufferFactory: BufferFactory<R> = Buffer.Companion::auto, Buffer.auto(size) { block(get(it)) }
crossinline block: (T) -> R,
/**
* Create a new buffer from this one with the given mapping function.
* Provided [bufferFactory] is used to construct the new buffer.
*/
public fun <T : Any, R : Any> Buffer<T>.map(
bufferFactory: BufferFactory<R>,
block: (T) -> R,
): Buffer<R> = bufferFactory(size) { block(get(it)) } ): Buffer<R> = bufferFactory(size) { block(get(it)) }
/** /**

View File

@ -1,6 +1,6 @@
package space.kscience.kmath.testutils package space.kscience.kmath.testutils
import space.kscience.kmath.operations.Group import space.kscience.kmath.operations.Ring
import space.kscience.kmath.operations.ScaleOperations import space.kscience.kmath.operations.ScaleOperations
import space.kscience.kmath.operations.invoke import space.kscience.kmath.operations.invoke
import kotlin.test.assertEquals import kotlin.test.assertEquals
@ -12,7 +12,7 @@ internal open class SpaceVerifier<T, out S>(
val b: T, val b: T,
val c: T, val c: T,
val x: Number, val x: Number,
) : AlgebraicVerifier<T, Group<T>> where S : Group<T>, S : ScaleOperations<T> { ) : AlgebraicVerifier<T, Ring<T>> where S : Ring<T>, S : ScaleOperations<T> {
override fun verify() { override fun verify() {
algebra { algebra {
assertEquals(a + b + c, a + (b + c), "Addition in $algebra is not associative.") assertEquals(a + b + c, a + (b + c), "Addition in $algebra is not associative.")

View File

@ -5,8 +5,8 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.runningReduce import kotlinx.coroutines.flow.runningReduce
import kotlinx.coroutines.flow.scan import kotlinx.coroutines.flow.scan
import space.kscience.kmath.operations.Group
import space.kscience.kmath.operations.GroupOperations import space.kscience.kmath.operations.GroupOperations
import space.kscience.kmath.operations.Ring
import space.kscience.kmath.operations.ScaleOperations import space.kscience.kmath.operations.ScaleOperations
import space.kscience.kmath.operations.invoke import space.kscience.kmath.operations.invoke
@ -14,7 +14,7 @@ public fun <T> Flow<T>.cumulativeSum(group: GroupOperations<T>): Flow<T> =
group { runningReduce { sum, element -> sum + element } } group { runningReduce { sum, element -> sum + element } }
@ExperimentalCoroutinesApi @ExperimentalCoroutinesApi
public fun <T, S> Flow<T>.mean(space: S): Flow<T> where S : Group<T>, S : ScaleOperations<T> = space { public fun <T, S> Flow<T>.mean(space: S): Flow<T> where S : Ring<T>, S : ScaleOperations<T> = space {
data class Accumulator(var sum: T, var num: Int) data class Accumulator(var sum: T, var num: Int)
scan(Accumulator(zero, 0)) { sum, element -> scan(Accumulator(zero, 0)) { sum, element ->

View File

@ -7,6 +7,7 @@ import space.kscience.kmath.linear.transpose
import space.kscience.kmath.nd.Structure2D import space.kscience.kmath.nd.Structure2D
import space.kscience.kmath.operations.DoubleField import space.kscience.kmath.operations.DoubleField
import space.kscience.kmath.operations.Ring import space.kscience.kmath.operations.Ring
import kotlin.jvm.JvmInline
/** /**
* A matrix with compile-time controlled dimension * A matrix with compile-time controlled dimension
@ -39,7 +40,8 @@ public interface DMatrix<T, R : Dimension, C : Dimension> : Structure2D<T> {
/** /**
* An inline wrapper for a Matrix * An inline wrapper for a Matrix
*/ */
public inline class DMatrixWrapper<T, R : Dimension, C : Dimension>( @JvmInline
public value class DMatrixWrapper<T, R : Dimension, C : Dimension>(
private val structure: Structure2D<T>, private val structure: Structure2D<T>,
) : DMatrix<T, R, C> { ) : DMatrix<T, R, C> {
override val shape: IntArray get() = structure.shape override val shape: IntArray get() = structure.shape
@ -68,7 +70,8 @@ public interface DPoint<T, D : Dimension> : Point<T> {
/** /**
* Dimension-safe point wrapper * Dimension-safe point wrapper
*/ */
public inline class DPointWrapper<T, D : Dimension>(public val point: Point<T>) : @JvmInline
public value class DPointWrapper<T, D : Dimension>(public val point: Point<T>) :
DPoint<T, D> { DPoint<T, D> {
override val size: Int get() = point.size override val size: Int get() = point.size
@ -81,7 +84,8 @@ public inline class DPointWrapper<T, D : Dimension>(public val point: Point<T>)
/** /**
* Basic operations on dimension-safe matrices. Operates on [Matrix] * Basic operations on dimension-safe matrices. Operates on [Matrix]
*/ */
public inline class DMatrixContext<T : Any, out A : Ring<T>>(public val context: LinearSpace<T, A>) { @JvmInline
public value class DMatrixContext<T : Any, out A : Ring<T>>(public val context: LinearSpace<T, A>) {
public inline fun <reified R : Dimension, reified C : Dimension> Matrix<T>.coerce(): DMatrix<T, R, C> { public inline fun <reified R : Dimension, reified C : Dimension> Matrix<T>.coerce(): DMatrix<T, R, C> {
require(rowNum == Dimension.dim<R>().toInt()) { require(rowNum == Dimension.dim<R>().toInt()) {
"Row number mismatch: expected ${Dimension.dim<R>()} but found $rowNum" "Row number mismatch: expected ${Dimension.dim<R>()} but found $rowNum"

View File

@ -14,7 +14,7 @@ import kotlin.math.pow
* *
* @param coefficients constant is the leftmost coefficient. * @param coefficients constant is the leftmost coefficient.
*/ */
public inline class Polynomial<T : Any>(public val coefficients: List<T>) public class Polynomial<T : Any>(public val coefficients: List<T>)
/** /**
* Returns a [Polynomial] instance with given [coefficients]. * Returns a [Polynomial] instance with given [coefficients].

View File

@ -0,0 +1,65 @@
/*
* Copyright 2015 Alexander Nozik.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package space.kscience.kmath.integration
import space.kscience.kmath.operations.DoubleField
import space.kscience.kmath.operations.Ring
import space.kscience.kmath.structures.Buffer
import space.kscience.kmath.structures.indices
/**
* A simple one-pass integrator based on Gauss rule
*/
public class GaussIntegrator<T : Any> internal constructor(
public val algebra: Ring<T>,
private val points: Buffer<T>,
private val weights: Buffer<T>,
) : UnivariateIntegrator<T> {
init {
require(points.size == weights.size) { "Inconsistent points and weights sizes" }
}
override fun integrate(integrand: UnivariateIntegrand<T>): UnivariateIntegrand<T> = with(algebra) {
val f = integrand.function
var res = zero
var c = zero
for (i in points.indices) {
val x: T = points[i]
val w: T = weights[i]
val y: T = w * f(x) - c
val t = res + y
c = t - res - y
res = t
}
return integrand + IntegrandValue(res) + IntegrandCalls(integrand.calls + points.size)
}
public companion object {
public fun integrate(
range: ClosedRange<Double>,
numPoints: Int = 100,
ruleFactory: GaussIntegratorRuleFactory<Double> = GaussLegendreDoubleRuleFactory,
function: (Double) -> Double,
): Double {
val (points, weights) = ruleFactory.build(numPoints, range)
return GaussIntegrator(DoubleField, points, weights).integrate(
UnivariateIntegrand(function, IntegrationRange(range))
).value!!
}
}
}

View File

@ -0,0 +1,166 @@
package space.kscience.kmath.integration
import space.kscience.kmath.operations.DoubleField
import space.kscience.kmath.operations.Ring
import space.kscience.kmath.structures.*
import kotlin.jvm.Synchronized
import kotlin.math.ulp
import kotlin.native.concurrent.ThreadLocal
public interface GaussIntegratorRuleFactory<T : Any> {
public val algebra: Ring<T>
public val bufferFactory: BufferFactory<T>
public fun build(numPoints: Int): Pair<Buffer<T>, Buffer<T>>
public companion object {
public fun double(numPoints: Int, range: ClosedRange<Double>): Pair<Buffer<Double>, Buffer<Double>> =
GaussLegendreDoubleRuleFactory.build(numPoints, range)
}
}
/**
* Create an integration rule by scaling existing normalized rule
*/
public fun <T : Comparable<T>> GaussIntegratorRuleFactory<T>.build(
numPoints: Int,
range: ClosedRange<T>,
): Pair<Buffer<T>, Buffer<T>> {
val normalized = build(numPoints)
val points = with(algebra) {
val length = range.endInclusive - range.start
normalized.first.map(bufferFactory) {
range.start + length * it
}
}
return points to normalized.second
}
/**
* Gauss integrator rule based ont Legendre polynomials. All rules are normalized to
*
* The code is based on Apache Commons Math source code version 3.6.1
* https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/org/apache/commons/math3/analysis/integration/gauss/LegendreRuleFactory.html
*/
@ThreadLocal
public object GaussLegendreDoubleRuleFactory : GaussIntegratorRuleFactory<Double> {
override val algebra: Ring<Double> get() = DoubleField
override val bufferFactory: BufferFactory<Double> get() = ::DoubleBuffer
private val cache = HashMap<Int, Pair<Buffer<Double>, Buffer<Double>>>()
@Synchronized
private fun getOrBuildRule(numPoints: Int): Pair<Buffer<Double>, Buffer<Double>> =
cache.getOrPut(numPoints) { buildRule(numPoints) }
private fun buildRule(numPoints: Int): Pair<Buffer<Double>, Buffer<Double>> {
if (numPoints == 1) {
// Break recursion.
return Pair(
DoubleBuffer(0.0),
DoubleBuffer(0.0)
)
}
// Get previous rule.
// If it has not been computed yet it will trigger a recursive call
// to this method.
val previousPoints: Buffer<Double> = getOrBuildRule(numPoints - 1).first
// Compute next rule.
val points = DoubleArray(numPoints)
val weights = DoubleArray(numPoints)
// Find i-th root of P[n+1] by bracketing.
val iMax = numPoints / 2
for (i in 0 until iMax) {
// Lower-bound of the interval.
var a: Double = if (i == 0) -1.0 else previousPoints[i - 1]
// Upper-bound of the interval.
var b: Double = if (iMax == 1) 1.0 else previousPoints[i]
// P[j-1](a)
var pma = 1.0
// P[j](a)
var pa = a
// P[j-1](b)
var pmb = 1.0
// P[j](b)
var pb = b
for (j in 1 until numPoints) {
val two_j_p_1 = 2 * j + 1
val j_p_1 = j + 1
// P[j+1](a)
val ppa = (two_j_p_1 * a * pa - j * pma) / j_p_1
// P[j+1](b)
val ppb = (two_j_p_1 * b * pb - j * pmb) / j_p_1
pma = pa
pa = ppa
pmb = pb
pb = ppb
}
// Now pa = P[n+1](a), and pma = P[n](a) (same holds for b).
// Middle of the interval.
var c = 0.5 * (a + b)
// P[j-1](c)
var pmc = 1.0
// P[j](c)
var pc = c
var done = false
while (!done) {
done = b - a <= c.ulp
pmc = 1.0
pc = c
for (j in 1 until numPoints) {
// P[j+1](c)
val ppc = ((2 * j + 1) * c * pc - j * pmc) / (j + 1)
pmc = pc
pc = ppc
}
// Now pc = P[n+1](c) and pmc = P[n](c).
if (!done) {
if (pa * pc <= 0) {
b = c
pmb = pmc
pb = pc
} else {
a = c
pma = pmc
pa = pc
}
c = 0.5 * (a + b)
}
}
val d = numPoints * (pmc - c * pc)
val w = 2 * (1 - c * c) / (d * d)
points[i] = c
weights[i] = w
val idx = numPoints - i - 1
points[idx] = -c
weights[idx] = w
}
// If "numberOfPoints" is odd, 0 is a root.
// Note: as written, the test for oddness will work for negative
// integers too (although it is not necessary here), preventing
// a FindBugs warning.
if (numPoints % 2 != 0) {
var pmc = 1.0
var j = 1
while (j < numPoints) {
pmc = -j * pmc / (j + 1)
j += 2
}
val d = numPoints * pmc
val w = 2 / (d * d)
points[iMax] = 0.0
weights[iMax] = w
}
return Pair(points.asBuffer(), weights.asBuffer())
}
override fun build(numPoints: Int): Pair<Buffer<Double>, Buffer<Double>> = getOrBuildRule(numPoints)
}

View File

@ -2,13 +2,13 @@ package space.kscience.kmath.geometry
import space.kscience.kmath.linear.Point import space.kscience.kmath.linear.Point
import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.misc.UnstableKMathAPI
import space.kscience.kmath.operations.GroupElement
import space.kscience.kmath.operations.ScaleOperations import space.kscience.kmath.operations.ScaleOperations
import space.kscience.kmath.operations.SpaceElement
import space.kscience.kmath.operations.invoke import space.kscience.kmath.operations.invoke
import kotlin.math.sqrt import kotlin.math.sqrt
@OptIn(UnstableKMathAPI::class) @OptIn(UnstableKMathAPI::class)
public interface Vector2D : Point<Double>, Vector, SpaceElement<Vector2D, Euclidean2DSpace> { public interface Vector2D : Point<Double>, Vector, GroupElement<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

View File

@ -2,13 +2,13 @@ package space.kscience.kmath.geometry
import space.kscience.kmath.linear.Point import space.kscience.kmath.linear.Point
import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.misc.UnstableKMathAPI
import space.kscience.kmath.operations.GroupElement
import space.kscience.kmath.operations.ScaleOperations import space.kscience.kmath.operations.ScaleOperations
import space.kscience.kmath.operations.SpaceElement
import space.kscience.kmath.operations.invoke import space.kscience.kmath.operations.invoke
import kotlin.math.sqrt import kotlin.math.sqrt
@OptIn(UnstableKMathAPI::class) @OptIn(UnstableKMathAPI::class)
public interface Vector3D : Point<Double>, Vector, SpaceElement<Vector3D, Euclidean3DSpace> { public interface Vector3D : Point<Double>, Vector, GroupElement<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

View File

@ -3,7 +3,7 @@ package space.kscience.kmath.histogram
import kotlinx.atomicfu.atomic import kotlinx.atomicfu.atomic
import kotlinx.atomicfu.getAndUpdate import kotlinx.atomicfu.getAndUpdate
import space.kscience.kmath.operations.DoubleField import space.kscience.kmath.operations.DoubleField
import space.kscience.kmath.operations.Group import space.kscience.kmath.operations.Ring
/** /**
* Common representation for atomic counters * Common representation for atomic counters
@ -37,7 +37,7 @@ public class LongCounter : Counter<Long> {
override val value: Long get() = innerValue.value override val value: Long get() = innerValue.value
} }
public class ObjectCounter<T : Any>(public val group: Group<T>) : Counter<T> { public class ObjectCounter<T : Any>(public val group: Ring<T>) : Counter<T> {
private val innerValue = atomic(group.zero) private val innerValue = atomic(group.zero)
override fun add(delta: T) { override fun add(delta: T) {

View File

@ -7,8 +7,8 @@ import space.kscience.kmath.nd.FieldND
import space.kscience.kmath.nd.Strides import space.kscience.kmath.nd.Strides
import space.kscience.kmath.nd.StructureND import space.kscience.kmath.nd.StructureND
import space.kscience.kmath.operations.Group import space.kscience.kmath.operations.Group
import space.kscience.kmath.operations.GroupElement
import space.kscience.kmath.operations.ScaleOperations import space.kscience.kmath.operations.ScaleOperations
import space.kscience.kmath.operations.SpaceElement
import space.kscience.kmath.operations.invoke import space.kscience.kmath.operations.invoke
/** /**
@ -23,7 +23,7 @@ public data class DomainBin<T : Comparable<T>>(
public class IndexedHistogram<T : Comparable<T>, V : Any>( public class IndexedHistogram<T : Comparable<T>, V : Any>(
override val context: IndexedHistogramSpace<T, V>, override val context: IndexedHistogramSpace<T, V>,
public val values: StructureND<V>, public val values: StructureND<V>,
) : Histogram<T, Bin<T>>, SpaceElement<IndexedHistogram<T, V>, IndexedHistogramSpace<T, V>> { ) : Histogram<T, Bin<T>>, GroupElement<IndexedHistogram<T, V>, IndexedHistogramSpace<T, V>> {
override fun get(point: Point<T>): Bin<T>? { override fun get(point: Point<T>): Bin<T>? {
val index = context.getIndex(point) ?: return null val index = context.getIndex(point) ?: return null

View File

@ -3,7 +3,7 @@ package space.kscience.kmath.histogram
import space.kscience.kmath.domains.UnivariateDomain import space.kscience.kmath.domains.UnivariateDomain
import space.kscience.kmath.misc.UnstableKMathAPI import space.kscience.kmath.misc.UnstableKMathAPI
import space.kscience.kmath.operations.Group import space.kscience.kmath.operations.Group
import space.kscience.kmath.operations.SpaceElement import space.kscience.kmath.operations.GroupElement
import space.kscience.kmath.structures.Buffer import space.kscience.kmath.structures.Buffer
import space.kscience.kmath.structures.asSequence import space.kscience.kmath.structures.asSequence
@ -31,7 +31,7 @@ public class UnivariateBin(
@OptIn(UnstableKMathAPI::class) @OptIn(UnstableKMathAPI::class)
public interface UnivariateHistogram : Histogram<Double, UnivariateBin>, public interface UnivariateHistogram : Histogram<Double, UnivariateBin>,
SpaceElement<UnivariateHistogram, Group<UnivariateHistogram>> { GroupElement<UnivariateHistogram, Group<UnivariateHistogram>> {
public operator fun get(value: Double): UnivariateBin? public operator fun get(value: Double): UnivariateBin?
public override operator fun get(point: Buffer<Double>): UnivariateBin? = get(point[0]) public override operator fun get(point: Buffer<Double>): UnivariateBin? = get(point[0])

View File

@ -75,7 +75,7 @@ public interface Nd4jArrayAlgebra<T, C : Algebra<T>> : AlgebraND<T, C> {
* @param T the type of the element contained in ND structure. * @param T the type of the element contained in ND structure.
* @param S the type of space of structure elements. * @param S the type of space of structure elements.
*/ */
public interface Nd4JArrayGroup<T, S : Group<T>> : GroupND<T, S>, Nd4jArrayAlgebra<T, S> { public interface Nd4JArrayGroup<T, S : Ring<T>> : GroupND<T, S>, Nd4jArrayAlgebra<T, S> {
public override val zero: Nd4jArrayStructure<T> public override val zero: Nd4jArrayStructure<T>
get() = Nd4j.zeros(*shape).wrap() get() = Nd4j.zeros(*shape).wrap()

View File

@ -11,7 +11,7 @@ import kotlin.math.*
/** /**
* Implements [UnivariateDistribution] for the normal (gaussian) distribution. * Implements [UnivariateDistribution] for the normal (gaussian) distribution.
*/ */
public inline class NormalDistribution(public val sampler: GaussianSampler) : UnivariateDistribution<Double> { public class NormalDistribution(public val sampler: GaussianSampler) : UnivariateDistribution<Double> {
public constructor( public constructor(
mean: Double, mean: Double,
standardDeviation: Double, standardDeviation: Double,

View File

@ -8,7 +8,7 @@ import space.kscience.kmath.structures.indices
* Arithmetic mean * Arithmetic mean
*/ */
public class Mean<T>( public class Mean<T>(
private val group: Group<T>, private val group: Ring<T>,
private val division: (sum: T, count: Int) -> T, private val division: (sum: T, count: Int) -> T,
) : ComposableStatistic<T, Pair<T, Int>, T>, BlockingStatistic<T, T> { ) : ComposableStatistic<T, Pair<T, Int>, T>, BlockingStatistic<T, T> {

View File

@ -28,42 +28,17 @@ public final class space/kscience/kmath/viktor/ViktorFieldND : space/kscience/km
public fun <init> ([I)V public fun <init> ([I)V
public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object; public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object;
public fun acos-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public fun acos-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
public synthetic fun acosh (Ljava/lang/Object;)Ljava/lang/Object;
public fun acosh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
public synthetic fun add (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun add (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public fun add-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public fun add-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object; public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object;
public fun asin-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public fun asin-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
public synthetic fun asinh (Ljava/lang/Object;)Ljava/lang/Object;
public fun asinh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object; public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object;
public fun atan-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public fun atan-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
public synthetic fun atanh (Ljava/lang/Object;)Ljava/lang/Object;
public fun atanh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun binaryOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
public fun binaryOperation (Ljava/lang/String;Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public fun binaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2;
public synthetic fun bindSymbol (Ljava/lang/String;)Ljava/lang/Object;
public fun bindSymbol (Ljava/lang/String;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun bindSymbolOrNull (Ljava/lang/String;)Ljava/lang/Object;
public fun bindSymbolOrNull (Ljava/lang/String;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun combine (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun combine (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND;
public fun combine-WKhNzhk (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lorg/jetbrains/bio/viktor/F64Array; public fun combine-WKhNzhk (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lorg/jetbrains/bio/viktor/F64Array;
public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object; public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object;
public fun cos-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public fun cos-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
public synthetic fun cosh (Ljava/lang/Object;)Ljava/lang/Object;
public fun cosh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public fun div (DLspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun div (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object;
public synthetic fun div (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
public synthetic fun div (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public fun div (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/nd/StructureND;
public fun div (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun div (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND;
public fun div (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun divide (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
public fun divide (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object; public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object;
public fun exp-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public fun exp-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
public synthetic fun getElementContext ()Lspace/kscience/kmath/operations/Algebra; public synthetic fun getElementContext ()Lspace/kscience/kmath/operations/Algebra;
@ -74,78 +49,34 @@ public final class space/kscience/kmath/viktor/ViktorFieldND : space/kscience/km
public fun getShape ()[I public fun getShape ()[I
public synthetic fun getZero ()Ljava/lang/Object; public synthetic fun getZero ()Ljava/lang/Object;
public fun getZero-6kW2wQc ()Lorg/jetbrains/bio/viktor/F64Array; public fun getZero-6kW2wQc ()Lorg/jetbrains/bio/viktor/F64Array;
public fun invoke (Lkotlin/jvm/functions/Function1;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
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;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
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-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public fun ln-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
public synthetic fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND;
public fun map-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lorg/jetbrains/bio/viktor/F64Array; public fun map-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lorg/jetbrains/bio/viktor/F64Array;
public synthetic fun mapIndexed (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun mapIndexed (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND;
public fun mapIndexed-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lorg/jetbrains/bio/viktor/F64Array; public fun mapIndexed-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lorg/jetbrains/bio/viktor/F64Array;
public fun minus (DLspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun minus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object;
public fun minus (Ljava/lang/Number;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object;
public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
public synthetic fun minus (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public fun minus (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/nd/StructureND;
public fun minus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun minus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND;
public fun minus-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public fun minus-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
public synthetic fun multiply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
public fun multiply (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object; public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object;
public fun number-8UOKELU (Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array; public fun number-8UOKELU (Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array;
public fun plus (DLspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun plus (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object;
public fun plus (Ljava/lang/Number;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object;
public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
public synthetic fun plus (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public fun plus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun plus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun plus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND;
public fun plus-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;D)Lorg/jetbrains/bio/viktor/F64Array; public fun plus-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;D)Lorg/jetbrains/bio/viktor/F64Array;
public fun plus-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public fun plus-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
public synthetic fun pow (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object;
public fun pow (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND;
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-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array; public fun power-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array;
public synthetic fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND; public synthetic fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND;
public fun produce-8UOKELU (Lkotlin/jvm/functions/Function2;)Lorg/jetbrains/bio/viktor/F64Array; public fun produce-8UOKELU (Lkotlin/jvm/functions/Function2;)Lorg/jetbrains/bio/viktor/F64Array;
public synthetic fun rightSideNumberOperation (Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object;
public fun rightSideNumberOperation (Ljava/lang/String;Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/nd/StructureND;
public fun rightSideNumberOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function2;
public synthetic fun scale (Ljava/lang/Object;D)Ljava/lang/Object; public synthetic fun scale (Ljava/lang/Object;D)Ljava/lang/Object;
public fun scale-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;D)Lorg/jetbrains/bio/viktor/F64Array; public fun scale-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;D)Lorg/jetbrains/bio/viktor/F64Array;
public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object; public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object;
public fun sin-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public fun sin-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
public synthetic fun sinh (Ljava/lang/Object;)Ljava/lang/Object;
public fun sinh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun sqrt (Ljava/lang/Object;)Ljava/lang/Object;
public fun sqrt (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object; public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object;
public fun tan-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array; public fun tan-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
public synthetic fun tanh (Ljava/lang/Object;)Ljava/lang/Object;
public fun tanh (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public fun times (DLspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun times (Ljava/lang/Number;Ljava/lang/Object;)Ljava/lang/Object;
public fun times (Ljava/lang/Number;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun times (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object; public synthetic fun times (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object;
public synthetic fun times (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
public synthetic fun times (Ljava/lang/Object;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public fun times (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun times (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND;
public fun times (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public fun times-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array; public fun times-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array;
public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object; public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object;
public fun unaryMinus (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND; public fun unaryMinus (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public synthetic fun unaryOperation (Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/Object;
public fun unaryOperation (Ljava/lang/String;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
public fun unaryOperationFunction (Ljava/lang/String;)Lkotlin/jvm/functions/Function1;
public synthetic fun unaryPlus (Ljava/lang/Object;)Ljava/lang/Object;
public fun unaryPlus (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
} }
public final class space/kscience/kmath/viktor/ViktorStructureND : space/kscience/kmath/nd/MutableStructureND { public final class space/kscience/kmath/viktor/ViktorStructureND : space/kscience/kmath/nd/MutableStructureND {
@ -159,8 +90,6 @@ public final class space/kscience/kmath/viktor/ViktorStructureND : space/kscienc
public fun get ([I)Ljava/lang/Double; public fun get ([I)Ljava/lang/Double;
public synthetic fun get ([I)Ljava/lang/Object; public synthetic fun get ([I)Ljava/lang/Object;
public static fun get-impl (Lorg/jetbrains/bio/viktor/F64Array;[I)Ljava/lang/Double; public static fun get-impl (Lorg/jetbrains/bio/viktor/F64Array;[I)Ljava/lang/Double;
public fun getDimension ()I
public static fun getDimension-impl (Lorg/jetbrains/bio/viktor/F64Array;)I
public final fun getF64Buffer ()Lorg/jetbrains/bio/viktor/F64Array; public final fun getF64Buffer ()Lorg/jetbrains/bio/viktor/F64Array;
public fun getShape ()[I public fun getShape ()[I
public static fun getShape-impl (Lorg/jetbrains/bio/viktor/F64Array;)[I public static fun getShape-impl (Lorg/jetbrains/bio/viktor/F64Array;)[I

View File

@ -1,14 +1,13 @@
pluginManagement { pluginManagement {
repositories { repositories {
maven("https://repo.kotlin.link")
mavenLocal() mavenLocal()
mavenCentral()
gradlePluginPortal() gradlePluginPortal()
jcenter() maven("https://repo.kotlin.link")
maven("https://dl.bintray.com/kotlin/kotlinx")
} }
val toolsVersion = "0.9.5-dev" val toolsVersion = "0.9.5-dev-2"
val kotlinVersion = "1.5.0-M2" val kotlinVersion = "1.5.0-RC"
plugins { plugins {
kotlin("multiplatform") version kotlinVersion kotlin("multiplatform") version kotlinVersion
@ -40,5 +39,5 @@ include(
":kmath-ast", ":kmath-ast",
":kmath-ejml", ":kmath-ejml",
":kmath-kotlingrad", ":kmath-kotlingrad",
":examples" ":examples",
) )