Skip to content

Commit 29db72f

Browse files
committed
Check if array is square
1 parent f4e8871 commit 29db72f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/lib/array.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,8 @@ end
494494
## Matrix functions that can be written as power series
495495

496496
function _realifydiag!(A)
497-
for i in 1:size(A,1)
497+
n = LinearAlgebra.checksquare(A)
498+
for i in 1:n
498499
@inbounds A[i,i] = real(A[i,i])
499500
end
500501
return A
@@ -528,8 +529,8 @@ _apply_series_func(f, A, args...) = f(A, args...)
528529

529530
@adjoint function _apply_series_func(func, A, args...)
530531
hasargs = !isempty(args)
532+
n = LinearAlgebra.checksquare(A)
531533
λ, U = eigen(A)
532-
n = length(λ)
533534
λ′ = _process_series_eigvals(func, λ)
534535
fλ, fback = Zygote.pullback(x->(func).(x, args...), λ′)
535536
fA = U * Diagonal(fλ) * U'

0 commit comments

Comments
 (0)