Skip to content

(Closes #1590) Add support for complex numbers - #3554

Merged
LonelyCat124 merged 37 commits into
masterfrom
mn416-complex
Aug 26, 2026
Merged

(Closes #1590) Add support for complex numbers#3554
LonelyCat124 merged 37 commits into
masterfrom
mn416-complex

Conversation

@mn416

@mn416 mn416 commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Closes #1590.

This PR:

  1. Adds a new ScalarType.Intrinsic.COMPLEX enumeration value.

  2. Adds a new ComplexLiteral PSyIR node, as complex literals are not a good fit for the existing Literal class (they are a composite structure which can contain named constants, and are not suitable for representation as a textual string like other literal values).

  3. Updates the frontend and backend to use/handle these new constructs.

  4. Fixes all the tests that previously assumed complex types would lead to UnsupportedFortranType. In all cases I simply replace complex with byte.

  5. Adds tests for the new functionality.

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (444841f) to head (10020bc).

Additional details and impacted files
@@            Coverage Diff             @@
##            master     #3554    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          397       399     +2     
  Lines        55790     56094   +304     
==========================================
+ Hits         55790     56094   +304     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mn416 mn416 changed the title Add support for complex types (Closes #1590) Add support for complex types Aug 12, 2026
@mn416 mn416 changed the title (Closes #1590) Add support for complex types (Closes #1590) Add support for complex numbers Aug 13, 2026
@LonelyCat124

LonelyCat124 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Before reviewing I'll just set CI running in case it flags anything. I had a quick look to check that we hadn't missed anything obvious.

@LonelyCat124 LonelyCat124 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@mn416 I didn't get to reviewing all the tests, I have some concerns about whether or not ComplexLiteral should subclass Literal. I've asked for input from Sergi and Andy as they have time - I don't think we should change it just from my current thoughts as without the usecases for .walk hitting Litearl I'm not sure. Its perhaps enough to have some Mixin that both inherit (so they are generally separate but you can do .walk(LiteralMixin) if you really want them all.

Comment thread src/psyclone/psyir/frontend/fparser2.py Outdated
Comment thread src/psyclone/psyir/frontend/fparser2.py
Comment thread src/psyclone/psyir/frontend/fparser2.py
Comment thread src/psyclone/psyir/frontend/fparser2.py Outdated
Comment thread src/psyclone/psyir/nodes/complex_literal.py Outdated
Comment thread src/psyclone/psyir/nodes/complex_literal.py
Comment thread src/psyclone/psyir/nodes/complex_literal.py
@mn416

mn416 commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator Author

Thank-you very much @LonelyCat124. I think I've addressed all outstanding comments. I'll pass it back to you.

@LonelyCat124 LonelyCat124 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@mn416 Almost there, a couple more small changes.

@mn416

mn416 commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @LonelyCat124, another bug squashed. Back to you.

@LonelyCat124

Copy link
Copy Markdown
Collaborator

I'm going to set the ITs going again. I was wondering whether we should have some compliation tests, but I didn't find anywhere appropriate for them so I think we can leave them for now - hopefully with NEMO having some complex requirements soon we can build that into the ITs.

@LonelyCat124

Copy link
Copy Markdown
Collaborator

Its all green, I'll merge in the morning, feel free to go ahead if anything else is ready before.

@LonelyCat124
LonelyCat124 merged commit d9515d0 into master Aug 26, 2026
16 checks passed
@LonelyCat124
LonelyCat124 deleted the mn416-complex branch August 26, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PSyIR] Add support for complex (imaginary) numbers

3 participants