Skip to content

Use DerivableInterfaces.permuteddims #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2025
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
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BlockSparseArrays"
uuid = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.9.0"
version = "0.9.1"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down Expand Up @@ -33,7 +33,7 @@ Adapt = "4.1.1"
Aqua = "0.8.9"
ArrayLayouts = "1.10.4"
BlockArrays = "1.2.0"
DerivableInterfaces = "0.5.2"
DerivableInterfaces = "0.5.3"
DiagonalArrays = "0.3"
Dictionaries = "0.4.3"
FillArrays = "1.13.0"
Expand Down
11 changes: 6 additions & 5 deletions src/blocksparsearrayinterface/blocksparsearrayinterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ using DerivableInterfaces:
AbstractArrayInterface,
DefaultArrayInterface,
interface,
permuteddims,
zero!
using LinearAlgebra: Adjoint, Transpose
using SparseArraysBase:
Expand Down Expand Up @@ -312,7 +313,7 @@ end
# `blockisequal_map[!]`.
# TODO: Maybe define a `BlockIsEqualInterface` for these kinds of functions.
function blockisequal_permutedims!(a_dest::AbstractArray, a_src::AbstractArray, perm)
blocks(a_dest) .= blocks(PermutedDimsArray(a_src, perm))
blocks(a_dest) .= blocks(permuteddims(a_src, perm))
return a_dest
end

Expand All @@ -322,7 +323,7 @@ end
@interface ::AbstractBlockSparseArrayInterface function Base.permutedims(
a::AbstractArray, perm
)
a_dest = similar(PermutedDimsArray(a, perm))
a_dest = similar(permuteddims(a, perm))
# TODO: Maybe define this as `@interface BlockIsEqualInterface() permutedims!(...)`.
blockisequal_permutedims!(a_dest, a, perm)
return a_dest
Expand All @@ -334,7 +335,7 @@ end
@interface ::AbstractBlockSparseArrayInterface function Base.permutedims!(
a_dest::AbstractArray, a_src::AbstractArray, perm
)
if all(blockisequal.(axes(a_dest), axes(PermutedDimsArray(a_src, perm))))
if all(blockisequal.(axes(a_dest), axes(permuteddims(a_src, perm))))
# TODO: Maybe define this as `@interface BlockIsEqualInterface() permutedims!(...)`.
blockisequal_permutedims!(a_dest, a_src, perm)
return a_dest
Expand Down Expand Up @@ -403,15 +404,15 @@ end
function SparseArraysBase.getstoredindex(
a::SparsePermutedDimsArrayBlocks{<:Any,N}, index::Vararg{Int,N}
) where {N}
return PermutedDimsArray(
return permuteddims(
getstoredindex(blocks(parent(a.array)), _getindices(index, _invperm(a.array))...),
_perm(a.array),
)
end
function SparseArraysBase.getunstoredindex(
a::SparsePermutedDimsArrayBlocks{<:Any,N}, index::Vararg{Int,N}
) where {N}
return PermutedDimsArray(
return permuteddims(
getunstoredindex(blocks(parent(a.array)), _getindices(index, _invperm(a.array))...),
_perm(a.array),
)
Expand Down
Loading