scipy: BUG: scipy.linalg.blas.dnrm2 may return error result when incx < 0
Describe your issue.
scipy.linalg.blas.dnrm2 may returns error result when incx<0 : input array:[10, 10, 10, 10, 10, 10, 10, 10, 10] n:5 offx:3 incx:-1 the scipy.linalg.blas.dnrm2 function returns result 20.0
If we calculate the result follow the document in netlib:
https://netlib.org/lapack/explore-html/df/d28/group__single__blas__level1_gab5393665c8f0e7d5de9bd1dd2ff0d9d0.html
we will get result sqrt(500) -> 22.36
Reproducing Code Example
import os
import time
import numpy as np
from scipy import linalg
x = [10,10,10,10,10,10,10,10,10]
n = 5
offx = 3
incx = -1
print(f"x:{x}")
print(f"n:{n}")
print(f"offx:{offx}")
print(f"incx:{incx}")
res = linalg.blas.dnrm2(x, n, offx, incx)
print(f"res:{res}")
Error message
x:[10, 10, 10, 10, 10, 10, 10, 10, 10]
n:5
offx:3
incx:-1
res:20.0
SciPy/NumPy/Python version information
1.7.3 1.21.5 sys.version_info(major=3, minor=7, micro=5, releaselevel=‘final’, serial=0)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 21 (20 by maintainers)
Commits related to this issue
- BUG, MAINT: bump OpenBLAS "the old way" * Related to gh-16930 * added a regression test, based on the reproducer in the issue, that I confirmed does indeed fail locally on x86_64 Linux via: `CIBW_BU... — committed to tylerjereddy/scipy by tylerjereddy 4 months ago
- BUG, MAINT: bump OpenBLAS "the old way" * Related to gh-16930 * added a regression test, based on the reproducer in the issue, that I confirmed does indeed fail locally on x86_64 Linux via: `CIBW_BU... — committed to tylerjereddy/scipy by tylerjereddy 4 months ago
- TST: PR 20215 revisions * skip the new regression test because OpenBLAS `0.3.26` doesn't fully fix gh-16930 [skip circle] [skip cirrus] — committed to tylerjereddy/scipy by tylerjereddy 4 months ago
- MAINT: bump OpenBLAS "the old way" (#20215) * Related to gh-16930, but doesn't fix it just yet, just updates to OpenBLAS `0.3.26` and adds an xfailed regression test (the test doesn't yet pass on a... — committed to scipy/scipy by tylerjereddy 4 months ago
- BUG: linalg: raise an error in dnrm2(..., incx<0) See https://github.com/scipy/scipy/issues/16930 for discussion. closes gh-16930 — committed to ev-br/scipy by ev-br 3 months ago
- BUG: linalg: raise an error in dnrm2(..., incx<0) See https://github.com/scipy/scipy/issues/16930 for discussion. closes gh-16930 — committed to ev-br/scipy by ev-br 3 months ago
True, my emphasis is on the fact that while we are defensive about LAPACK version, which perfectly fine, we should be careful about indirect consequences of bumping other things up.
Otherwise I don’t think we have urgency or good reasons to bump up all the way (though 3.10 included Anderson’s safety scaling paradigm which are really good but they can wait).
working on it, given that the “new way” in https://github.com/scipy/scipy/pull/20074 may need a bit more time
looks like
0.3.21.dev
if I’m looking in the right place: https://github.com/scipy/scipy/blob/2aee5efcbe3720f41fe55f336f492ae0acbecdee/tools/openblas_support.py#L16-L17