Skip to content

Commit 8da3b9f

Browse files
authored
Remove basis field in MTable (#101)
1 parent 1b4ebdc commit 8da3b9f

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/mtables.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,48 +12,48 @@ Multiplicative table, stored explicitly as an AbstractMatrix{I}.
1212
mt(-i, j) == b[star(b[i])*b[j]]
1313
```
1414
"""
15-
struct MTable{T,I<:Integer,B<:AbstractBasis{T,I},Ms,M<:AbstractMatrix} <:
15+
struct MTable{T,I<:Integer,Ms<:MultiplicativeStructure{T,I},M<:AbstractMatrix} <:
1616
MultiplicativeStructure{T,I}
17-
basis::B
1817
mstr::Ms
1918
table::M
2019
lock::Base.Threads.SpinLock
2120
end
2221

2322
function MTable(
24-
basis::AbstractBasis{T,I},
25-
mstr::MultiplicativeStructure,
23+
mstr::MultiplicativeStructure{T,I},
2624
dims::NTuple{2,I},
2725
) where {T,I<:Integer}
28-
Base.require_one_based_indexing(basis)
26+
bas = basis(mstr)
27+
Base.require_one_based_indexing(bas)
2928

30-
if Base.haslength(basis)
31-
@assert length(basis) first(dims)
32-
@assert length(basis) last(dims)
29+
if Base.haslength(bas)
30+
@assert length(bas) first(dims)
31+
@assert length(bas) last(dims)
3332
end
3433

35-
C = typeof(mstr(first(basis), first(basis)))
34+
C = typeof(mstr(first(bas), first(bas)))
3635
table = Matrix{C}(undef, dims)
3736
# this is to avoid situation with allocated garbage in table
3837
# we want table to consist of #undefs as "sentiel values"
3938
@assert !isbitstype(C) || dims == (0, 0)
4039

41-
return MTable(basis, mstr, table, Base.Threads.SpinLock())
40+
return MTable(mstr, table, Base.Threads.SpinLock())
4241
end
4342

4443
function MTable(
4544
basis::AbstractBasis{T,I},
4645
dims::NTuple{2,I},
4746
) where {T,I<:Integer}
48-
return MTable(basis, DiracMStructure(basis, *), dims)
47+
return MTable(DiracMStructure(basis, *), dims)
4948
end
5049

5150
Base.@propagate_inbounds function __absindex(mt::MTable, i::Integer)
5251
return ifelse(i > 0, i, oftype(i, star(mt, abs(i))))
5352
end
5453

5554
Base.size(mt::MTable, i::Vararg) = size(mt.table, i...)
56-
Base.getindex(mt::MTable, i::Integer) = mt.basis[__absindex(mt, i)]
55+
Base.getindex(mt::MTable, i::Integer) = mt.mstr[__absindex(mt, i)]
56+
basis(mstr::MTable) = basis(mstr.mstr)
5757

5858
function __iscomputed(mt::MTable, i, j)
5959
return isassigned(mt.table, i, j)

test/quadratic_form.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ end
108108
@testset "Chebyshev basis" begin
109109
implicit = cheby_basis()
110110
mstr = ChebyMStruct(implicit)
111-
mt = SA.MTable(implicit, mstr, (0, 0))
111+
mt = SA.MTable(mstr, (0, 0))
112112
sub = SA.SubBasis(implicit, 1:3)
113113
test_vector_interface(sub)
114114
fixed = SA.FixedBasis(implicit; n = 3)

0 commit comments

Comments
 (0)