forked from kscience/kmath
minor corrections
This commit is contained in:
parent
0e793eba26
commit
35928e7960
@ -5,7 +5,7 @@ import space.kscience.kmath.tensors.api.Tensor
|
|||||||
import space.kscience.kmath.tensors.core.algebras.TensorLinearStructure
|
import space.kscience.kmath.tensors.core.algebras.TensorLinearStructure
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [Tensor] implementation provided with [MutableBuffer]
|
* Represents [Tensor] over a [MutableBuffer] intended to be used through [DoubleTensor] and [IntTensor]
|
||||||
*/
|
*/
|
||||||
public open class BufferedTensor<T> internal constructor(
|
public open class BufferedTensor<T> internal constructor(
|
||||||
override val shape: IntArray,
|
override val shape: IntArray,
|
||||||
@ -14,7 +14,7 @@ public open class BufferedTensor<T> internal constructor(
|
|||||||
) : Tensor<T> {
|
) : Tensor<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [TensorLinearStructure] with the same shape
|
* Buffer strides based on [TensorLinearStructure] implementation
|
||||||
*/
|
*/
|
||||||
public val linearStructure: TensorLinearStructure
|
public val linearStructure: TensorLinearStructure
|
||||||
get() = TensorLinearStructure(shape)
|
get() = TensorLinearStructure(shape)
|
||||||
@ -25,23 +25,12 @@ public open class BufferedTensor<T> internal constructor(
|
|||||||
public val numElements: Int
|
public val numElements: Int
|
||||||
get() = linearStructure.linearSize
|
get() = linearStructure.linearSize
|
||||||
|
|
||||||
/**
|
|
||||||
* @param index [IntArray] with size equal to tensor dimension
|
|
||||||
* @return the element by multidimensional index
|
|
||||||
*/
|
|
||||||
override fun get(index: IntArray): T = mutableBuffer[bufferStart + linearStructure.offset(index)]
|
override fun get(index: IntArray): T = mutableBuffer[bufferStart + linearStructure.offset(index)]
|
||||||
|
|
||||||
/**
|
|
||||||
* @param index the [IntArray] with size equal to tensor dimension
|
|
||||||
* @param value the value to set
|
|
||||||
*/
|
|
||||||
override fun set(index: IntArray, value: T) {
|
override fun set(index: IntArray, value: T) {
|
||||||
mutableBuffer[bufferStart + linearStructure.offset(index)] = value
|
mutableBuffer[bufferStart + linearStructure.offset(index)] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the sequence of pairs multidimensional indices and values
|
|
||||||
*/
|
|
||||||
override fun elements(): Sequence<Pair<IntArray, T>> = linearStructure.indices().map {
|
override fun elements(): Sequence<Pair<IntArray, T>> = linearStructure.indices().map {
|
||||||
it to this[it]
|
it to this[it]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user