diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt index cc1764643..c07726ad6 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/BufferNDAlgebra.kt @@ -50,7 +50,7 @@ public interface BufferNDAlgebra : NDAlgebra { 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) } diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDStructure.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDStructure.kt index 09c6fa198..4aa1c7d52 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDStructure.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/nd/NDStructure.kt @@ -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 NDStructure.mapToBuffer( public class MutableNDBuffer( strides: Strides, buffer: MutableBuffer, -) : NDBuffer(strides,buffer), MutableNDStructure { +) : NDBuffer(strides, buffer), MutableNDStructure { init { require(strides.linearSize == buffer.size) {