diff --git a/doc/cln.dvi b/doc/cln.dvi index a1e064d..086cf54 100644 Binary files a/doc/cln.dvi and b/doc/cln.dvi differ diff --git a/doc/cln.html b/doc/cln.html index 9e9c2b8..f464153 100644 --- a/doc/cln.html +++ b/doc/cln.html @@ -1,6 +1,6 @@
- +i386
, m68k
, sparc
, mips
, arm
).
@@ -292,7 +293,7 @@ This section describes how to install the CLN package on your system.
To build CLN, you need a C++ compiler.
Actually, you need GNU g++ 2.7.0
or newer.
On HPPA, you need GNU g++ 2.8.0
or newer.
-I recommend GNU egcs 1.1
or newer.
+I recommend GNU g++ 2.95
or newer.
@@ -315,6 +316,8 @@ of static and global variables, a feature which I could implement for GNU g++ only. +
make
installed.
+g++
miscompiles the division routines
--enable-shared to work, you need egcs-1.1.2 or newer.
-
-On MIPS (SGI Irix 6), pass option --without-gmp
to configure. gmp does
-not work when compiled in `n32' binary format on Irix.
-
-
By default, only a static library is built. You can build CLN as a shared
library too, by calling configure
with the option `--enable-shared'.
@@ -467,6 +467,9 @@ library.
As with any autoconfiguring GNU software, installation is as easy as this: @@ -552,6 +555,8 @@ Rational number Floating-point number
+
+
The base class cl_number
is an abstract base class.
It is not useful to declare a variable of this type except if you want
to completely disable compile-time type checking and use run-time type
@@ -559,17 +564,24 @@ checking instead.
+
+
+
The class cl_N
comprises real and complex numbers. There is
no special class for complex numbers since complex numbers with imaginary
part 0
are automatically converted to real numbers.
+
The class cl_R
comprises real numbers of different kinds. It is an
abstract class.
+
+
+
The class cl_RA
comprises exact real numbers: rational numbers, including
integers. There is no special class for non-integral rational numbers
since rational numbers with denominator 1
are automatically converted
@@ -577,6 +589,7 @@ to integers.
+
The class cl_F
implements floating-point approximations to real numbers.
It is an abstract class.
@@ -584,6 +597,9 @@ It is an abstract class.
Some numbers are represented as exact numbers: there is no loss of information @@ -625,6 +641,9 @@ is completely transparent.
Not all real numbers can be represented exactly. (There is an easy mathematical @@ -635,6 +654,7 @@ CLN implements ordinary floating-point numbers, with mantissa and exponent.
+
The elementary operations (+
, -
, *
, /
, ...)
only return approximate results. For example, the value of the expression
(cl_F) 0.3 + (cl_F) 0.4
prints as `0.70000005', not as
@@ -665,6 +685,7 @@ Floating point numbers come in four flavors:
cl_SF
.
They have 1 sign bit, 8 exponent bits (including the exponent's sign),
and 17 mantissa bits (including the "hidden" bit).
@@ -672,6 +693,7 @@ They don't consume heap allocation.
cl_FF
.
They have 1 sign bit, 8 exponent bits (including the exponent's sign),
and 24 mantissa bits (including the "hidden" bit).
@@ -680,6 +702,7 @@ This corresponds closely to the C/C++ type `float'.
cl_DF
.
They have 1 sign bit, 11 exponent bits (including the exponent's sign),
and 53 mantissa bits (including the "hidden" bit).
@@ -688,6 +711,7 @@ This corresponds closely to the C/C++ type `double'.
cl_LF
.
They have 1 sign bit, 32 exponent bits (including the exponent's sign),
and n mantissa bits (including the "hidden" bit), where n >= 64.
@@ -708,6 +732,7 @@ with larger exponent range.
+
As a user of CLN, you can forget about the differences between the
four floating-point types and just declare all your floating-point
variables as being of type cl_F
. This has the advantage that
@@ -723,6 +748,9 @@ the floating point contagion rule happened to change in the future.)
Complex numbers, as implemented by the class cl_N
, have a real
@@ -739,6 +767,9 @@ through application of sqrt
or transcendental functions.
Conversions from any class to any its superclasses ("base classes" in
@@ -796,6 +827,7 @@ Conversions from `const char *' are provided for the classes
cl_R
, cl_N
.
The easiest way to specify a value which is outside of the range of the
C++ built-in types is therefore to specify it as a string, like this:
+
cl_I order_of_rubiks_cube_group = "43252003274489856000"; @@ -815,12 +847,16 @@ the functions
int cl_I_to_int (const cl_I& x)
unsigned int cl_I_to_uint (const cl_I& x)
long cl_I_to_long (const cl_I& x)
unsigned long cl_I_to_ulong (const cl_I& x)
x
as element of the C type ctype. If x
is not
representable in the range of ctype, a runtime error occurs.
@@ -837,8 +873,10 @@ the functions
float cl_float_approx (const type& x)
double cl_double_approx (const type& x)
x
of C type ctype.
If abs(x)
is too close to 0 (underflow), 0 is returned.
If abs(x)
is too large (overflow), an IEEE infinity is returned.
@@ -849,8 +887,10 @@ Conversions from any class to any of its subclasses ("derived classes" in
C++ terminology) are not provided. Instead, you can assert and check
that a value belongs to a certain subclass, and return it as element of that
class, using the `As' and `The' macros.
+
As(type)(value)
checks that value belongs to
type and returns it as such.
+
The(type)(value)
assumes that value belongs to
type and returns it as such. It is your responsibility to ensure
that this assumption is valid.
@@ -967,10 +1007,12 @@ defines the following operations:
type operator + (const type&, const type&)
type operator - (const type&, const type&)
type operator - (const type&)
@@ -979,18 +1021,22 @@ Returns the negative of the argument.
type plus1 (const type& x)
x + 1
.
type minus1 (const type& x)
x - 1
.
type operator * (const type&, const type&)
type square (const type& x)
x * x
.
@@ -1004,10 +1050,12 @@ defines the following operations:
type operator / (const type&, const type&)
type recip (const type&)
cl_I
defines an "exact quotient" function:
cl_I exquo (const cl_I& x, const cl_I& y)
y
divides x
, and returns the quotient x
/y
.
@@ -1034,12 +1083,14 @@ The following exponentiation functions are defined:
cl_I expt_pos (const cl_I& x, const cl_I& y)
cl_RA expt_pos (const cl_RA& x, const cl_I& y)
y
must be > 0. Returns x^y
.
cl_RA expt (const cl_RA& x, const cl_I& y)
cl_R expt (const cl_R& x, const cl_I& y)
cl_N expt (const cl_N& x, const cl_I& y)
@@ -1057,6 +1108,7 @@ defines the following operation:
type abs (const type& x)
x
.
This is x
if x >= 0
, and -x
if x <= 0
.
@@ -1082,6 +1134,7 @@ defines the following operation:
type signum (const type& x)
x
, in the same number format as x
.
This is defined as x / abs(x)
if x
is non-zero, and
x
if x
is zero. If x
is real, the value is either
@@ -1100,10 +1153,12 @@ Each of the classes cl_RA
, cl_I
defines the following
cl_I numerator (const type& x)
x
.
cl_I denominator (const type& x)
x
.
@@ -1124,6 +1179,7 @@ The class cl_N
defines the following operation:
cl_N complex (const cl_R& a, const cl_R& b)
a+bi
, that is, the complex number with
real part a
and imaginary part b
.
@@ -1136,14 +1192,17 @@ Each of the classes cl_N
, cl_R
defines the following o
cl_R realpart (const type& x)
x
.
cl_R imagpart (const type& x)
x
.
type conjugate (const type& x)
x
.
@@ -1164,6 +1223,9 @@ We have the relations
Each of the classes cl_N
, cl_R
, cl_RA
, cl_I
,
@@ -1175,18 +1237,22 @@ defines the following operations:
bool operator == (const type&, const type&)
bool operator != (const type&, const type&)
uint32 cl_equal_hashcode (const type&)
==
. This hash code depends on the number's value,
not its type or precision.
cl_boolean zerop (const type& x)
x == 0
@@ -1200,33 +1266,42 @@ defines the following operations:
cl_signean cl_compare (const type& x, const type& y)
x
and y
. Returns +1 if x
>y
,
-1 if x
<y
, 0 if x
=y
.
bool operator <= (const type&, const type&)
bool operator < (const type&, const type&)
bool operator >= (const type&, const type&)
bool operator > (const type&, const type&)
cl_boolean minusp (const type& x)
x < 0
cl_boolean plusp (const type& x)
x > 0
type max (const type& x, const type& y)
x
and y
.
type min (const type& x, const type& y)
x
and y
.
@@ -1242,6 +1317,9 @@ there is no floating point number whose value is exactly 1/3
.
When a real number is to be converted to an integer, there is no "best" @@ -1311,15 +1389,19 @@ defines the following operations:
cl_I floor1 (const type& x)
floor(x)
.
cl_I ceiling1 (const type& x)
ceiling(x)
.
cl_I truncate1 (const type& x)
truncate(x)
.
cl_I round1 (const type& x)
round(x)
.
@@ -1408,12 +1490,16 @@ defines the following operations:
type_div_t floor2 (const type& x, const type& y)
type_div_t ceiling2 (const type& x, const type& y)
type_div_t truncate2 (const type& x, const type& y)
type_div_t round2 (const type& x, const type& y)
@@ -1432,12 +1518,16 @@ defines the following operations:
type ffloor (const type& x)
type fceiling (const type& x)
type ftruncate (const type& x)
type fround (const type& x)
@@ -1477,12 +1567,16 @@ defines the following operations:
type_fdiv_t ffloor2 (const type& x)
type_fdiv_t fceiling2 (const type& x)
type_fdiv_t ftruncate2 (const type& x)
type_fdiv_t fround2 (const type& x)
and similarly for class cl_R
, but with quotient type cl_F
.
@@ -1537,8 +1631,10 @@ The classes cl_R
, cl_I
define the following operations
type mod (const type& x, const type& y)
type rem (const type& x, const type& y)
type sqrt (const type& x)
x
must be >= 0. This function returns the square root of x
,
normalized to be >= 0. If x
is the square of a rational number,
sqrt(x)
will be a rational number, else it will return a
@@ -1569,6 +1666,7 @@ The classes cl_RA
, cl_I
define the following operation
cl_boolean sqrtp (const type& x, type* root)
x
is a perfect square. If so, it returns true
and the exact square root in *root
, else it returns false.
@@ -1581,6 +1679,7 @@ Furthermore, for integers, similarly:
cl_boolean isqrt (const type& x, type* root)
x
should be >= 0. This function sets *root
to
floor(sqrt(x))
and returns the same value as sqrtp
:
the boolean value (expt(*root,2) == x)
.
@@ -1595,6 +1694,7 @@ define the following operation:
cl_boolean rootp (const type& x, const cl_I& n, type* root)
x
must be >= 0. n
must be > 0.
This tests whether x
is an n
th power of a rational number.
If so, it returns true and the exact root in *root
, else it returns
@@ -1610,6 +1710,7 @@ for class cl_N
:
cl_N sqrt (const cl_N& z)
z
, as defined by the formula
sqrt(z) = exp(log(z)/2)
. Conversion to a floating-point type
or to a complex number are done if necessary. The range of the result is the
@@ -1622,6 +1723,9 @@ The result is an exact number only if z
is an exact number.
The transcendental functions return an exact result if the argument
@@ -1638,6 +1742,7 @@ For example, cos(0) = 1
returns the rational number 1
.
cl_R exp (const cl_R& x)
cl_N exp (const cl_N& x)
x
. This is e^x
where
@@ -1646,10 +1751,12 @@ is the entire complex plane excluding 0.
cl_R ln (const cl_R& x)
x
must be > 0. Returns the (natural) logarithm of x.
cl_N log (const cl_N& x)
x
is real and positive,
this is ln(x)
. In general, log(x) = log(abs(x)) + i*phase(x)
.
The range of the result is the strip in the complex plane
@@ -1657,6 +1764,7 @@ The range of the result is the strip in the complex plane
cl_R phase (const cl_N& x)
x
in its polar representation as a
complex number. That is, phase(x) = atan(realpart(x),imagpart(x))
.
This is also the imaginary part of log(x)
.
@@ -1678,6 +1786,7 @@ Returns the logarithm of a
with respect to base b
.
cl_N expt (const cl_N& x, const cl_N& y)
x^y = exp(y*log(x))
.
@@ -1689,6 +1798,7 @@ The constant e = exp(1) = 2.71828... is returned by the following functions:
cl_F cl_exp1 (cl_float_format_t f)
f
.
cl_F cl_exp1 (const cl_F& y)
@@ -1708,6 +1818,7 @@ Returns e as a float of format cl_default_float_format
.
cl_R sin (const cl_R& x)
sin(x)
. The range of the result is the interval
-1 <= sin(x) <= 1
.
@@ -1717,6 +1828,7 @@ Returns sin(z)
. The range of the result is the entire complex plane
cl_R cos (const cl_R& x)
cos(x)
. The range of the result is the interval
-1 <= cos(x) <= 1
.
@@ -1726,25 +1838,31 @@ Returns cos(z)
. The range of the result is the entire complex plane
struct cl_cos_sin_t { cl_R cos; cl_R sin; };
cl_cos_sin_t cl_cos_sin (const cl_R& x)
sin(x)
and cos(x)
. This is more efficient than
+
computing them separately. The relation cos^2 + sin^2 = 1
will
hold only approximately.
cl_R tan (const cl_R& x)
cl_N tan (const cl_N& x)
tan(x) = sin(x)/cos(x)
.
cl_N cis (const cl_R& x)
cl_N cis (const cl_N& x)
exp(i*x)
. The name `cis' means "cos + i sin", because
e^(i*x) = cos(x) + i*sin(x)
.
+
+
cl_N asin (const cl_N& z)
arcsin(z)
. This is defined as
@@ -1757,6 +1875,7 @@ with realpart = pi/2
and imagpart > 0
.
cl_N acos (const cl_N& z)
arccos(z)
. This is defined as
arccos(z) = pi/2 - arcsin(z) = log(z+i*sqrt(1-z^2))/i
and satisfies arccos(-z) = pi - arccos(z)
.
@@ -1765,6 +1884,8 @@ The range of the result is the strip in the complex domain
with realpart = 0
and imagpart < 0
and the numbers
with realpart = pi
and imagpart > 0
.
+
+
cl_R atan (const cl_R& x, const cl_R& y)
realpart = pi/2
and imagpart <= 0
.
-The constant pi = 3.14... is returned by the following functions: + + +Archimedes' constant pi = 3.14... is returned by the following functions:
cl_F cl_pi (cl_float_format_t f)
f
.
cl_F cl_pi (const cl_F& y)
@@ -1819,6 +1943,7 @@ Returns pi as a float of format cl_default_float_format
.
cl_R sinh (const cl_R& x)
sinh(x)
.
cl_N sinh (const cl_N& z)
@@ -1827,6 +1952,7 @@ Returns sinh(z)
. The range of the result is the entire complex plan
cl_R cosh (const cl_R& x)
cosh(x)
. The range of the result is the interval
cosh(x) >= 1
.
@@ -1836,20 +1962,24 @@ Returns cosh(z)
. The range of the result is the entire complex plan
struct cl_cosh_sinh_t { cl_R cosh; cl_R sinh; };
cl_cosh_sinh_t cl_cosh_sinh (const cl_R& x)
sinh(x)
and cosh(x)
. This is more efficient than
computing them separately. The relation cosh^2 - sinh^2 = 1
will
hold only approximately.
cl_R tanh (const cl_R& x)
cl_N tanh (const cl_N& x)
tanh(x) = sinh(x)/cosh(x)
.
cl_N asinh (const cl_N& z)
arsinh(z)
. This is defined as
arsinh(z) = log(z+sqrt(1+z^2))
and satisfies
arsinh(-z) = -arsinh(z)
.
@@ -1860,6 +1990,7 @@ with imagpart = pi/2
and realpart < 0
.
cl_N acosh (const cl_N& z)
arcosh(z)
. This is defined as
arcosh(z) = 2*log(sqrt((z+1)/2)+sqrt((z-1)/2))
.
The range of the result is the half-strip in the complex domain
@@ -1868,6 +1999,7 @@ excluding the numbers with realpart = 0
and -pi < imagpar
cl_N atanh (const cl_N& z)
-
+
Returns
artanh(z)
. This is defined as
artanh(z) = (log(1+z)-log(1-z)) / 2
and satisfies
artanh(-z) = -artanh(z)
. The range of the result is
@@ -1880,6 +2012,9 @@ with imagpart = pi/2
and realpart >= 0
.
4.8.4 Euler gamma
+
Euler's constant C = 0.577... is returned by the following functions:
@@ -1889,6 +2024,7 @@ Euler's constant C = 0.577... is returned by the following functions:
cl_F cl_eulerconst (cl_float_format_t f)
-
+
Returns Euler's constant as a float of format
f
.
cl_F cl_eulerconst (const cl_F& y)
@@ -1902,12 +2038,14 @@ Returns Euler's constant as a float of format cl_default_float_format
Catalan's constant G = 0.915... is returned by the following functions:
+
cl_F cl_catalanconst (cl_float_format_t f)
-
+
Returns Catalan's constant as a float of format
f
.
cl_F cl_catalanconst (const cl_F& y)
@@ -1922,6 +2060,9 @@ Returns Catalan's constant as a float of format cl_default_float_format4.8.5 Riemann zeta
+
Riemann's zeta function at an integral point s>1
is returned by the
@@ -1932,6 +2073,7 @@ following functions:
cl_F cl_zeta (int s, cl_float_format_t f)
-
+
Returns Riemann's zeta function at
s
as a float of format f
.
cl_F cl_zeta (int s, const cl_F& y)
@@ -1971,54 +2113,69 @@ on each of the bit positions in parallel.
cl_I lognot (const cl_I& x)
-
+
cl_I operator ~ (const cl_I& x)
-
+
Logical not, like
~x
in C. This is the same as -1-x
.
cl_I logand (const cl_I& x, const cl_I& y)
-
+
cl_I operator & (const cl_I& x, const cl_I& y)
-
+
Logical and, like
x & y
in C.
cl_I logior (const cl_I& x, const cl_I& y)
-
+
cl_I operator | (const cl_I& x, const cl_I& y)
-
+
Logical (inclusive) or, like
x | y
in C.
cl_I logxor (const cl_I& x, const cl_I& y)
-
+
cl_I operator ^ (const cl_I& x, const cl_I& y)
-
+
Exclusive or, like
x ^ y
in C.
cl_I logeqv (const cl_I& x, const cl_I& y)
-
+
Bitwise equivalence, like
~(x ^ y)
in C.
cl_I lognand (const cl_I& x, const cl_I& y)
-
+
Bitwise not and, like
~(x & y)
in C.
cl_I lognor (const cl_I& x, const cl_I& y)
-
+
Bitwise not or, like
~(x | y)
in C.
cl_I logandc1 (const cl_I& x, const cl_I& y)
-
+
Logical and, complementing the first argument, like
~x & y
in C.
cl_I logandc2 (const cl_I& x, const cl_I& y)
-
+
Logical and, complementing the second argument, like
x & ~y
in C.
cl_I logorc1 (const cl_I& x, const cl_I& y)
-
+
Logical or, complementing the first argument, like
~x | y
in C.
cl_I logorc2 (const cl_I& x, const cl_I& y)
-
+
Logical or, complementing the second argument, like
x | ~y
in C.
@@ -2028,6 +2185,7 @@ These operations are all available though the function
cl_I boole (cl_boole op, const cl_I& x, const cl_I& y)
-
+
where
@@ -2046,16 +2219,19 @@ Other functions that view integers as bit strings:
+
represents the bit interval containing the bits
The complete internal representation of a float is encoded in the type
+
+
+
+
+
+
+
@@ -2385,6 +2599,7 @@ The type
The modifying C/C++ operators
+
to the beginning of your source files, before the inclusion of any CLN
include files. This flag will enable the following operators:
@@ -2594,12 +2828,16 @@ For the classes
@@ -2616,14 +2854,19 @@ For the class
@@ -2635,6 +2878,7 @@ For the classes
All computations deal with the internal representations of the numbers.
@@ -2676,8 +2927,10 @@ Several external representations may denote the same number, for example,
Converting an internal to an external representation is called "printing",
+
converting an external to an internal representation is called "reading".
-In CLN, is it always true that conversion of an internal to an external
+
+In CLN, it is always true that conversion of an internal to an external
representation and then back to an internal representation will yield the
same internal representation. Symbolically:
The global variable
CLN implements modular integers, i.e. integers modulo a fixed integer N.
@@ -3212,9 +3471,11 @@ Modular integer rings are constructed using the function
CLN implements two symbolic (non-numeric) data types: strings and symbols.
@@ -3373,6 +3661,9 @@ CLN implements two symbolic (non-numeric) data types: strings and symbols.
The class
@@ -3397,6 +3688,7 @@ Strings are constructed through the following constructors:
Symbols are uniquified strings: all symbols with the same name are shared.
@@ -3453,6 +3752,7 @@ Symbols are constructed through the following constructor:
+
+
+
@@ -3586,6 +3891,7 @@ return the same polynomial ring.
Using C++ as an implementation language provides
@@ -3802,6 +4142,7 @@ Efficiency: It compiles to machine code.
All the number classes are reference count classes: They only contain a pointer
@@ -3937,6 +4284,9 @@ environment variables, or directly substitute the appropriate values.
Until you have installed CLN in a public place, the following options are
@@ -3973,6 +4323,10 @@ linking a CLN application it is sufficient to give the flag
Here is a summary of the include files and their contents.
@@ -4168,6 +4522,7 @@ Includes all of the above.
A function which computes the nth Fibonacci number can be written as follows.
+
@@ -4244,9 +4599,17 @@ automatically reclaimed (garbage collected). Only the result survives and
gets passed to the caller.
+
+The file
When debugging a CLN application with GNU
+
This function must not return control to its caller.
Floating point underflow denotes the situation when a floating-point number
@@ -4362,9 +4734,8 @@ cl_boolean cl_inhibit_floating_point_underflow
to
The output of the function
+
+
The
-This document was generated on 14 January 2000 using
+This document was generated on 4 May 2000 using
texi2html 1.56k.
op
must have one of the 16 values (each one stands for a function
@@ -2036,6 +2194,21 @@ which combines two bits into one bit): boole_clr
, boole_set
boole_and
, boole_ior
, boole_xor
, boole_eqv
,
boole_nand
, boole_nor
, boole_andc1
, boole_andc2
,
boole_orc1
, boole_orc2
.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
cl_boolean logtest (const cl_I& x, const cl_I& y)
x
and y
, i.e. if
logand(x,y) != 0
.
cl_boolean logbitp (const cl_I& n, const cl_I& x)
n
th bit (from the right) of x
is set.
Bit 0 is the least significant bit.
uintL logcount (const cl_I& x)
x
, if x
>= 0, or
the number of zero bits in x
, if x
< 0.
@@ -2069,6 +2245,7 @@ struct cl_byte { uintL size; uintL position; };
position
...position+size-1
of an integer.
The constructor cl_byte(size,position)
constructs a cl_byte
.
@@ -2078,16 +2255,19 @@ The constructor cl_byte(size,position)
constructs a cl_byte
cl_I ldb (const cl_I& n, const cl_byte& b)
n
described by the bit interval b
and returns them as a nonnegative integer with b.size
bits.
cl_boolean ldb_test (const cl_I& n, const cl_byte& b)
b
is set in
n
.
cl_I dpb (const cl_I& newbyte, const cl_I& n, const cl_byte& b)
n
, with the bits described by the bit interval b
replaced by newbyte
. Only the lowest b.size
bits of
newbyte
are relevant.
@@ -2102,11 +2282,13 @@ functions are their counterparts without shifting:
cl_I mask_field (const cl_I& n, const cl_byte& b)
b
copied from the corresponding bits in n
, the other bits zero.
cl_I deposit_field (const cl_I& newbyte, const cl_I& n, const cl_byte& b)
b
come from newbyte
and the other bits come from n
.
@@ -2137,33 +2319,39 @@ for common arithmetic operations:
cl_boolean oddp (const cl_I& x)
x
is 1. Equivalent to
mod(x,2) != 0
.
cl_boolean evenp (const cl_I& x)
x
is 0. Equivalent to
mod(x,2) == 0
.
cl_I operator << (const cl_I& x, const cl_I& n)
x
by n
bits to the left. n
should be >=0.
Equivalent to x * expt(2,n)
.
cl_I operator >> (const cl_I& x, const cl_I& n)
x
by n
bits to the right. n
should be >=0.
Bits shifted out to the right are thrown away.
Equivalent to floor(x / expt(2,n))
.
cl_I ash (const cl_I& x, const cl_I& y)
x
by y
bits to the left (if y
>=0) or
by -y
bits to the right (if y
<=0). In other words, this
returns floor(x * expt(2,y))
.
uintL integer_length (const cl_I& x)
x
in two's complement notation. This is the smallest n >= 0 such that
-2^n <= x < 2^n. If x > 0, this is the unique n > 0 such that
@@ -2171,12 +2359,14 @@ in two's complement notation. This is the smallest n >= 0 such that
uintL ord2 (const cl_I& x)
x
must be non-zero. This function returns the number of 0 bits at the
right of x
in two's complement notation. This is the largest n >= 0
such that 2^n divides x
.
uintL power2p (const cl_I& x)
x
must be > 0. This function checks whether x
is a power of 2.
If x
= 2^(n-1), it returns n. Else it returns 0.
(See also the function logp
.)
@@ -2190,6 +2380,7 @@ If x
= 2^(n-1), it returns n. Else it returns 0.
uint32 gcd (uint32 a, uint32 b)
cl_I gcd (const cl_I& a, const cl_I& b)
a
and b
,
@@ -2197,6 +2388,7 @@ normalized to be >= 0.
cl_I xgcd (const cl_I& a, const cl_I& b, cl_I* u, cl_I* v)
g
of
a
and b
and at the same time the representation of g
as an integral linear combination of a
and b
:
@@ -2208,11 +2400,13 @@ value, in the following sense: If a
and b
are non-zero
cl_I lcm (const cl_I& a, const cl_I& b)
a
and b
,
normalized to be >= 0.
cl_boolean logp (const cl_I& a, const cl_I& b, cl_RA* l)
cl_boolean logp (const cl_RA& a, const cl_RA& b, cl_RA* l)
a
must be > 0. b
must be >0 and != 1. If log(a,b) is
@@ -2228,17 +2422,20 @@ it returns false.
cl_I factorial (uintL n)
n
must be a small integer >= 0. This function returns the factorial
n
! = 1*2*...*n
.
cl_I doublefactorial (uintL n)
n
must be a small integer >= 0. This function returns the
doublefactorial n
!! = 1*3*...*n
or
n
!! = 2*4*...*n
, respectively.
cl_I binomial (uintL n, uintL k)
n
and k
must be small integers >= 0. This function returns the
binomial coefficient
(n
choose k
) = n
! / k
! (n-k)
!
@@ -2265,6 +2462,7 @@ defines the following operations.
type scale_float (const type& x, sintL delta)
type scale_float (const type& x, const cl_I& delta)
x*2^delta
. This is more efficient than an explicit multiplication
@@ -2280,27 +2478,32 @@ representation of floating-point numbers.
sintL float_exponent (const type& x)
e
of x
.
For x = 0.0
, this is 0. For x
non-zero, this is the unique
integer with 2^(e-1) <= abs(x) < 2^e
.
sintL float_radix (const type& x)
2
.
type float_sign (const type& x)
s
of x
as a float. The value is 1 for
x
>= 0, -1 for x
< 0.
uintL float_digits (const type& x)
x
, including the hidden bit. The value only depends on the type
of x
, not on its value.
uintL float_precision (const type& x)
x
. Since denormalized numbers are not supported,
this is the same as float_digits(x)
if x
is non-zero, and
@@ -2309,6 +2512,11 @@ this is the same as float_digits(x)
if x
is non-zero,
cl_decoded_float
(or cl_decoded_sfloat
, cl_decoded_ffloat
,
cl_decoded_dfloat
, cl_decoded_lfloat
, respectively), defined by
@@ -2326,6 +2534,7 @@ and returned by the function
cl_decoded_typefloat decode_float (const type& x)
x
non-zero, this returns (-1)^s
, e
, m
with
x = (-1)^s * 2^e * m
and 0.5 <= m < 1.0
. For x
= 0,
it returns (-1)^s
=1, e
=0, m
=0.
@@ -2336,7 +2545,7 @@ it returns (-1)^s
=1, e
=0, m
=0.
A complete decoding in terms of integers is provided as type
-struct cl_idecoded_float {
+struct cl_idecoded_float {
cl_I mantissa; cl_I exponent; cl_I sign;
};
@@ -2349,6 +2558,7 @@ by the following function:
cl_idecoded_float integer_decode_float (const type& x)
x
non-zero, this returns (-1)^s
, e
, m
with
x = (-1)^s * 2^e * m
and m
an integer with float_digits(x)
bits. For x
= 0, it returns (-1)^s
=1, e
=0, m
=0.
@@ -2364,6 +2574,7 @@ Some other function, implemented only for class cl_F
:
cl_F float_sign (const cl_F& x, const cl_F& y)
y
and whose sign is that of x
. If x
is
zero, it is treated as positive. Same for y
.
@@ -2372,6 +2583,9 @@ zero, it is treated as positive. Same for y
.
4.11 Conversion functions
+cl_float_format_t
describes a floating-point format.
cl_float_format_t cl_float_format (uintL n)
n
decimal digits in the mantissa (after the decimal point).
@@ -2394,6 +2609,7 @@ Returns the floating point format of x
.
cl_float_format_t cl_default_float_format
cl_F cl_float (const type&x, cl_float_format_t f)
x
as a float of format f
.
cl_F cl_float (const type&x, const cl_F& y)
cl_F most_positive_float (cl_float_format_t f)
f
.
cl_F most_negative_float (cl_float_format_t f)
f
.
cl_F least_positive_float (cl_float_format_t f)
f
.
cl_F least_negative_float (cl_float_format_t f)
f
.
cl_F float_epsilon (cl_float_format_t f)
1+e != 1
.
cl_F float_negative_epsilon (cl_float_format_t f)
1-e != 1
.
@@ -2469,6 +2692,7 @@ defines the following operation:
cl_RA rational (const type& x)
x
as an exact number. If x
is already
an exact number, this is x
. If x
is a floating-point number,
the value is a rational number whose denominator is a power of 2.
@@ -2483,6 +2707,7 @@ the function
cl_RA rationalize (const cl_R& x)
x
is a floating-point number, it actually represents an interval
of real numbers, and this function returns the rational number with
smallest denominator (and smallest numerator, in magnitude)
@@ -2524,6 +2749,7 @@ a complicated but deterministic way.
cl_random_state cl_default_random_state
@@ -2540,12 +2766,14 @@ below are called without
cl_random_state
argument.
uint32 random32 ()
cl_I random_I (cl_random_state& randomstate, const cl_I& n)
cl_I random_I (const cl_I& n)
n
must be an integer > 0. This function returns a random integer x
in the range 0 <= x < n
.
@@ -2553,6 +2781,7 @@ in the range 0 <= x < n
.
cl_F random_F (const cl_F& n)
n
must be a float > 0. This function returns a random floating-point
number of the same format as n
in the range 0 <= x < n
.
@@ -2560,6 +2789,7 @@ number of the same format as n
in the range 0 <= x <
cl_R random_R (const cl_R& n)
random_I
if n
is an integer and like random_F
if n
is a float.
@@ -2567,6 +2797,9 @@ if n
is a float.
4.13 Obfuscating operators
++=
, -=
, *=
, /=
,
@@ -2581,6 +2814,7 @@ to get happy, then add
cl_N
, cl_R
, cl_RA
,
type& operator += (type&, const type&)
type& operator -= (type&, const type&)
type& operator *= (type&, const type&)
type& operator /= (type&, const type&)
cl_I
:
type& operator &= (type&, const type&)
type& operator |= (type&, const type&)
type& operator ^= (type&, const type&)
type& operator <<= (type&, const type&)
type& operator >>= (type&, const type&)
cl_N
, cl_R
, cl_RA
,
type& operator ++ (type& x)
++x
.
void operator ++ (type& x, int)
@@ -2643,6 +2887,7 @@ The postfix operator x++
.
type& operator -- (type& x)
--x
.
void operator -- (type& x, int)
@@ -2659,10 +2904,16 @@ efficient.
5. Input/Output
+5.1 Internal and printed representation
+read(print(x)) == x
.
This is called "print-read consistency".
@@ -3058,7 +3311,7 @@ using this variable name. Default is "x"
.
cl_default_print_flags
contains the default values,
-used by the function fprint
,
+used by the function fprint
.
@@ -3163,10 +3416,16 @@ Tests whether the given number is an element of the number ring R.
7. Modular integers
+7.1 Modular integer rings
+cl_modint_ring cl_find_modint_ring (const cl_I& N)
N
, like powers of two
and odd numbers for which Montgomery multiplication will be a win,
+
and precomputes any necessary auxiliary data for computing modulo N
.
There is a cache table of rings, indexed by N
(or, more precisely,
by abs(N)
). This ensures that the precomputation costs are reduced
@@ -3229,8 +3490,10 @@ Modular integer rings can be compared for equality:
bool operator== (const cl_modint_ring&, const cl_modint_ring&)
bool operator!= (const cl_modint_ring&, const cl_modint_ring&)
cl_find_modint_ring
with the same argument necessarily return the
same ring because it is memoized in the cache table.
@@ -3248,22 +3511,27 @@ Given a modular integer ring R
, the following members can be used.
cl_I R->modulus
abs(N)
.
cl_MI R->zero()
0 mod N
.
cl_MI R->one()
1 mod N
.
cl_MI R->canonhom (const cl_I& x)
x mod N
.
cl_I R->retract (const cl_MI& x)
R->canonhom
. It returns the
standard representative (>=0
, <N
) of x
.
@@ -3271,6 +3539,7 @@ standard representative (>=0
, <N
) of x
cl_MI R->random()
N
.
@@ -3282,15 +3551,18 @@ The following operations are defined on modular integers.
cl_modint_ring x.ring ()
x
belongs.
cl_MI operator+ (const cl_MI&, const cl_MI&)
cl_MI operator- (const cl_MI&, const cl_MI&)
cl_MI operator* (const cl_MI&, const cl_MI&)
cl_MI square (const cl_MI&)
cl_MI recip (const cl_MI& x)
x^-1
of a modular integer x
. x
must be coprime to the modulus, otherwise an error message is issued.
cl_MI div (const cl_MI& x, const cl_MI& y)
x*y^-1
of two modular integers x
, y
.
y
must be coprime to the modulus, otherwise an error message is issued.
cl_MI expt_pos (const cl_MI& x, const cl_I& y)
y
must be > 0. Returns x^y
.
cl_MI expt (const cl_MI& x, const cl_I& y)
x^y
. If y
is negative, x
must be coprime to the
modulus, else an error message is issued.
cl_MI operator<< (const cl_MI& x, const cl_I& y)
x*2^y
.
cl_MI operator>> (const cl_MI& x, const cl_I& y)
x*2^-y
. When y
is positive, the modulus must be odd,
or an error message is issued.
bool operator== (const cl_MI&, const cl_MI&)
bool operator!= (const cl_MI&, const cl_MI&)
cl_boolean zerop (const cl_MI& x)
x
is 0 mod N
.
@@ -3356,8 +3639,10 @@ input/output).
void fprint (cl_ostream stream, const cl_MI& x)
cl_ostream operator<< (cl_ostream stream, const cl_MI& x)
x
on the stream
. The output may depend
on the global printer settings in the variable cl_default_print_flags
.
@@ -3365,6 +3650,9 @@ on the global printer settings in the variable cl_default_print_flags8. Symbolic data types
+
8.1 Strings
+cl_string (const char * s)
s
.
cl_string (const char * ptr, unsigned long len)
@@ -3417,17 +3709,21 @@ Assignment from cl_string
and const char *
.
s.length()
strlen(s)
s
.
s[i]
i
th character of the string s
.
i
must be in the range 0 <= i < s.length()
.
bool equal (const cl_string& s1, const cl_string& s2)
const char *
.
@@ -3435,6 +3731,9 @@ plain const char *
.
8.2 Symbols
+cl_symbol (const cl_string& s)
cl_string
: Returns the string which names the symbol
bool equal (const cl_symbol& sym1, const cl_symbol& sym2)
9. Univariate polynomials
+cl_univpoly_complex_ring cl_find_univpoly_ring (const cl_complex_ring& R)
cl_univpoly_complex_ring cl_find_univpoly_ring (const cl_complex_ring& R, const cl_symbol& varname)
cl_univpoly_real_ring cl_find_univpoly_ring (const cl_real_ring& R)
@@ -3620,27 +3926,33 @@ Given a univariate polynomial ring R
, the following members can be
cl_ring R->basering()
cl_UP R->zero()
0 in R
, a polynomial of degree -1.
cl_UP R->one()
1 in R
, a polynomial of degree <= 0.
cl_UP R->canonhom (const cl_I& x)
x in R
, a polynomial of degree <= 0.
cl_UP R->monomial (const cl_ring_element& x, uintL e)
x * X^e
, where X
is the
indeterminate.
cl_UP R->create (sintL degree)
-1
. After creating the polynomial, you should put in the coefficients,
using the set_coeff
member function, and then call the finalize
@@ -3655,12 +3967,14 @@ The following are the only destructive operations on univariate polynomials.
void set_coeff (cl_UP& x, uintL index, const cl_ring_element& y)
X^index
in x
to be y
.
After changing a polynomial and before applying any "normal" operation on it,
you should call its finalize
member function.
void finalize (cl_UP& x)
cl_univpoly_ring x.ring ()
x
belongs.
cl_UP operator+ (const cl_UP&, const cl_UP&)
cl_UP operator- (const cl_UP&, const cl_UP&)
cl_UP operator- (const cl_UP&)
@@ -3691,44 +4008,54 @@ Returns the negative of a univariate polynomial.
cl_UP operator* (const cl_UP&, const cl_UP&)
cl_UP square (const cl_UP&)
cl_UP expt_pos (const cl_UP& x, const cl_I& y)
y
must be > 0. Returns x^y
.
bool operator== (const cl_UP&, const cl_UP&)
bool operator!= (const cl_UP&, const cl_UP&)
cl_boolean zerop (const cl_UP& x)
x
is 0 in R
.
sintL degree (const cl_UP& x)
-1
.
cl_ring_element coeff (const cl_UP& x, uintL index)
X^index
in the polynomial x
.
cl_ring_element x (const cl_ring_element& y)
x
is a polynomial and y
belongs to the base ring,
then `x(y)' returns the value of the substitution of y
into
x
.
cl_UP deriv (const cl_UP& x)
x
with respect to the
indeterminate X
.
@@ -3742,8 +4069,10 @@ input/output).
void fprint (cl_ostream stream, const cl_UP& x)
cl_ostream operator<< (cl_ostream stream, const cl_UP& x)
x
on the stream
. The output may
depend on the global printer settings in the variable
cl_default_print_flags
.
@@ -3761,18 +4090,26 @@ The following functions return special polynomials.
cl_UP_I cl_tschebychev (sintL n)
cl_UP_I cl_hermite (sintL n)
cl_UP_RA cl_legendre (sintL n)
cl_UP_I cl_laguerre (sintL n)
10.1 Why C++ ?
+operation+ (const cl_MI&, const cl_MI&)
requires that both
+like that operator+ (const cl_MI&, const cl_MI&)
requires that both
arguments belong to the same modular ring cannot be expressed as a compile-time
information.
@@ -3847,6 +4188,8 @@ Object sharing: An operation like x+0
returns x
withou
it.
i386
, m68k
, sparc
, mips
, arm
).
O(N^2)
@@ -3891,6 +4234,7 @@ algorithm.
For very large numbers (more than 12000 decimal digits), CLN uses
Schönhage-Strassen
+
multiplication, which is an asymptotically
optimal multiplication algorithm.
10.4 Garbage collection
+11.1 Compiler options
+-lcln
.
11.2 Include files
+fibonacci.cc
in the subdirectory examples
+contains this implementation together with an even faster algorithm.
+
+
11.4 Debugging support
+gdb
, two facilities are
@@ -4279,6 +4642,7 @@ CLN offers a function cl_print
, callable from the debugger,
for printing number objects. In order to get this function, you have
to define the macro `CL_DEBUG' and then include all the header files
for which you want cl_print
debugging support. For example:
+
#define CL_DEBUG
@@ -4305,6 +4669,7 @@ only with number objects and similar. Therefore CLN offers a member function
debug_print()
on all CLN types. The same macro `CL_DEBUG'
is needed for this member function to be implemented. Under gdb
,
you call it like this:
+
(gdb) print s
@@ -4325,6 +4690,9 @@ Unfortunately, this feature does not seem to work under all circumstances.
12. Customizing
+12.2 Floating-point underflow
+cl_true
, the error will be inhibited, and a floating-point zero
-will be generated instead.
-The default value of cl_inhibit_floating_point_underflow
is
-cl_false
.
+will be generated instead. The default value of
+cl_inhibit_floating_point_underflow
is cl_false
.
@@ -4374,6 +4745,7 @@ The default value of cl_inhibit_floating_point_underflow
is
fprint
may be customized by changing the
value of the global variable cl_default_print_flags
.
+
@@ -4397,6 +4769,8 @@ void (*cl_free_hook) (void* ptr) = ...;
cl_malloc_hook
function must not return a NULL
pointer.
@@ -4416,7 +4790,7 @@ Jump to: