Refactor/ndalgebra #197
@ -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)
|
||||||
}
|
}
|
||||||
|
@ -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()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user