Fix: logspace generate wrong result for integer arguments#1129
Open
MadhurKumar004 wants to merge 1 commit intofortran-lang:masterfrom
Open
Fix: logspace generate wrong result for integer arguments#1129MadhurKumar004 wants to merge 1 commit intofortran-lang:masterfrom
MadhurKumar004 wants to merge 1 commit intofortran-lang:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1129 +/- ##
=======================================
Coverage 68.55% 68.55%
=======================================
Files 396 396
Lines 12746 12746
Branches 1376 1376
=======================================
Hits 8738 8738
Misses 4008 4008 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes a bug in the logspace function where integer arguments caused integer overflow and produced incorrect results. The issue occurred because integer exponents were being computed using integer arithmetic before being raised to powers, leading to overflow for large values.
Changes:
- Changed exponent arrays from integer to real/complex types to avoid integer overflow
- Updated return type of integer+integer variant from integer to real(dp)
- Added explicit endpoint setting to maintain numerical precision at boundaries
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/math/stdlib_math_logspace.fypp | Modified three integer-argument procedures to use real/complex exponent arrays and convert integer inputs to real before calling linspace, preventing integer overflow |
| src/math/stdlib_math.fypp | Updated function signature for integer start/end/base variant to return real(dp) instead of integer, with corresponding comment update |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This resolves the issue of logspace giving wrong result. Please review if the approach is right
Fix: #1055