Examples fix

This commit is contained in:
Alexander Nozik 2019-06-08 16:30:06 +03:00
parent f480aa1c5c
commit cd1c155e7d
2 changed files with 5 additions and 10 deletions

View File

@ -9,15 +9,10 @@ structures. In `kmath` performance depends on which particular context was used
Let us consider following contexts: Let us consider following contexts:
```kotlin ```kotlin
// specialized nd-field for Double. It works as generic Double field as well
val specializedField = NDField.real(intArrayOf(dim, dim))
// automatically build context most suited for given type. // automatically build context most suited for given type.
val autoField = NDField.auto(intArrayOf(dim, dim), RealField) val autoField = NDField.auto(RealField, dim, dim)
// specialized nd-field for Double. It works as generic Double field as well
//A field implementing lazy computations. All elements are computed on-demand val specializedField = NDField.real(dim, dim)
val lazyField = NDField.lazy(intArrayOf(dim, dim), RealField)
//A generic boxing field. It should be used for objects, not primitives. //A generic boxing field. It should be used for objects, not primitives.
val genericField = NDField.buffered(intArrayOf(dim, dim), RealField) val genericField = NDField.buffered(intArrayOf(dim, dim), RealField)
``` ```
@ -32,7 +27,7 @@ to it `n = 1000` times.
The code to run this looks like: The code to run this looks like:
```kotlin ```kotlin
specializedField.run { specializedField.run {
var res = one var res: NDBuffer<Double> = one
repeat(n) { repeat(n) {
res += 1.0 res += 1.0
} }
@ -93,7 +88,7 @@ In this case it completes in about `4x-5x` time due to boxing.
The boxing field produced by The boxing field produced by
```kotlin ```kotlin
genericField.run { genericField.run {
var res = one var res: NDBuffer<Double> = one
repeat(n) { repeat(n) {
res += 1.0 res += 1.0
} }