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 95b814e163 - Show all commits

View File

@ -2,8 +2,12 @@ package space.kscience.kmath.tensors
import space.kscience.kmath.linear.BufferMatrix import space.kscience.kmath.linear.BufferMatrix
import space.kscience.kmath.linear.RealMatrixContext.toBufferMatrix import space.kscience.kmath.linear.RealMatrixContext.toBufferMatrix
import space.kscience.kmath.nd.Matrix
import space.kscience.kmath.nd.MutableNDBuffer import space.kscience.kmath.nd.MutableNDBuffer
import space.kscience.kmath.nd.Structure2D
import space.kscience.kmath.nd.as2D import space.kscience.kmath.nd.as2D
import space.kscience.kmath.structures.Buffer
import space.kscience.kmath.structures.BufferAccessor2D
import space.kscience.kmath.structures.MutableBuffer import space.kscience.kmath.structures.MutableBuffer
import space.kscience.kmath.structures.toList import space.kscience.kmath.structures.toList
@ -22,7 +26,8 @@ public fun <T : Any> BufferTensor<T>.toBufferMatrix(): BufferMatrix<T> {
return BufferMatrix(shape[0], shape[1], this.buffer) return BufferMatrix(shape[0], shape[1], this.buffer)
} }
public fun <T : Any> BufferMatrix<T>.BufferTensor(): BufferTensor<T> { // T???
return BufferTensor(intArrayOf(rowNum, colNum), buffer) public fun BufferMatrix<Double>.BufferTensor(): BufferTensor<Double> {
return BufferTensor(intArrayOf(rowNum, colNum), BufferAccessor2D(rowNum, colNum, Buffer.Companion::real).create(this))
} }