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
|
||||
|
||||
/**
|
||||
* [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(
|
||||
override val shape: IntArray,
|
||||
@ -14,7 +14,7 @@ public open class BufferedTensor<T> internal constructor(
|
||||
) : Tensor<T> {
|
||||
|
||||
/**
|
||||
* [TensorLinearStructure] with the same shape
|
||||
* Buffer strides based on [TensorLinearStructure] implementation
|
||||
*/
|
||||
public val linearStructure: TensorLinearStructure
|
||||
get() = TensorLinearStructure(shape)
|
||||
@ -25,23 +25,12 @@ public open class BufferedTensor<T> internal constructor(
|
||||
public val numElements: Int
|
||||
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)]
|
||||
|
||||
/**
|
||||
* @param index the [IntArray] with size equal to tensor dimension
|
||||
* @param value the value to set
|
||||
*/
|
||||
override fun set(index: IntArray, value: T) {
|
||||
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 {
|
||||
it to this[it]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user