1
0
mirror of https://github.com/kalmarek/GroupRings.jl.git synced 2024-12-28 18:50:29 +01:00

add ProductNotDefined error

This commit is contained in:
Marek Kaluba 2021-06-19 00:48:04 +02:00
parent a1f5f0a24c
commit 5caa4facbb
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15

View File

@ -13,6 +13,21 @@ _product(::Val{true}, g, h) = star(g) * h
# additionally it may implement
# * basis(ms)
struct ProductNotDefined <: Exception
i::Any
j::Any
msg::Any
end
function Base.showerror(io::IO, ex::ProductNotDefined)
print(io, "Product of elements $(ex.i) and $(ex.j) is not defined on the basis")
print(io, " or the multiplicative structure could not be completed")
if isdefined(ex, :msg)
print(io, ": $(ex.msg)")
end
print(io, ".")
end
struct TrivialMStructure{Tw,I,B<:AbstractBasis} <: MultiplicativeStructure{Tw,I}
basis::B
end
@ -28,5 +43,6 @@ Base.@propagate_inbounds function Base.getindex(mstr::TrivialMStructure, i::Inte
b = basis(mstr)
g, h = b[i], b[j]
gh = _product(mstr, g, h)
gh in b || throw(ProductNotDefined(i, j, "$g · $h = $gh"))
return b[gh]
end