Skip to content

Commit c88bf3f

Browse files
committed
Backport a 1.10 implementation for LinearAlgebra.diagind
1 parent 3d774aa commit c88bf3f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/wrappers.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,18 @@ end
164164

165165
using LinearAlgebra: Diagonal
166166
@interface ::AbstractArrayInterface storedvalues(D::Diagonal) = LinearAlgebra.diag(D)
167+
168+
# compat with LTS:
169+
@static if VERSION v"1.11"
170+
_diagind = LinearAlgebra.diagind
171+
else
172+
function _diagind(x::Diagonal, ::IndexCartesian)
173+
return view(CartesianIndices(x), LinearAlgebra.diagind(x))
174+
end
175+
end
167176
@interface ::AbstractArrayInterface eachstoredindex(D::Diagonal) =
168-
LinearAlgebra.diagind(D, IndexCartesian())
177+
_diagind(D, IndexCartesian())
178+
169179
@interface ::AbstractArrayInterface isstored(D::Diagonal, i::Int, j::Int) =
170180
i == j && Base.checkbounds(Bool, D, i, j)
171181
@interface ::AbstractArrayInterface function getstoredindex(D::Diagonal, i::Int, j::Int)

0 commit comments

Comments
 (0)