forked from kscience/kmath
Safe item method and view_as added
This commit is contained in:
parent
f15ac20323
commit
4aa1df0628
@ -14,9 +14,13 @@ public class RealTensor(
|
||||
TensorStrides(shape),
|
||||
RealBuffer(buffer)
|
||||
) {
|
||||
override fun item(): Double = buffer[0]
|
||||
override fun item(): Double {
|
||||
check(buffer.size > 0) { "The tensor is empty" }
|
||||
return buffer[0]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class RealTensorAlgebra : TensorPartialDivisionAlgebra<Double, RealTensor> {
|
||||
|
||||
override fun Double.plus(other: RealTensor): RealTensor {
|
||||
@ -116,6 +120,10 @@ public class RealTensorAlgebra : TensorPartialDivisionAlgebra<Double, RealTensor
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun RealTensor.view_as(other: RealTensor): RealTensor {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun RealTensor.abs(): RealTensor {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ public interface TensorAlgebra<T, TensorType : TensorStructure<T>>{
|
||||
|
||||
//https://pytorch.org/docs/stable/tensor_view.html
|
||||
public fun TensorType.view(shape: IntArray): TensorType
|
||||
public fun TensorType.view_as(other: TensorType): TensorType
|
||||
|
||||
//https://pytorch.org/docs/stable/generated/torch.abs.html
|
||||
public fun TensorType.abs(): TensorType
|
||||
|
Loading…
Reference in New Issue
Block a user