v0.3.0-dev-9 #324
@ -0,0 +1,28 @@
|
|||||||
|
package space.kscience.kmath.tensors
|
||||||
|
|
||||||
|
import space.kscience.kmath.linear.BufferMatrix
|
||||||
|
import space.kscience.kmath.linear.RealMatrixContext.toBufferMatrix
|
||||||
|
import space.kscience.kmath.nd.MutableNDBuffer
|
||||||
|
import space.kscience.kmath.nd.as2D
|
||||||
|
import space.kscience.kmath.structures.MutableBuffer
|
||||||
|
import space.kscience.kmath.structures.toList
|
||||||
|
|
||||||
|
public open class BufferTensor<T>(
|
||||||
|
override val shape: IntArray,
|
||||||
|
buffer: MutableBuffer<T>
|
||||||
|
) :
|
||||||
|
TensorStructure<T>,
|
||||||
|
MutableNDBuffer<T>(
|
||||||
|
TensorStrides(shape),
|
||||||
|
buffer
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
public fun <T : Any> BufferTensor<T>.toBufferMatrix(): BufferMatrix<T> {
|
||||||
|
return BufferMatrix(shape[0], shape[1], this.buffer)
|
||||||
|
}
|
||||||
|
|
||||||
|
public fun <T : Any> BufferMatrix<T>.BufferTensor(): BufferTensor<T> {
|
||||||
|
return BufferTensor(intArrayOf(rowNum, colNum), buffer)
|
||||||
|
}
|
||||||
|
|
@ -1,19 +1,19 @@
|
|||||||
package space.kscience.kmath.tensors
|
package space.kscience.kmath.tensors
|
||||||
|
|
||||||
|
import space.kscience.kmath.linear.BufferMatrix
|
||||||
|
import space.kscience.kmath.linear.RealMatrixContext.toBufferMatrix
|
||||||
import space.kscience.kmath.nd.MutableNDBuffer
|
import space.kscience.kmath.nd.MutableNDBuffer
|
||||||
|
import space.kscience.kmath.nd.as2D
|
||||||
|
import space.kscience.kmath.structures.Buffer
|
||||||
import space.kscience.kmath.structures.RealBuffer
|
import space.kscience.kmath.structures.RealBuffer
|
||||||
import space.kscience.kmath.structures.array
|
import space.kscience.kmath.structures.array
|
||||||
|
import space.kscience.kmath.structures.toList
|
||||||
|
|
||||||
|
|
||||||
public class RealTensor(
|
public class RealTensor(
|
||||||
override val shape: IntArray,
|
shape: IntArray,
|
||||||
buffer: DoubleArray
|
buffer: DoubleArray
|
||||||
) :
|
) : BufferTensor<Double>(shape, RealBuffer(buffer))
|
||||||
TensorStructure<Double>,
|
|
||||||
MutableNDBuffer<Double>(
|
|
||||||
TensorStrides(shape),
|
|
||||||
RealBuffer(buffer)
|
|
||||||
)
|
|
||||||
|
|
||||||
public class RealTensorAlgebra : TensorPartialDivisionAlgebra<Double, RealTensor> {
|
public class RealTensorAlgebra : TensorPartialDivisionAlgebra<Double, RealTensor> {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user