Skip to content

Commit 8050d1f

Browse files
authored
Merge pull request #881 from jvdp1/fix_svd_1
svd - check the size of storage space
2 parents 38e8e0e + e244e13 commit 8050d1f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/stdlib_linalg_svd.fypp

+5-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,11 @@ submodule(stdlib_linalg) stdlib_linalg_svd
269269
if (info==0) then
270270

271271
!> Prepare working storage
272-
lwork = nint(real(work_dummy(1),kind=${rk}$), kind=ilp)
272+
! Check if the returned working storage space is smaller than the largest value
273+
! allowed by lwork
274+
lwork = merge(nint(real(work_dummy(1),kind=${rk}$), kind=ilp) &
275+
, huge(lwork) &
276+
, real(work_dummy(1),kind=${rk}$) < real(huge(lwork),kind=${rk}$) )
273277
allocate(work(lwork))
274278

275279
!> Compute SVD

0 commit comments

Comments
 (0)