You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First draft for complex number (#33), please take a look.
Changes from the discussion on the issue:
I added a public reciprocal function since I needed it internally anyway.
The power function only takes positive integer exponents, because I used De Moivre’s theorem. Accordingly weighted_product also only supports integer weights. If anyone knows a more generic algorithm, please let me know.
Documentation is also still missing, and I didn't do any changes to the main maths module yet.
Please let me know what you think.
I apologize in advance for not being very responsive - I'm currently on vacation and probably won't have a lot of time to work on this.
I made some improvements to the weighted_x functions in the main math module based on Hayleigh’s feedback, and I think we could align the complex number implementation in the same way to incorporate that feedback as well (e.g. see the math library thread on the Gleam Discord server under “sharing”).
I think it would be great if we could generalize the weighted_product, power, nth_root, and other related functions, to accept real exponents by implementing the logarithm for complex numbers, such that we can compute z^a = exp(a * log(z)), where z is a complex number, a is a real number, and log(z) = log(|z|) + i * arg(z).
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
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.
First draft for complex number (#33), please take a look.
Changes from the discussion on the issue:
Documentation is also still missing, and I didn't do any changes to the main maths module yet.
Please let me know what you think.
I apologize in advance for not being very responsive - I'm currently on vacation and probably won't have a lot of time to work on this.
- Sigma