lapack icon indicating copy to clipboard operation
lapack copied to clipboard

Possible bug in `svd(.)` / `DLASCL`

Open SzymonNowakowski opened this issue 3 years ago • 0 comments

I believe I found a bug in LAPACK in svd(.) / DLASCL function. It may be related to issue #672.

Problem description

R routine svd(.) from LAPACK crashes in DLASCL on a full rank matrix with dimensions 1999x1928.

In fact, the entire R console crashes, even if a call is protected by try-catch block (this try-catch behavior is not shown in Problem replication section below).

Problem replication

library(Rfssa)
load_github_data("https://github.com/SzymonNowakowski/DMRnet/blob/testing_branch/data/crashes_DLASCL_Lapack_3.10.3.RData")
svd(crashes_svd)
# ** On entry to DLASCL parameter number  4 had an illegal value
$        #the R console crashes 

But crashes_svd matrix is a full rank matrix with dimensions 1999x1928, with no infinite or NA values, it should decompose in svd:

library(Rfssa)
load_github_data("https://github.com/SzymonNowakowski/DMRnet/blob/testing_branch/data/crashes_DLASCL_Lapack_3.10.3.RData")
sum(!is.finite(crashes_svd))
# [1] 0                                            # no infinite values
sum(is.na(crashes_svd))
# [1] 0                                            # no NA values
qr(crashes_svd)$rank
# [1] 1928                                         # full rank
dim(crashes_svd)
# [1] 1999 1928

Software versions

Ubuntu 20.04, R 4.2.1, LAPACK 3.10.3:

> sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.5 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=pl_PL.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=pl_PL.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=pl_PL.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=pl_PL.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] compiler_4.2.1 tools_4.2.1

Other LAPACK versions

Similar to issue #672, this problem seems to be Lapack-version specific. The particular matrix from https://github.com/SzymonNowakowski/DMRnet/blob/testing_branch/data/crashes_DLASCL_Lapack_3.10.3.RData file crashes in Lapack-3.10.3 but passes successfully svd() decomposition in Lapack-3.9.0

Checklist

  • [x] I've included a minimal example to reproduce the issue
  • [ ] I'd be willing to make a PR to solve this issue

SzymonNowakowski avatar Nov 02 '22 11:11 SzymonNowakowski