Commit 37aa43a
Restrict Diagonal sqrt branch to positive diag (#1203)
As noted in #1193,
the `sqrt(::Digonal{<:Real})` method requires the diagonal element to be
positive, so that `sqrt` is defined for the individual elements. We
therefore may restrict the diagonal branch in the dense `sqrt` method to
matrices with positive `diag` if the `eltype` is `Real`.
Fixes #1193
After this,
```julia
julia> A = diagm(0 => [1.0, -1.0])
2×2 Matrix{Float64}:
1.0 0.0
0.0 -1.0
julia> sqrt(A)
2×2 Matrix{ComplexF64}:
1.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+1.0im
```
(cherry picked from commit 16d9d61)1 parent 87542a7 commit 37aa43a
2 files changed
+8
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
972 | 972 | | |
973 | 973 | | |
974 | 974 | | |
975 | | - | |
| 975 | + | |
| 976 | + | |
976 | 977 | | |
977 | 978 | | |
978 | 979 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
984 | 984 | | |
985 | 985 | | |
986 | 986 | | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
987 | 993 | | |
988 | 994 | | |
989 | 995 | | |
| |||
0 commit comments