From 8368886c1b78ffd597915f8624fe88edd5b608d1 Mon Sep 17 00:00:00 2001 From: Martmists Date: Sat, 28 Dec 2024 02:49:09 +0100 Subject: [PATCH] ifft --- README.md | 2 +- build.gradle.kts | 2 +- .../martmists/ndarray/simd/F64TwoAxisArray.kt | 28 ++++++++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0637e50..99a3e51 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ repositories { } dependencies { - implementation("com.martmists.ndarray-simd:ndarray-simd:1.3.0") + implementation("com.martmists.ndarray-simd:ndarray-simd:1.3.1") } ``` diff --git a/build.gradle.kts b/build.gradle.kts index 939373a..e7f2fe7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,7 +14,7 @@ plugins { } group = "com.martmists.ndarray-simd" -version = "1.3.0" +version = "1.3.1" val isProduction = (findProperty("production") ?: System.getProperty("production")) != null repositories { diff --git a/src/commonMain/kotlin/com/martmists/ndarray/simd/F64TwoAxisArray.kt b/src/commonMain/kotlin/com/martmists/ndarray/simd/F64TwoAxisArray.kt index 3a53aff..fb349ab 100644 --- a/src/commonMain/kotlin/com/martmists/ndarray/simd/F64TwoAxisArray.kt +++ b/src/commonMain/kotlin/com/martmists/ndarray/simd/F64TwoAxisArray.kt @@ -1,7 +1,6 @@ package com.martmists.ndarray.simd import com.martmists.ndarray.simd.impl.create -import com.martmists.ndarray.simd.impl.unsupported /** * A 2D specialization type for [F64Array]. @@ -390,6 +389,23 @@ interface F64TwoAxisArray : F64Array { */ fun fftC2CInPlace() + /** + * Performs an inverse Complex-to-Complex FFT on this array in-place. + * The second axis has to be [real, imag]. + * The resulting array is not normalized. + * + * @since 1.3.1 + */ + fun ifftC2CInPlace() { + // Conjugate + V[_I, 1] = -V[_I, 1] + + fftC2CInPlace() + + // Conjugate again + V[_I, 1] = -V[_I, 1] + } + /** * Performs a Complex-to-Complex FFT on this array. * The second axis has to be [real, imag]. @@ -400,6 +416,16 @@ interface F64TwoAxisArray : F64Array { */ fun fftC2C() = copy().apply { fftC2CInPlace() } + /** + * Performs an inverse Complex-to-Complex FFT on this array. + * The second axis has to be [real, imag]. + * The resulting array is not normalized. + * + * @return the IFFT result + * @since 1.3.1 + */ + fun ifftC2C() = copy().apply { ifftC2CInPlace() } + companion object { /** * Creates a [F64TwoAxisArray] from a [DoubleArray].