Merge branch 'master' into dev

This commit is contained in:
Alexander Nozik 2020-01-12 10:02:28 +03:00
commit 8662935dbe
8 changed files with 99 additions and 37 deletions

View File

@ -1,37 +0,0 @@
package scientifik.kmath.coroutines
import scientifik.kmath.operations.RealField
import scientifik.kmath.operations.SpaceOperations
import kotlin.jvm.JvmName
/**
* A suspendable univariate function defined in algebraic context
*/
interface UFunction<T, C : SpaceOperations<T>> {
suspend operator fun C.invoke(arg: T): T
}
suspend fun UFunction<Double, RealField>.invoke(arg: Double) = RealField.invoke(arg)
/**
* A suspendable multivariate (N->1) function defined on algebraic context
*/
interface MFunction<T, C : SpaceOperations<T>> {
/**
* The input dimension of the function
*/
val dimension: UInt
suspend operator fun C.invoke(vararg args: T): T
}
suspend fun MFunction<Double, RealField>.invoke(args: DoubleArray) = RealField.invoke(*args.toTypedArray())
@JvmName("varargInvoke")
suspend fun MFunction<Double, RealField>.invoke(vararg args: Double) = RealField.invoke(*args.toTypedArray())
/**
* A suspendable univariate function with parameter
*/
interface ParametricUFunction<T, P, C : SpaceOperations<T>> {
suspend operator fun C.invoke(arg: T, parameter: P): T
}

View File

@ -0,0 +1,23 @@
plugins {
id("scientifik.mpp")
//id("scientifik.atomic")
}
kotlin.sourceSets {
commonMain {
dependencies {
api(project(":kmath-core"))
api("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:${Scientifik.coroutinesVersion}")
}
}
jvmMain {
dependencies {
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Scientifik.coroutinesVersion}")
}
}
jsMain {
dependencies {
api("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:${Scientifik.coroutinesVersion}")
}
}
}

View File

@ -0,0 +1,2 @@
package scientifik.kmath.functions

View File

@ -0,0 +1,4 @@
package scientifik.kmath.functions
interface Polynomial {
}

View File

@ -0,0 +1,54 @@
package scientifik.kmath.misc
import scientifik.kmath.operations.RealField
import scientifik.kmath.operations.SpaceOperations
import kotlin.jvm.JvmName
/**
* A regular function that could be called only inside specific algebra context
*/
interface UFunction<T, C : SpaceOperations<T>> {
operator fun C.invoke(arg: T): T
}
/**
* A suspendable univariate function defined in algebraic context
*/
interface USFunction<T, C : SpaceOperations<T>> {
suspend operator fun C.invoke(arg: T): T
}
suspend fun USFunction<Double, RealField>.invoke(arg: Double) = RealField.invoke(arg)
interface MFunction<T, C : SpaceOperations<T>> {
/**
* The input dimension of the function
*/
val dimension: UInt
operator fun C.invoke(vararg args: T): T
}
/**
* A suspendable multivariate (N->1) function defined on algebraic context
*/
interface MSFunction<T, C : SpaceOperations<T>> {
/**
* The input dimension of the function
*/
val dimension: UInt
suspend operator fun C.invoke(vararg args: T): T
}
suspend fun MSFunction<Double, RealField>.invoke(args: DoubleArray) = RealField.invoke(*args.toTypedArray())
@JvmName("varargInvoke")
suspend fun MSFunction<Double, RealField>.invoke(vararg args: Double) = RealField.invoke(*args.toTypedArray())
/**
* A suspendable parametric function with parameter
*/
interface PSFunction<T, P, C : SpaceOperations<T>> {
suspend operator fun C.invoke(arg: T, parameter: P): T
}

View File

@ -0,0 +1,7 @@
package scientifik.kmath.interpolation
import scientifik.kmath.functions.MathFunction
interface Interpolator<X, Y> {
fun interpolate(points: Collection<Pair<X, Y>>): MathFunction<X, *, Y>
}

View File

@ -0,0 +1,4 @@
package scientifik.kmath.interpolation
class LinearInterpolator {
}

View File

@ -0,0 +1,5 @@
package scientifik.kmath.interpolation
import org.junit.Assert.*
class LinearInterpolatorTest