Skip to content

fix: use matching precision for logspace base and exponents - #16397

Open
harsh-thakkar7 wants to merge 1 commit into
stdlib-js:developfrom
harsh-thakkar7:fix/16335-logspace-base-dtype
Open

harsh-thakkar7 wants to merge 1 commit into
stdlib-js:developfrom
harsh-thakkar7:fix/16335-logspace-base-dtype

Conversation

@harsh-thakkar7

Copy link
Copy Markdown
Contributor

Resolves #16335.

Description

This pull request:

  • ensures a primitive base is normalized to the real precision expected by the selected kernel (float32 for float32/complex64, float64 for float64/complex128);
  • computes through float64/complex128 when a float64 base ndarray is paired with a single-precision output, then downcasts only the result, per the maintainer guidance in the issue;
  • casts start and stop to that compute precision so non-integer exponents are not rounded before the higher-precision computation;
  • adds public and private regression tests, including a test that fails on the original base dtype normalization.

Related Issues

Questions

No.

Other

Validation: test.main.js 595/595, test.assign.js 441/441, test.normalize_arguments.js 30/30, and test.js 3/3. ESLint reports 0 errors (two pre-existing max-lines warnings). The non-integer regression changes the result from 1105.12939453125 to 1105.1297607421875, matching double-precision evaluation downcast to float32.

Checklist

AI Assistance

  • Yes

  • No

  • Code generation

  • Test/benchmark generation

  • Documentation (including examples)

  • Research and understanding

Disclosure

This PR was prepared with Qoder AI assistance under the contributor's direction. All changed code and tests were reviewed and executed locally.


@stdlib-js/reviewers

@harsh-thakkar7
harsh-thakkar7 requested a review from a team October 31, 2026 05:48
@stdlib-bot stdlib-bot added BLAS Issue or pull request related to Basic Linear Algebra Subprograms (BLAS). Needs Review A pull request which needs code review. First-time Contributor A pull request from a contributor who has never previously committed to the project repository. labels Oct 31, 2026
@Shubham-Padkonde

Copy link
Copy Markdown

Hi Harsh, would independent tests for the temporary-buffer copy-back path be useful here? The new float64-base / float32-output tests use contiguous outputs; base.js now computes into tmp and then assigns back to out.

If you haven't already planned it, could you and a maintainer approve me taking a test-only follow-up for a non-contiguous output with a nonzero offset and a reversed output view? I'd check the computed values, returned object identity, and sentinel elements outside each view, with a non-integer exponent to exercise the higher-precision path. This would build on your implementation. I haven't run the package or these cases yet.

@stdlib-bot stdlib-bot removed the First-time Contributor A pull request from a contributor who has never previously committed to the project repository. label Oct 31, 2026
@harsh-thakkar7

Copy link
Copy Markdown
Contributor Author

Hi @Shubham-Padkonde, sorry for the slow reply. Yes, independent tests for the copy-back path would be useful, and please go ahead with the test-only follow-up for a non-contiguous output with a nonzero offset and a reversed output view. Checking the computed values, returned object identity, and the sentinel elements outside each view all sound right, and the non-integer exponent for the higher-precision path is a good idea. Thanks for asking first!

@Shubham-Padkonde

Copy link
Copy Markdown

Thanks, Harsh. I’ll wait for the precision decision on #16335 before building on this PR. If the float64 temporary stays, would the maintainers like me to add the two output-view tests in a separate PR after this lands? That would keep your implementation and the test follow-up independently reviewable.

@stdlib-bot stdlib-bot added the Potential Duplicate There might be another pull request resolving the same issue. label Nov 14, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BLAS Issue or pull request related to Basic Linear Algebra Subprograms (BLAS). Needs Review A pull request which needs code review. Potential Duplicate There might be another pull request resolving the same issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: blas/ext/logspace passes a float64 base to the float32 slogspace kernel

3 participants