@@ -1505,6 +1505,23 @@ size_t ngfft_twiddle_count(ngfft_plan<T>& plan, cval_t<dft_algorithm, algo>);
15051505template <typename T, dft_algorithm algo>
15061506bool ngfft_initialize (ngfft_plan<T>& plan, cval_t <dft_algorithm, algo>);
15071507
1508+ /* *
1509+ * @brief Executes the FFT with separate input and output buffers.
1510+ *
1511+ * The transform reads from the input buffer and writes the result to the output
1512+ * buffer. No scaling is applied.
1513+ *
1514+ * @tparam T Floating-point scalar type.
1515+ * @tparam algo FFT algorithm.
1516+ * @tparam inverse If true, performs the inverse FFT; otherwise the forward FFT.
1517+ * @param plan The initialized plan.
1518+ * @param out Output buffer of `2^plan.l2fftsize` complex elements.
1519+ * @param in Input buffer of `2^plan.l2fftsize` complex elements.
1520+ */
1521+ template <typename T, dft_algorithm algo, bool inverse>
1522+ void ngfft_execute (const ngfft_plan<T>& plan, cval_t <dft_algorithm, algo>, cbool_t <inverse>, complex <T>* out,
1523+ const complex <T>* in);
1524+
15081525/* *
15091526 * @brief Executes the FFT in-place on the given complex buffer.
15101527 *
@@ -1518,25 +1535,48 @@ bool ngfft_initialize(ngfft_plan<T>& plan, cval_t<dft_algorithm, algo>);
15181535 * @param inout Input/output buffer of `2^plan.l2fftsize` complex elements.
15191536 */
15201537template <typename T, dft_algorithm algo, bool inverse>
1521- void ngfft_execute (const ngfft_plan<T>& plan, cval_t <dft_algorithm, algo>, cbool_t <inverse>,
1522- complex <T>* inout);
1538+ KFR_INLINE void ngfft_execute (const ngfft_plan<T>& plan, cval_t <dft_algorithm, algo>, cbool_t <inverse>,
1539+ complex <T>* inout)
1540+ {
1541+ return ngfft_execute<T, algo, inverse>(plan, cval<dft_algorithm, algo>, cbool_t <inverse>(), inout, inout);
1542+ }
15231543
15241544/* *
15251545 * @brief Executes the FFT in-place with a runtime direction flag.
15261546 * @copydetails ngfft_execute(const ngfft_plan<T>&, cval_t<dft_algorithm,algo>, cbool_t<inverse>, complex<T>*)
15271547 * @param inverse If true, performs the inverse FFT; otherwise the forward FFT.
15281548 */
15291549template <typename T, dft_algorithm algo>
1530- inline void ngfft_execute (const ngfft_plan<T>& plan, cval_t <dft_algorithm, algo>, bool inverse,
1531- complex <T>* inout)
1550+ KFR_INLINE void ngfft_execute (const ngfft_plan<T>& plan, cval_t <dft_algorithm, algo>, bool inverse,
1551+ complex <T>* inout)
1552+ {
1553+ if (inverse)
1554+ {
1555+ return ngfft_execute<T, algo, true >(plan, cval<dft_algorithm, algo>, ctrue, inout, inout);
1556+ }
1557+ else
1558+ {
1559+ return ngfft_execute<T, algo, false >(plan, cval<dft_algorithm, algo>, cfalse, inout, inout);
1560+ }
1561+ }
1562+
1563+ /* *
1564+ * @brief Executes the FFT with separate input and output buffers and a runtime direction flag.
1565+ * @copydetails ngfft_execute(const ngfft_plan<T>&, cval_t<dft_algorithm,algo>, cbool_t<inverse>, complex<T>*,
1566+ * const complex<T>*)
1567+ * @param inverse If true, performs the inverse FFT; otherwise the forward FFT.
1568+ */
1569+ template <typename T, dft_algorithm algo>
1570+ KFR_INLINE void ngfft_execute (const ngfft_plan<T>& plan, cval_t <dft_algorithm, algo>, bool inverse,
1571+ complex <T>* out, const complex <T>* in)
15321572{
15331573 if (inverse)
15341574 {
1535- return ngfft_execute<T, algo, true >(plan, cval<dft_algorithm, algo>, ctrue, inout );
1575+ return ngfft_execute<T, algo, true >(plan, cval<dft_algorithm, algo>, ctrue, out, in );
15361576 }
15371577 else
15381578 {
1539- return ngfft_execute<T, algo, false >(plan, cval<dft_algorithm, algo>, cfalse, inout );
1579+ return ngfft_execute<T, algo, false >(plan, cval<dft_algorithm, algo>, cfalse, out, in );
15401580 }
15411581}
15421582
@@ -1585,13 +1625,36 @@ inline bool ngfft_initialize(ngfft_plan<T>& plan, dft_algorithm algo = dft_algor
15851625 * @param algo FFT algorithm (defaults to `fourstep`).
15861626 */
15871627template <typename T, bool inverse>
1588- inline void ngfft_execute (const ngfft_plan<T>& plan, cbool_t <inverse>, complex <T>* inout,
1589- dft_algorithm algo = dft_algorithm::fourstep)
1628+ KFR_INLINE void ngfft_execute (const ngfft_plan<T>& plan, cbool_t <inverse>, complex <T>* inout,
1629+ dft_algorithm algo = dft_algorithm::fourstep)
15901630{
15911631 switch (algo)
15921632 {
15931633 case dft_algorithm::fourstep:
1594- return ngfft_execute (plan, cval<dft_algorithm, dft_algorithm::fourstep>, cbool_t <inverse>(), inout);
1634+ return ngfft_execute (plan, cval<dft_algorithm, dft_algorithm::fourstep>, cbool_t <inverse>(), inout,
1635+ inout);
1636+ default :
1637+ KFR_UNREACHABLE ;
1638+ }
1639+ }
1640+
1641+ /* *
1642+ * @brief Executes the FFT with separate input and output buffers, a compile-time direction and runtime
1643+ * algorithm.
1644+ * @tparam inverse If true, performs the inverse FFT; otherwise the forward FFT.
1645+ * @param plan The initialized plan.
1646+ * @param out Output buffer of `2^plan.l2fftsize` complex elements.
1647+ * @param in Input buffer of `2^plan.l2fftsize` complex elements.
1648+ * @param algo FFT algorithm (defaults to `fourstep`).
1649+ */
1650+ template <typename T, bool inverse>
1651+ KFR_INLINE void ngfft_execute (const ngfft_plan<T>& plan, cbool_t <inverse>, complex <T>* out,
1652+ const complex <T>* in, dft_algorithm algo = dft_algorithm::fourstep)
1653+ {
1654+ switch (algo)
1655+ {
1656+ case dft_algorithm::fourstep:
1657+ return ngfft_execute (plan, cval<dft_algorithm, dft_algorithm::fourstep>, cbool_t <inverse>(), out, in);
15951658 default :
15961659 KFR_UNREACHABLE ;
15971660 }
@@ -1605,13 +1668,31 @@ inline void ngfft_execute(const ngfft_plan<T>& plan, cbool_t<inverse>, complex<T
16051668 * @param algo FFT algorithm (defaults to `fourstep`).
16061669 */
16071670template <typename T>
1608- inline void ngfft_execute (const ngfft_plan<T>& plan, bool inverse, complex <T>* inout,
1609- dft_algorithm algo = dft_algorithm::fourstep)
1671+ KFR_INLINE void ngfft_execute (const ngfft_plan<T>& plan, bool inverse, complex <T>* inout,
1672+ dft_algorithm algo = dft_algorithm::fourstep)
1673+ {
1674+ if (inverse)
1675+ return ngfft_execute (plan, ctrue, inout, inout, algo);
1676+ else
1677+ return ngfft_execute (plan, cfalse, inout, inout, algo);
1678+ }
1679+
1680+ /* *
1681+ * @brief Executes the FFT with separate input and output buffers, runtime direction and algorithm.
1682+ * @param plan The initialized plan.
1683+ * @param inverse If true, performs the inverse FFT; otherwise the forward FFT.
1684+ * @param out Output buffer of `2^plan.l2fftsize` complex elements.
1685+ * @param in Input buffer of `2^plan.l2fftsize` complex elements.
1686+ * @param algo FFT algorithm (defaults to `fourstep`).
1687+ */
1688+ template <typename T>
1689+ KFR_INLINE void ngfft_execute (const ngfft_plan<T>& plan, bool inverse, complex <T>* out, const complex <T>* in,
1690+ dft_algorithm algo = dft_algorithm::fourstep)
16101691{
16111692 if (inverse)
1612- return ngfft_execute (plan, ctrue, inout , algo);
1693+ return ngfft_execute (plan, ctrue, out, in , algo);
16131694 else
1614- return ngfft_execute (plan, cfalse, inout , algo);
1695+ return ngfft_execute (plan, cfalse, out, in , algo);
16151696}
16161697
16171698#ifdef KFR_CLASSIC_FFT
0 commit comments