Dom::Rational
-- the field of
rational numbersDom::Rational
is the field of rational numbers
represented by elements of the domains DOM_INT
or DOM_RAT
.
Dom::Rational(x)
x |
- | an integer or a rational number |
Cat::QuotientField(
Dom::Integer
), Cat::DifferentialRing
,
Cat::OrderedSet
Dom::Complex
, Dom::Float
, Dom::Numerical
, Dom::Rational
, Dom::Real
Dom::Rational
is the domain of rational numbers
represented by expressions of type DOM_INT
or
DOM_RAT
.Dom::Rational
are usually not created
explicitly. However, if one creates elements using the usual syntax, it
is checked wether the input is of type DOM_INT
or
DOM_RAT
. This means Dom::Rational
is a
faēcade domain which creates elements of domain type
DOM_INT
or DOM_RAT
.Dom::Rational
is
trivial, it contains constants only.Dom::Rational
has the domain Dom::Numerical
as its super domain,
i.e., it inherits each method which is defined by
Dom::Numerical
and not re-implemented by
Dom::Rational
. Methods described below are re-implemented
by Dom::Rational
.denom(dom x)
x
.denom
.diff(dom z, <, any
x...> )
z
if it is called with only one
argument. Otherwise it returns 0.diff
.numer(dom x)
x
.numer
.random()
a/b
where
a
and b
are integers between -999 and
999.retract(dom x)
x
if it is an integer and
FAIL
otherwise.convert_to(dom x, any
T)
x
to an
element of type T
, or, if T
is not a domain,
to the domain type of T
. If the conversion fails,
FAIL
is returned.T
: DOM_INT
, Dom::Integer
, Dom::Rational
, DOM_RAT
, DOM_FLOAT
, Dom::Float
and Dom::Numerical
.testtype(any x, dom
T)
x
to the
domain Dom::Rational
. This is the case if x
is of type DOM_INT
or
DOM_RAT
. It returns
TRUE
if it can perform the conversion. Otherwise
FAIL
is returned.testtype
and not directly by the
user. Example 2 demonstrates this
behaviour.Creating some rational numbers using
Dom::Rational
. This example also shows that
Dom::Rational
is a faēcade domain.
>> Dom::Rational(2/3) ; domtype(%)
2/3 DOM_RAT
>> Dom::Rational(2.0)
Error: illegal arguments [Dom::Rational::new]
By tracing the method
Dom::Rational::testtype
we can see the interaction between
testtype
and
Dom::Rational::testtype
.
>> prog::trace(Dom::Rational::testtype): delete x: testtype(x, Dom::Rational); testtype(3/4, Dom::Rational); prog::untrace(Dom::Rational::testtype):
enter 'Dom::Rational::testtype' with args : x, Dom::Rational leave 'Dom::Rational::testtype' with result : FAIL FALSE enter 'Dom::Rational::testtype' with args : 3/4, Dom::Rational leave 'Dom::Rational::testtype' with result : TRUE TRUE
Ax::canonicalRep
, Ax::systemRep
,
Ax::canonicalOrder
,
Ax::efficientOperation("_divide")
,
Ax::efficientOperation("_mult")
,
Ax::efficientOperation("_invert")