forked from kscience/kmath
e9c31b7827
# Conflicts: # README.md # build.gradle.kts # examples/src/main/kotlin/space/kscience/kmath/stat/DistributionBenchmark.kt # examples/src/main/kotlin/space/kscience/kmath/structures/ParallelRealNDField.kt # kmath-ast/README.md # kmath-ast/build.gradle.kts # kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/MstExpression.kt # kmath-complex/README.md # kmath-complex/build.gradle.kts # kmath-complex/src/commonMain/kotlin/space/kscience/kmath/complex/ComplexNDField.kt # kmath-core/README.md # kmath-core/build.gradle.kts # kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/MST.kt # kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/MstAlgebra.kt # kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/RealNDField.kt # kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/RealBufferField.kt # kmath-coroutines/build.gradle.kts # kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/chains/BlockingRealChain.kt # kmath-coroutines/src/jvmMain/kotlin/space/kscience/kmath/structures/LazyNDStructure.kt # kmath-dimensions/src/commonTest/kotlin/kscience/dimensions/DMatrixContextTest.kt # kmath-for-real/README.md # kmath-functions/README.md # kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/Interpolator.kt # kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/LoessInterpolator.kt # kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/XYPointSet.kt # kmath-geometry/build.gradle.kts # kmath-nd4j/README.md # kmath-nd4j/build.gradle.kts # kmath-stat/src/commonMain/kotlin/space/kscience/kmath/distributions/FactorizedDistribution.kt # kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Distribution.kt # kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Fitting.kt # kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/OptimizationProblem.kt # kmath-stat/src/jvmMain/kotlin/space/kscience/kmath/stat/distributions.kt # kmath-viktor/src/main/kotlin/space/kscience/kmath/viktor/ViktorNDStructure.kt |
||
---|---|---|
.. | ||
docs | ||
src | ||
build.gradle.kts | ||
README.md |
Module kmath-nd4j
ND4J based implementations of KMath abstractions.
- nd4jarraystructure : NDStructure wrapper for INDArray
- nd4jarrayrings : Rings over Nd4jArrayStructure of Int and Long
- nd4jarrayfields : Fields over Nd4jArrayStructure of Float and Double
Artifact:
The Maven coordinates of this project are space.kscience:kmath-nd4j:0.3.0-dev-4
.
Gradle:
repositories {
maven { url 'https://repo.kotlin.link' }
maven { url 'https://dl.bintray.com/hotkeytlt/maven' }
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // include for builds based on kotlin-eap
}
dependencies {
implementation 'space.kscience:kmath-nd4j:0.3.0-dev-4'
}
Gradle Kotlin DSL:
repositories {
maven("https://repo.kotlin.link")
maven("https://dl.bintray.com/kotlin/kotlin-eap") // include for builds based on kotlin-eap
maven("https://dl.bintray.com/hotkeytlt/maven") // required for a
}
dependencies {
implementation("space.kscience:kmath-nd4j:0.3.0-dev-4")
}
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.