KMP library for tensors #300

Merged
grinisrit merged 215 commits from feature/tensor-algebra into dev 2021-05-08 09:48:04 +03:00
2 changed files with 21 additions and 23 deletions
Showing only changes of commit f15ac20323 - Show all commits

View File

@ -19,25 +19,6 @@ public class RealTensor(
public class RealTensorAlgebra : TensorPartialDivisionAlgebra<Double, RealTensor> { public class RealTensorAlgebra : TensorPartialDivisionAlgebra<Double, RealTensor> {
override fun add(a: RealTensor, b: RealTensor): RealTensor {
TODO("Not yet implemented")
}
override fun multiply(a: RealTensor, k: Number): RealTensor {
TODO("Not yet implemented")
}
override val zero: RealTensor
get() = TODO("Not yet implemented")
override fun multiply(a: RealTensor, b: RealTensor): RealTensor {
TODO("Not yet implemented")
}
override val one: RealTensor
get() = TODO("Not yet implemented")
override fun Double.plus(other: RealTensor): RealTensor { override fun Double.plus(other: RealTensor): RealTensor {
val n = other.buffer.size val n = other.buffer.size
val arr = other.buffer.array val arr = other.buffer.array
@ -51,6 +32,10 @@ public class RealTensorAlgebra : TensorPartialDivisionAlgebra<Double, RealTensor
TODO("Not yet implemented") TODO("Not yet implemented")
} }
override fun RealTensor.plus(other: RealTensor): RealTensor {
TODO("Not yet implemented")
}
override fun RealTensor.plusAssign(value: Double) { override fun RealTensor.plusAssign(value: Double) {
TODO("Not yet implemented") TODO("Not yet implemented")
} }
@ -67,6 +52,10 @@ public class RealTensorAlgebra : TensorPartialDivisionAlgebra<Double, RealTensor
TODO("Not yet implemented") TODO("Not yet implemented")
} }
override fun RealTensor.minus(other: RealTensor): RealTensor {
TODO("Not yet implemented")
}
override fun RealTensor.minusAssign(value: Double) { override fun RealTensor.minusAssign(value: Double) {
TODO("Not yet implemented") TODO("Not yet implemented")
} }
@ -83,6 +72,10 @@ public class RealTensorAlgebra : TensorPartialDivisionAlgebra<Double, RealTensor
TODO("Not yet implemented") TODO("Not yet implemented")
} }
override fun RealTensor.times(other: RealTensor): RealTensor {
TODO("Not yet implemented")
}
override fun RealTensor.timesAssign(value: Double) { override fun RealTensor.timesAssign(value: Double) {
TODO("Not yet implemented") TODO("Not yet implemented")
} }
@ -91,6 +84,10 @@ public class RealTensorAlgebra : TensorPartialDivisionAlgebra<Double, RealTensor
TODO("Not yet implemented") TODO("Not yet implemented")
} }
override fun RealTensor.unaryMinus(): RealTensor {
TODO("Not yet implemented")
}
override fun RealTensor.dot(other: RealTensor): RealTensor { override fun RealTensor.dot(other: RealTensor): RealTensor {
TODO("Not yet implemented") TODO("Not yet implemented")
} }

View File

@ -1,25 +1,26 @@
package space.kscience.kmath.tensors package space.kscience.kmath.tensors
import space.kscience.kmath.operations.Ring
import space.kscience.kmath.operations.RingWithNumbers
// https://proofwiki.org/wiki/Definition:Algebra_over_Ring // https://proofwiki.org/wiki/Definition:Algebra_over_Ring
public interface TensorAlgebra<T, TensorType : TensorStructure<T>>: RingWithNumbers<TensorType> { public interface TensorAlgebra<T, TensorType : TensorStructure<T>>{
public operator fun T.plus(other: TensorType): TensorType public operator fun T.plus(other: TensorType): TensorType
public operator fun TensorType.plus(value: T): TensorType public operator fun TensorType.plus(value: T): TensorType
public operator fun TensorType.plus(other: TensorType): TensorType
public operator fun TensorType.plusAssign(value: T): Unit public operator fun TensorType.plusAssign(value: T): Unit
public operator fun TensorType.plusAssign(other: TensorType): Unit public operator fun TensorType.plusAssign(other: TensorType): Unit
public operator fun T.minus(other: TensorType): TensorType public operator fun T.minus(other: TensorType): TensorType
public operator fun TensorType.minus(value: T): TensorType public operator fun TensorType.minus(value: T): TensorType
public operator fun TensorType.minus(other: TensorType): TensorType
public operator fun TensorType.minusAssign(value: T): Unit public operator fun TensorType.minusAssign(value: T): Unit
public operator fun TensorType.minusAssign(other: TensorType): Unit public operator fun TensorType.minusAssign(other: TensorType): Unit
public operator fun T.times(other: TensorType): TensorType public operator fun T.times(other: TensorType): TensorType
public operator fun TensorType.times(value: T): TensorType public operator fun TensorType.times(value: T): TensorType
public operator fun TensorType.times(other: TensorType): TensorType
public operator fun TensorType.timesAssign(value: T): Unit public operator fun TensorType.timesAssign(value: T): Unit
public operator fun TensorType.timesAssign(other: TensorType): Unit public operator fun TensorType.timesAssign(other: TensorType): Unit
public operator fun TensorType.unaryMinus(): TensorType
//https://pytorch.org/docs/stable/generated/torch.matmul.html //https://pytorch.org/docs/stable/generated/torch.matmul.html