Skip to content

test: migrate blas/base/dznrm2 to ULP-based assertions - #16272

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-dznrm2
Oct 24, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-dznrm2

Conversation

@kgryte

@kgryte kgryte commented Oct 20, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

  • migrates the tests for blas/base/dznrm2 from relative tolerance assertions to ULP-based assertions, following the same approach as the sibling migration for blas/base/scnrm2 (test: migrate blas/base/scnrm2 to ULP-based assertions #16261).

  • removes the local isApprox test helper (along with the @stdlib/constants/float64/eps and @stdlib/math/base/special/abs imports) and replaces each call site with t.strictEqual( isAlmostSameValue( actual, expected, <ulp> ), true, 'returns expected value' );, using @stdlib/assert/is-almost-same-value.

  • tightens four truncated reference values so that the ULP comparison is meaningful. The removed helper iterated over expected.length, but every call site passed a scalar return value, so the loop body never executed and the numeric results were effectively unasserted. As a result, several reference values had only been recorded to ~6 significant digits. The replacements are the correctly rounded double-precision values of the exact L2 norms and agree with the previously recorded digits:

    • 14.1 → 14.106735979665885 (sqrt(199))
    • 2.82842e+150 → 2.82842712474619e+150 (sqrt(8)*1e150)
    • 2.82843e-155 → 2.82842712474619e-155 (sqrt(8)*1e-155)
    • 3.51283e-154 → 3.512833614050059e-154

    Each was computed independently at 80 decimal digits of precision and then correctly rounded to the nearest float64, so the expectations remain independent references rather than a recording of implementation output.

ULP bounds

Bounds were measured by instrumenting each assertion with @stdlib/number/float64/base/ulp-difference over every test case and then tightened to the minimum passing integer:

File ULP
test/test.dznrm2.js 0
test/test.ndarray.js 0
test/test.dznrm2.native.js 1
test/test.ndarray.native.js 1

The measured minimum for the JavaScript implementation is 0 ULP at every call site: against correctly rounded references, dznrm2 returns exactly the expected value. This is expected, since the scaled sum-of-squares accumulation only scales by powers of two (exact) before a correctly rounded sqrt.

The native bounds could not be measured locally because the native add-on is not built in this environment (those tests skip), so they are set to a conservative 1, matching how the corresponding native test files were handled in #16261.

The full package test suite was run twice at the final bounds to confirm determinism; both runs were green (test.dznrm2.js: 9 passing, test.ndarray.js: 14 passing, test.js: 5 passing, native files skipped). make eslint-tests TESTS_FILTER=".*/blas/base/dznrm2/.*" is clean, and only test files are changed.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

  • Is updating the four truncated reference values in scope here? Without it, the ULP comparison would require bounds on the order of 1e12, which would defeat the purpose of the migration. test: migrate blas/base/scnrm2 to ULP-based assertions #16261 made the equivalent change for 14.1 → 14.106736183166504, so this follows that precedent, but it is a larger set of values and worth a second look.
  • Should the native test files use 0 to match the JavaScript files instead of the conservative 1? They were left at 1 since the bound could not be verified against a built add-on here.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Opened as a draft pending reviewer input on the two questions above.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

This PR was authored by Claude Code running as an unattended scheduled task: it selected the package, studied the prior art in #11352 and #16261, applied the migration, measured the ULP bounds, and wrote this description.


@stdlib-js/reviewers


Generated by Claude Code

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PXiBYMSEGcZzLHx2zuU33q
@stdlib-bot stdlib-bot added BLAS Issue or pull request related to Basic Linear Algebra Subprograms (BLAS). Good First PR A pull request resolving a Good First Issue. labels Oct 20, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
blas/base/dznrm2 $\\color{green}452/452$
$\\color{green}+100.00\\%$
$\\color{green}37/37$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}452/452$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

@kgryte kgryte added the Tests Pull requests specifically adding tests. label Oct 24, 2026
@kgryte
kgryte marked this pull request as ready for review October 24, 2026 02:50
@kgryte
kgryte requested a review from a team October 24, 2026 02:50
@kgryte
kgryte merged commit 913219c into develop Oct 24, 2026
66 checks passed
@kgryte
kgryte deleted the kgryte/ulp-dznrm2 branch October 24, 2026 02:52
@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. and removed Needs Review A pull request which needs code review. labels Oct 24, 2026
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). Good First PR A pull request resolving a Good First Issue. Tests Pull requests specifically adding tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants