Dev #194

Merged
altavir merged 266 commits from dev into master 2021-01-20 17:32:32 +03:00
3 changed files with 6 additions and 3 deletions
Showing only changes of commit 2bc62356d6 - Show all commits

View File

@ -14,8 +14,9 @@ class BoxingNDField<T, F : Field<T>>(
fun buildBuffer(size: Int, initializer: (Int) -> T): Buffer<T> =
bufferFactory(size, initializer)
override fun check(vararg elements: NDBuffer<T>) {
override fun check(vararg elements: NDBuffer<T>): Array<out NDBuffer<T>> {
if (!elements.all { it.strides == this.strides }) error("Element strides are not the same as context strides")
return elements
}
override val zero: BufferedNDFieldElement<T, F> by lazy { produce { zero } }

View File

@ -14,8 +14,9 @@ class BoxingNDRing<T, R : Ring<T>>(
fun buildBuffer(size: Int, initializer: (Int) -> T): Buffer<T> =
bufferFactory(size, initializer)
override fun check(vararg elements: NDBuffer<T>) {
override fun check(vararg elements: NDBuffer<T>): Array<out NDBuffer<T>> {
if (!elements.all { it.strides == this.strides }) error("Element strides are not the same as context strides")
return elements
}
override val zero: BufferedNDRingElement<T, R> by lazy { produce { zero } }

View File

@ -5,8 +5,9 @@ import scientifik.kmath.operations.*
interface BufferedNDAlgebra<T, C> : NDAlgebra<T, C, NDBuffer<T>> {
val strides: Strides
override fun check(vararg elements: NDBuffer<T>) {
override fun check(vararg elements: NDBuffer<T>): Array<out NDBuffer<T>> {
if (!elements.all { it.strides == this.strides }) error("Strides mismatch")
return elements
}
/**