Open
Conversation
Complex{Num}^Real operations were failing with 'UndefVarError: Pow not defined'
because the method in solver/main.jl referenced non-existent Symbolics.Pow.
Changes:
- Add ^(::Complex{Num}, ::Real) method using polar form in src/num.jl
- Fix ^(::Complex{T}, ::Num) in solver/main.jl to use SymbolicUtils.term
- Add tests for Complex{Num} power operations in test/complex.jl
The polar form implementation avoids boolean conditionals that fail with
symbolic values, using r^p * (cos(p*θ) + i*sin(p*θ)) instead.
…e tests
- Replace Symbolics.wrap with Complex{Num} for type stability in solver/main.jl
- Expand Rational method to use polar form directly (preserves exact Rational values)
- Add shape inference tests for Complex{T}^Num as requested
The Rational method is needed to resolve ambiguity between:
- ^(::Complex{Num}, ::Real) (our method)
- Base.^(::Complex{T}, ::Rational) where T<:Real (Base's method)
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1741 +/- ##
===========================================
+ Coverage 22.92% 80.66% +57.73%
===========================================
Files 55 56 +1
Lines 5082 5337 +255
===========================================
+ Hits 1165 4305 +3140
+ Misses 3917 1032 -2885 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
Could you please rebase this PR? While I'm all but certain tests will pass with the latest changes, it would be nice to make sure. I'll merge as soon as they do. |
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.
As before in #1740, but with the proposal of @AayushSabharwal.
Complex{Num}^Realoperations were failing withUndefVarError: Pow not definedbecause the method insolver/main.jlreferenced non-existentSymbolics.Pow.Changes
^(::Complex{Num}, ::Real)method using polar form insrc/num.jl^(::Complex{T}, ::Num)insolver/main.jlto use type-stableComplex{Num}constructorComplex{Num}power operations including shape inferenceWhy polar form?
The polar form implementation
r^p * (cos(p*θ) + i*sin(p*θ))avoids boolean conditionals that fail with symbolic values.Fixes
Enables Cardano's cubic formula and similar operations requiring complex symbolic intermediate values.