1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! Reference (scalar f64 FFT) backend for the Poulpy lattice cryptography library.
//!
//! This module provides [`FFT64Ref`], a backend implementation for [`poulpy_hal`] that uses
//! scalar `f64` FFT arithmetic. It is the canonical reference implementation: portable across
//! all CPU architectures, prioritising correctness and debuggability over throughput.
//!
//! # Architecture
//!
//! `poulpy-hal` defines a hardware abstraction layer (HAL) via the [`Backend`](poulpy_hal::layouts::Backend)
//! trait and a family of _open extension point_ (OEP) traits in [`poulpy_hal::oep`]. This module
//! implements every OEP trait for the [`FFT64Ref`] backend by delegating to the reference
//! functions provided by `crate::reference::fft64`.
//!
//! The internal modules are organised by operation domain:
//!
//! | Module | Domain |
//! |-----------------|-----------------------------------------------------------|
//! | `module` | Backend handle lifecycle, FFT table management |
//! | `scratch` | Temporary memory allocation and arena-style sub-allocation, now provided by shared `poulpy-hal` portable defaults |
//! | `znx` | Single ring element (`Z[X]/(X^n+1)`) arithmetic |
//! | `vec_znx` | Vectors of ring elements (limb decomposition), now provided by shared `poulpy-hal` portable defaults |
//! | `vec_znx_big` | Large-coefficient (multi-word) ring element vectors, now provided by shared `poulpy-hal` FFT64 defaults |
//! | `vec_znx_dft` | Fourier-domain ring element vectors, now provided by shared `poulpy-hal` FFT64 defaults |
//! | `reim` | Real/imaginary interleaved FFT primitives |
//! | `svp` | Scalar-vector product in frequency domain, now provided by shared `poulpy-hal` FFT64 defaults |
//!
//! # Scalar types
//!
//! - `ScalarPrep = f64`: coefficients in the DFT / frequency domain.
//! - `ScalarBig = i64`: coefficients in the large-integer (multi-word) domain.
//! meaning each coefficient occupies exactly one scalar word.
pub use crateFFTModuleHandle;
pub use FFT64ReimTable;
/// Reference (portable) CPU backend using f64 FFT.
///
/// `FFT64Ref` is a zero-sized marker type that selects the reference CPU backend
/// when used as the type parameter `B` in [`poulpy_hal::layouts::Module<B>`](poulpy_hal::layouts::Module)
/// and related HAL types. It implements all open extension point (OEP) traits from
/// `poulpy_hal::oep` by delegating to the portable reference functions in
/// `crate::reference::fft64`.
///
/// # Backend characteristics
///
/// - **ScalarPrep**: `f64` — DFT-domain coefficients are 64-bit IEEE 754 floats.
/// - **ScalarBig**: `i64` — large-coefficient ring elements use 64-bit signed integers.
/// - **FFT tables**: precomputed twiddle factors stored in the module handle
/// (`FFT64RefHandle`), shared across all operations on the same module.
///
/// # Thread safety
///
/// `FFT64Ref` is `Send + Sync` (derived from being a zero-sized, field-less struct).
/// The `Module<FFT64Ref>` that holds the FFT tables is also `Send + Sync`, so modules can
/// be shared across threads. Individual operations require exclusive (`&mut`) access to their
/// output buffers and scratch space, preventing data races at the API level.
;