diff --git a/kmath-core/src/commonMain/kotlin/scientifik/kmath/misc/functions.kt b/kmath-core/src/commonMain/kotlin/scientifik/kmath/misc/functions.kt deleted file mode 100644 index cef8209ed..000000000 --- a/kmath-core/src/commonMain/kotlin/scientifik/kmath/misc/functions.kt +++ /dev/null @@ -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> { - suspend operator fun C.invoke(arg: T): T -} - -suspend fun UFunction.invoke(arg: Double) = RealField.invoke(arg) - -/** - * A suspendable multivariate (N->1) function defined on algebraic context - */ -interface MFunction> { - /** - * The input dimension of the function - */ - val dimension: UInt - - suspend operator fun C.invoke(vararg args: T): T -} - -suspend fun MFunction.invoke(args: DoubleArray) = RealField.invoke(*args.toTypedArray()) -@JvmName("varargInvoke") -suspend fun MFunction.invoke(vararg args: Double) = RealField.invoke(*args.toTypedArray()) - -/** - * A suspendable univariate function with parameter - */ -interface ParametricUFunction> { - suspend operator fun C.invoke(arg: T, parameter: P): T -} diff --git a/kmath-functions/build.gradle.kts b/kmath-functions/build.gradle.kts new file mode 100644 index 000000000..373d9b8ac --- /dev/null +++ b/kmath-functions/build.gradle.kts @@ -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}") + } + } +} diff --git a/kmath-functions/src/commonMain/kotlin/scientifik.kmath.functions/Piecewise.kt b/kmath-functions/src/commonMain/kotlin/scientifik.kmath.functions/Piecewise.kt new file mode 100644 index 000000000..d1263e58b --- /dev/null +++ b/kmath-functions/src/commonMain/kotlin/scientifik.kmath.functions/Piecewise.kt @@ -0,0 +1,2 @@ +package scientifik.kmath.functions + diff --git a/kmath-functions/src/commonMain/kotlin/scientifik.kmath.functions/Polynomial.kt b/kmath-functions/src/commonMain/kotlin/scientifik.kmath.functions/Polynomial.kt new file mode 100644 index 000000000..855ed26cd --- /dev/null +++ b/kmath-functions/src/commonMain/kotlin/scientifik.kmath.functions/Polynomial.kt @@ -0,0 +1,4 @@ +package scientifik.kmath.functions + +interface Polynomial { +} \ No newline at end of file diff --git a/kmath-functions/src/commonMain/kotlin/scientifik.kmath.functions/functions.kt b/kmath-functions/src/commonMain/kotlin/scientifik.kmath.functions/functions.kt new file mode 100644 index 000000000..c26443926 --- /dev/null +++ b/kmath-functions/src/commonMain/kotlin/scientifik.kmath.functions/functions.kt @@ -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> { + operator fun C.invoke(arg: T): T +} + +/** + * A suspendable univariate function defined in algebraic context + */ +interface USFunction> { + suspend operator fun C.invoke(arg: T): T +} + +suspend fun USFunction.invoke(arg: Double) = RealField.invoke(arg) + + +interface MFunction> { + /** + * 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> { + /** + * The input dimension of the function + */ + val dimension: UInt + + suspend operator fun C.invoke(vararg args: T): T +} + +suspend fun MSFunction.invoke(args: DoubleArray) = RealField.invoke(*args.toTypedArray()) +@JvmName("varargInvoke") +suspend fun MSFunction.invoke(vararg args: Double) = RealField.invoke(*args.toTypedArray()) + +/** + * A suspendable parametric function with parameter + */ +interface PSFunction> { + suspend operator fun C.invoke(arg: T, parameter: P): T +} diff --git a/kmath-functions/src/commonMain/kotlin/scientifik/kmath/interpolation/Interpolator.kt b/kmath-functions/src/commonMain/kotlin/scientifik/kmath/interpolation/Interpolator.kt new file mode 100644 index 000000000..0b1ca7795 --- /dev/null +++ b/kmath-functions/src/commonMain/kotlin/scientifik/kmath/interpolation/Interpolator.kt @@ -0,0 +1,7 @@ +package scientifik.kmath.interpolation + +import scientifik.kmath.functions.MathFunction + +interface Interpolator { + fun interpolate(points: Collection>): MathFunction +} \ No newline at end of file diff --git a/kmath-functions/src/commonMain/kotlin/scientifik/kmath/interpolation/LinearInterpolator.kt b/kmath-functions/src/commonMain/kotlin/scientifik/kmath/interpolation/LinearInterpolator.kt new file mode 100644 index 000000000..4db9da7b6 --- /dev/null +++ b/kmath-functions/src/commonMain/kotlin/scientifik/kmath/interpolation/LinearInterpolator.kt @@ -0,0 +1,4 @@ +package scientifik.kmath.interpolation + +class LinearInterpolator { +} \ No newline at end of file diff --git a/kmath-functions/src/commonTest/kotlin/scientifik/kmath/interpolation/LinearInterpolatorTest.kt b/kmath-functions/src/commonTest/kotlin/scientifik/kmath/interpolation/LinearInterpolatorTest.kt new file mode 100644 index 000000000..34202b388 --- /dev/null +++ b/kmath-functions/src/commonTest/kotlin/scientifik/kmath/interpolation/LinearInterpolatorTest.kt @@ -0,0 +1,5 @@ +package scientifik.kmath.interpolation + +import org.junit.Assert.* + +class LinearInterpolatorTest \ No newline at end of file