Switch to multik-default

This commit is contained in:
Alexander Nozik 2021-10-18 12:52:24 +03:00
parent a81ab474f7
commit dccc92bf2f
3 changed files with 11 additions and 9 deletions

View File

@ -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<Double>().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()
}

View File

@ -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 {

View File

@ -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<T, A : Ring<T>> internal constructor(
override val elementAlgebra: A
) : RingOpsND<T, A> {
public fun MutableMultiArray<T, DN>.wrap(): MultikTensor<T> = MultikTensor(this)
public fun MutableMultiArray<T, *>.wrap(): MultikTensor<T> = MultikTensor(this.asDNArray())
override fun structureND(shape: Shape, initializer: A.(IntArray) -> T): MultikTensor<T> {
val res = mk.zeros<T, DN>(shape, type).asDNArray()