diff --git a/NDTensors/src/lib/BlockSparseArrays/ext/BlockSparseArraysGradedAxesExt/src/BlockSparseArraysGradedAxesExt.jl b/NDTensors/src/lib/BlockSparseArrays/ext/BlockSparseArraysGradedAxesExt/src/BlockSparseArraysGradedAxesExt.jl index 3a815d4ea2..85fcaab49f 100644 --- a/NDTensors/src/lib/BlockSparseArrays/ext/BlockSparseArraysGradedAxesExt/src/BlockSparseArraysGradedAxesExt.jl +++ b/NDTensors/src/lib/BlockSparseArrays/ext/BlockSparseArraysGradedAxesExt/src/BlockSparseArraysGradedAxesExt.jl @@ -138,7 +138,7 @@ function Base.show( io::IO, mime::MIME"text/plain", a::Adjoint{<:Any,<:BlockSparseMatrix}; kwargs... ) axes_a = axes(a) - a_nondual = BlockSparseArray(blocks(a'), dual.(nondual.(axes(a))))' + a_nondual = BlockSparseArray(blocks(a'), dual.(nondual.(axes(a'))))' return blocksparse_show(io, mime, a_nondual, axes_a; kwargs...) end diff --git a/NDTensors/src/lib/BlockSparseArrays/src/BlockSparseArrays.jl b/NDTensors/src/lib/BlockSparseArrays/src/BlockSparseArrays.jl index af59ae7f51..d0a1e4cdd7 100644 --- a/NDTensors/src/lib/BlockSparseArrays/src/BlockSparseArrays.jl +++ b/NDTensors/src/lib/BlockSparseArrays/src/BlockSparseArrays.jl @@ -16,6 +16,7 @@ include("abstractblocksparsearray/arraylayouts.jl") include("abstractblocksparsearray/sparsearrayinterface.jl") include("abstractblocksparsearray/broadcast.jl") include("abstractblocksparsearray/map.jl") +include("abstractblocksparsearray/linearalgebra.jl") include("blocksparsearray/defaults.jl") include("blocksparsearray/blocksparsearray.jl") include("BlockArraysSparseArrayInterfaceExt/BlockArraysSparseArrayInterfaceExt.jl") diff --git a/NDTensors/src/lib/BlockSparseArrays/src/abstractblocksparsearray/linearalgebra.jl b/NDTensors/src/lib/BlockSparseArrays/src/abstractblocksparsearray/linearalgebra.jl new file mode 100644 index 0000000000..144ea47593 --- /dev/null +++ b/NDTensors/src/lib/BlockSparseArrays/src/abstractblocksparsearray/linearalgebra.jl @@ -0,0 +1,18 @@ +using LinearAlgebra: Adjoint, Transpose + +# Like: https://github.com/JuliaLang/julia/blob/v1.11.1/stdlib/LinearAlgebra/src/transpose.jl#L184 +# but also takes the dual of the axes. +# Fixes an issue raised in: +# https://github.com/ITensor/ITensors.jl/issues/1336#issuecomment-2353434147 +function Base.copy(a::Adjoint{T,<:AbstractBlockSparseMatrix{T}}) where {T} + a_dest = similar(parent(a), axes(a)) + a_dest .= a + return a_dest +end + +# More efficient than the generic `LinearAlgebra` version. +function Base.copy(a::Transpose{T,<:AbstractBlockSparseMatrix{T}}) where {T} + a_dest = similar(parent(a), axes(a)) + a_dest .= a + return a_dest +end