Skip to content

Fix: logspace generate wrong result for integer arguments#1129

Open
MadhurKumar004 wants to merge 1 commit intofortran-lang:masterfrom
MadhurKumar004:fix-1055
Open

Fix: logspace generate wrong result for integer arguments#1129
MadhurKumar004 wants to merge 1 commit intofortran-lang:masterfrom
MadhurKumar004:fix-1055

Conversation

@MadhurKumar004
Copy link

This resolves the issue of logspace giving wrong result. Please review if the approach is right
Fix: #1055

@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.55%. Comparing base (eec591d) to head (d082e96).

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.
📢 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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@jvdp1 jvdp1 requested a review from loiseaujc February 25, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

logspace generates wrong results for integer arguments

2 participants