Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SparseArraysBase"
uuid = "0d5efcca-f356-4864-8770-e1ed8d78f208"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.2.9"
version = "0.2.10"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand Down
14 changes: 12 additions & 2 deletions src/wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,20 @@
end
end

using LinearAlgebra: Diagonal
using LinearAlgebra: LinearAlgebra, Diagonal
@interface ::AbstractArrayInterface storedvalues(D::Diagonal) = LinearAlgebra.diag(D)

# compat with LTS:
@static if VERSION ≥ v"1.11"
_diagind = LinearAlgebra.diagind
else
function _diagind(x::Diagonal, ::IndexCartesian)
return view(CartesianIndices(x), LinearAlgebra.diagind(x))

Check warning on line 173 in src/wrappers.jl

View check run for this annotation

Codecov / codecov/patch

src/wrappers.jl#L172-L173

Added lines #L172 - L173 were not covered by tests
end
end
@interface ::AbstractArrayInterface eachstoredindex(D::Diagonal) =
LinearAlgebra.diagind(D, IndexCartesian())
_diagind(D, IndexCartesian())

@interface ::AbstractArrayInterface isstored(D::Diagonal, i::Int, j::Int) =
i == j && Base.checkbounds(Bool, D, i, j)
@interface ::AbstractArrayInterface function getstoredindex(D::Diagonal, i::Int, j::Int)
Expand Down
Loading