The call RingQ()
produces the CoCoA ring which represents Q, the field of
rational numbers. Calling RingQ()
several times will always produce the
same unique CoCoA ring representing Q.
Please see the documentation in ring
for a full description of
operations elements of a ring. Strictly, there is a limit on the size
of elements you can create, but the limit is typically high enough not
to be bothersome.
RingQ()
is the fraction field of RingZ()
; please see the documentation
in FractionField
for a description of the additional operations
available (over those of a plain ring).
Here is a summary of the functions offered:
RingQ() |
returns the CoCoALib ring representing Q |
IsQ(R) |
says whether the ring R is actually RingQ() |
NewQEmbeddingHom(S) |
creates the (partial) homomorphism Q --> S |
(but see also CanonicalHom ) |
The function RingQ()
simply returns the unique instance of the CoCoALib
ring representing Q. This instance is managed by GlobalManager
, see its
documentation.
The function MakeUniqueInstanceOfRingQ
is the only function which can
call the ctor of RingQImpl
. The only function which is supposed to
call MakeUniqueInstanceOfRingQ
is the ctor of GlobalManager
. I have
discouraged others from calling MakeUniqueInstanceOfRingQ
by not putting
it in the header file RingQ.H
-- see bugs section in GlobalManager
.
RingQImpl
is the implementation of the field of rational numbers
following the scheme laid by RingBase
and FractionFieldBase
. Almost
all member functions are trivial: indeed, virtually all the work is done by
the GMP library. Once you have understood how RingZImpl
works, the
implementation here should be easy to follow.
The implementation of RingQImpl::InducedHomImpl::myApply
turns out to
be a bit lengthy, but I do not see how to improve it. Since partial
homomorphisms can be built, myApply
maps numerator and denominator then
must check that their images can be divided. I cannot reuse the
implementation of FractionFieldImpl::InducedHomImpl::myApply
because
there is no equivalent of RefNum
and RefDen
in RingQImpl
.
This code is probably not "exception safe"; I do not know what the mpq_* functions do when there is insufficient memory to proceed. Making the code "exception safe" could well be non-trivial: I suspect a sort of auto_ptr to an mpq_t value might be needed.
How to check that induced homomorphisms are vaguely sensible?? e.g. given Z->Z[x] ker=0, but cannot induce Q->Z[x]; so it is not sufficient simply to check that the kernel is zero.