forked from kscience/kmath
[WIP] Refactor NDStructures
This commit is contained in:
parent
332c04b573
commit
0baec14059
@ -50,7 +50,7 @@ public interface BufferNDAlgebra<T, C> : NDAlgebra<T, C> {
|
||||
val aBuffer = a.ndBuffer
|
||||
val bBuffer = b.ndBuffer
|
||||
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)
|
||||
}
|
||||
|
@ -217,9 +217,7 @@ public class DefaultStrides private constructor(override val shape: IntArray) :
|
||||
}
|
||||
|
||||
override fun offset(index: IntArray): Int = index.mapIndexed { i, value ->
|
||||
if (value < 0 || value >= shape[i])
|
||||
throw IndexOutOfBoundsException("Index $value out of shape bounds: (0,${this.shape[i]})")
|
||||
|
||||
if (value < 0 || value >= shape[i]) throw IndexOutOfBoundsException("Index $value out of shape bounds: (0,${this.shape[i]})")
|
||||
value * strides[i]
|
||||
}.sum()
|
||||
|
||||
@ -332,7 +330,7 @@ public inline fun <T, reified R : Any> NDStructure<T>.mapToBuffer(
|
||||
public class MutableNDBuffer<T>(
|
||||
strides: Strides,
|
||||
buffer: MutableBuffer<T>,
|
||||
) : NDBuffer<T>(strides,buffer), MutableNDStructure<T> {
|
||||
) : NDBuffer<T>(strides, buffer), MutableNDStructure<T> {
|
||||
|
||||
init {
|
||||
require(strides.linearSize == buffer.size) {
|
||||
|
Loading…
Reference in New Issue
Block a user