@@ -26,6 +26,29 @@ function check_input(::typeof(schur_vals!), A::AbstractMatrix, vals, ::AbstractA
2626 return nothing
2727end
2828
29+ function check_input (:: typeof (schur_full!), A:: AbstractMatrix , TZv, :: DiagonalAlgorithm )
30+ m, n = size (A)
31+ @assert m == n && isdiag (A)
32+ T, Z, vals = TZv
33+ @assert vals isa AbstractVector && Z isa Diagonal
34+ @check_scalar (T, A)
35+ @check_size (Z, (m, m))
36+ @check_scalar (Z, A)
37+ @check_size (vals, (n,))
38+ # Diagonal doesn't need to promote to complex scalartype since we know it is diagonalizable
39+ @check_scalar (vals, A)
40+ return nothing
41+ end
42+ function check_input (:: typeof (schur_vals!), A:: AbstractMatrix , vals, :: DiagonalAlgorithm )
43+ m, n = size (A)
44+ @assert m == n && isdiag (A)
45+ @assert vals isa AbstractVector
46+ @check_size (vals, (n,))
47+ # Diagonal doesn't need to promote to complex scalartype since we know it is diagonalizable
48+ @check_scalar (vals, A)
49+ return nothing
50+ end
51+
2952# Outputs
3053# -------
3154function initialize_output (:: typeof (schur_full!), A:: AbstractMatrix , :: AbstractAlgorithm )
@@ -39,6 +62,17 @@ function initialize_output(::typeof(schur_vals!), A::AbstractMatrix, ::AbstractA
3962 vals = similar (A, complex (eltype (A)), n)
4063 return vals
4164end
65+ function initialize_output (:: typeof (schur_full!), A:: Diagonal , :: DiagonalAlgorithm )
66+ n = size (A, 1 )
67+ Z = similar (A)
68+ vals = similar (A, eltype (A), n)
69+ return (A, Z, vals)
70+ end
71+ function initialize_output (:: typeof (schur_vals!), A:: Diagonal , :: DiagonalAlgorithm )
72+ n = size (A, 1 )
73+ vals = similar (A, eltype (A), n)
74+ return vals
75+ end
4276
4377# Implementation
4478# --------------
@@ -72,3 +106,20 @@ function schur_vals!(A::AbstractMatrix, vals, alg::LAPACK_EigAlgorithm)
72106 end
73107 return vals
74108end
109+
110+ # Diagonal logic
111+ # --------------
112+ function schur_full! (A:: Diagonal , (T, Z, vals):: Tuple{Diagonal, Diagonal, <:AbstractVector} , alg:: DiagonalAlgorithm )
113+ check_input (schur_full!, A, (T, Z, vals), alg)
114+ copy! (vals, diagview (A))
115+ one! (Z)
116+ T === A || copy! (T, A)
117+ return T, Z, vals
118+ end
119+
120+ function schur_vals! (A:: Diagonal , vals:: AbstractVector , alg:: DiagonalAlgorithm )
121+ check_input (schur_vals!, A, vals, alg)
122+ Ad = diagview (A)
123+ vals === Ad || copy! (vals, Ad)
124+ return vals
125+ end
0 commit comments