The function CanonicalHom
can be used to create certain simple
canonical homomorphisms. If it is unable to produce the required
homomorphism then it will throw an exception of type ErrorInfo
having error code ERR::CanonicalHom
(see error
).
In all cases the syntax is:
CanonicalHom(domain, codomain)
You can use CanonicalHom
whenever the domain is Z or Q, or if
codomain is formed from domain in a single step. Here is a complete
of the cases when you CanonicalHom
will work:
if domain == codomain if codomain == FractionField(domain) if domain == CoeffRing(codomain) if codomain is a quotient of domain if domain is RingZ if domain is RingQ (result may be a partial hom)
Structurally simple and rather tedious. It is "important" that the cases of the
domain being RingZ
or RingQ
are tested last because the other cases offer
"shortcuts" (compared to RingZEmbeddingHom
and RingQEmbeddingHom
).
If you don't like "goto, have a go at rewriting the implementation. I'll accept it so long as it is no more complicated than the current implementation!
Pity I cannot combine IsPolyRing
and AsPolyRing
to produce simpler code.
Are there any missing cases?