KMP library for tensors #300

Merged
grinisrit merged 215 commits from feature/tensor-algebra into dev 2021-05-08 09:48:04 +03:00
Showing only changes of commit d8ef190ed8 - Show all commits

View File

@ -189,11 +189,6 @@ public interface Strides {
*/ */
public fun index(offset: Int): IntArray public fun index(offset: Int): IntArray
/**
* Get next multidimensional index from the current multidimensional index
*/
public fun nextIndex(index: IntArray): IntArray
/** /**
* The size of linear buffer to accommodate all elements of ND-structure corresponding to strides * The size of linear buffer to accommodate all elements of ND-structure corresponding to strides
*/ */
@ -232,7 +227,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]) throw IndexOutOfBoundsException("Index $value out of shape bounds: (0,${shape[i]})") if (value < 0 || value >= shape[i]) throw IndexOutOfBoundsException("Index $value out of shape bounds: (0,${this.shape[i]})")
value * strides[i] value * strides[i]
}.sum() }.sum()
@ -250,10 +245,6 @@ public class DefaultStrides private constructor(override val shape: IntArray) :
return res return res
} }
override fun nextIndex(index: IntArray): IntArray {
TODO("Not yet implemented")
}
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (this === other) return true if (this === other) return true
if (other !is DefaultStrides) return false if (other !is DefaultStrides) return false
@ -275,7 +266,6 @@ public class DefaultStrides private constructor(override val shape: IntArray) :
} }
} }
public inline fun <reified T : Any> StructureND<T>.combine( public inline fun <reified T : Any> StructureND<T>.combine(
struct: StructureND<T>, struct: StructureND<T>,
crossinline block: (T, T) -> T, crossinline block: (T, T) -> T,