mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-12-04 18:11:26 +01:00
optionally coerce to G when called G(a::Vector)
This commit is contained in:
parent
ae97c20e62
commit
ba4400efbb
@ -72,16 +72,16 @@ end
|
|||||||
(G::DirectProductGroup)(g::DirectProductGroupElem) = G(g.elts)
|
(G::DirectProductGroup)(g::DirectProductGroupElem) = G(g.elts)
|
||||||
|
|
||||||
doc"""
|
doc"""
|
||||||
(G::DirectProductGroup)(a::Vector; checked=true)
|
(G::DirectProductGroup)(a::Vector, check::Bool=true)
|
||||||
> Constructs element of the direct product group `G` by coercing each element
|
> Constructs element of the $n$-fold direct product group `G` by coercing each
|
||||||
> of vector `a` to the corresponding factor of `G`. If `checked` flag is set to
|
> element of vector `a` to `G.group`. If `check` flag is set to `false` no
|
||||||
> `false` no checks on the correctness are performed.
|
> checks on the correctness are performed.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
function (G::DirectProductGroup){T<:GroupElem}(a::Vector{T})
|
function (G::DirectProductGroup)(a::Vector, check::Bool=true)
|
||||||
length(a) == length(G.factors) || throw("Cannot coerce $a to $G: they have
|
if check
|
||||||
different number of factors")
|
G.n == length(a) || throw("Can not coerce to DirectProductGroup: lengths differ")
|
||||||
@assert elem_type(first(G.factors)) == T
|
a = G.group.(a)
|
||||||
|
end
|
||||||
return DirectProductGroupElem(a)
|
return DirectProductGroupElem(a)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user