Skip to content

feat(rf): c64/c128 complex types, DFT + IQ mixer examples - #395

Merged
godofecht merged 1 commit into
mainfrom
feat/complex-types-w0
Aug 10, 2026
Merged

godofecht merged 1 commit into
mainfrom
feat/complex-types-w0

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

Summary

  • Add c64 and c128 complex number types backed by C99 _Complex (float complex / double complex)
  • Constructors: c64(re, im), c128(re, im), c64(x) for real-only
  • Complex builtins: creal, cimag, cabs, carg, conj, cexp, clog, csqrt, cpow
  • Automatic numeric promotion: c64 + c128 -> c128, c64 + f64 -> c128
  • #include <complex.h> emitted in all generated C
  • printf renders complex as (re + im j) since C has no complex format specifier
  • Examples: examples/rf/dft.flow (8-point DFT), examples/rf/iq_mixer.flow (quadrature mixer)
  • Tests: tests/unit/test_complex_types.py (15 tests)
  • Docs: types.md, overview.md, CHANGELOG.md, ROADMAP.md updated

This is the first piece of W0 (RF/SDR beachhead) on the roadmap. Next steps: quantity literals, IQ type alias, rate-typed Signal.

Test plan

  • 1224/1224 unit tests pass (including 15 new complex tests)
  • examples/rf/dft.flow compiles and runs, prints correct spectrum
  • examples/rf/iq_mixer.flow compiles and runs, mixer output verified

This pull request includes code written with the assistance of AI.
The code has not yet been reviewed by a human.

Generated with Devin

Add C99 _Complex-backed complex number types for the RF/SDR beachhead
(W0 on the roadmap). c64 maps to float complex, c128 to double complex.

Parser: new C64/C128 tokens and keywords, parse_type support, c64()/c128()
as constructor calls in primary position.

Type checker: C64/C128 TypeKinds, _is_complex helper, numeric promotion
(c64 + c128 -> c128, c64 + f64 -> c128), complex builtins (creal, cimag,
cabs, carg, conj, cexp, clog, csqrt, cpow).

C generator: float complex / double complex type mapping, CMPLXF/CMPLX
constructor emission, complex.h include, printf as (re + im j), zero
defaults, byte sizes (8/16).

Examples: examples/rf/dft.flow (8-point DFT with spectral peak check),
examples/rf/iq_mixer.flow (quadrature mixer).

Tests: tests/unit/test_complex_types.py (15 tests, all passing).
Docs: types.md, overview.md, CHANGELOG, ROADMAP updated.

1224/1224 tests pass.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@cursor

cursor Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@godofecht
godofecht merged commit 6261164 into main Aug 10, 2026
@godofecht
godofecht deleted the feat/complex-types-w0 branch August 10, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant