kmath/kmath-nd4j
2020-10-29 23:59:36 +07:00
..
docs Rename API classes, update readme files 2020-10-29 15:39:53 +07:00
src Uncomment expressions benchmark, and add factory methods for Nd4jRing and Nd4jField 2020-10-29 23:59:36 +07:00
build.gradle.kts Regenerate readme 2020-10-29 15:44:30 +07:00
README.md Regenerate readme 2020-10-29 15:44:30 +07:00

ND4J NDStructure implementation (kmath-nd4j)

This subproject implements the following features:

Artifact:

This module artifact: kscience.kmath:kmath-nd4j:0.2.0-dev-3.

Bintray release version: Download

Bintray development version: Download

Gradle:

repositories {
    maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
    maven { url 'https://dl.bintray.com/mipt-npm/kscience' }
    maven { url 'https://dl.bintray.com/mipt-npm/dev' }
    maven { url 'https://dl.bintray.com/hotkeytlt/maven' }

}

dependencies { implementation 'kscience.kmath:kmath-nd4j:0.2.0-dev-3' }

**Gradle Kotlin DSL:**

```kotlin
repositories {
    maven("https://dl.bintray.com/kotlin/kotlin-eap")
    maven("https://dl.bintray.com/mipt-npm/kscience")
    maven("https://dl.bintray.com/mipt-npm/dev")
    maven("https://dl.bintray.com/hotkeytlt/maven")
}

dependencies {
    implementation("kscience.kmath:kmath-nd4j:0.2.0-dev-3")
}

Examples

NDStructure wrapper for INDArray:

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

val array = Nd4j.ones(2, 2).asRealStructure()
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 = RealNd4jArrayField(intArrayOf(2, 2))
val array = Nd4j.rand(2, 2).asRealStructure()

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

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

Contributed by Iaroslav Postovalov.