diff --git a/examples/src/main/kotlin/space/kscience/kmath/tensors/multik.kt b/examples/src/main/kotlin/space/kscience/kmath/tensors/multik.kt index fc6d7dd56..5383b5c3e 100644 --- a/examples/src/main/kotlin/space/kscience/kmath/tensors/multik.kt +++ b/examples/src/main/kotlin/space/kscience/kmath/tensors/multik.kt @@ -5,6 +5,7 @@ package space.kscience.kmath.tensors +import edu.mcgill.kaliningraph.power import org.jetbrains.kotlinx.multik.api.Multik import org.jetbrains.kotlinx.multik.api.linalg.dot import org.jetbrains.kotlinx.multik.api.math.exp @@ -12,13 +13,12 @@ import org.jetbrains.kotlinx.multik.api.ndarray import org.jetbrains.kotlinx.multik.ndarray.operations.minus import org.jetbrains.kotlinx.multik.ndarray.operations.plus import org.jetbrains.kotlinx.multik.ndarray.operations.unaryMinus +import space.kscience.kmath.multik.multikND +import space.kscience.kmath.nd.one +import space.kscience.kmath.operations.DoubleField -fun main() { - val a = Multik.ndarray(intArrayOf(1, 2, 3)) +fun main(): Unit = with(DoubleField.multikND) { + val a = Multik.ndarray(intArrayOf(1, 2, 3)).asType().wrap() val b = Multik.ndarray(doubleArrayOf(1.0, 2.0, 3.0)) - 2 + (-a) - 2 - - a dot a - - a.exp() + one(a.shape) - a + power() } \ No newline at end of file diff --git a/kmath-multik/build.gradle.kts b/kmath-multik/build.gradle.kts index 16a7ab652..df2292f2e 100644 --- a/kmath-multik/build.gradle.kts +++ b/kmath-multik/build.gradle.kts @@ -6,7 +6,7 @@ description = "JetBrains Multik connector" dependencies { api(project(":kmath-tensors")) - api("org.jetbrains.kotlinx:multik-api:0.1.0") + api("org.jetbrains.kotlinx:multik-default:0.1.0") } readme { diff --git a/kmath-multik/src/main/kotlin/space/kscience/kmath/multik/MultikOpsND.kt b/kmath-multik/src/main/kotlin/space/kscience/kmath/multik/MultikOpsND.kt index 9ee5087e9..4068ba9b9 100644 --- a/kmath-multik/src/main/kotlin/space/kscience/kmath/multik/MultikOpsND.kt +++ b/kmath-multik/src/main/kotlin/space/kscience/kmath/multik/MultikOpsND.kt @@ -1,5 +1,7 @@ package space.kscience.kmath.multik +import org.jetbrains.kotlinx.multik.api.math.cos +import org.jetbrains.kotlinx.multik.api.math.sin import org.jetbrains.kotlinx.multik.api.mk import org.jetbrains.kotlinx.multik.api.zeros import org.jetbrains.kotlinx.multik.ndarray.data.* @@ -18,7 +20,7 @@ public open class MultikRingOpsND> internal constructor( override val elementAlgebra: A ) : RingOpsND { - public fun MutableMultiArray.wrap(): MultikTensor = MultikTensor(this) + public fun MutableMultiArray.wrap(): MultikTensor = MultikTensor(this.asDNArray()) override fun structureND(shape: Shape, initializer: A.(IntArray) -> T): MultikTensor { val res = mk.zeros(shape, type).asDNArray()