Dev #72

Merged
altavir merged 16 commits from dev into master 2019-06-26 18:54:12 +03:00
Showing only changes of commit 88759807ab - Show all commits

View File

@ -1,5 +1,8 @@
package scientifik.kmath.structures
import scientifik.kmath.linear.transpose
import scientifik.kmath.operations.Complex
import scientifik.kmath.operations.toComplex
import kotlin.system.measureTimeMillis
fun main() {
@ -31,4 +34,24 @@ fun main() {
}
println("Complex addition completed in $complexTime millis")
}
}
fun complexExample() {
//Create a context for 2-d structure with complex values
NDField.complex(4, 8).run {
//a constant real-valued structure
val x = one * 2.5
operator fun Number.plus(other: Complex) = Complex(this.toDouble() + other.re, other.im)
//a structure generator specific to this context
val matrix = produce { (k, l) ->
k + l*i
}
//Perform sum
val sum = matrix + x + 1.0
//Represent the sum as 2d-structure and transpose
sum.as2D().transpose()
}
}