Skip to content

Commit

Permalink
store indicies instead of elts
Browse files Browse the repository at this point in the history
But this makes the abstraction useless...
  • Loading branch information
kalmarek committed Dec 1, 2024
1 parent ad67331 commit f0a91dd
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/bases_fixed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Base.iterate(b::FiniteSupportBasis, state) = iterate(supp(b), state)
# return Base.IndexStyle(V)
# end

# To break ambiguity
# ??
Base.@propagate_inbounds function Base.getindex(
b::FiniteSupportBasis,
i::Integer,
Expand Down Expand Up @@ -53,25 +51,22 @@ mstructure(fb::FixedBasis) = fb.table
Base.in(x, b::FixedBasis) = haskey(mstructure(b), x)
Base.getindex(b::FixedBasis{T}, x::T) where {T} = mstructure(b)[x]

struct SubBasis{T,I,V,B<:AbstractBasis{T,I}} <: FiniteSupportBasis{T,I}
supporting_elts::V
struct SubBasis{T,I,V<:AbstractVector{I},B<:AbstractBasis{T,I}} <:
FiniteSupportBasis{T,I}
supporting_idcs::V
parent_basis::B
end

supp(sb::SubBasis) = sb.supporting_elts
supp(sb::SubBasis) = sb.supporting_idcs
Base.parent(sub::SubBasis) = sub.parent_basis

Check warning on line 61 in src/bases_fixed.jl

View check run for this annotation

Codecov / codecov/patch

src/bases_fixed.jl#L61

Added line #L61 was not covered by tests

Base.in(x, b::SubBasis) = x in supp(b)
function Base.getindex(b::SubBasis{T,I}, x::T) where {T,I<:Integer}
k = findfirst(==(x), supp(b))
isnothing(k) && throw("x=$x is not supported on SubBasis")
@info T I
return convert(I, k)
return convert(I, parent(b)[supp(b)[x]])

Check warning on line 65 in src/bases_fixed.jl

View check run for this annotation

Codecov / codecov/patch

src/bases_fixed.jl#L63-L65

Added lines #L63 - L65 were not covered by tests
end

function Base.getindex(b::SubBasis{T,T}, x::T) where {T}
x in supp(b) && return x
throw("x=$x is not supported on SubBasis")
parent(b)[x] in supp(b) && return x

Check warning on line 69 in src/bases_fixed.jl

View check run for this annotation

Codecov / codecov/patch

src/bases_fixed.jl#L68-L69

Added lines #L68 - L69 were not covered by tests
end

struct SubMStructure{SB<:SubBasis,MS} <: MultiplicativeStructure
Expand Down

0 comments on commit f0a91dd

Please sign in to comment.