Viktor prototype with compiler bug
This commit is contained in:
parent
f9836a6477
commit
cbac4fca33
@ -13,6 +13,12 @@ fun main() {
|
|||||||
|
|
||||||
val viktorField = ViktorNDField(intArrayOf(dim, dim))
|
val viktorField = ViktorNDField(intArrayOf(dim, dim))
|
||||||
|
|
||||||
|
autoField.run {
|
||||||
|
var res = one
|
||||||
|
repeat(n/2) {
|
||||||
|
res += 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
measureAndPrint("Automatic field addition") {
|
measureAndPrint("Automatic field addition") {
|
||||||
autoField.run {
|
autoField.run {
|
||||||
@ -23,6 +29,22 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viktorField.run {
|
||||||
|
var res = one
|
||||||
|
repeat(n/2) {
|
||||||
|
res += one
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
measureAndPrint("Viktor field addition") {
|
||||||
|
viktorField.run {
|
||||||
|
var res = one
|
||||||
|
repeat(n) {
|
||||||
|
res += one
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
measureAndPrint("Raw Viktor") {
|
measureAndPrint("Raw Viktor") {
|
||||||
val one = F64Array.full(init = 1.0, shape = *intArrayOf(dim, dim))
|
val one = F64Array.full(init = 1.0, shape = *intArrayOf(dim, dim))
|
||||||
var res = one
|
var res = one
|
||||||
@ -30,13 +52,4 @@ fun main() {
|
|||||||
res = res + one
|
res = res + one
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
measureAndPrint("Viktor field addition") {
|
|
||||||
viktorField.run {
|
|
||||||
var res = one
|
|
||||||
repeat(n) {
|
|
||||||
res += 1.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -65,9 +65,15 @@ class ViktorNDField(override val shape: IntArray) : NDField<Double, RealField, V
|
|||||||
}
|
}
|
||||||
}.asStructure()
|
}.asStructure()
|
||||||
|
|
||||||
override fun ViktorNDStructure.plus(b: ViktorNDStructure): ViktorNDStructure =
|
override fun add(a: ViktorNDStructure, b: ViktorNDStructure): ViktorNDStructure {
|
||||||
(f64Buffer + b.f64Buffer).asStructure()
|
return (a.f64Buffer + b.f64Buffer).asStructure()
|
||||||
|
}
|
||||||
|
|
||||||
override fun ViktorNDStructure.minus(b: ViktorNDStructure): ViktorNDStructure =
|
// override inline fun ViktorNDStructure.plus(b: ViktorNDStructure): ViktorNDStructure {
|
||||||
(f64Buffer - b.f64Buffer).asStructure()
|
// return (f64Buffer + b.f64Buffer).asStructure()
|
||||||
|
// }
|
||||||
|
|
||||||
|
override fun multiply(a: ViktorNDStructure, k: Number): ViktorNDStructure {
|
||||||
|
return (a.f64Buffer * k.toDouble()).asStructure()
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user