graph LR X["x[n]\nInput"] --> Z0["zโปยน"] Z0 --> Z1["zโปยน"] Z1 --> Z2["zโปยน"] Z2 --> Z3["โฏ"] X --> M0["ร hโ"] Z0 --> M1["ร hโ"] Z1 --> M2["ร hโ"] Z2 --> M3["ร hโ"] M0 --> SUM["+"] M1 --> SUM M2 --> SUM M3 --> SUM SUM --> Y["y[n]\nOutput"] style X fill:#4caf50,color:#fff style Y fill:#ff9800,color:#fff style M0 fill:#e3f2fd style M1 fill:#e3f2fd style M2 fill:#e3f2fd style M3 fill:#e3f2fd
graph LR subgraph "Python ๐" P1["Prototype first\nEasy to debug"] P2["numpy/scipy stack\nSlow loops"] end subgraph "Rust ๐ฆ" R1["Memory safe\nZero-cost abstractions"] R2["Cargo ecosystem\nNear-C speed"] end subgraph "C++ โก" C1["Maximum performance\nFFTW / MKL"] C2["Mature ecosystem\nFine-grained control"] end P1 --> R1 R1 --> C1 style P1 fill:#4caf50,color:#fff style P2 fill:#81c784 style R1 fill:#ff5722,color:#fff style R2 fill:#ff8a65 style C1 fill:#2196f3,color:#fff style C2 fill:#64b5f6
graph LR E0["Initial ellipsoid\nEโ(40ยฒ)"] --> O["Oracle:\nviolated constraint?"] O -->|"Yes โ๏ธ"| CUT["Add cutting plane"] CUT --> UPDATE["Shrink ellipsoid\nEโ โ Eโโโ"] UPDATE --> O O -->|"No โ "| DONE["Optimal found!"] DONE --> SF["Spectral\nFactorization"] SF --> CSDQ["CSD\nQuantize"] style E0 fill:#e3f2fd style O fill:#fff9c4 style CUT fill:#ffe0b2 style UPDATE fill:#f3e5f5 style DONE fill:#c8e6c9 style SF fill:#e1f5fe style CSDQ fill:#fff3e0
graph LR START(["x = r[k]"]) --> NR["x[0] โฅ 0?\nNon-negative real"] NR -->|No โ| CUT1["g = [-1,0,...]\nf = -x[0]"] NR -->|Yes โ | PB["Passband:\nLยฒ โค R(ฯ) โค Uยฒ"] PB -->|Violated โ| CUT2["g = ยฑAโ(ฯ)\nf = R(ฯ) โ bound"] PB -->|OK โ | SB["Stopband:\nR(ฯ) โค Sยฒ"] SB -->|Violated โ| CUT3["g = ยฑAโ(ฯ)\nf = R(ฯ) - Sยฒ"] SB -->|OK โ | NNR["Non-redundant:\nR(ฯ) โฅ 0"] NNR -->|Violated โ| CUT4["g = -Aโแตฃ(ฯ)\nf = -R(ฯ)"] NNR -->|OK โ | OPT["Optimal โ "] style NR fill:#e3f2fd style PB fill:#fff9c4 style SB fill:#ffe0b2 style NNR fill:#f3e5f5 style OPT fill:#c8e6c9 style CUT1 fill:#ffcdd2 style CUT2 fill:#ffcdd2 style CUT3 fill:#ffcdd2 style CUT4 fill:#ffcdd2
graph LR R["r* (optimal)\nAutocorrelation"] --> SF["Spectral\nFactor"] SF --> H["h (continuous)\nImpulse response"] H --> CSDQ["CSD quantize\nโค nnz non-zero digits"] CSDQ --> HCSD["hฬ (CSD)"] HCSD --> INV["Inverse Spectral\nFactor"] INV --> RCSD["rฬ (CSD)\nAutocorrelation"] style R fill:#4caf50,color:#fff style SF fill:#2196f3,color:#fff style H fill:#ff9800,color:#fff style CSDQ fill:#9c27b0,color:#fff style HCSD fill:#e91e63,color:#fff style INV fill:#00bcd4,color:#fff style RCSD fill:#ff5722,color:#fff
graph TD A["Full Spectrum Matrix A\n(m ร n)"] --> AP["Ap: passband rows\n0 โค ฯ โค ฯโ"] A --> AS["As: stopband rows\nฯโ โค ฯ โค ฯ"] A --> ANR["Anr: transition rows\nฯโ < ฯ < ฯโ"] style A fill:#e3f2fd style AP fill:#c8e6c9 style AS fill:#ffcdd2 style ANR fill:#fff9c4
graph TD subgraph "Relative Performance" CPP["C++\n303ms\n1.0ร"] -.-> RUST["Rust ๐\n286ms\n0.95ร"] RUST --> PY["Python\n4046ms\n14.2ร"] end style CPP fill:#2196f3,color:#fff style RUST fill:#4caf50,color:#fff style PY fill:#ff5722,color:#fff
graph TD subgraph "Optimization Loop (~95% of time)" O1["Constraint check\n(matrix dot product)"] O2["Ellipsoid update"] O3["Cutting plane"] O1 --> O2 --> O3 --> O1 end subgraph "Spectral Factorization (~5%)" S1["Power spectrum\n(FFT or matrix)"] S2["Hilbert transform\n(FFT-based)"] S1 --> S2 end style O1 fill:#e3f2fd style O2 fill:#f3e5f5 style O3 fill:#fff9c4 style S1 fill:#e8f5e9 style S2 fill:#fff3e0
graph TD P["Same Parameters โ "] --> C["CSD Quantization:"] P --> F["FFT Library:"] P --> A["FP Accumulation:"] C --> C1["All three:\ndirect doubleโdouble\ncsd_quantize() โ "] C --> C2["(was Python/Rust string\nround-trip, fixed now)"] F --> F1["C++: FFTW3 (rfft)"] F --> F2["Python: numpy.fft\n(rfft, like C++)"] F --> F3["Rust: realfft\n(rfft, like C++)"] A --> A1["Over 2000+ iterations,\nULP differences compound ๐"] C1 --> D["Different cutting planes โ"] F1 --> D F2 --> D F3 --> D A1 --> D D --> R["Different Pareto-optimal points\nAll satisfying same constraints โ "] style P fill:#c8e6c9 style C fill:#fff9c4 style F fill:#fff9c4 style A fill:#fff9c4 style D fill:#ffe0b2 style R fill:#c8e6c9
graph LR subgraph "Completed โ " C1["Direct csd_quantize()\nin Rust + Python"] C2["rfft for power\nspectrum (all 3 langs)"] C3["Pre-allocated\ngradient buffer"] end subgraph "Future ๐" M1["SIMD-optimized\nArr operations"] M2["Benchmark harness\n(hyperfine/criterion)"] M3["GitHub Actions CI\nfor all 3 langs"] end style C1 fill:#4caf50,color:#fff style C2 fill:#4caf50,color:#fff style C3 fill:#4caf50,color:#fff style M1 fill:#fff9c4 style M2 fill:#fff9c4 style M3 fill:#fff9c4