Update examples to use with
instead of invoke
on algebras
This commit is contained in:
parent
cd4bfdf59e
commit
a384b323c3
@ -10,7 +10,6 @@ import kscience.kmath.linear.Matrix
|
|||||||
import kscience.kmath.linear.MatrixContext
|
import kscience.kmath.linear.MatrixContext
|
||||||
import kscience.kmath.linear.inverseWithLup
|
import kscience.kmath.linear.inverseWithLup
|
||||||
import kscience.kmath.linear.real
|
import kscience.kmath.linear.real
|
||||||
import kscience.kmath.operations.invoke
|
|
||||||
import org.openjdk.jmh.annotations.Scope
|
import org.openjdk.jmh.annotations.Scope
|
||||||
import org.openjdk.jmh.annotations.State
|
import org.openjdk.jmh.annotations.State
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
@ -34,14 +33,14 @@ internal class LinearAlgebraBenchmark {
|
|||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
fun cmLUPInversion() {
|
fun cmLUPInversion() {
|
||||||
CMMatrixContext {
|
with(CMMatrixContext) {
|
||||||
inverse(matrix)
|
inverse(matrix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
fun ejmlInverse() {
|
fun ejmlInverse() {
|
||||||
EjmlMatrixContext {
|
with(EjmlMatrixContext) {
|
||||||
inverse(matrix)
|
inverse(matrix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package kscience.kmath.benchmarks
|
|||||||
|
|
||||||
import kscience.kmath.nd.*
|
import kscience.kmath.nd.*
|
||||||
import kscience.kmath.operations.RealField
|
import kscience.kmath.operations.RealField
|
||||||
import kscience.kmath.operations.invoke
|
|
||||||
import kscience.kmath.structures.Buffer
|
import kscience.kmath.structures.Buffer
|
||||||
import org.openjdk.jmh.annotations.Benchmark
|
import org.openjdk.jmh.annotations.Benchmark
|
||||||
import org.openjdk.jmh.annotations.Scope
|
import org.openjdk.jmh.annotations.Scope
|
||||||
@ -12,7 +11,7 @@ import org.openjdk.jmh.annotations.State
|
|||||||
internal class NDFieldBenchmark {
|
internal class NDFieldBenchmark {
|
||||||
@Benchmark
|
@Benchmark
|
||||||
fun autoFieldAdd() {
|
fun autoFieldAdd() {
|
||||||
autoField {
|
with(autoField) {
|
||||||
var res: NDStructure<Double> = one
|
var res: NDStructure<Double> = one
|
||||||
repeat(n) { res += one }
|
repeat(n) { res += one }
|
||||||
}
|
}
|
||||||
@ -20,7 +19,7 @@ internal class NDFieldBenchmark {
|
|||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
fun specializedFieldAdd() {
|
fun specializedFieldAdd() {
|
||||||
specializedField {
|
with(specializedField) {
|
||||||
var res: NDStructure<Double> = one
|
var res: NDStructure<Double> = one
|
||||||
repeat(n) { res += 1.0 }
|
repeat(n) { res += 1.0 }
|
||||||
}
|
}
|
||||||
@ -29,7 +28,7 @@ internal class NDFieldBenchmark {
|
|||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
fun boxingFieldAdd() {
|
fun boxingFieldAdd() {
|
||||||
genericField {
|
with(genericField) {
|
||||||
var res: NDStructure<Double> = one
|
var res: NDStructure<Double> = one
|
||||||
repeat(n) { res += 1.0 }
|
repeat(n) { res += 1.0 }
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package kscience.kmath.benchmarks
|
|||||||
|
|
||||||
import kscience.kmath.nd.*
|
import kscience.kmath.nd.*
|
||||||
import kscience.kmath.operations.RealField
|
import kscience.kmath.operations.RealField
|
||||||
import kscience.kmath.operations.invoke
|
|
||||||
import kscience.kmath.viktor.ViktorNDField
|
import kscience.kmath.viktor.ViktorNDField
|
||||||
import org.jetbrains.bio.viktor.F64Array
|
import org.jetbrains.bio.viktor.F64Array
|
||||||
import org.openjdk.jmh.annotations.Benchmark
|
import org.openjdk.jmh.annotations.Benchmark
|
||||||
@ -21,7 +20,7 @@ internal class ViktorBenchmark {
|
|||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
fun automaticFieldAddition() {
|
fun automaticFieldAddition() {
|
||||||
autoField {
|
with(autoField) {
|
||||||
var res: NDStructure<Double> = one
|
var res: NDStructure<Double> = one
|
||||||
repeat(n) { res += 1.0 }
|
repeat(n) { res += 1.0 }
|
||||||
}
|
}
|
||||||
@ -29,7 +28,7 @@ internal class ViktorBenchmark {
|
|||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
fun realFieldAddition() {
|
fun realFieldAddition() {
|
||||||
realField {
|
with(realField) {
|
||||||
var res: NDStructure<Double> = one
|
var res: NDStructure<Double> = one
|
||||||
repeat(n) { res += 1.0 }
|
repeat(n) { res += 1.0 }
|
||||||
}
|
}
|
||||||
@ -37,7 +36,7 @@ internal class ViktorBenchmark {
|
|||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
fun viktorFieldAddition() {
|
fun viktorFieldAddition() {
|
||||||
viktorField {
|
with(viktorField) {
|
||||||
var res = one
|
var res = one
|
||||||
repeat(n) { res += 1.0 }
|
repeat(n) { res += 1.0 }
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package kscience.kmath.benchmarks
|
|||||||
|
|
||||||
import kscience.kmath.nd.*
|
import kscience.kmath.nd.*
|
||||||
import kscience.kmath.operations.RealField
|
import kscience.kmath.operations.RealField
|
||||||
import kscience.kmath.operations.invoke
|
|
||||||
import kscience.kmath.viktor.ViktorNDField
|
import kscience.kmath.viktor.ViktorNDField
|
||||||
import org.jetbrains.bio.viktor.F64Array
|
import org.jetbrains.bio.viktor.F64Array
|
||||||
import org.openjdk.jmh.annotations.Benchmark
|
import org.openjdk.jmh.annotations.Benchmark
|
||||||
@ -22,7 +21,7 @@ internal class ViktorLogBenchmark {
|
|||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
fun realFieldLog() {
|
fun realFieldLog() {
|
||||||
realField {
|
with(realField) {
|
||||||
val fortyTwo = produce { 42.0 }
|
val fortyTwo = produce { 42.0 }
|
||||||
var res = one
|
var res = one
|
||||||
repeat(n) { res = ln(fortyTwo) }
|
repeat(n) { res = ln(fortyTwo) }
|
||||||
@ -31,7 +30,7 @@ internal class ViktorLogBenchmark {
|
|||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
fun viktorFieldLog() {
|
fun viktorFieldLog() {
|
||||||
viktorField {
|
with(viktorField) {
|
||||||
val fortyTwo = produce { 42.0 }
|
val fortyTwo = produce { 42.0 }
|
||||||
var res = one
|
var res = one
|
||||||
repeat(n) { res = ln(fortyTwo) }
|
repeat(n) { res = ln(fortyTwo) }
|
||||||
|
Loading…
Reference in New Issue
Block a user