Skip to content

Commit

Permalink
Add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Dec 15, 2024
1 parent 114a86a commit 2f0f302
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
14 changes: 14 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ maxdegree_basis
explicit_basis_covering
```

## Basis elements

```@docs
Polynomial
SemisimpleElement
```

## Monomial basis

```@docs
Expand All @@ -40,3 +47,10 @@ ChebyshevFirstKind
ChebyshevSecondKind
Trigonometric
```

## Additional basis

```@docs
FixedBasis
SemisimpleBasis
```
31 changes: 27 additions & 4 deletions src/fixed.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
"""
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}}
Expand All @@ -13,18 +21,33 @@ function Base.show(io::IO, b::FixedBasis)
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 MultiPoly{P}
polynomials::Vector{P}
"""
struct SemisimpleElement{P}
polynomials::Vector{P}
end
Elements of [`SemisimpleBasis`](@ref).
"""
struct SemisimpleElement{P}
elements::Vector{P}
end
SA.star(p::MultiPoly) = MultiPoly(SA.star.(p.polynomials))
SA.star(p::SemisimpleElement) = SemisimpleElement(SA.star.(p.polynomials))

Base.getindex(b::SemisimpleBasis, i::Integer) = MultiPoly(getindex.(b.bases, i))
Base.getindex(b::SemisimpleBasis, i::Integer) = SemisimpleElement(getindex.(b.bases, i))

function Base.show(io::IO, b::SemisimpleBasis)
if length(b.bases) == 1
Expand Down
4 changes: 2 additions & 2 deletions test/fixed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using DynamicPolynomials
@test sprint(show, semi) ==
"Semisimple basis with 2 simple sub-bases:\n FixedBasis([$p1])\n FixedBasis([$p2])"
mult = semi[1]
@test all(mult.polynomials .≈ [p1, p2])
@test all(mult.elements .≈ [p1, p2])
smult = SA.star(mult)
@test all(smult.polynomials .≈ [p2, p1])
@test all(smult.elements .≈ [p2, p1])
end

0 comments on commit 2f0f302

Please sign in to comment.