Refactor/ndalgebra #197

Merged
altavir merged 11 commits from refactor/ndalgebra into dev 2021-01-28 20:13:39 +03:00
2 changed files with 3 additions and 5 deletions
Showing only changes of commit 0baec14059 - Show all commits

View File

@ -50,7 +50,7 @@ public interface BufferNDAlgebra<T, C> : NDAlgebra<T, C> {
val aBuffer = a.ndBuffer val aBuffer = a.ndBuffer
val bBuffer = b.ndBuffer val bBuffer = b.ndBuffer
val buffer = bufferFactory(strides.linearSize) { offset -> val buffer = bufferFactory(strides.linearSize) { offset ->
elementContext.transform(aBuffer.buffer[offset], bBuffer[offset]) elementContext.transform(aBuffer.buffer[offset], bBuffer.buffer[offset])
} }
return NDBuffer(strides, buffer) return NDBuffer(strides, buffer)
} }

View File

@ -217,9 +217,7 @@ public class DefaultStrides private constructor(override val shape: IntArray) :
} }
override fun offset(index: IntArray): Int = index.mapIndexed { i, value -> override fun offset(index: IntArray): Int = index.mapIndexed { i, value ->
if (value < 0 || value >= shape[i]) if (value < 0 || value >= shape[i]) throw IndexOutOfBoundsException("Index $value out of shape bounds: (0,${this.shape[i]})")
throw IndexOutOfBoundsException("Index $value out of shape bounds: (0,${this.shape[i]})")
value * strides[i] value * strides[i]
}.sum() }.sum()