@@ -425,31 +425,39 @@ function lahqr!(H::StridedMatrix{Float64})
425425end
426426
427427# # Cholesky + singular values
428- function spteqr ! (
428+ function pteqr ! (
429429 compz:: Char ,
430430 d:: StridedVector{Float64} ,
431431 e:: StridedVector{Float64} ,
432432 Z:: StridedMatrix{Float64} ,
433- work:: StridedVector{Float64} = Vector {Float64} (undef, 4 length (d)) ,
433+ work:: StridedVector{Float64} ,
434434)
435-
436435 n = length (d)
437436 ldz = stride (Z, 2 )
438437
439438 # Checks
440- length (e) >= n - 1 || throw (DimensionMismatch (" subdiagonal vector is too short" ))
439+ if length (e) < n - 1
440+ throw (DimensionMismatch (" subdiagonal vector is too short" ))
441+ end
442+ chkstride1 (d)
443+ chkstride1 (e)
444+ chkstride1 (Z)
441445 if compz == ' N'
442- elseif compz == in (' V' , ' I' )
443- size (Z, 1 ) >= n || throw (DimensionMismatch (" Z does not have enough rows" ))
444- size (Z, 2 ) >= ldz || throw (DimensionMismatch (" Z does not have enough columns" ))
446+ elseif compz ∈ (' V' , ' I' )
447+ if size (Z, 1 ) < n
448+ throw (DimensionMismatch (" Z does not have enough rows" ))
449+ end
450+ if size (Z, 2 ) < ldz
451+ throw (DimensionMismatch (" Z does not have enough columns" ))
452+ end
445453 else
446454 throw (ArgumentError (" compz must be either 'N', 'V', or 'I'" ))
447455 end
448456
449- info = Vector {BlasInt} (undef, 1 )
457+ info = Ref {BlasInt} (1 )
450458
451459 ccall (
452- (@blasfunc (: dpteqr_ ), liblapack_name),
460+ (@blasfunc (dpteqr_), liblapack_name),
453461 Cvoid,
454462 (
455463 Ref{UInt8},
@@ -459,7 +467,7 @@ function spteqr!(
459467 Ptr{Float64},
460468 Ref{BlasInt},
461469 Ptr{Float64},
462- Ptr {BlasInt},
470+ Ref {BlasInt},
463471 ),
464472 compz,
465473 n,
@@ -471,9 +479,23 @@ function spteqr!(
471479 info,
472480 )
473481
474- info[1 ] == 0 || throw (LAPACKException (info[1 ]))
482+ if info[] != 0
483+ throw (LAPACKException (info[]))
484+ end
485+
486+ return d, Z
487+ end
475488
476- d, Z
489+ function pteqr! (compz:: Char , d:: StridedVector{Float64} , e:: StridedVector{Float64} )
490+ n = length (d)
491+
492+ Z = if compz == ' I'
493+ Matrix {Float64} (undef, n, n)
494+ else
495+ Matrix {Float64} (undef, 0 , 0 )
496+ end
497+ work = Vector {Float64} (undef, 4 * n)
498+ return pteqr! (compz, d, e, Z, work)
477499end
478500
479501# Gu's dnc eigensolver
0 commit comments