Skip to content

Commit 30dcf88

Browse files
committed
use space_isequal for Mul axis checks
1 parent bf41a6c commit 30dcf88

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ authors = ["ITensor developers <[email protected]> and contributors"]
44
version = "0.4.19"
55

66
[deps]
7+
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
78
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
89
BlockSparseArrays = "2c9a651f-6452-4ace-a6ac-809f4280fbb4"
910
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
@@ -23,6 +24,7 @@ TensorAlgebra = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
2324
GradedArraysTensorAlgebraExt = "TensorAlgebra"
2425

2526
[compat]
27+
ArrayLayouts = "1.11.2"
2628
BlockArrays = "1.6"
2729
BlockSparseArrays = "0.8, 0.9.3"
2830
Compat = "4.16"

src/gradedarray.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ using BlockSparseArrays:
99
sparsemortar
1010
using LinearAlgebra: Adjoint
1111
using TypeParameterAccessors: similartype, unwrap_array_type
12+
using ArrayLayouts: ArrayLayouts
1213

1314
const GradedArray{T,N,A<:AbstractArray{T,N},Blocks<:AbstractArray{A,N},Axes<:Tuple{AbstractGradedUnitRange{<:Integer},Vararg{AbstractGradedUnitRange{<:Integer}}}} = BlockSparseArray{
1415
T,N,A,Blocks,Axes
@@ -236,3 +237,11 @@ function Base.showarg(io::IO, a::GradedArray, toplevel::Bool)
236237
print(io, concretetype_to_string_truncated(typeof(a); param_truncation_length=40))
237238
return nothing
238239
end
240+
241+
const AnyGradedMatrix{T} = Union{GradedMatrix{T},Adjoint{T,<:GradedMatrix{T}}}
242+
243+
function ArrayLayouts._check_mul_axes(A::AnyGradedMatrix, B::AnyGradedMatrix)
244+
axA = axes(A, 2)
245+
axB = axes(B, 1)
246+
return space_isequal(dual(axA), axB) || ArrayLayouts.throw_mul_axes_err(axA, axB)
247+
end

0 commit comments

Comments
 (0)