Add Complex<T> and IComplexNumber<TSelf, T> (WIP — scoping question)#127331
Closed
Add Complex<T> and IComplexNumber<TSelf, T> (WIP — scoping question)#127331
Conversation
Copilot
AI
changed the title
[WIP] Add support for Complex<T> with IFloatingPointIeee754<T>
Add Complex<T> and IComplexNumber<TSelf, T> (WIP — scoping question)
Apr 23, 2026
Member
|
@copilot, lets go with a third different approach instead where we expose |
Contributor
Author
|
@tannergooding I've opened a new pull request, #127333, to work on those changes. Once the pull request is ready, I'll request review from you. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-numerics |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement the approved API surface from #117451 for a generic
Complex<T> where T : IFloatingPointIeee754<T>plus a correspondingIComplexNumber<TSelf, T>interface, and expand the non-genericComplexto implement the new interface.Status: no code committed yet — need scoping direction before proceeding
After analyzing the approved surface against the existing implementation, the scope is substantially larger than a single surgical change and I want to confirm direction before committing code. Specifically, landing this requires:
IComplexNumber<TSelf, T>interface (generic-math family).Complex<T>struct with ~100+ members: operators,Create/CreateFromPolarCoordinates,GetMagnitude/GetPhase,Conjugate/Reciprocal/Abs, full transcendental suite (Sqrt,Exp/ExpM1/Exp2/Exp10/…,Log/LogP1/Log2/Log10/…,Sin/Cos/Tan+*h+*Pi,Asin/Acos/Atan+*h+*Pi),Hypot,Pow,RootN,DegreesToRadians/RadiansToDegrees,MultiplyAddEstimate(5 overloads),MaxMagnitude/MinMagnitude(+Number) overloads,Is*predicates, parsing/formatting forchar/byte/string, and the fullINumberBase/ISignedNumber/IFloatingPointConstants/IAdditiveIdentity/IMultiplicativeIdentityexplicit impls.double-specific algorithms inComplex.csto arbitraryT : IFloatingPointIeee754<T>, including several precomputed magic constants (s_sqrtRescaleThreshold,s_asinOverflowThreshold,s_log2,InverseOfLog10, …) and IEEE‑754 edge-case handling (NaN/±∞/signed‑zero propagation) that today rely ondouble‑specific values.Complex(Acosh/Asinh/Atanh,CosPi/SinPi/TanPi,Cbrt,DegreesToRadians/RadiansToDegrees,ExpM1/Exp2/Exp2M1/Exp10/Exp10M1,Hypot,LogP1/Log2/Log2P1/Log10P1, newLog/MaxMagnitude/MinMagnitude/*Number/Powoverloads,MultiplyAddEstimate,RootN) and theIComplexNumber<Complex, double>explicit impls.ref/System.Runtime.Numerics.csupdates and test coverage inComplexTests/ComplexTests.GenericMath.cs.Per repo policy any commit must compile and pass tests, so I'd rather not push a large approximation of the math.
Description
Proposed approaches (please pick one):
IComplexNumber<TSelf, T>, theComplex<T>skeleton (layout, ctor,Real/Imaginary, arithmetic operators,Conjugate,Abs,Create/CreateFromPolarCoordinates,GetMagnitude/GetPhase,Is*,Equals/GetHashCode/ToString, generic-math explicit impls that port cleanly toT), the full ref assembly surface, and the non-genericComplexinterface wiring. Defer transcendental math (Sqrt,Log*,Exp*,Asin/Acos/Atan+ variants,Pow,Sinh/Cosh/Tanh,Hypot,RootN) to follow-up PRs so each port of adouble-tuned algorithm to genericTcan be reviewed and tested on its own.IComplexNumber<TSelf, T>+ the new methods on non-genericComplex(which can reuse existingdoublealgorithms), and leaveComplex<T>for a separate PR.T-generic equivalents of thedoublerescale thresholds for types likeHalf/float).Example of the target shape once landed:
No files are modified in this PR yet — awaiting direction on scope.
Note
This PR description was authored by GitHub Copilot.