kmath-nd4j

ND4J based implementations of KMath abstractions.

  • # : NDStructure wrapper for INDArray

  • # : Rings over Nd4jArrayStructure of Int and Long

  • # : Fields over Nd4jArrayStructure of Float and Double

Artifact:

The Maven coordinates of this project are space.kscience:kmath-nd4j:0.3.0-dev-16.

Gradle:

repositories {
maven { url 'https://repo.kotlin.link' }
mavenCentral()
}

dependencies {
implementation 'space.kscience:kmath-nd4j:0.3.0-dev-16'
}

Gradle Kotlin DSL:

repositories {
maven("https://repo.kotlin.link")
mavenCentral()
}

dependencies {
implementation("space.kscience:kmath-nd4j:0.3.0-dev-16")
}

Examples

NDStructure wrapper for INDArray:

import org.nd4j.linalg.factory.*
import scientifik.kmath.nd4j.*
import scientifik.kmath.structures.*

val array = Nd4j.ones(2, 2).asDoubleStructure()
println(array[0, 0]) // 1.0
array[intArrayOf(0, 0)] = 24.0
println(array[0, 0]) // 24.0

Fast element-wise and in-place arithmetics for INDArray:

import org.nd4j.linalg.factory.*
import scientifik.kmath.nd4j.*
import scientifik.kmath.operations.*

val field = DoubleNd4jArrayField(intArrayOf(2, 2))
val array = Nd4j.rand(2, 2).asDoubleStructure()

val res = field {
(25.0 / array + 20) * 4
}

println(res.ndArray)
// [[ 250.6449, 428.5840],
// [ 269.7913, 202.2077]]

Contributed by Iaroslav Postovalov.

Packages

space.kscience.kmath.nd4j
Link copied to clipboard