Description Details Author(s) Examples
Methods for Arithmetic functions in the clock package: +
,
-
, *
, /
, ^
.
The unary arithmetic functions (viz “+
” and
“-
”) do no coercion.
The binary arithmetic functions coerce numeric <op> clock
and
clock <op> numeric
to clock
, except for ^
, for
which only clock^numeric
is defined.
Multiplicative inverses are calculated using Fermat's theorem: if
p is prime and (a,p)=1 then a^(p-1)=1 (mod p). From this we deduce that a.a^(p-2)=1 (mod p), or
a^-1=a^(p-2) (mod p). It
might be slightly more efficient to use a look-up table but the
bookkeeping overhead for dealing with zero and NA
would be
large. Multiplicative inverses are not defined for composite moduli.
Powers are calculated using Euler's generalization of Fermat: if (a,n)=1 then a^phi(n)=1 (mod n). So if m=p.phi(n)+q we would have a^n=a^q (mod n), and this is used in the package. It might be possible to use the multiplicative order of a for composite n but again overheads would be considerable.
Robin K. S. Hankin
1 2 3 4 5 6 7 8 9 10 11 12 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.