I believe I found a bug in LAPACK in svd(.) / dgesdd function:
Problem description
R routine svd(.) from LAPACK crashes in dgesdd on a full rank matrix with dimensions 5344x263.
Problem replication
library(Rfssa)
load_github_data("https://github.com/SzymonNowakowski/DMRnet/blob/testing_branch/data/crashes_svd.RData")
svd(crashes_svd)
Error in La.svd(x, nu, nv) : error code 1 from Lapack routine 'dgesdd'
But crashes_svd is a full rank matrix, it should decompose in svd(.):
> qr(crashes_svd)$rank
[1] 263
> dim(crashes_svd)
[1] 5344 263
EDIT 07/04/2022:
The above example (a matrix 5344x263) is minimal to reproduce the bug - If you remove a row or a column from that matrix, svd(.) successfully decomposes a resulting matrix into SVD components.
I have verified, that (in general) removing random rows or columns of that special matrix makes it pass the SVD, but one can also remove them in a certain order, obtaining a sequence of matrices failing SVD computation:
crashes_svd_col <- crashes_svd[, -51] #removing the 51st column
svd(crashes_svd_col)
# Error in La.svd(x, nu, nv) : error code 1 from Lapack routine 'dgesdd'
crashes_svd <- crashes_svd[-393,] #removing a sequence of rows: 393, 962, 642
svd(crashes_svd)
# Error in La.svd(x, nu, nv) : error code 1 from Lapack routine 'dgesdd'
crashes_svd <- crashes_svd[-962,]
svd(crashes_svd)
# Error in La.svd(x, nu, nv) : error code 1 from Lapack routine 'dgesdd'
crashes_svd <- crashes_svd[-642,]
svd(crashes_svd)
# Error in La.svd(x, nu, nv) : error code 1 from Lapack routine 'dgesdd'
END OF EDIT 07/04/2022
Software versions
Windows 7, R 4.2.0, LAPACK 3.10.0:
> La_version()
[1] "3.10.0"
> print(sessionInfo())
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Windows 7, R 4.1.0, LAPACK 3.9.0:
> La_version()
[1] "3.9.0"
> print(sessionInfo())
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Ubuntu 20.04, R 4.1.2, LAPACK 3.9.0:
> La_version()
[1] "3.9.0"
> print(sessionInfo())
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS
Checklist
I believe I found a bug in
LAPACKinsvd(.)/dgesddfunction:Problem description
R routine
svd(.)fromLAPACKcrashes indgesddon a full rank matrix with dimensions 5344x263.Problem replication
But
crashes_svdis a full rank matrix, it should decompose insvd(.):> qr(crashes_svd)$rank[1] 263> dim(crashes_svd)[1] 5344 263EDIT 07/04/2022:
The above example (a matrix 5344x263) is minimal to reproduce the bug - If you remove a row or a column from that matrix,svd(.)successfully decomposes a resulting matrix into SVD components.I have verified, that (in general) removing random rows or columns of that special matrix makes it pass the SVD, but one can also remove them in a certain order, obtaining a sequence of matrices failing SVD computation:
END OF EDIT 07/04/2022
Software versions
Windows 7,
R4.2.0,LAPACK3.10.0:> La_version()[1] "3.10.0"> print(sessionInfo())Windows 7,
R4.1.0,LAPACK3.9.0:> La_version()[1] "3.9.0"> print(sessionInfo())Ubuntu 20.04,
R4.1.2,LAPACK3.9.0:> La_version()[1] "3.9.0"> print(sessionInfo())Checklist