-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathfixed.jl
65 lines (55 loc) · 1.77 KB
/
fixed.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""
struct FixedBasis{B,M,T,V} <:
SA.ExplicitBasis{SA.AlgebraElement{Algebra{FullBasis{B,M},B,M},T,V},Int}
elements::Vector{SA.AlgebraElement{Algebra{FullBasis{B,M},B,M},T,V}}
end
Fixed basis with polynomials `elements`.
"""
struct FixedBasis{B,M,T,V} <:
SA.ExplicitBasis{SA.AlgebraElement{Algebra{FullBasis{B,M},B,M},T,V},Int}
elements::Vector{SA.AlgebraElement{Algebra{FullBasis{B,M},B,M},T,V}}
end
Base.length(b::FixedBasis) = length(b.elements)
Base.getindex(b::FixedBasis, i::Integer) = b.elements[i]
function Base.show(io::IO, b::FixedBasis)
print(io, "FixedBasis(")
_show_vector(io, MIME"text/plain"(), b.elements)
print(io, ")")
return
end
"""
struct SemisimpleBasis{T,I,B<:SA.ExplicitBasis{T,I}} <: SA.ExplicitBasis{T,I}
bases::Vector{B}
end
Semisimple basis for use with [SymbolicWedderburn](https://github.com/kalmarek/SymbolicWedderburn.jl/).
Its elements are of [`SemisimpleElement`](@ref)s.
"""
struct SemisimpleBasis{T,I,B<:SA.ExplicitBasis{T,I}} <: SA.ExplicitBasis{T,I}
bases::Vector{B}
end
Base.length(b::SemisimpleBasis) = length(first(b.bases))
"""
struct SemisimpleElement{P}
polynomials::Vector{P}
end
Elements of [`SemisimpleBasis`](@ref).
"""
struct SemisimpleElement{P}
elements::Vector{P}
end
SA.star(p::SemisimpleElement) = SemisimpleElement(SA.star.(p.elements))
function Base.getindex(b::SemisimpleBasis, i::Integer)
return SemisimpleElement(getindex.(b.bases, i))
end
function Base.show(io::IO, b::SemisimpleBasis)
if length(b.bases) == 1
print(io, "Simple basis:")
else
print(io, "Semisimple basis with $(length(b.bases)) simple sub-bases:")
end
for basis in b.bases
println(io)
print(io, " ")
print(io, basis)
end
end