Skip to content

Commit

Permalink
Dual the axes in adjoint in a more elegant way
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman committed May 31, 2024
1 parent 41b5493 commit 5ab1564
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ using BlockArrays: AbstractBlockVector, Block, BlockedUnitRange, blocks
using ..BlockSparseArrays:
BlockSparseArrays,
AbstractBlockSparseArray,
AbstractBlockSparseMatrix,
BlockSparseArray,
BlockSparseMatrix,
block_merge
Expand Down Expand Up @@ -67,8 +68,11 @@ function Base.eachindex(a::AbstractBlockSparseArray)
return CartesianIndices(nondual.(axes(a)))
end

function Base.adjoint(a::BlockSparseMatrix)
return Adjoint(BlockSparseArray(blocks(a), dual.(axes(a))))
# TODO: Handle this through some kind of trait dispatch, maybe
# a `SymmetryStyle`-like trait to check if the block sparse
# matrix has graded axes.
function Base.axes(a::Adjoint{<:Any,<:AbstractBlockSparseMatrix})
return dual.(reverse(axes(a')))
end

# This is a temporary fix for `show` being broken for BlockSparseArrays
Expand Down

0 comments on commit 5ab1564

Please sign in to comment.