Skip to content

Prepare for freestanding mode by making complex support optional - #68

Open
danieltowner wants to merge 1 commit into
mainfrom
freestanding_complex
Open

danieltowner wants to merge 1 commit into
mainfrom
freestanding_complex

Conversation

@danieltowner

@danieltowner danieltowner commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Freestanding builds have no <complex> header, so complex support must be easy to disable. To allow that, add a complex_traits<T> customisation point (std::complex is the only provided specialisation), define complex_number in terms of it, and use complex_number, vec_complex and complex_element_type instead of naming std::complex in the generic and x86 code. Behaviour for std::complex is unchanged.

@danieltowner
danieltowner added this pull request to stack #64 November 20, 2026 14:26
@omalyshe

Copy link
Copy Markdown
Contributor

Freestanding builds have no , so complex support must be easy to disable.

Is the description incomplete? I guess something should go after "no", shouldn't it?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block approval of the trait-based complex-type changes.

No open issues 🎉

What changed in this PR

Prepares xvec for future freestanding builds by decoupling complex-vector operations from std::complex, while preserving support for it.

Changes:

  • Adds complex_traits<T> as a customization point for complex-like types.
  • Updates generic and x86 implementations to use trait-based complex concepts and component types.
  • Adds tests covering a user-defined complex type’s component access, comparison, conjugation, multiplication, and fused multiply-add.
File Description
test/​TestSimdComplex.cpp Adds coverage for a custom complex type enabled through traits.
include/​xvec/​x86/​x86_impl.hpp Generalizes complex arithmetic and comparison overloads.
include/​xvec/​simd Uses traits to extract real and imaginary component types.
include/​xvec/​generic/​generic_impl.hpp Generalizes complex element access, fused multiply-add, and conjugation.
include/​xvec/​detail/​utilities.hpp Defines complex traits, their contract, and component-type helpers.
include/​xvec/​detail/​std_complex.hpp Uses trait-derived component types in rounding operations.
include/​xvec/​detail/​operators.hpp Uses traits for complex comparison component types.
include/​xvec/​detail/​core.hpp Makes conversion and vectorization checks trait-based.

Review effort: Balanced

@danieltowner

Copy link
Copy Markdown
Contributor Author

Freestanding builds have no , so complex support must be easy to disable.

Is the description incomplete? I guess something should go after "no", shouldn't it?

The text contained the angled brackets which weren't rendering properly. Now replaced by escaped angles.

@danieltowner
danieltowner force-pushed the freestanding_complex branch 2 times, most recently from 5a3c963 to c8e5e87 Compare November 20, 2026 17:29
@danieltowner
danieltowner removed this pull request from stack #64 November 20, 2026 17:40
@danieltowner
danieltowner added this pull request to stack #75 November 20, 2026 17:40
@danieltowner
danieltowner force-pushed the freestanding_complex branch 2 times, most recently from ab17d89 to 2be10aa Compare November 21, 2026 17:34
Base automatically changed from perf_complex_fma to main November 21, 2026 17:35
Freestanding builds have no <complex>, so complex support must be easy to
disable. To allow that, add a complex_traits<T> customisation point
(std::complex is the only provided specialisation), define complex_number
in terms of it, and use complex_number, vec_complex and complex_element_type
instead of naming std::complex in the generic and x86 code. Behaviour for
std::complex is unchanged.

This branch has not been deployed

No deployments
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.

3 participants