Skip to content

Commit

Permalink
Add parent for AlgebraElement
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Jun 12, 2024
1 parent 5bd4ae5 commit e8343c1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/algebra_elts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ function Base.deepcopy_internal(a::AlgebraElement, id::IdDict)
end

# call overload:
(a::AlgebraElement)(x) = coeffs(a)[basis(parent(a))[x]]
Base.setindex!(a::AlgebraElement, v, idx) = a.coeffs[basis(parent(a))[idx]] = v
(a::AlgebraElement)(x) = coeffs(a)[basis(a)[x]]
Base.setindex!(a::AlgebraElement, v, idx) = a.coeffs[basis(a)[idx]] = v

# AlgebraElement specific functions

function supp(a::AlgebraElement)
b = basis(parent(a))
b = basis(a)
return [b[i] for (i, _) in nonzero_pairs(coeffs(a))]
end

Expand Down
5 changes: 3 additions & 2 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ Base.parent(a::AlgebraElement) = a.parent
Base.eltype(a::AlgebraElement) = valtype(coeffs(a))
coeffs(a::AlgebraElement) = a.coeffs
function coeffs(x::AlgebraElement, b::AbstractBasis)
return coeffs(coeffs(x), basis(parent(x)), b)
return coeffs(coeffs(x), basis(x), b)
end
basis(a::AlgebraElement) = basis(parent(a))

function AlgebraElement(coeffs, A::AbstractStarAlgebra)
_sanity_checks(coeffs, A)
Expand Down Expand Up @@ -87,7 +88,7 @@ function Base.isone(a::AlgebraElement)
if basis(A) isa DiracBasis
return c == cfs1
else
dc = coeffs(c, basis(parent(a)), DiracBasis{UInt}(object(parent(a))))
dc = coeffs(c, basis(a), DiracBasis{UInt}(object(parent(a))))
return dc == cfs1
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/group_algebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
z = sum((one(RG) - RG(g)) * star(one(RG) - RG(g)) for g in G)
@test SA.aug(z) == 0

@test SA.supp(z) == sort(collect(basis(parent(z))))
@test SA.supp(z) == sort(collect(basis(z)))
@test SA.supp(RG(1) + RG(g)) == [one(G), g]
@test SA.supp(a) == [one(G), h, g]

Expand Down

0 comments on commit e8343c1

Please sign in to comment.