pre-0.0.3 #46

Merged
altavir merged 75 commits from dev into master 2019-02-20 13:05:39 +03:00
2 changed files with 7 additions and 3 deletions
Showing only changes of commit c0bdacecb3 - Show all commits

View File

@ -33,9 +33,6 @@ interface Space<T> {
operator fun T.times(k: Number) = multiply(this, k.toDouble())
operator fun T.div(k: Number) = multiply(this, 1.0 / k.toDouble())
operator fun Number.times(b: T) = b * this
fun Iterable<T>.sum(): T = fold(zero) { left, right -> add(left,right) }
fun Sequence<T>.sum(): T = fold(zero) { left, right -> add(left, right) }
}
/**

View File

@ -0,0 +1,7 @@
package scientifik.kmath.operations
import scientifik.kmath.structures.Buffer
import scientifik.kmath.structures.asSequence
fun <T> Space<T>.sum(data : Iterable<T>): T = data.fold(zero) { left, right -> add(left,right) }
fun <T> Space<T>.sum(data : Sequence<T>): T = data.fold(zero) { left, right -> add(left, right) }