diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/ComplexTensorAlgebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/ComplexTensorAlgebra.kt new file mode 100644 index 000000000..3f5b7d667 --- /dev/null +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/ComplexTensorAlgebra.kt @@ -0,0 +1,47 @@ +package space.kscience.kmath.tensors + +public interface ComplexTensorAlgebra, + ComplexTensorType : ComplexTensorStructure> + : TensorPartialDivisionAlgebra{ + + //https://pytorch.org/docs/stable/generated/torch.view_as_complex.html + public fun RealTensorType.viewAsComplex(): ComplexTensorType + + //https://pytorch.org/docs/stable/generated/torch.angle.html + public fun ComplexTensorType.angle(): RealTensorType + + //https://pytorch.org/docs/stable/generated/torch.stft.html#torch.stft + public fun ComplexTensorType.stft( + nFFT: Int, + hopLength: Int, + winLength: Int, + window: RealTensorType, + normalised: Boolean, + oneSided: Boolean + ) + + //https://pytorch.org/docs/stable/generated/torch.istft.html#torch.istft + public fun ComplexTensorType.istft( + nFFT: Int, + hopLength: Int, + winLength: Int, + window: RealTensorType, + center: Boolean, + normalised: Boolean, + oneSided: Boolean, + length: Int + ) + + //https://pytorch.org/docs/stable/generated/torch.bartlett_window.html#torch.bartlett_window + public fun bartlettWindow(windowLength: Int, periodic: Boolean): RealTensorType + + //https://pytorch.org/docs/stable/generated/torch.blackman_window.html#torch.blackman_window + public fun blackmanWindow(windowLength: Int, periodic: Boolean): RealTensorType + + //https://pytorch.org/docs/stable/generated/torch.hamming_window.html#torch.hamming_window + public fun hammingWindow(windowLength: Int, periodic: Boolean, alpha: T, beta: T): RealTensorType + + //https://pytorch.org/docs/stable/generated/torch.kaiser_window.html#torch.kaiser_window + public fun kaiserWindow(windowLength: Int, periodic: Boolean, beta: T): RealTensorType +} \ No newline at end of file diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/ComplexTensorStructure.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/ComplexTensorStructure.kt new file mode 100644 index 000000000..0e0975830 --- /dev/null +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/ComplexTensorStructure.kt @@ -0,0 +1,14 @@ +package space.kscience.kmath.tensors + +public interface ComplexTensorStructure> : TensorStructure { + + //https://pytorch.org/docs/master/generated/torch.view_as_real.html + public fun viewAsReal(): RealTensorType + + //https://pytorch.org/docs/stable/generated/torch.real.html + public fun realPart(): RealTensorType + + //https://pytorch.org/docs/stable/generated/torch.imag.html + public fun imaginaryPart(): RealTensorType + +} \ No newline at end of file diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/RealAnalyticTensorAlgebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/RealAnalyticTensorAlgebra.kt index a93ebcb89..f610361fc 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/RealAnalyticTensorAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/RealAnalyticTensorAlgebra.kt @@ -146,5 +146,5 @@ public class RealAnalyticTensorAlgebra: } -public inline fun RealAnalyticTensorAlgebra(block: RealTensorAlgebra.() -> R): R = +public inline fun RealAnalyticTensorAlgebra(block: RealAnalyticTensorAlgebra.() -> R): R = RealAnalyticTensorAlgebra().block() \ No newline at end of file diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/RealLinearOpsTensorAlgebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/RealLinearOpsTensorAlgebra.kt index dcd740356..6b1957b8c 100644 --- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/RealLinearOpsTensorAlgebra.kt +++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/tensors/RealLinearOpsTensorAlgebra.kt @@ -127,5 +127,5 @@ public class RealLinearOpsTensorAlgebra : } -public inline fun RealLinearOpsTensorAlgebra(block: RealTensorAlgebra.() -> R): R = +public inline fun RealLinearOpsTensorAlgebra(block: RealLinearOpsTensorAlgebra.() -> R): R = RealLinearOpsTensorAlgebra().block() \ No newline at end of file