diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/RealTensorAlgebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/RealTensorAlgebra.kt index f234d7d6a..cad01c4d0 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/RealTensorAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/RealTensorAlgebra.kt @@ -1,6 +1,5 @@ package space.kscience.kmath.tensors -import space.kscience.kmath.linear.LupDecompositionFeature import space.kscience.kmath.nd.MutableNDBuffer import space.kscience.kmath.structures.RealBuffer import space.kscience.kmath.structures.array @@ -15,6 +14,9 @@ public class RealTensor( TensorStrides(shape), RealBuffer(buffer) ) { + /* + * TODO: Andrei remove item() + */ override fun item(): Double { check(buffer.size > 0) { "The tensor is empty" } return buffer[0] @@ -24,6 +26,10 @@ public class RealTensor( public class RealTensorAlgebra : TensorPartialDivisionAlgebra { + override fun RealTensor.value(): Double { + TODO("Andrei") + } + override fun Double.plus(other: RealTensor): RealTensor { val n = other.buffer.size val arr = other.buffer.array @@ -34,95 +40,95 @@ public class RealTensorAlgebra : TensorPartialDivisionAlgebra { + TODO("Not yet implemented") + } + override fun RealTensor.svd(): Triple { /** * Main first task for @AlyaNovikova diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/TensorAlgebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/TensorAlgebra.kt index 03f6f05c2..b2586e1e9 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/TensorAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/TensorAlgebra.kt @@ -1,7 +1,9 @@ package space.kscience.kmath.tensors // https://proofwiki.org/wiki/Definition:Algebra_over_Ring -public interface TensorAlgebra>{ +public interface TensorAlgebra> { + + public fun TensorType.value(): T public operator fun T.plus(other: TensorType): TensorType public operator fun TensorType.plus(value: T): TensorType @@ -69,6 +71,9 @@ public interface TensorPartialDivisionAlgebra //https://pytorch.org/docs/stable/generated/torch.lu.html public fun TensorType.lu(): Pair + //https://pytorch.org/docs/stable/generated/torch.lu_unpack.html + public fun lu_unpack(A_LU: TensorType, pivots: TensorType): Triple + //https://pytorch.org/docs/stable/generated/torch.svd.html public fun TensorType.svd(): Triple diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/TensorStructure.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/TensorStructure.kt index 6d2d855b6..3775ea2e5 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/TensorStructure.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/TensorStructure.kt @@ -3,6 +3,10 @@ package space.kscience.kmath.tensors import space.kscience.kmath.nd.MutableNDStructure public interface TensorStructure : MutableNDStructure { + + /* + * TODO: Andrei remove item() and value() + */ public fun item(): T // A tensor can have empty shape, in which case it represents just a value