You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3676 lines
135 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
  1. This is Info file cln.info, produced by Makeinfo version 1.68 from the
  2. input file cln.texi.
  3. This file documents CLN, a Class Library for Numbers.
  4. Published by Bruno Haible, `<haible@clisp.cons.org>' and Richard
  5. Kreckel, `<kreckel@ginac.de>'.
  6. Copyright (C) Bruno Haible 1995, 1996, 1997, 1998, 1999, 2000.
  7. Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice are
  9. preserved on all copies.
  10. Permission is granted to copy and distribute modified versions of this
  11. manual under the conditions for verbatim copying, provided that the
  12. entire resulting derived work is distributed under the terms of a
  13. permission notice identical to this one.
  14. Permission is granted to copy and distribute translations of this manual
  15. into another language, under the above conditions for modified versions,
  16. except that this permission notice may be stated in a translation
  17. approved by the author.
  18. 
  19. File: cln.info, Node: Top, Next: Introduction, Prev: (dir), Up: (dir)
  20. * Menu:
  21. * Introduction::
  22. * Installation::
  23. * Ordinary number types::
  24. * Functions on numbers::
  25. * Input/Output::
  26. * Rings::
  27. * Modular integers::
  28. * Symbolic data types::
  29. * Univariate polynomials::
  30. * Internals::
  31. * Using the library::
  32. * Customizing::
  33. * Index::
  34. -- The Detailed Node Listing --
  35. Installation
  36. * Prerequisites::
  37. * Building the library::
  38. * Installing the library::
  39. * Cleaning up::
  40. Prerequisites
  41. * C++ compiler::
  42. * Make utility::
  43. * Sed utility::
  44. Ordinary number types
  45. * Exact numbers::
  46. * Floating-point numbers::
  47. * Complex numbers::
  48. * Conversions::
  49. Functions on numbers
  50. * Constructing numbers::
  51. * Elementary functions::
  52. * Elementary rational functions::
  53. * Elementary complex functions::
  54. * Comparisons::
  55. * Rounding functions::
  56. * Roots::
  57. * Transcendental functions::
  58. * Functions on integers::
  59. * Functions on floating-point numbers::
  60. * Conversion functions::
  61. * Random number generators::
  62. * Obfuscating operators::
  63. Constructing numbers
  64. * Constructing integers::
  65. * Constructing rational numbers::
  66. * Constructing floating-point numbers::
  67. * Constructing complex numbers::
  68. Transcendental functions
  69. * Exponential and logarithmic functions::
  70. * Trigonometric functions::
  71. * Hyperbolic functions::
  72. * Euler gamma::
  73. * Riemann zeta::
  74. Functions on integers
  75. * Logical functions::
  76. * Number theoretic functions::
  77. * Combinatorial functions::
  78. Conversion functions
  79. * Conversion to floating-point numbers::
  80. * Conversion to rational numbers::
  81. Input/Output
  82. * Internal and printed representation::
  83. * Input functions::
  84. * Output functions::
  85. Modular integers
  86. * Modular integer rings::
  87. * Functions on modular integers::
  88. Symbolic data types
  89. * Strings::
  90. * Symbols::
  91. Univariate polynomials
  92. * Univariate polynomial rings::
  93. * Functions on univariate polynomials::
  94. * Special polynomials::
  95. Internals
  96. * Why C++ ?::
  97. * Memory efficiency::
  98. * Speed efficiency::
  99. * Garbage collection::
  100. Using the library
  101. * Compiler options::
  102. * Include files::
  103. * An Example::
  104. * Debugging support::
  105. Customizing
  106. * Error handling::
  107. * Floating-point underflow::
  108. * Customizing I/O::
  109. * Customizing the memory allocator::
  110. 
  111. File: cln.info, Node: Introduction, Next: Installation, Prev: Top, Up: Top
  112. Introduction
  113. ************
  114. CLN is a library for computations with all kinds of numbers. It has a
  115. rich set of number classes:
  116. * Integers (with unlimited precision),
  117. * Rational numbers,
  118. * Floating-point numbers:
  119. - Short float,
  120. - Single float,
  121. - Double float,
  122. - Long float (with unlimited precision),
  123. * Complex numbers,
  124. * Modular integers (integers modulo a fixed integer),
  125. * Univariate polynomials.
  126. The subtypes of the complex numbers among these are exactly the types
  127. of numbers known to the Common Lisp language. Therefore `CLN' can be
  128. used for Common Lisp implementations, giving `CLN' another meaning: it
  129. becomes an abbreviation of "Common Lisp Numbers".
  130. The CLN package implements
  131. * Elementary functions (`+', `-', `*', `/', `sqrt', comparisons,
  132. ...),
  133. * Logical functions (logical `and', `or', `not', ...),
  134. * Transcendental functions (exponential, logarithmic, trigonometric,
  135. hyperbolic functions and their inverse functions).
  136. CLN is a C++ library. Using C++ as an implementation language provides
  137. * efficiency: it compiles to machine code,
  138. * type safety: the C++ compiler knows about the number types and
  139. complains if, for example, you try to assign a float to an integer
  140. variable.
  141. * algebraic syntax: You can use the `+', `-', `*', `=', `==', ...
  142. operators as in C or C++.
  143. CLN is memory efficient:
  144. * Small integers and short floats are immediate, not heap allocated.
  145. * Heap-allocated memory is reclaimed through an automatic,
  146. non-interruptive garbage collection.
  147. CLN is speed efficient:
  148. * The kernel of CLN has been written in assembly language for some
  149. CPUs (`i386', `m68k', `sparc', `mips', `arm').
  150. * On all CPUs, CLN may be configured to use the superefficient
  151. low-level routines from GNU GMP version 3.
  152. * It uses Karatsuba multiplication, which is significantly faster
  153. for large numbers than the standard multiplication algorithm.
  154. * For very large numbers (more than 12000 decimal digits), it uses
  155. Sch�nhage-Strassen multiplication, which is an asymptotically
  156. optimal multiplication algorithm, for multiplication, division and
  157. radix conversion.
  158. CLN aims at being easily integrated into larger software packages:
  159. * The garbage collection imposes no burden on the main application.
  160. * The library provides hooks for memory allocation and exceptions.
  161. 
  162. File: cln.info, Node: Installation, Next: Ordinary number types, Prev: Introduction, Up: Top
  163. Installation
  164. ************
  165. This section describes how to install the CLN package on your system.
  166. * Menu:
  167. * Prerequisites::
  168. * Building the library::
  169. * Installing the library::
  170. * Cleaning up::
  171. 
  172. File: cln.info, Node: Prerequisites, Next: Building the library, Prev: Installation, Up: Installation
  173. Prerequisites
  174. =============
  175. * Menu:
  176. * C++ compiler::
  177. * Make utility::
  178. * Sed utility::
  179. 
  180. File: cln.info, Node: C++ compiler, Next: Make utility, Prev: Prerequisites, Up: Prerequisites
  181. C++ compiler
  182. ------------
  183. To build CLN, you need a C++ compiler. Actually, you need GNU `g++
  184. 2.7.0' or newer. On HPPA, you need GNU `g++ 2.8.0' or newer. I
  185. recommend GNU `g++ 2.95' or newer.
  186. The following C++ features are used: classes, member functions,
  187. overloading of functions and operators, constructors and destructors,
  188. inline, const, multiple inheritance, templates.
  189. The following C++ features are not used: `new', `delete', virtual
  190. inheritance, exceptions.
  191. CLN relies on semi-automatic ordering of initializations of static and
  192. global variables, a feature which I could implement for GNU g++ only.
  193. 
  194. File: cln.info, Node: Make utility, Next: Sed utility, Prev: C++ compiler, Up: Prerequisites
  195. Make utility
  196. ------------
  197. To build CLN, you also need to have GNU `make' installed.
  198. 
  199. File: cln.info, Node: Sed utility, Prev: Make utility, Up: Prerequisites
  200. Sed utility
  201. -----------
  202. To build CLN on HP-UX, you also need to have GNU `sed' installed. This
  203. is because the libtool script, which creates the CLN library, relies on
  204. `sed', and the vendor's `sed' utility on these systems is too limited.
  205. 
  206. File: cln.info, Node: Building the library, Next: Installing the library, Prev: Prerequisites, Up: Installation
  207. Building the library
  208. ====================
  209. As with any autoconfiguring GNU software, installation is as easy as
  210. this:
  211. $ ./configure
  212. $ make
  213. $ make check
  214. If on your system, `make' is not GNU `make', you have to use `gmake'
  215. instead of `make' above.
  216. The `configure' command checks out some features of your system and C++
  217. compiler and builds the `Makefile's. The `make' command builds the
  218. library. This step may take 4 hours on an average workstation. The
  219. `make check' runs some test to check that no important subroutine has
  220. been miscompiled.
  221. The `configure' command accepts options. To get a summary of them, try
  222. $ ./configure --help
  223. Some of the options are explained in detail in the `INSTALL.generic'
  224. file.
  225. You can specify the C compiler, the C++ compiler and their options
  226. through the following environment variables when running `configure':
  227. `CC'
  228. Specifies the C compiler.
  229. `CFLAGS'
  230. Flags to be given to the C compiler when compiling programs (not
  231. when linking).
  232. `CXX'
  233. Specifies the C++ compiler.
  234. `CXXFLAGS'
  235. Flags to be given to the C++ compiler when compiling programs (not
  236. when linking).
  237. Examples:
  238. $ CC="gcc" CFLAGS="-O" CXX="g++" CXXFLAGS="-O" ./configure
  239. $ CC="gcc -V 2.7.2" CFLAGS="-O -g" \
  240. CXX="g++ -V 2.7.2" CXXFLAGS="-O -g" ./configure
  241. $ CC="gcc -V 2.8.1" CFLAGS="-O -fno-exceptions" \
  242. CXX="g++ -V 2.8.1" CXXFLAGS="-O -fno-exceptions" ./configure
  243. $ CC="gcc -V egcs-2.91.60" CFLAGS="-O2 -fno-exceptions" \
  244. CXX="g++ -V egcs-2.91.60" CFLAGS="-O2 -fno-exceptions" ./configure
  245. Note that for these environment variables to take effect, you have to
  246. set them (assuming a Bourne-compatible shell) on the same line as the
  247. `configure' command. If you made the settings in earlier shell
  248. commands, you have to `export' the environment variables before calling
  249. `configure'. In a `csh' shell, you have to use the `setenv' command for
  250. setting each of the environment variables.
  251. On Linux, `g++' needs 15 MB to compile the tests. So you should better
  252. have 17 MB swap space and 1 MB room in $TMPDIR.
  253. If you use `g++' version 2.7.x, don't add `-O2' to the CXXFLAGS,
  254. because `g++ -O' generates better code for CLN than `g++ -O2'.
  255. If you use `g++' version 2.8.x or egcs-2.91.x (a.k.a. egcs-1.1) or
  256. gcc-2.95.x, I recommend adding `-fno-exceptions' to the CXXFLAGS. This
  257. will likely generate better code.
  258. If you use `g++' version egcs-2.91.x (egcs-1.1) or gcc-2.95.x on Sparc,
  259. add either `-O' or `-O2 -fno-schedule-insns' to the CXXFLAGS. With
  260. full `-O2', `g++' miscompiles the division routines. Also, for
  261. -enable-shared to work, you need egcs-1.1.2 or newer.
  262. By default, only a static library is built. You can build CLN as a
  263. shared library too, by calling `configure' with the option
  264. `--enable-shared'. To get it built as a shared library only, call
  265. `configure' with the options `--enable-shared --disable-static'.
  266. If you use `g++' version egcs-2.91.x (egcs-1.1) on Sparc, you cannot
  267. use `--enable-shared' because `g++' would miscompile parts of the
  268. library.
  269. 
  270. File: cln.info, Node: Installing the library, Next: Cleaning up, Prev: Building the library, Up: Installation
  271. Installing the library
  272. ======================
  273. As with any autoconfiguring GNU software, installation is as easy as
  274. this:
  275. $ make install
  276. The `make install' command installs the library and the include files
  277. into public places (`/usr/local/lib/' and `/usr/local/include/', if you
  278. haven't specified a `--prefix' option to `configure'). This step may
  279. require superuser privileges.
  280. If you have already built the library and wish to install it, but didn't
  281. specify `--prefix=...' at configure time, just re-run `configure',
  282. giving it the same options as the first time, plus the `--prefix=...'
  283. option.
  284. 
  285. File: cln.info, Node: Cleaning up, Prev: Installing the library, Up: Installation
  286. Cleaning up
  287. ===========
  288. You can remove system-dependent files generated by `make' through
  289. $ make clean
  290. You can remove all files generated by `make', thus reverting to a
  291. virgin distribution of CLN, through
  292. $ make distclean
  293. 
  294. File: cln.info, Node: Ordinary number types, Next: Functions on numbers, Prev: Installation, Up: Top
  295. Ordinary number types
  296. *********************
  297. CLN implements the following class hierarchy:
  298. Number
  299. cl_number
  300. <cl_number.h>
  301. |
  302. |
  303. Real or complex number
  304. cl_N
  305. <cl_complex.h>
  306. |
  307. |
  308. Real number
  309. cl_R
  310. <cl_real.h>
  311. |
  312. +-------------------+-------------------+
  313. | |
  314. Rational number Floating-point number
  315. cl_RA cl_F
  316. <cl_rational.h> <cl_float.h>
  317. | |
  318. | +-------------+-------------+-------------+
  319. Integer | | | |
  320. cl_I Short-Float Single-Float Double-Float Long-Float
  321. <cl_integer.h> cl_SF cl_FF cl_DF cl_LF
  322. <cl_sfloat.h> <cl_ffloat.h> <cl_dfloat.h> <cl_lfloat.h>
  323. The base class `cl_number' is an abstract base class. It is not useful
  324. to declare a variable of this type except if you want to completely
  325. disable compile-time type checking and use run-time type checking
  326. instead.
  327. The class `cl_N' comprises real and complex numbers. There is no
  328. special class for complex numbers since complex numbers with imaginary
  329. part `0' are automatically converted to real numbers.
  330. The class `cl_R' comprises real numbers of different kinds. It is an
  331. abstract class.
  332. The class `cl_RA' comprises exact real numbers: rational numbers,
  333. including integers. There is no special class for non-integral rational
  334. numbers since rational numbers with denominator `1' are automatically
  335. converted to integers.
  336. The class `cl_F' implements floating-point approximations to real
  337. numbers. It is an abstract class.
  338. * Menu:
  339. * Exact numbers::
  340. * Floating-point numbers::
  341. * Complex numbers::
  342. * Conversions::
  343. 
  344. File: cln.info, Node: Exact numbers, Next: Floating-point numbers, Prev: Ordinary number types, Up: Ordinary number types
  345. Exact numbers
  346. =============
  347. Some numbers are represented as exact numbers: there is no loss of
  348. information when such a number is converted from its mathematical value
  349. to its internal representation. On exact numbers, the elementary
  350. operations (`+', `-', `*', `/', comparisons, ...) compute the completely
  351. correct result.
  352. In CLN, the exact numbers are:
  353. * rational numbers (including integers),
  354. * complex numbers whose real and imaginary parts are both rational
  355. numbers.
  356. Rational numbers are always normalized to the form
  357. `NUMERATOR/DENOMINATOR' where the numerator and denominator are coprime
  358. integers and the denominator is positive. If the resulting denominator
  359. is `1', the rational number is converted to an integer.
  360. Small integers (typically in the range `-2^30'...`2^30-1', for 32-bit
  361. machines) are especially efficient, because they consume no heap
  362. allocation. Otherwise the distinction between these immediate integers
  363. (called "fixnums") and heap allocated integers (called "bignums") is
  364. completely transparent.
  365. 
  366. File: cln.info, Node: Floating-point numbers, Next: Complex numbers, Prev: Exact numbers, Up: Ordinary number types
  367. Floating-point numbers
  368. ======================
  369. Not all real numbers can be represented exactly. (There is an easy
  370. mathematical proof for this: Only a countable set of numbers can be
  371. stored exactly in a computer, even if one assumes that it has unlimited
  372. storage. But there are uncountably many real numbers.) So some
  373. approximation is needed. CLN implements ordinary floating-point
  374. numbers, with mantissa and exponent.
  375. The elementary operations (`+', `-', `*', `/', ...) only return
  376. approximate results. For example, the value of the expression `(cl_F)
  377. 0.3 + (cl_F) 0.4' prints as `0.70000005', not as `0.7'. Rounding errors
  378. like this one are inevitable when computing with floating-point numbers.
  379. Nevertheless, CLN rounds the floating-point results of the operations
  380. `+', `-', `*', `/', `sqrt' according to the "round-to-even" rule: It
  381. first computes the exact mathematical result and then returns the
  382. floating-point number which is nearest to this. If two floating-point
  383. numbers are equally distant from the ideal result, the one with a `0'
  384. in its least significant mantissa bit is chosen.
  385. Similarly, testing floating point numbers for equality `x == y' is
  386. gambling with random errors. Better check for `abs(x - y) < epsilon'
  387. for some well-chosen `epsilon'.
  388. Floating point numbers come in four flavors:
  389. * Short floats, type `cl_SF'. They have 1 sign bit, 8 exponent bits
  390. (including the exponent's sign), and 17 mantissa bits (including
  391. the "hidden" bit). They don't consume heap allocation.
  392. * Single floats, type `cl_FF'. They have 1 sign bit, 8 exponent
  393. bits (including the exponent's sign), and 24 mantissa bits
  394. (including the "hidden" bit). In CLN, they are represented as
  395. IEEE single-precision floating point numbers. This corresponds
  396. closely to the C/C++ type `float'.
  397. * Double floats, type `cl_DF'. They have 1 sign bit, 11 exponent
  398. bits (including the exponent's sign), and 53 mantissa bits
  399. (including the "hidden" bit). In CLN, they are represented as
  400. IEEE double-precision floating point numbers. This corresponds
  401. closely to the C/C++ type `double'.
  402. * Long floats, type `cl_LF'. They have 1 sign bit, 32 exponent bits
  403. (including the exponent's sign), and n mantissa bits (including
  404. the "hidden" bit), where n >= 64. The precision of a long float
  405. is unlimited, but once created, a long float has a fixed
  406. precision. (No "lazy recomputation".)
  407. Of course, computations with long floats are more expensive than those
  408. with smaller floating-point formats.
  409. CLN does not implement features like NaNs, denormalized numbers and
  410. gradual underflow. If the exponent range of some floating-point type is
  411. too limited for your application, choose another floating-point type
  412. with larger exponent range.
  413. As a user of CLN, you can forget about the differences between the four
  414. floating-point types and just declare all your floating-point variables
  415. as being of type `cl_F'. This has the advantage that when you change
  416. the precision of some computation (say, from `cl_DF' to `cl_LF'), you
  417. don't have to change the code, only the precision of the initial
  418. values. Also, many transcendental functions have been declared as
  419. returning a `cl_F' when the argument is a `cl_F', but such declarations
  420. are missing for the types `cl_SF', `cl_FF', `cl_DF', `cl_LF'. (Such
  421. declarations would be wrong if the floating point contagion rule
  422. happened to change in the future.)
  423. 
  424. File: cln.info, Node: Complex numbers, Next: Conversions, Prev: Floating-point numbers, Up: Ordinary number types
  425. Complex numbers
  426. ===============
  427. Complex numbers, as implemented by the class `cl_N', have a real part
  428. and an imaginary part, both real numbers. A complex number whose
  429. imaginary part is the exact number `0' is automatically converted to a
  430. real number.
  431. Complex numbers can arise from real numbers alone, for example through
  432. application of `sqrt' or transcendental functions.
  433. 
  434. File: cln.info, Node: Conversions, Prev: Complex numbers, Up: Ordinary number types
  435. Conversions
  436. ===========
  437. Conversions from any class to any its superclasses ("base classes" in
  438. C++ terminology) is done automatically.
  439. Conversions from the C built-in types `long' and `unsigned long' are
  440. provided for the classes `cl_I', `cl_RA', `cl_R', `cl_N' and
  441. `cl_number'.
  442. Conversions from the C built-in types `int' and `unsigned int' are
  443. provided for the classes `cl_I', `cl_RA', `cl_R', `cl_N' and
  444. `cl_number'. However, these conversions emphasize efficiency. Their
  445. range is therefore limited:
  446. - The conversion from `int' works only if the argument is < 2^29 and
  447. > -2^29.
  448. - The conversion from `unsigned int' works only if the argument is <
  449. 2^29.
  450. In a declaration like `cl_I x = 10;' the C++ compiler is able to do the
  451. conversion of `10' from `int' to `cl_I' at compile time already. On the
  452. other hand, code like `cl_I x = 1000000000;' is in error. So, if you
  453. want to be sure that an `int' whose magnitude is not guaranteed to be <
  454. 2^29 is correctly converted to a `cl_I', first convert it to a `long'.
  455. Similarly, if a large `unsigned int' is to be converted to a `cl_I',
  456. first convert it to an `unsigned long'.
  457. Conversions from the C built-in type `float' are provided for the
  458. classes `cl_FF', `cl_F', `cl_R', `cl_N' and `cl_number'.
  459. Conversions from the C built-in type `double' are provided for the
  460. classes `cl_DF', `cl_F', `cl_R', `cl_N' and `cl_number'.
  461. Conversions from `const char *' are provided for the classes `cl_I',
  462. `cl_RA', `cl_SF', `cl_FF', `cl_DF', `cl_LF', `cl_F', `cl_R', `cl_N'.
  463. The easiest way to specify a value which is outside of the range of the
  464. C++ built-in types is therefore to specify it as a string, like this:
  465. cl_I order_of_rubiks_cube_group = "43252003274489856000";
  466. Note that this conversion is done at runtime, not at compile-time.
  467. Conversions from `cl_I' to the C built-in types `int', `unsigned int',
  468. `long', `unsigned long' are provided through the functions
  469. `int cl_I_to_int (const cl_I& x)'
  470. `unsigned int cl_I_to_uint (const cl_I& x)'
  471. `long cl_I_to_long (const cl_I& x)'
  472. `unsigned long cl_I_to_ulong (const cl_I& x)'
  473. Returns `x' as element of the C type CTYPE. If `x' is not
  474. representable in the range of CTYPE, a runtime error occurs.
  475. Conversions from the classes `cl_I', `cl_RA', `cl_SF', `cl_FF',
  476. `cl_DF', `cl_LF', `cl_F' and `cl_R' to the C built-in types `float' and
  477. `double' are provided through the functions
  478. `float cl_float_approx (const TYPE& x)'
  479. `double cl_double_approx (const TYPE& x)'
  480. Returns an approximation of `x' of C type CTYPE. If `abs(x)' is
  481. too close to 0 (underflow), 0 is returned. If `abs(x)' is too
  482. large (overflow), an IEEE infinity is returned.
  483. Conversions from any class to any of its subclasses ("derived classes"
  484. in C++ terminology) are not provided. Instead, you can assert and check
  485. that a value belongs to a certain subclass, and return it as element of
  486. that class, using the `As' and `The' macros. `As(TYPE)(VALUE)' checks
  487. that VALUE belongs to TYPE and returns it as such. `The(TYPE)(VALUE)'
  488. assumes that VALUE belongs to TYPE and returns it as such. It is your
  489. responsibility to ensure that this assumption is valid. Example:
  490. cl_I x = ...;
  491. if (!(x >= 0)) abort();
  492. cl_I ten_x = The(cl_I)(expt(10,x)); // If x >= 0, 10^x is an integer.
  493. // In general, it would be a rational number.
  494. 
  495. File: cln.info, Node: Functions on numbers, Next: Input/Output, Prev: Ordinary number types, Up: Top
  496. Functions on numbers
  497. ********************
  498. Each of the number classes declares its mathematical operations in the
  499. corresponding include file. For example, if your code operates with
  500. objects of type `cl_I', it should `#include <cl_integer.h>'.
  501. * Menu:
  502. * Constructing numbers::
  503. * Elementary functions::
  504. * Elementary rational functions::
  505. * Elementary complex functions::
  506. * Comparisons::
  507. * Rounding functions::
  508. * Roots::
  509. * Transcendental functions::
  510. * Functions on integers::
  511. * Functions on floating-point numbers::
  512. * Conversion functions::
  513. * Random number generators::
  514. * Obfuscating operators::
  515. 
  516. File: cln.info, Node: Constructing numbers, Next: Elementary functions, Prev: Functions on numbers, Up: Functions on numbers
  517. Constructing numbers
  518. ====================
  519. Here is how to create number objects "from nothing".
  520. * Menu:
  521. * Constructing integers::
  522. * Constructing rational numbers::
  523. * Constructing floating-point numbers::
  524. * Constructing complex numbers::
  525. 
  526. File: cln.info, Node: Constructing integers, Next: Constructing rational numbers, Prev: Constructing numbers, Up: Constructing numbers
  527. Constructing integers
  528. ---------------------
  529. `cl_I' objects are most easily constructed from C integers and from
  530. strings. See *Note Conversions::.
  531. 
  532. File: cln.info, Node: Constructing rational numbers, Next: Constructing floating-point numbers, Prev: Constructing integers, Up: Constructing numbers
  533. Constructing rational numbers
  534. -----------------------------
  535. `cl_RA' objects can be constructed from strings. The syntax for
  536. rational numbers is described in *Note Internal and printed
  537. representation::. Another standard way to produce a rational number is
  538. through application of `operator /' or `recip' on integers.
  539. 
  540. File: cln.info, Node: Constructing floating-point numbers, Next: Constructing complex numbers, Prev: Constructing rational numbers, Up: Constructing numbers
  541. Constructing floating-point numbers
  542. -----------------------------------
  543. `cl_F' objects with low precision are most easily constructed from C
  544. `float' and `double'. See *Note Conversions::.
  545. To construct a `cl_F' with high precision, you can use the conversion
  546. from `const char *', but you have to specify the desired precision
  547. within the string. (See *Note Internal and printed representation::.)
  548. Example:
  549. cl_F e = "0.271828182845904523536028747135266249775724709369996e+1_40";
  550. will set `e' to the given value, with a precision of 40 decimal digits.
  551. The programmatic way to construct a `cl_F' with high precision is
  552. through the `cl_float' conversion function, see *Note Conversion to
  553. floating-point numbers::. For example, to compute `e' to 40 decimal
  554. places, first construct 1.0 to 40 decimal places and then apply the
  555. exponential function:
  556. cl_float_format_t precision = cl_float_format(40);
  557. cl_F e = exp(cl_float(1,precision));
  558. 
  559. File: cln.info, Node: Constructing complex numbers, Prev: Constructing floating-point numbers, Up: Constructing numbers
  560. Constructing complex numbers
  561. ----------------------------
  562. Non-real `cl_N' objects are normally constructed through the function
  563. cl_N complex (const cl_R& realpart, const cl_R& imagpart)
  564. See *Note Elementary complex functions::.
  565. 
  566. File: cln.info, Node: Elementary functions, Next: Elementary rational functions, Prev: Constructing numbers, Up: Functions on numbers
  567. Elementary functions
  568. ====================
  569. Each of the classes `cl_N', `cl_R', `cl_RA', `cl_I', `cl_F', `cl_SF',
  570. `cl_FF', `cl_DF', `cl_LF' defines the following operations:
  571. `TYPE operator + (const TYPE&, const TYPE&)'
  572. Addition.
  573. `TYPE operator - (const TYPE&, const TYPE&)'
  574. Subtraction.
  575. `TYPE operator - (const TYPE&)'
  576. Returns the negative of the argument.
  577. `TYPE plus1 (const TYPE& x)'
  578. Returns `x + 1'.
  579. `TYPE minus1 (const TYPE& x)'
  580. Returns `x - 1'.
  581. `TYPE operator * (const TYPE&, const TYPE&)'
  582. Multiplication.
  583. `TYPE square (const TYPE& x)'
  584. Returns `x * x'.
  585. Each of the classes `cl_N', `cl_R', `cl_RA', `cl_F', `cl_SF', `cl_FF',
  586. `cl_DF', `cl_LF' defines the following operations:
  587. `TYPE operator / (const TYPE&, const TYPE&)'
  588. Division.
  589. `TYPE recip (const TYPE&)'
  590. Returns the reciprocal of the argument.
  591. The class `cl_I' doesn't define a `/' operation because in the C/C++
  592. language this operator, applied to integral types, denotes the `floor'
  593. or `truncate' operation (which one of these, is implementation
  594. dependent). (*Note Rounding functions::) Instead, `cl_I' defines an
  595. "exact quotient" function:
  596. `cl_I exquo (const cl_I& x, const cl_I& y)'
  597. Checks that `y' divides `x', and returns the quotient `x'/`y'.
  598. The following exponentiation functions are defined:
  599. `cl_I expt_pos (const cl_I& x, const cl_I& y)'
  600. `cl_RA expt_pos (const cl_RA& x, const cl_I& y)'
  601. `y' must be > 0. Returns `x^y'.
  602. `cl_RA expt (const cl_RA& x, const cl_I& y)'
  603. `cl_R expt (const cl_R& x, const cl_I& y)'
  604. `cl_N expt (const cl_N& x, const cl_I& y)'
  605. Returns `x^y'.
  606. Each of the classes `cl_R', `cl_RA', `cl_I', `cl_F', `cl_SF', `cl_FF',
  607. `cl_DF', `cl_LF' defines the following operation:
  608. `TYPE abs (const TYPE& x)'
  609. Returns the absolute value of `x'. This is `x' if `x >= 0', and
  610. `-x' if `x <= 0'.
  611. The class `cl_N' implements this as follows:
  612. `cl_R abs (const cl_N x)'
  613. Returns the absolute value of `x'.
  614. Each of the classes `cl_N', `cl_R', `cl_RA', `cl_I', `cl_F', `cl_SF',
  615. `cl_FF', `cl_DF', `cl_LF' defines the following operation:
  616. `TYPE signum (const TYPE& x)'
  617. Returns the sign of `x', in the same number format as `x'. This
  618. is defined as `x / abs(x)' if `x' is non-zero, and `x' if `x' is
  619. zero. If `x' is real, the value is either 0 or 1 or -1.
  620. 
  621. File: cln.info, Node: Elementary rational functions, Next: Elementary complex functions, Prev: Elementary functions, Up: Functions on numbers
  622. Elementary rational functions
  623. =============================
  624. Each of the classes `cl_RA', `cl_I' defines the following operations:
  625. `cl_I numerator (const TYPE& x)'
  626. Returns the numerator of `x'.
  627. `cl_I denominator (const TYPE& x)'
  628. Returns the denominator of `x'.
  629. The numerator and denominator of a rational number are normalized in
  630. such a way that they have no factor in common and the denominator is
  631. positive.
  632. 
  633. File: cln.info, Node: Elementary complex functions, Next: Comparisons, Prev: Elementary rational functions, Up: Functions on numbers
  634. Elementary complex functions
  635. ============================
  636. The class `cl_N' defines the following operation:
  637. `cl_N complex (const cl_R& a, const cl_R& b)'
  638. Returns the complex number `a+bi', that is, the complex number with
  639. real part `a' and imaginary part `b'.
  640. Each of the classes `cl_N', `cl_R' defines the following operations:
  641. `cl_R realpart (const TYPE& x)'
  642. Returns the real part of `x'.
  643. `cl_R imagpart (const TYPE& x)'
  644. Returns the imaginary part of `x'.
  645. `TYPE conjugate (const TYPE& x)'
  646. Returns the complex conjugate of `x'.
  647. We have the relations
  648. `x = complex(realpart(x), imagpart(x))'
  649. `conjugate(x) = complex(realpart(x), -imagpart(x))'
  650. 
  651. File: cln.info, Node: Comparisons, Next: Rounding functions, Prev: Elementary complex functions, Up: Functions on numbers
  652. Comparisons
  653. ===========
  654. Each of the classes `cl_N', `cl_R', `cl_RA', `cl_I', `cl_F', `cl_SF',
  655. `cl_FF', `cl_DF', `cl_LF' defines the following operations:
  656. `bool operator == (const TYPE&, const TYPE&)'
  657. `bool operator != (const TYPE&, const TYPE&)'
  658. Comparison, as in C and C++.
  659. `uint32 cl_equal_hashcode (const TYPE&)'
  660. Returns a 32-bit hash code that is the same for any two numbers
  661. which are the same according to `=='. This hash code depends on
  662. the number's value, not its type or precision.
  663. `cl_boolean zerop (const TYPE& x)'
  664. Compare against zero: `x == 0'
  665. Each of the classes `cl_R', `cl_RA', `cl_I', `cl_F', `cl_SF', `cl_FF',
  666. `cl_DF', `cl_LF' defines the following operations:
  667. `cl_signean cl_compare (const TYPE& x, const TYPE& y)'
  668. Compares `x' and `y'. Returns +1 if `x'>`y', -1 if `x'<`y', 0 if
  669. `x'=`y'.
  670. `bool operator <= (const TYPE&, const TYPE&)'
  671. `bool operator < (const TYPE&, const TYPE&)'
  672. `bool operator >= (const TYPE&, const TYPE&)'
  673. `bool operator > (const TYPE&, const TYPE&)'
  674. Comparison, as in C and C++.
  675. `cl_boolean minusp (const TYPE& x)'
  676. Compare against zero: `x < 0'
  677. `cl_boolean plusp (const TYPE& x)'
  678. Compare against zero: `x > 0'
  679. `TYPE max (const TYPE& x, const TYPE& y)'
  680. Return the maximum of `x' and `y'.
  681. `TYPE min (const TYPE& x, const TYPE& y)'
  682. Return the minimum of `x' and `y'.
  683. When a floating point number and a rational number are compared, the
  684. float is first converted to a rational number using the function
  685. `rational'. Since a floating point number actually represents an
  686. interval of real numbers, the result might be surprising. For example,
  687. `(cl_F)(cl_R)"1/3" == (cl_R)"1/3"' returns false because there is no
  688. floating point number whose value is exactly `1/3'.
  689. 
  690. File: cln.info, Node: Rounding functions, Next: Roots, Prev: Comparisons, Up: Functions on numbers
  691. Rounding functions
  692. ==================
  693. When a real number is to be converted to an integer, there is no "best"
  694. rounding. The desired rounding function depends on the application.
  695. The Common Lisp and ISO Lisp standards offer four rounding functions:
  696. `floor(x)'
  697. This is the largest integer <=`x'.
  698. `ceiling(x)'
  699. This is the smallest integer >=`x'.
  700. `truncate(x)'
  701. Among the integers between 0 and `x' (inclusive) the one nearest
  702. to `x'.
  703. `round(x)'
  704. The integer nearest to `x'. If `x' is exactly halfway between two
  705. integers, choose the even one.
  706. These functions have different advantages:
  707. `floor' and `ceiling' are translation invariant: `floor(x+n) = floor(x)
  708. + n' and `ceiling(x+n) = ceiling(x) + n' for every `x' and every
  709. integer `n'.
  710. On the other hand, `truncate' and `round' are symmetric: `truncate(-x)
  711. = -truncate(x)' and `round(-x) = -round(x)', and furthermore `round' is
  712. unbiased: on the "average", it rounds down exactly as often as it
  713. rounds up.
  714. The functions are related like this:
  715. `ceiling(m/n) = floor((m+n-1)/n) = floor((m-1)/n)+1' for rational
  716. numbers `m/n' (`m', `n' integers, `n'>0), and
  717. `truncate(x) = sign(x) * floor(abs(x))'
  718. Each of the classes `cl_R', `cl_RA', `cl_F', `cl_SF', `cl_FF', `cl_DF',
  719. `cl_LF' defines the following operations:
  720. `cl_I floor1 (const TYPE& x)'
  721. Returns `floor(x)'.
  722. `cl_I ceiling1 (const TYPE& x)'
  723. Returns `ceiling(x)'.
  724. `cl_I truncate1 (const TYPE& x)'
  725. Returns `truncate(x)'.
  726. `cl_I round1 (const TYPE& x)'
  727. Returns `round(x)'.
  728. Each of the classes `cl_R', `cl_RA', `cl_I', `cl_F', `cl_SF', `cl_FF',
  729. `cl_DF', `cl_LF' defines the following operations:
  730. `cl_I floor1 (const TYPE& x, const TYPE& y)'
  731. Returns `floor(x/y)'.
  732. `cl_I ceiling1 (const TYPE& x, const TYPE& y)'
  733. Returns `ceiling(x/y)'.
  734. `cl_I truncate1 (const TYPE& x, const TYPE& y)'
  735. Returns `truncate(x/y)'.
  736. `cl_I round1 (const TYPE& x, const TYPE& y)'
  737. Returns `round(x/y)'.
  738. These functions are called `floor1', ... here instead of `floor', ...,
  739. because on some systems, system dependent include files define `floor'
  740. and `ceiling' as macros.
  741. In many cases, one needs both the quotient and the remainder of a
  742. division. It is more efficient to compute both at the same time than
  743. to perform two divisions, one for quotient and the next one for the
  744. remainder. The following functions therefore return a structure
  745. containing both the quotient and the remainder. The suffix `2'
  746. indicates the number of "return values". The remainder is defined as
  747. follows:
  748. * for the computation of `quotient = floor(x)', `remainder = x -
  749. quotient',
  750. * for the computation of `quotient = floor(x,y)', `remainder = x -
  751. quotient*y',
  752. and similarly for the other three operations.
  753. Each of the classes `cl_R', `cl_RA', `cl_F', `cl_SF', `cl_FF', `cl_DF',
  754. `cl_LF' defines the following operations:
  755. `struct TYPE_div_t { cl_I quotient; TYPE remainder; };'
  756. `TYPE_div_t floor2 (const TYPE& x)'
  757. `TYPE_div_t ceiling2 (const TYPE& x)'
  758. `TYPE_div_t truncate2 (const TYPE& x)'
  759. `TYPE_div_t round2 (const TYPE& x)'
  760. Each of the classes `cl_R', `cl_RA', `cl_I', `cl_F', `cl_SF', `cl_FF',
  761. `cl_DF', `cl_LF' defines the following operations:
  762. `struct TYPE_div_t { cl_I quotient; TYPE remainder; };'
  763. `TYPE_div_t floor2 (const TYPE& x, const TYPE& y)'
  764. `TYPE_div_t ceiling2 (const TYPE& x, const TYPE& y)'
  765. `TYPE_div_t truncate2 (const TYPE& x, const TYPE& y)'
  766. `TYPE_div_t round2 (const TYPE& x, const TYPE& y)'
  767. Sometimes, one wants the quotient as a floating-point number (of the
  768. same format as the argument, if the argument is a float) instead of as
  769. an integer. The prefix `f' indicates this.
  770. Each of the classes `cl_F', `cl_SF', `cl_FF', `cl_DF', `cl_LF' defines
  771. the following operations:
  772. `TYPE ffloor (const TYPE& x)'
  773. `TYPE fceiling (const TYPE& x)'
  774. `TYPE ftruncate (const TYPE& x)'
  775. `TYPE fround (const TYPE& x)'
  776. and similarly for class `cl_R', but with return type `cl_F'.
  777. The class `cl_R' defines the following operations:
  778. `cl_F ffloor (const TYPE& x, const TYPE& y)'
  779. `cl_F fceiling (const TYPE& x, const TYPE& y)'
  780. `cl_F ftruncate (const TYPE& x, const TYPE& y)'
  781. `cl_F fround (const TYPE& x, const TYPE& y)'
  782. These functions also exist in versions which return both the quotient
  783. and the remainder. The suffix `2' indicates this.
  784. Each of the classes `cl_F', `cl_SF', `cl_FF', `cl_DF', `cl_LF' defines
  785. the following operations:
  786. `struct TYPE_fdiv_t { TYPE quotient; TYPE remainder; };'
  787. `TYPE_fdiv_t ffloor2 (const TYPE& x)'
  788. `TYPE_fdiv_t fceiling2 (const TYPE& x)'
  789. `TYPE_fdiv_t ftruncate2 (const TYPE& x)'
  790. `TYPE_fdiv_t fround2 (const TYPE& x)'
  791. and similarly for class `cl_R', but with quotient type `cl_F'.
  792. The class `cl_R' defines the following operations:
  793. `struct TYPE_fdiv_t { cl_F quotient; cl_R remainder; };'
  794. `TYPE_fdiv_t ffloor2 (const TYPE& x, const TYPE& y)'
  795. `TYPE_fdiv_t fceiling2 (const TYPE& x, const TYPE& y)'
  796. `TYPE_fdiv_t ftruncate2 (const TYPE& x, const TYPE& y)'
  797. `TYPE_fdiv_t fround2 (const TYPE& x, const TYPE& y)'
  798. Other applications need only the remainder of a division. The
  799. remainder of `floor' and `ffloor' is called `mod' (abbreviation of
  800. "modulo"). The remainder `truncate' and `ftruncate' is called `rem'
  801. (abbreviation of "remainder").
  802. * `mod(x,y) = floor2(x,y).remainder = x - floor(x/y)*y'
  803. * `rem(x,y) = truncate2(x,y).remainder = x - truncate(x/y)*y'
  804. If `x' and `y' are both >= 0, `mod(x,y) = rem(x,y) >= 0'. In general,
  805. `mod(x,y)' has the sign of `y' or is zero, and `rem(x,y)' has the sign
  806. of `x' or is zero.
  807. The classes `cl_R', `cl_I' define the following operations:
  808. `TYPE mod (const TYPE& x, const TYPE& y)'
  809. `TYPE rem (const TYPE& x, const TYPE& y)'
  810. 
  811. File: cln.info, Node: Roots, Next: Transcendental functions, Prev: Rounding functions, Up: Functions on numbers
  812. Roots
  813. =====
  814. Each of the classes `cl_R', `cl_F', `cl_SF', `cl_FF', `cl_DF', `cl_LF'
  815. defines the following operation:
  816. `TYPE sqrt (const TYPE& x)'
  817. `x' must be >= 0. This function returns the square root of `x',
  818. normalized to be >= 0. If `x' is the square of a rational number,
  819. `sqrt(x)' will be a rational number, else it will return a
  820. floating-point approximation.
  821. The classes `cl_RA', `cl_I' define the following operation:
  822. `cl_boolean sqrtp (const TYPE& x, TYPE* root)'
  823. This tests whether `x' is a perfect square. If so, it returns true
  824. and the exact square root in `*root', else it returns false.
  825. Furthermore, for integers, similarly:
  826. `cl_boolean isqrt (const TYPE& x, TYPE* root)'
  827. `x' should be >= 0. This function sets `*root' to `floor(sqrt(x))'
  828. and returns the same value as `sqrtp': the boolean value
  829. `(expt(*root,2) == x)'.
  830. For `n'th roots, the classes `cl_RA', `cl_I' define the following
  831. operation:
  832. `cl_boolean rootp (const TYPE& x, const cl_I& n, TYPE* root)'
  833. `x' must be >= 0. `n' must be > 0. This tests whether `x' is an
  834. `n'th power of a rational number. If so, it returns true and the
  835. exact root in `*root', else it returns false.
  836. The only square root function which accepts negative numbers is the one
  837. for class `cl_N':
  838. `cl_N sqrt (const cl_N& z)'
  839. Returns the square root of `z', as defined by the formula `sqrt(z)
  840. = exp(log(z)/2)'. Conversion to a floating-point type or to a
  841. complex number are done if necessary. The range of the result is
  842. the right half plane `realpart(sqrt(z)) >= 0' including the
  843. positive imaginary axis and 0, but excluding the negative
  844. imaginary axis. The result is an exact number only if `z' is an
  845. exact number.
  846. 
  847. File: cln.info, Node: Transcendental functions, Next: Functions on integers, Prev: Roots, Up: Functions on numbers
  848. Transcendental functions
  849. ========================
  850. The transcendental functions return an exact result if the argument is
  851. exact and the result is exact as well. Otherwise they must return
  852. inexact numbers even if the argument is exact. For example, `cos(0) =
  853. 1' returns the rational number `1'.
  854. * Menu:
  855. * Exponential and logarithmic functions::
  856. * Trigonometric functions::
  857. * Hyperbolic functions::
  858. * Euler gamma::
  859. * Riemann zeta::
  860. 
  861. File: cln.info, Node: Exponential and logarithmic functions, Next: Trigonometric functions, Prev: Transcendental functions, Up: Transcendental functions
  862. Exponential and logarithmic functions
  863. -------------------------------------
  864. `cl_R exp (const cl_R& x)'
  865. `cl_N exp (const cl_N& x)'
  866. Returns the exponential function of `x'. This is `e^x' where `e'
  867. is the base of the natural logarithms. The range of the result is
  868. the entire complex plane excluding 0.
  869. `cl_R ln (const cl_R& x)'
  870. `x' must be > 0. Returns the (natural) logarithm of x.
  871. `cl_N log (const cl_N& x)'
  872. Returns the (natural) logarithm of x. If `x' is real and positive,
  873. this is `ln(x)'. In general, `log(x) = log(abs(x)) + i*phase(x)'.
  874. The range of the result is the strip in the complex plane `-pi <
  875. imagpart(log(x)) <= pi'.
  876. `cl_R phase (const cl_N& x)'
  877. Returns the angle part of `x' in its polar representation as a
  878. complex number. That is, `phase(x) =
  879. atan(realpart(x),imagpart(x))'. This is also the imaginary part
  880. of `log(x)'. The range of the result is the interval `-pi <
  881. phase(x) <= pi'. The result will be an exact number only if
  882. `zerop(x)' or if `x' is real and positive.
  883. `cl_R log (const cl_R& a, const cl_R& b)'
  884. `a' and `b' must be > 0. Returns the logarithm of `a' with respect
  885. to base `b'. `log(a,b) = ln(a)/ln(b)'. The result can be exact
  886. only if `a = 1' or if `a' and `b' are both rational.
  887. `cl_N log (const cl_N& a, const cl_N& b)'
  888. Returns the logarithm of `a' with respect to base `b'. `log(a,b)
  889. = log(a)/log(b)'.
  890. `cl_N expt (const cl_N& x, const cl_N& y)'
  891. Exponentiation: Returns `x^y = exp(y*log(x))'.
  892. The constant e = exp(1) = 2.71828... is returned by the following
  893. functions:
  894. `cl_F cl_exp1 (cl_float_format_t f)'
  895. Returns e as a float of format `f'.
  896. `cl_F cl_exp1 (const cl_F& y)'
  897. Returns e in the float format of `y'.
  898. `cl_F cl_exp1 (void)'
  899. Returns e as a float of format `cl_default_float_format'.
  900. 
  901. File: cln.info, Node: Trigonometric functions, Next: Hyperbolic functions, Prev: Exponential and logarithmic functions, Up: Transcendental functions
  902. Trigonometric functions
  903. -----------------------
  904. `cl_R sin (const cl_R& x)'
  905. Returns `sin(x)'. The range of the result is the interval `-1 <=
  906. sin(x) <= 1'.
  907. `cl_N sin (const cl_N& z)'
  908. Returns `sin(z)'. The range of the result is the entire complex
  909. plane.
  910. `cl_R cos (const cl_R& x)'
  911. Returns `cos(x)'. The range of the result is the interval `-1 <=
  912. cos(x) <= 1'.
  913. `cl_N cos (const cl_N& x)'
  914. Returns `cos(z)'. The range of the result is the entire complex
  915. plane.
  916. `struct cl_cos_sin_t { cl_R cos; cl_R sin; };'
  917. `cl_cos_sin_t cl_cos_sin (const cl_R& x)'
  918. Returns both `sin(x)' and `cos(x)'. This is more efficient than
  919. computing them separately. The relation `cos^2 + sin^2 = 1' will
  920. hold only approximately.
  921. `cl_R tan (const cl_R& x)'
  922. `cl_N tan (const cl_N& x)'
  923. Returns `tan(x) = sin(x)/cos(x)'.
  924. `cl_N cis (const cl_R& x)'
  925. `cl_N cis (const cl_N& x)'
  926. Returns `exp(i*x)'. The name `cis' means "cos + i sin", because
  927. `e^(i*x) = cos(x) + i*sin(x)'.
  928. `cl_N asin (const cl_N& z)'
  929. Returns `arcsin(z)'. This is defined as `arcsin(z) =
  930. log(iz+sqrt(1-z^2))/i' and satisfies `arcsin(-z) = -arcsin(z)'.
  931. The range of the result is the strip in the complex domain `-pi/2
  932. <= realpart(arcsin(z)) <= pi/2', excluding the numbers with
  933. `realpart = -pi/2' and `imagpart < 0' and the numbers with
  934. `realpart = pi/2' and `imagpart > 0'.
  935. `cl_N acos (const cl_N& z)'
  936. Returns `arccos(z)'. This is defined as `arccos(z) = pi/2 -
  937. arcsin(z) = log(z+i*sqrt(1-z^2))/i' and satisfies `arccos(-z) = pi
  938. - arccos(z)'. The range of the result is the strip in the complex
  939. domain `0 <= realpart(arcsin(z)) <= pi', excluding the numbers
  940. with `realpart = 0' and `imagpart < 0' and the numbers with
  941. `realpart = pi' and `imagpart > 0'.
  942. `cl_R atan (const cl_R& x, const cl_R& y)'
  943. Returns the angle of the polar representation of the complex number
  944. `x+iy'. This is `atan(y/x)' if `x>0'. The range of the result is
  945. the interval `-pi < atan(x,y) <= pi'. The result will be an exact
  946. number only if `x > 0' and `y' is the exact `0'. WARNING: In
  947. Common Lisp, this function is called as `(atan y x)', with
  948. reversed order of arguments.
  949. `cl_R atan (const cl_R& x)'
  950. Returns `arctan(x)'. This is the same as `atan(1,x)'. The range of
  951. the result is the interval `-pi/2 < atan(x) < pi/2'. The result
  952. will be an exact number only if `x' is the exact `0'.
  953. `cl_N atan (const cl_N& z)'
  954. Returns `arctan(z)'. This is defined as `arctan(z) =
  955. (log(1+iz)-log(1-iz)) / 2i' and satisfies `arctan(-z) =
  956. -arctan(z)'. The range of the result is the strip in the complex
  957. domain `-pi/2 <= realpart(arctan(z)) <= pi/2', excluding the
  958. numbers with `realpart = -pi/2' and `imagpart >= 0' and the numbers
  959. with `realpart = pi/2' and `imagpart <= 0'.
  960. Archimedes' constant pi = 3.14... is returned by the following
  961. functions:
  962. `cl_F cl_pi (cl_float_format_t f)'
  963. Returns pi as a float of format `f'.
  964. `cl_F cl_pi (const cl_F& y)'
  965. Returns pi in the float format of `y'.
  966. `cl_F cl_pi (void)'
  967. Returns pi as a float of format `cl_default_float_format'.
  968. 
  969. File: cln.info, Node: Hyperbolic functions, Next: Euler gamma, Prev: Trigonometric functions, Up: Transcendental functions
  970. Hyperbolic functions
  971. --------------------
  972. `cl_R sinh (const cl_R& x)'
  973. Returns `sinh(x)'.
  974. `cl_N sinh (const cl_N& z)'
  975. Returns `sinh(z)'. The range of the result is the entire complex
  976. plane.
  977. `cl_R cosh (const cl_R& x)'
  978. Returns `cosh(x)'. The range of the result is the interval
  979. `cosh(x) >= 1'.
  980. `cl_N cosh (const cl_N& z)'
  981. Returns `cosh(z)'. The range of the result is the entire complex
  982. plane.
  983. `struct cl_cosh_sinh_t { cl_R cosh; cl_R sinh; };'
  984. `cl_cosh_sinh_t cl_cosh_sinh (const cl_R& x)'
  985. Returns both `sinh(x)' and `cosh(x)'. This is more efficient than
  986. computing them separately. The relation `cosh^2 - sinh^2 = 1' will
  987. hold only approximately.
  988. `cl_R tanh (const cl_R& x)'
  989. `cl_N tanh (const cl_N& x)'
  990. Returns `tanh(x) = sinh(x)/cosh(x)'.
  991. `cl_N asinh (const cl_N& z)'
  992. Returns `arsinh(z)'. This is defined as `arsinh(z) =
  993. log(z+sqrt(1+z^2))' and satisfies `arsinh(-z) = -arsinh(z)'. The
  994. range of the result is the strip in the complex domain `-pi/2 <=
  995. imagpart(arsinh(z)) <= pi/2', excluding the numbers with `imagpart
  996. = -pi/2' and `realpart > 0' and the numbers with `imagpart = pi/2'
  997. and `realpart < 0'.
  998. `cl_N acosh (const cl_N& z)'
  999. Returns `arcosh(z)'. This is defined as `arcosh(z) =
  1000. 2*log(sqrt((z+1)/2)+sqrt((z-1)/2))'. The range of the result is
  1001. the half-strip in the complex domain `-pi < imagpart(arcosh(z)) <=
  1002. pi, realpart(arcosh(z)) >= 0', excluding the numbers with
  1003. `realpart = 0' and `-pi < imagpart < 0'.
  1004. `cl_N atanh (const cl_N& z)'
  1005. Returns `artanh(z)'. This is defined as `artanh(z) =
  1006. (log(1+z)-log(1-z)) / 2' and satisfies `artanh(-z) = -artanh(z)'.
  1007. The range of the result is the strip in the complex domain `-pi/2
  1008. <= imagpart(artanh(z)) <= pi/2', excluding the numbers with
  1009. `imagpart = -pi/2' and `realpart <= 0' and the numbers with
  1010. `imagpart = pi/2' and `realpart >= 0'.
  1011. 
  1012. File: cln.info, Node: Euler gamma, Next: Riemann zeta, Prev: Hyperbolic functions, Up: Transcendental functions
  1013. Euler gamma
  1014. -----------
  1015. Euler's constant C = 0.577... is returned by the following functions:
  1016. `cl_F cl_eulerconst (cl_float_format_t f)'
  1017. Returns Euler's constant as a float of format `f'.
  1018. `cl_F cl_eulerconst (const cl_F& y)'
  1019. Returns Euler's constant in the float format of `y'.
  1020. `cl_F cl_eulerconst (void)'
  1021. Returns Euler's constant as a float of format
  1022. `cl_default_float_format'.
  1023. Catalan's constant G = 0.915... is returned by the following functions:
  1024. `cl_F cl_catalanconst (cl_float_format_t f)'
  1025. Returns Catalan's constant as a float of format `f'.
  1026. `cl_F cl_catalanconst (const cl_F& y)'
  1027. Returns Catalan's constant in the float format of `y'.
  1028. `cl_F cl_catalanconst (void)'
  1029. Returns Catalan's constant as a float of format
  1030. `cl_default_float_format'.
  1031. 
  1032. File: cln.info, Node: Riemann zeta, Prev: Euler gamma, Up: Transcendental functions
  1033. Riemann zeta
  1034. ------------
  1035. Riemann's zeta function at an integral point `s>1' is returned by the
  1036. following functions:
  1037. `cl_F cl_zeta (int s, cl_float_format_t f)'
  1038. Returns Riemann's zeta function at `s' as a float of format `f'.
  1039. `cl_F cl_zeta (int s, const cl_F& y)'
  1040. Returns Riemann's zeta function at `s' in the float format of `y'.
  1041. `cl_F cl_zeta (int s)'
  1042. Returns Riemann's zeta function at `s' as a float of format
  1043. `cl_default_float_format'.
  1044. 
  1045. File: cln.info, Node: Functions on integers, Next: Functions on floating-point numbers, Prev: Transcendental functions, Up: Functions on numbers
  1046. Functions on integers
  1047. =====================
  1048. * Menu:
  1049. * Logical functions::
  1050. * Number theoretic functions::
  1051. * Combinatorial functions::
  1052. 
  1053. File: cln.info, Node: Logical functions, Next: Number theoretic functions, Prev: Functions on integers, Up: Functions on integers
  1054. Logical functions
  1055. -----------------
  1056. Integers, when viewed as in two's complement notation, can be thought as
  1057. infinite bit strings where the bits' values eventually are constant.
  1058. For example,
  1059. 17 = ......00010001
  1060. -6 = ......11111010
  1061. The logical operations view integers as such bit strings and operate on
  1062. each of the bit positions in parallel.
  1063. `cl_I lognot (const cl_I& x)'
  1064. `cl_I operator ~ (const cl_I& x)'
  1065. Logical not, like `~x' in C. This is the same as `-1-x'.
  1066. `cl_I logand (const cl_I& x, const cl_I& y)'
  1067. `cl_I operator & (const cl_I& x, const cl_I& y)'
  1068. Logical and, like `x & y' in C.
  1069. `cl_I logior (const cl_I& x, const cl_I& y)'
  1070. `cl_I operator | (const cl_I& x, const cl_I& y)'
  1071. Logical (inclusive) or, like `x | y' in C.
  1072. `cl_I logxor (const cl_I& x, const cl_I& y)'
  1073. `cl_I operator ^ (const cl_I& x, const cl_I& y)'
  1074. Exclusive or, like `x ^ y' in C.
  1075. `cl_I logeqv (const cl_I& x, const cl_I& y)'
  1076. Bitwise equivalence, like `~(x ^ y)' in C.
  1077. `cl_I lognand (const cl_I& x, const cl_I& y)'
  1078. Bitwise not and, like `~(x & y)' in C.
  1079. `cl_I lognor (const cl_I& x, const cl_I& y)'
  1080. Bitwise not or, like `~(x | y)' in C.
  1081. `cl_I logandc1 (const cl_I& x, const cl_I& y)'
  1082. Logical and, complementing the first argument, like `~x & y' in C.
  1083. `cl_I logandc2 (const cl_I& x, const cl_I& y)'
  1084. Logical and, complementing the second argument, like `x & ~y' in C.
  1085. `cl_I logorc1 (const cl_I& x, const cl_I& y)'
  1086. Logical or, complementing the first argument, like `~x | y' in C.
  1087. `cl_I logorc2 (const cl_I& x, const cl_I& y)'
  1088. Logical or, complementing the second argument, like `x | ~y' in C.
  1089. These operations are all available though the function
  1090. `cl_I boole (cl_boole op, const cl_I& x, const cl_I& y)'
  1091. where `op' must have one of the 16 values (each one stands for a
  1092. function which combines two bits into one bit): `boole_clr',
  1093. `boole_set', `boole_1', `boole_2', `boole_c1', `boole_c2', `boole_and',
  1094. `boole_ior', `boole_xor', `boole_eqv', `boole_nand', `boole_nor',
  1095. `boole_andc1', `boole_andc2', `boole_orc1', `boole_orc2'.
  1096. Other functions that view integers as bit strings:
  1097. `cl_boolean logtest (const cl_I& x, const cl_I& y)'
  1098. Returns true if some bit is set in both `x' and `y', i.e. if
  1099. `logand(x,y) != 0'.
  1100. `cl_boolean logbitp (const cl_I& n, const cl_I& x)'
  1101. Returns true if the `n'th bit (from the right) of `x' is set. Bit
  1102. 0 is the least significant bit.
  1103. `uintL logcount (const cl_I& x)'
  1104. Returns the number of one bits in `x', if `x' >= 0, or the number
  1105. of zero bits in `x', if `x' < 0.
  1106. The following functions operate on intervals of bits in integers. The
  1107. type
  1108. struct cl_byte { uintL size; uintL position; };
  1109. represents the bit interval containing the bits
  1110. `position'...`position+size-1' of an integer. The constructor
  1111. `cl_byte(size,position)' constructs a `cl_byte'.
  1112. `cl_I ldb (const cl_I& n, const cl_byte& b)'
  1113. extracts the bits of `n' described by the bit interval `b' and
  1114. returns them as a nonnegative integer with `b.size' bits.
  1115. `cl_boolean ldb_test (const cl_I& n, const cl_byte& b)'
  1116. Returns true if some bit described by the bit interval `b' is set
  1117. in `n'.
  1118. `cl_I dpb (const cl_I& newbyte, const cl_I& n, const cl_byte& b)'
  1119. Returns `n', with the bits described by the bit interval `b'
  1120. replaced by `newbyte'. Only the lowest `b.size' bits of `newbyte'
  1121. are relevant.
  1122. The functions `ldb' and `dpb' implicitly shift. The following functions
  1123. are their counterparts without shifting:
  1124. `cl_I mask_field (const cl_I& n, const cl_byte& b)'
  1125. returns an integer with the bits described by the bit interval `b'
  1126. copied from the corresponding bits in `n', the other bits zero.
  1127. `cl_I deposit_field (const cl_I& newbyte, const cl_I& n, const cl_byte& b)'
  1128. returns an integer where the bits described by the bit interval `b'
  1129. come from `newbyte' and the other bits come from `n'.
  1130. The following relations hold:
  1131. `ldb (n, b) = mask_field(n, b) >> b.position',
  1132. `dpb (newbyte, n, b) = deposit_field (newbyte << b.position, n,
  1133. b)',
  1134. `deposit_field(newbyte,n,b) = n ^ mask_field(n,b) ^
  1135. mask_field(new_byte,b)'.
  1136. The following operations on integers as bit strings are efficient
  1137. shortcuts for common arithmetic operations:
  1138. `cl_boolean oddp (const cl_I& x)'
  1139. Returns true if the least significant bit of `x' is 1. Equivalent
  1140. to `mod(x,2) != 0'.
  1141. `cl_boolean evenp (const cl_I& x)'
  1142. Returns true if the least significant bit of `x' is 0. Equivalent
  1143. to `mod(x,2) == 0'.
  1144. `cl_I operator << (const cl_I& x, const cl_I& n)'
  1145. Shifts `x' by `n' bits to the left. `n' should be >=0. Equivalent
  1146. to `x * expt(2,n)'.
  1147. `cl_I operator >> (const cl_I& x, const cl_I& n)'
  1148. Shifts `x' by `n' bits to the right. `n' should be >=0. Bits
  1149. shifted out to the right are thrown away. Equivalent to `floor(x
  1150. / expt(2,n))'.
  1151. `cl_I ash (const cl_I& x, const cl_I& y)'
  1152. Shifts `x' by `y' bits to the left (if `y'>=0) or by `-y' bits to
  1153. the right (if `y'<=0). In other words, this returns `floor(x *
  1154. expt(2,y))'.
  1155. `uintL integer_length (const cl_I& x)'
  1156. Returns the number of bits (excluding the sign bit) needed to
  1157. represent `x' in two's complement notation. This is the smallest n
  1158. >= 0 such that -2^n <= x < 2^n. If x > 0, this is the unique n > 0
  1159. such that 2^(n-1) <= x < 2^n.
  1160. `uintL ord2 (const cl_I& x)'
  1161. `x' must be non-zero. This function returns the number of 0 bits
  1162. at the right of `x' in two's complement notation. This is the
  1163. largest n >= 0 such that 2^n divides `x'.
  1164. `uintL power2p (const cl_I& x)'
  1165. `x' must be > 0. This function checks whether `x' is a power of 2.
  1166. If `x' = 2^(n-1), it returns n. Else it returns 0. (See also the
  1167. function `logp'.)
  1168. 
  1169. File: cln.info, Node: Number theoretic functions, Next: Combinatorial functions, Prev: Logical functions, Up: Functions on integers
  1170. Number theoretic functions
  1171. --------------------------
  1172. `uint32 gcd (uint32 a, uint32 b)'
  1173. `cl_I gcd (const cl_I& a, const cl_I& b)'
  1174. This function returns the greatest common divisor of `a' and `b',
  1175. normalized to be >= 0.
  1176. `cl_I xgcd (const cl_I& a, const cl_I& b, cl_I* u, cl_I* v)'
  1177. This function ("extended gcd") returns the greatest common divisor
  1178. `g' of `a' and `b' and at the same time the representation of `g'
  1179. as an integral linear combination of `a' and `b': `u' and `v' with
  1180. `u*a+v*b = g', `g' >= 0. `u' and `v' will be normalized to be of
  1181. smallest possible absolute value, in the following sense: If `a'
  1182. and `b' are non-zero, and `abs(a) != abs(b)', `u' and `v' will
  1183. satisfy the inequalities `abs(u) <= abs(b)/(2*g)', `abs(v) <=
  1184. abs(a)/(2*g)'.
  1185. `cl_I lcm (const cl_I& a, const cl_I& b)'
  1186. This function returns the least common multiple of `a' and `b',
  1187. normalized to be >= 0.
  1188. `cl_boolean logp (const cl_I& a, const cl_I& b, cl_RA* l)'
  1189. `cl_boolean logp (const cl_RA& a, const cl_RA& b, cl_RA* l)'
  1190. `a' must be > 0. `b' must be >0 and != 1. If log(a,b) is rational
  1191. number, this function returns true and sets *l = log(a,b), else it
  1192. returns false.
  1193. 
  1194. File: cln.info, Node: Combinatorial functions, Prev: Number theoretic functions, Up: Functions on integers
  1195. Combinatorial functions
  1196. -----------------------
  1197. `cl_I factorial (uintL n)'
  1198. `n' must be a small integer >= 0. This function returns the
  1199. factorial `n'! = `1*2*...*n'.
  1200. `cl_I doublefactorial (uintL n)'
  1201. `n' must be a small integer >= 0. This function returns the
  1202. doublefactorial `n'!! = `1*3*...*n' or `n'!! = `2*4*...*n',
  1203. respectively.
  1204. `cl_I binomial (uintL n, uintL k)'
  1205. `n' and `k' must be small integers >= 0. This function returns the
  1206. binomial coefficient (`n' choose `k') = `n'! / `k'! `(n-k)'! for
  1207. 0 <= k <= n, 0 else.
  1208. 
  1209. File: cln.info, Node: Functions on floating-point numbers, Next: Conversion functions, Prev: Functions on integers, Up: Functions on numbers
  1210. Functions on floating-point numbers
  1211. ===================================
  1212. Recall that a floating-point number consists of a sign `s', an exponent
  1213. `e' and a mantissa `m'. The value of the number is `(-1)^s * 2^e * m'.
  1214. Each of the classes `cl_F', `cl_SF', `cl_FF', `cl_DF', `cl_LF' defines
  1215. the following operations.
  1216. `TYPE scale_float (const TYPE& x, sintL delta)'
  1217. `TYPE scale_float (const TYPE& x, const cl_I& delta)'
  1218. Returns `x*2^delta'. This is more efficient than an explicit
  1219. multiplication because it copies `x' and modifies the exponent.
  1220. The following functions provide an abstract interface to the underlying
  1221. representation of floating-point numbers.
  1222. `sintL float_exponent (const TYPE& x)'
  1223. Returns the exponent `e' of `x'. For `x = 0.0', this is 0. For
  1224. `x' non-zero, this is the unique integer with `2^(e-1) <= abs(x) <
  1225. 2^e'.
  1226. `sintL float_radix (const TYPE& x)'
  1227. Returns the base of the floating-point representation. This is
  1228. always `2'.
  1229. `TYPE float_sign (const TYPE& x)'
  1230. Returns the sign `s' of `x' as a float. The value is 1 for `x' >=
  1231. 0, -1 for `x' < 0.
  1232. `uintL float_digits (const TYPE& x)'
  1233. Returns the number of mantissa bits in the floating-point
  1234. representation of `x', including the hidden bit. The value only
  1235. depends on the type of `x', not on its value.
  1236. `uintL float_precision (const TYPE& x)'
  1237. Returns the number of significant mantissa bits in the
  1238. floating-point representation of `x'. Since denormalized numbers
  1239. are not supported, this is the same as `float_digits(x)' if `x' is
  1240. non-zero, and 0 if `x' = 0.
  1241. The complete internal representation of a float is encoded in the type
  1242. `cl_decoded_float' (or `cl_decoded_sfloat', `cl_decoded_ffloat',
  1243. `cl_decoded_dfloat', `cl_decoded_lfloat', respectively), defined by
  1244. struct cl_decoded_TYPEfloat {
  1245. TYPE mantissa; cl_I exponent; TYPE sign;
  1246. };
  1247. and returned by the function
  1248. `cl_decoded_TYPEfloat decode_float (const TYPE& x)'
  1249. For `x' non-zero, this returns `(-1)^s', `e', `m' with `x = (-1)^s
  1250. * 2^e * m' and `0.5 <= m < 1.0'. For `x' = 0, it returns
  1251. `(-1)^s'=1, `e'=0, `m'=0. `e' is the same as returned by the
  1252. function `float_exponent'.
  1253. A complete decoding in terms of integers is provided as type
  1254. struct cl_idecoded_float {
  1255. cl_I mantissa; cl_I exponent; cl_I sign;
  1256. };
  1257. by the following function:
  1258. `cl_idecoded_float integer_decode_float (const TYPE& x)'
  1259. For `x' non-zero, this returns `(-1)^s', `e', `m' with `x = (-1)^s
  1260. * 2^e * m' and `m' an integer with `float_digits(x)' bits. For `x'
  1261. = 0, it returns `(-1)^s'=1, `e'=0, `m'=0. WARNING: The exponent
  1262. `e' is not the same as the one returned by the functions
  1263. `decode_float' and `float_exponent'.
  1264. Some other function, implemented only for class `cl_F':
  1265. `cl_F float_sign (const cl_F& x, const cl_F& y)'
  1266. This returns a floating point number whose precision and absolute
  1267. value is that of `y' and whose sign is that of `x'. If `x' is
  1268. zero, it is treated as positive. Same for `y'.
  1269. 
  1270. File: cln.info, Node: Conversion functions, Next: Random number generators, Prev: Functions on floating-point numbers, Up: Functions on numbers
  1271. Conversion functions
  1272. ====================
  1273. * Menu:
  1274. * Conversion to floating-point numbers::
  1275. * Conversion to rational numbers::
  1276. 
  1277. File: cln.info, Node: Conversion to floating-point numbers, Next: Conversion to rational numbers, Prev: Conversion functions, Up: Conversion functions
  1278. Conversion to floating-point numbers
  1279. ------------------------------------
  1280. The type `cl_float_format_t' describes a floating-point format.
  1281. `cl_float_format_t cl_float_format (uintL n)'
  1282. Returns the smallest float format which guarantees at least `n'
  1283. decimal digits in the mantissa (after the decimal point).
  1284. `cl_float_format_t cl_float_format (const cl_F& x)'
  1285. Returns the floating point format of `x'.
  1286. `cl_float_format_t cl_default_float_format'
  1287. Global variable: the default float format used when converting
  1288. rational numbers to floats.
  1289. To convert a real number to a float, each of the types `cl_R', `cl_F',
  1290. `cl_I', `cl_RA', `int', `unsigned int', `float', `double' defines the
  1291. following operations:
  1292. `cl_F cl_float (const TYPE&x, cl_float_format_t f)'
  1293. Returns `x' as a float of format `f'.
  1294. `cl_F cl_float (const TYPE&x, const cl_F& y)'
  1295. Returns `x' in the float format of `y'.
  1296. `cl_F cl_float (const TYPE&x)'
  1297. Returns `x' as a float of format `cl_default_float_format' if it
  1298. is an exact number, or `x' itself if it is already a float.
  1299. Of course, converting a number to a float can lose precision.
  1300. Every floating-point format has some characteristic numbers:
  1301. `cl_F most_positive_float (cl_float_format_t f)'
  1302. Returns the largest (most positive) floating point number in float
  1303. format `f'.
  1304. `cl_F most_negative_float (cl_float_format_t f)'
  1305. Returns the smallest (most negative) floating point number in
  1306. float format `f'.
  1307. `cl_F least_positive_float (cl_float_format_t f)'
  1308. Returns the least positive floating point number (i.e. > 0 but
  1309. closest to 0) in float format `f'.
  1310. `cl_F least_negative_float (cl_float_format_t f)'
  1311. Returns the least negative floating point number (i.e. < 0 but
  1312. closest to 0) in float format `f'.
  1313. `cl_F float_epsilon (cl_float_format_t f)'
  1314. Returns the smallest floating point number e > 0 such that `1+e !=
  1315. 1'.
  1316. `cl_F float_negative_epsilon (cl_float_format_t f)'
  1317. Returns the smallest floating point number e > 0 such that `1-e !=
  1318. 1'.
  1319. 
  1320. File: cln.info, Node: Conversion to rational numbers, Prev: Conversion to floating-point numbers, Up: Conversion functions
  1321. Conversion to rational numbers
  1322. ------------------------------
  1323. Each of the classes `cl_R', `cl_RA', `cl_F' defines the following
  1324. operation:
  1325. `cl_RA rational (const TYPE& x)'
  1326. Returns the value of `x' as an exact number. If `x' is already an
  1327. exact number, this is `x'. If `x' is a floating-point number, the
  1328. value is a rational number whose denominator is a power of 2.
  1329. In order to convert back, say, `(cl_F)(cl_R)"1/3"' to `1/3', there is
  1330. the function
  1331. `cl_RA rationalize (const cl_R& x)'
  1332. If `x' is a floating-point number, it actually represents an
  1333. interval of real numbers, and this function returns the rational
  1334. number with smallest denominator (and smallest numerator, in
  1335. magnitude) which lies in this interval. If `x' is already an
  1336. exact number, this function returns `x'.
  1337. If `x' is any float, one has
  1338. `cl_float(rational(x),x) = x'
  1339. `cl_float(rationalize(x),x) = x'
  1340. 
  1341. File: cln.info, Node: Random number generators, Next: Obfuscating operators, Prev: Conversion functions, Up: Functions on numbers
  1342. Random number generators
  1343. ========================
  1344. A random generator is a machine which produces (pseudo-)random numbers.
  1345. The include file `<cl_random.h>' defines a class `cl_random_state'
  1346. which contains the state of a random generator. If you make a copy of
  1347. the random number generator, the original one and the copy will produce
  1348. the same sequence of random numbers.
  1349. The following functions return (pseudo-)random numbers in different
  1350. formats. Calling one of these modifies the state of the random number
  1351. generator in a complicated but deterministic way.
  1352. The global variable
  1353. cl_random_state cl_default_random_state
  1354. contains a default random number generator. It is used when the
  1355. functions below are called without `cl_random_state' argument.
  1356. `uint32 random32 (cl_random_state& randomstate)'
  1357. `uint32 random32 ()'
  1358. Returns a random unsigned 32-bit number. All bits are equally
  1359. random.
  1360. `cl_I random_I (cl_random_state& randomstate, const cl_I& n)'
  1361. `cl_I random_I (const cl_I& n)'
  1362. `n' must be an integer > 0. This function returns a random integer
  1363. `x' in the range `0 <= x < n'.
  1364. `cl_F random_F (cl_random_state& randomstate, const cl_F& n)'
  1365. `cl_F random_F (const cl_F& n)'
  1366. `n' must be a float > 0. This function returns a random
  1367. floating-point number of the same format as `n' in the range `0 <=
  1368. x < n'.
  1369. `cl_R random_R (cl_random_state& randomstate, const cl_R& n)'
  1370. `cl_R random_R (const cl_R& n)'
  1371. Behaves like `random_I' if `n' is an integer and like `random_F'
  1372. if `n' is a float.
  1373. 
  1374. File: cln.info, Node: Obfuscating operators, Prev: Random number generators, Up: Functions on numbers
  1375. Obfuscating operators
  1376. =====================
  1377. The modifying C/C++ operators `+=', `-=', `*=', `/=', `&=', `|=', `^=',
  1378. `<<=', `>>=' are not available by default because their use tends to
  1379. make programs unreadable. It is trivial to get away without them.
  1380. However, if you feel that you absolutely need these operators to get
  1381. happy, then add
  1382. #define WANT_OBFUSCATING_OPERATORS
  1383. to the beginning of your source files, before the inclusion of any CLN
  1384. include files. This flag will enable the following operators:
  1385. For the classes `cl_N', `cl_R', `cl_RA', `cl_F', `cl_SF', `cl_FF',
  1386. `cl_DF', `cl_LF':
  1387. `TYPE& operator += (TYPE&, const TYPE&)'
  1388. `TYPE& operator -= (TYPE&, const TYPE&)'
  1389. `TYPE& operator *= (TYPE&, const TYPE&)'
  1390. `TYPE& operator /= (TYPE&, const TYPE&)'
  1391. For the class `cl_I':
  1392. `TYPE& operator += (TYPE&, const TYPE&)'
  1393. `TYPE& operator -= (TYPE&, const TYPE&)'
  1394. `TYPE& operator *= (TYPE&, const TYPE&)'
  1395. `TYPE& operator &= (TYPE&, const TYPE&)'
  1396. `TYPE& operator |= (TYPE&, const TYPE&)'
  1397. `TYPE& operator ^= (TYPE&, const TYPE&)'
  1398. `TYPE& operator <<= (TYPE&, const TYPE&)'
  1399. `TYPE& operator >>= (TYPE&, const TYPE&)'
  1400. For the classes `cl_N', `cl_R', `cl_RA', `cl_I', `cl_F', `cl_SF',
  1401. `cl_FF', `cl_DF', `cl_LF':
  1402. `TYPE& operator ++ (TYPE& x)'
  1403. The prefix operator `++x'.
  1404. `void operator ++ (TYPE& x, int)'
  1405. The postfix operator `x++'.
  1406. `TYPE& operator -- (TYPE& x)'
  1407. The prefix operator `--x'.
  1408. `void operator -- (TYPE& x, int)'
  1409. The postfix operator `x--'.
  1410. Note that by using these obfuscating operators, you wouldn't gain
  1411. efficiency: In CLN `x += y;' is exactly the same as `x = x+y;', not
  1412. more efficient.
  1413. 
  1414. File: cln.info, Node: Input/Output, Next: Rings, Prev: Functions on numbers, Up: Top
  1415. Input/Output
  1416. ************
  1417. * Menu:
  1418. * Internal and printed representation::
  1419. * Input functions::
  1420. * Output functions::
  1421. 
  1422. File: cln.info, Node: Internal and printed representation, Next: Input functions, Prev: Input/Output, Up: Input/Output
  1423. Internal and printed representation
  1424. ===================================
  1425. All computations deal with the internal representations of the numbers.
  1426. Every number has an external representation as a sequence of ASCII
  1427. characters. Several external representations may denote the same
  1428. number, for example, "20.0" and "20.000".
  1429. Converting an internal to an external representation is called
  1430. "printing", converting an external to an internal representation is
  1431. called "reading". In CLN, it is always true that conversion of an
  1432. internal to an external representation and then back to an internal
  1433. representation will yield the same internal representation.
  1434. Symbolically: `read(print(x)) == x'. This is called "print-read
  1435. consistency".
  1436. Different types of numbers have different external representations (case
  1437. is insignificant):
  1438. Integers
  1439. External representation: SIGN{DIGIT}+. The reader also accepts the
  1440. Common Lisp syntaxes SIGN{DIGIT}+`.' with a trailing dot for
  1441. decimal integers and the `#NR', `#b', `#o', `#x' prefixes.
  1442. Rational numbers
  1443. External representation: SIGN{DIGIT}+`/'{DIGIT}+. The `#NR',
  1444. `#b', `#o', `#x' prefixes are allowed here as well.
  1445. Floating-point numbers
  1446. External representation: SIGN{DIGIT}*EXPONENT or
  1447. SIGN{DIGIT}*`.'{DIGIT}*EXPONENT or SIGN{DIGIT}*`.'{DIGIT}+. A
  1448. precision specifier of the form _PREC may be appended. There must
  1449. be at least one digit in the non-exponent part. The exponent has
  1450. the syntax EXPMARKER EXPSIGN {DIGIT}+. The exponent marker is
  1451. `s' for short-floats,
  1452. `f' for single-floats,
  1453. `d' for double-floats,
  1454. `L' for long-floats,
  1455. or `e', which denotes a default float format. The precision
  1456. specifying suffix has the syntax _PREC where PREC denotes the
  1457. number of valid mantissa digits (in decimal, excluding leading
  1458. zeroes), cf. also function `cl_float_format'.
  1459. Complex numbers
  1460. External representation:
  1461. In algebraic notation: `REALPART+IMAGPARTi'. Of course, if
  1462. IMAGPART is negative, its printed representation begins with
  1463. a `-', and the `+' between REALPART and IMAGPART may be
  1464. omitted. Note that this notation cannot be used when the
  1465. IMAGPART is rational and the rational number's base is >18,
  1466. because the `i' is then read as a digit.
  1467. In Common Lisp notation: `#C(REALPART IMAGPART)'.
  1468. 
  1469. File: cln.info, Node: Input functions, Next: Output functions, Prev: Internal and printed representation, Up: Input/Output
  1470. Input functions
  1471. ===============
  1472. Including `<cl_io.h>' defines a type `cl_istream', which is the type of
  1473. the first argument to all input functions. Unless you build and use CLN
  1474. with the macro CL_IO_STDIO being defined, `cl_istream' is the same as
  1475. `istream&'.
  1476. The variable
  1477. `cl_istream cl_stdin' contains the standard input stream.
  1478. These are the simple input functions:
  1479. `int freadchar (cl_istream stream)'
  1480. Reads a character from `stream'. Returns `cl_EOF' (not a `char'!)
  1481. if the end of stream was encountered or an error occurred.
  1482. `int funreadchar (cl_istream stream, int c)'
  1483. Puts back `c' onto `stream'. `c' must be the result of the last
  1484. `freadchar' operation on `stream'.
  1485. Each of the classes `cl_N', `cl_R', `cl_RA', `cl_I', `cl_F', `cl_SF',
  1486. `cl_FF', `cl_DF', `cl_LF' defines, in `<cl_TYPE_io.h>', the following
  1487. input function:
  1488. `cl_istream operator>> (cl_istream stream, TYPE& result)'
  1489. Reads a number from `stream' and stores it in the `result'.
  1490. The most flexible input functions, defined in `<cl_TYPE_io.h>', are the
  1491. following:
  1492. `cl_N read_complex (cl_istream stream, const cl_read_flags& flags)'
  1493. `cl_R read_real (cl_istream stream, const cl_read_flags& flags)'
  1494. `cl_F read_float (cl_istream stream, const cl_read_flags& flags)'
  1495. `cl_RA read_rational (cl_istream stream, const cl_read_flags& flags)'
  1496. `cl_I read_integer (cl_istream stream, const cl_read_flags& flags)'
  1497. Reads a number from `stream'. The `flags' are parameters which
  1498. affect the input syntax. Whitespace before the number is silently
  1499. skipped.
  1500. `cl_N read_complex (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)'
  1501. `cl_R read_real (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)'
  1502. `cl_F read_float (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)'
  1503. `cl_RA read_rational (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)'
  1504. `cl_I read_integer (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse)'
  1505. Reads a number from a string in memory. The `flags' are parameters
  1506. which affect the input syntax. The string starts at `string' and
  1507. ends at `string_limit' (exclusive limit). `string_limit' may also
  1508. be `NULL', denoting the entire string, i.e. equivalent to
  1509. `string_limit = string + strlen(string)'. If `end_of_parse' is
  1510. `NULL', the string in memory must contain exactly one number and
  1511. nothing more, else a fatal error will be signalled. If
  1512. `end_of_parse' is not `NULL', `*end_of_parse' will be assigned a
  1513. pointer past the last parsed character (i.e. `string_limit' if
  1514. nothing came after the number). Whitespace is not allowed.
  1515. The structure `cl_read_flags' contains the following fields:
  1516. `cl_read_syntax_t syntax'
  1517. The possible results of the read operation. Possible values are
  1518. `syntax_number', `syntax_real', `syntax_rational',
  1519. `syntax_integer', `syntax_float', `syntax_sfloat',
  1520. `syntax_ffloat', `syntax_dfloat', `syntax_lfloat'.
  1521. `cl_read_lsyntax_t lsyntax'
  1522. Specifies the language-dependent syntax variant for the read
  1523. operation. Possible values are
  1524. `lsyntax_standard'
  1525. accept standard algebraic notation only, no complex numbers,
  1526. `lsyntax_algebraic'
  1527. accept the algebraic notation `X+Yi' for complex numbers,
  1528. `lsyntax_commonlisp'
  1529. accept the `#b', `#o', `#x' syntaxes for binary, octal,
  1530. hexadecimal numbers, `#BASER' for rational numbers in a given
  1531. base, `#c(REALPART IMAGPART)' for complex numbers,
  1532. `lsyntax_all'
  1533. accept all of these extensions.
  1534. `unsigned int rational_base'
  1535. The base in which rational numbers are read.
  1536. `cl_float_format_t float_flags.default_float_format'
  1537. The float format used when reading floats with exponent marker `e'.
  1538. `cl_float_format_t float_flags.default_lfloat_format'
  1539. The float format used when reading floats with exponent marker `l'.
  1540. `cl_boolean float_flags.mantissa_dependent_float_format'
  1541. When this flag is true, floats specified with more digits than
  1542. corresponding to the exponent marker they contain, but without
  1543. _NNN suffix, will get a precision corresponding to their number of
  1544. significant digits.
  1545. 
  1546. File: cln.info, Node: Output functions, Prev: Input functions, Up: Input/Output
  1547. Output functions
  1548. ================
  1549. Including `<cl_io.h>' defines a type `cl_ostream', which is the type of
  1550. the first argument to all output functions. Unless you build and use
  1551. CLN with the macro CL_IO_STDIO being defined, `cl_ostream' is the same
  1552. as `ostream&'.
  1553. The variable
  1554. `cl_ostream cl_stdout' contains the standard output stream.
  1555. The variable
  1556. `cl_ostream cl_stderr' contains the standard error output stream.
  1557. These are the simple output functions:
  1558. `void fprintchar (cl_ostream stream, char c)'
  1559. Prints the character `x' literally on the `stream'.
  1560. `void fprint (cl_ostream stream, const char * string)'
  1561. Prints the `string' literally on the `stream'.
  1562. `void fprintdecimal (cl_ostream stream, int x)'
  1563. `void fprintdecimal (cl_ostream stream, const cl_I& x)'
  1564. Prints the integer `x' in decimal on the `stream'.
  1565. `void fprintbinary (cl_ostream stream, const cl_I& x)'
  1566. Prints the integer `x' in binary (base 2, without prefix) on the
  1567. `stream'.
  1568. `void fprintoctal (cl_ostream stream, const cl_I& x)'
  1569. Prints the integer `x' in octal (base 8, without prefix) on the
  1570. `stream'.
  1571. `void fprinthexadecimal (cl_ostream stream, const cl_I& x)'
  1572. Prints the integer `x' in hexadecimal (base 16, without prefix) on
  1573. the `stream'.
  1574. Each of the classes `cl_N', `cl_R', `cl_RA', `cl_I', `cl_F', `cl_SF',
  1575. `cl_FF', `cl_DF', `cl_LF' defines, in `<cl_TYPE_io.h>', the following
  1576. output functions:
  1577. `void fprint (cl_ostream stream, const TYPE& x)'
  1578. `cl_ostream operator<< (cl_ostream stream, const TYPE& x)'
  1579. Prints the number `x' on the `stream'. The output may depend on
  1580. the global printer settings in the variable
  1581. `cl_default_print_flags'. The `ostream' flags and settings
  1582. (flags, width and locale) are ignored.
  1583. The most flexible output function, defined in `<cl_TYPE_io.h>', are the
  1584. following:
  1585. void print_complex (cl_ostream stream, const cl_print_flags& flags,
  1586. const cl_N& z);
  1587. void print_real (cl_ostream stream, const cl_print_flags& flags,
  1588. const cl_R& z);
  1589. void print_float (cl_ostream stream, const cl_print_flags& flags,
  1590. const cl_F& z);
  1591. void print_rational (cl_ostream stream, const cl_print_flags& flags,
  1592. const cl_RA& z);
  1593. void print_integer (cl_ostream stream, const cl_print_flags& flags,
  1594. const cl_I& z);
  1595. Prints the number `x' on the `stream'. The `flags' are parameters which
  1596. affect the output.
  1597. The structure type `cl_print_flags' contains the following fields:
  1598. `unsigned int rational_base'
  1599. The base in which rational numbers are printed. Default is `10'.
  1600. `cl_boolean rational_readably'
  1601. If this flag is true, rational numbers are printed with radix
  1602. specifiers in Common Lisp syntax (`#NR' or `#b' or `#o' or `#x'
  1603. prefixes, trailing dot). Default is false.
  1604. `cl_boolean float_readably'
  1605. If this flag is true, type specific exponent markers have
  1606. precedence over 'E'. Default is false.
  1607. `cl_float_format_t default_float_format'
  1608. Floating point numbers of this format will be printed using the
  1609. 'E' exponent marker. Default is `cl_float_format_ffloat'.
  1610. `cl_boolean complex_readably'
  1611. If this flag is true, complex numbers will be printed using the
  1612. Common Lisp syntax `#C(REALPART IMAGPART)'. Default is false.
  1613. `cl_string univpoly_varname'
  1614. Univariate polynomials with no explicit indeterminate name will be
  1615. printed using this variable name. Default is `"x"'.
  1616. The global variable `cl_default_print_flags' contains the default
  1617. values, used by the function `fprint'.
  1618. 
  1619. File: cln.info, Node: Rings, Next: Modular integers, Prev: Input/Output, Up: Top
  1620. Rings
  1621. *****
  1622. CLN has a class of abstract rings.
  1623. Ring
  1624. cl_ring
  1625. <cl_ring.h>
  1626. Rings can be compared for equality:
  1627. `bool operator== (const cl_ring&, const cl_ring&)'
  1628. `bool operator!= (const cl_ring&, const cl_ring&)'
  1629. These compare two rings for equality.
  1630. Given a ring `R', the following members can be used.
  1631. `void R->fprint (cl_ostream stream, const cl_ring_element& x)'
  1632. `cl_boolean R->equal (const cl_ring_element& x, const cl_ring_element& y)'
  1633. `cl_ring_element R->zero ()'
  1634. `cl_boolean R->zerop (const cl_ring_element& x)'
  1635. `cl_ring_element R->plus (const cl_ring_element& x, const cl_ring_element& y)'
  1636. `cl_ring_element R->minus (const cl_ring_element& x, const cl_ring_element& y)'
  1637. `cl_ring_element R->uminus (const cl_ring_element& x)'
  1638. `cl_ring_element R->one ()'
  1639. `cl_ring_element R->canonhom (const cl_I& x)'
  1640. `cl_ring_element R->mul (const cl_ring_element& x, const cl_ring_element& y)'
  1641. `cl_ring_element R->square (const cl_ring_element& x)'
  1642. `cl_ring_element R->expt_pos (const cl_ring_element& x, const cl_I& y)'
  1643. The following rings are built-in.
  1644. `cl_null_ring cl_0_ring'
  1645. The null ring, containing only zero.
  1646. `cl_complex_ring cl_C_ring'
  1647. The ring of complex numbers. This corresponds to the type `cl_N'.
  1648. `cl_real_ring cl_R_ring'
  1649. The ring of real numbers. This corresponds to the type `cl_R'.
  1650. `cl_rational_ring cl_RA_ring'
  1651. The ring of rational numbers. This corresponds to the type `cl_RA'.
  1652. `cl_integer_ring cl_I_ring'
  1653. The ring of integers. This corresponds to the type `cl_I'.
  1654. Type tests can be performed for any of `cl_C_ring', `cl_R_ring',
  1655. `cl_RA_ring', `cl_I_ring':
  1656. `cl_boolean instanceof (const cl_number& x, const cl_number_ring& R)'
  1657. Tests whether the given number is an element of the number ring R.
  1658. 
  1659. File: cln.info, Node: Modular integers, Next: Symbolic data types, Prev: Rings, Up: Top
  1660. Modular integers
  1661. ****************
  1662. * Menu:
  1663. * Modular integer rings::
  1664. * Functions on modular integers::
  1665. 
  1666. File: cln.info, Node: Modular integer rings, Next: Functions on modular integers, Prev: Modular integers, Up: Modular integers
  1667. Modular integer rings
  1668. =====================
  1669. CLN implements modular integers, i.e. integers modulo a fixed integer N.
  1670. The modulus is explicitly part of every modular integer. CLN doesn't
  1671. allow you to (accidentally) mix elements of different modular rings,
  1672. e.g. `(3 mod 4) + (2 mod 5)' will result in a runtime error. (Ideally
  1673. one would imagine a generic data type `cl_MI(N)', but C++ doesn't have
  1674. generic types. So one has to live with runtime checks.)
  1675. The class of modular integer rings is
  1676. Ring
  1677. cl_ring
  1678. <cl_ring.h>
  1679. |
  1680. |
  1681. Modular integer ring
  1682. cl_modint_ring
  1683. <cl_modinteger.h>
  1684. and the class of all modular integers (elements of modular integer
  1685. rings) is
  1686. Modular integer
  1687. cl_MI
  1688. <cl_modinteger.h>
  1689. Modular integer rings are constructed using the function
  1690. `cl_modint_ring cl_find_modint_ring (const cl_I& N)'
  1691. This function returns the modular ring `Z/NZ'. It takes care of
  1692. finding out about special cases of `N', like powers of two and odd
  1693. numbers for which Montgomery multiplication will be a win, and
  1694. precomputes any necessary auxiliary data for computing modulo `N'.
  1695. There is a cache table of rings, indexed by `N' (or, more
  1696. precisely, by `abs(N)'). This ensures that the precomputation
  1697. costs are reduced to a minimum.
  1698. Modular integer rings can be compared for equality:
  1699. `bool operator== (const cl_modint_ring&, const cl_modint_ring&)'
  1700. `bool operator!= (const cl_modint_ring&, const cl_modint_ring&)'
  1701. These compare two modular integer rings for equality. Two
  1702. different calls to `cl_find_modint_ring' with the same argument
  1703. necessarily return the same ring because it is memoized in the
  1704. cache table.
  1705. 
  1706. File: cln.info, Node: Functions on modular integers, Prev: Modular integer rings, Up: Modular integers
  1707. Functions on modular integers
  1708. =============================
  1709. Given a modular integer ring `R', the following members can be used.
  1710. `cl_I R->modulus'
  1711. This is the ring's modulus, normalized to be nonnegative: `abs(N)'.
  1712. `cl_MI R->zero()'
  1713. This returns `0 mod N'.
  1714. `cl_MI R->one()'
  1715. This returns `1 mod N'.
  1716. `cl_MI R->canonhom (const cl_I& x)'
  1717. This returns `x mod N'.
  1718. `cl_I R->retract (const cl_MI& x)'
  1719. This is a partial inverse function to `R->canonhom'. It returns the
  1720. standard representative (`>=0', `<N') of `x'.
  1721. `cl_MI R->random(cl_random_state& randomstate)'
  1722. `cl_MI R->random()'
  1723. This returns a random integer modulo `N'.
  1724. The following operations are defined on modular integers.
  1725. `cl_modint_ring x.ring ()'
  1726. Returns the ring to which the modular integer `x' belongs.
  1727. `cl_MI operator+ (const cl_MI&, const cl_MI&)'
  1728. Returns the sum of two modular integers. One of the arguments may
  1729. also be a plain integer.
  1730. `cl_MI operator- (const cl_MI&, const cl_MI&)'
  1731. Returns the difference of two modular integers. One of the
  1732. arguments may also be a plain integer.
  1733. `cl_MI operator- (const cl_MI&)'
  1734. Returns the negative of a modular integer.
  1735. `cl_MI operator* (const cl_MI&, const cl_MI&)'
  1736. Returns the product of two modular integers. One of the arguments
  1737. may also be a plain integer.
  1738. `cl_MI square (const cl_MI&)'
  1739. Returns the square of a modular integer.
  1740. `cl_MI recip (const cl_MI& x)'
  1741. Returns the reciprocal `x^-1' of a modular integer `x'. `x' must
  1742. be coprime to the modulus, otherwise an error message is issued.
  1743. `cl_MI div (const cl_MI& x, const cl_MI& y)'
  1744. Returns the quotient `x*y^-1' of two modular integers `x', `y'.
  1745. `y' must be coprime to the modulus, otherwise an error message is
  1746. issued.
  1747. `cl_MI expt_pos (const cl_MI& x, const cl_I& y)'
  1748. `y' must be > 0. Returns `x^y'.
  1749. `cl_MI expt (const cl_MI& x, const cl_I& y)'
  1750. Returns `x^y'. If `y' is negative, `x' must be coprime to the
  1751. modulus, else an error message is issued.
  1752. `cl_MI operator<< (const cl_MI& x, const cl_I& y)'
  1753. Returns `x*2^y'.
  1754. `cl_MI operator>> (const cl_MI& x, const cl_I& y)'
  1755. Returns `x*2^-y'. When `y' is positive, the modulus must be odd,
  1756. or an error message is issued.
  1757. `bool operator== (const cl_MI&, const cl_MI&)'
  1758. `bool operator!= (const cl_MI&, const cl_MI&)'
  1759. Compares two modular integers, belonging to the same modular
  1760. integer ring, for equality.
  1761. `cl_boolean zerop (const cl_MI& x)'
  1762. Returns true if `x' is `0 mod N'.
  1763. The following output functions are defined (see also the chapter on
  1764. input/output).
  1765. `void fprint (cl_ostream stream, const cl_MI& x)'
  1766. `cl_ostream operator<< (cl_ostream stream, const cl_MI& x)'
  1767. Prints the modular integer `x' on the `stream'. The output may
  1768. depend on the global printer settings in the variable
  1769. `cl_default_print_flags'.
  1770. 
  1771. File: cln.info, Node: Symbolic data types, Next: Univariate polynomials, Prev: Modular integers, Up: Top
  1772. Symbolic data types
  1773. *******************
  1774. CLN implements two symbolic (non-numeric) data types: strings and
  1775. symbols.
  1776. * Menu:
  1777. * Strings::
  1778. * Symbols::
  1779. 
  1780. File: cln.info, Node: Strings, Next: Symbols, Prev: Symbolic data types, Up: Symbolic data types
  1781. Strings
  1782. =======
  1783. The class
  1784. String
  1785. cl_string
  1786. <cl_string.h>
  1787. implements immutable strings.
  1788. Strings are constructed through the following constructors:
  1789. `cl_string (const char * s)'
  1790. Returns an immutable copy of the (zero-terminated) C string `s'.
  1791. `cl_string (const char * ptr, unsigned long len)'
  1792. Returns an immutable copy of the `len' characters at `ptr[0]',
  1793. ..., `ptr[len-1]'. NUL characters are allowed.
  1794. The following functions are available on strings:
  1795. `operator ='
  1796. Assignment from `cl_string' and `const char *'.
  1797. `s.length()'
  1798. `strlen(s)'
  1799. Returns the length of the string `s'.
  1800. `s[i]'
  1801. Returns the `i'th character of the string `s'. `i' must be in the
  1802. range `0 <= i < s.length()'.
  1803. `bool equal (const cl_string& s1, const cl_string& s2)'
  1804. Compares two strings for equality. One of the arguments may also
  1805. be a plain `const char *'.
  1806. 
  1807. File: cln.info, Node: Symbols, Prev: Strings, Up: Symbolic data types
  1808. Symbols
  1809. =======
  1810. Symbols are uniquified strings: all symbols with the same name are
  1811. shared. This means that comparison of two symbols is fast (effectively
  1812. just a pointer comparison), whereas comparison of two strings must in
  1813. the worst case walk both strings until their end. Symbols are used,
  1814. for example, as tags for properties, as names of variables in
  1815. polynomial rings, etc.
  1816. Symbols are constructed through the following constructor:
  1817. `cl_symbol (const cl_string& s)'
  1818. Looks up or creates a new symbol with a given name.
  1819. The following operations are available on symbols:
  1820. `cl_string (const cl_symbol& sym)'
  1821. Conversion to `cl_string': Returns the string which names the
  1822. symbol `sym'.
  1823. `bool equal (const cl_symbol& sym1, const cl_symbol& sym2)'
  1824. Compares two symbols for equality. This is very fast.
  1825. 
  1826. File: cln.info, Node: Univariate polynomials, Next: Internals, Prev: Symbolic data types, Up: Top
  1827. Univariate polynomials
  1828. **********************
  1829. * Menu:
  1830. * Univariate polynomial rings::
  1831. * Functions on univariate polynomials::
  1832. * Special polynomials::
  1833. 
  1834. File: cln.info, Node: Univariate polynomial rings, Next: Functions on univariate polynomials, Prev: Univariate polynomials, Up: Univariate polynomials
  1835. Univariate polynomial rings
  1836. ===========================
  1837. CLN implements univariate polynomials (polynomials in one variable)
  1838. over an arbitrary ring. The indeterminate variable may be either
  1839. unnamed (and will be printed according to
  1840. `cl_default_print_flags.univpoly_varname', which defaults to `x') or
  1841. carry a given name. The base ring and the indeterminate are explicitly
  1842. part of every polynomial. CLN doesn't allow you to (accidentally) mix
  1843. elements of different polynomial rings, e.g. `(a^2+1) * (b^3-1)' will
  1844. result in a runtime error. (Ideally this should return a multivariate
  1845. polynomial, but they are not yet implemented in CLN.)
  1846. The classes of univariate polynomial rings are
  1847. Ring
  1848. cl_ring
  1849. <cl_ring.h>
  1850. |
  1851. |
  1852. Univariate polynomial ring
  1853. cl_univpoly_ring
  1854. <cl_univpoly.h>
  1855. |
  1856. +----------------+-------------------+
  1857. | | |
  1858. Complex polynomial ring | Modular integer polynomial ring
  1859. cl_univpoly_complex_ring | cl_univpoly_modint_ring
  1860. <cl_univpoly_complex.h> | <cl_univpoly_modint.h>
  1861. |
  1862. +----------------+
  1863. | |
  1864. Real polynomial ring |
  1865. cl_univpoly_real_ring |
  1866. <cl_univpoly_real.h> |
  1867. |
  1868. +----------------+
  1869. | |
  1870. Rational polynomial ring |
  1871. cl_univpoly_rational_ring |
  1872. <cl_univpoly_rational.h> |
  1873. |
  1874. +----------------+
  1875. |
  1876. Integer polynomial ring
  1877. cl_univpoly_integer_ring
  1878. <cl_univpoly_integer.h>
  1879. and the corresponding classes of univariate polynomials are
  1880. Univariate polynomial
  1881. cl_UP
  1882. <cl_univpoly.h>
  1883. |
  1884. +----------------+-------------------+
  1885. | | |
  1886. Complex polynomial | Modular integer polynomial
  1887. cl_UP_N | cl_UP_MI
  1888. <cl_univpoly_complex.h> | <cl_univpoly_modint.h>
  1889. |
  1890. +----------------+
  1891. | |
  1892. Real polynomial |
  1893. cl_UP_R |
  1894. <cl_univpoly_real.h> |
  1895. |
  1896. +----------------+
  1897. | |
  1898. Rational polynomial |
  1899. cl_UP_RA |
  1900. <cl_univpoly_rational.h> |
  1901. |
  1902. +----------------+
  1903. |
  1904. Integer polynomial
  1905. cl_UP_I
  1906. <cl_univpoly_integer.h>
  1907. Univariate polynomial rings are constructed using the functions
  1908. `cl_univpoly_ring cl_find_univpoly_ring (const cl_ring& R)'
  1909. `cl_univpoly_ring cl_find_univpoly_ring (const cl_ring& R, const cl_symbol& varname)'
  1910. This function returns the polynomial ring `R[X]', unnamed or named.
  1911. `R' may be an arbitrary ring. This function takes care of finding
  1912. out about special cases of `R', such as the rings of complex
  1913. numbers, real numbers, rational numbers, integers, or modular
  1914. integer rings. There is a cache table of rings, indexed by `R'
  1915. and `varname'. This ensures that two calls of this function with
  1916. the same arguments will return the same polynomial ring.
  1917. `cl_univpoly_complex_ring cl_find_univpoly_ring (const cl_complex_ring& R)'
  1918. `cl_univpoly_complex_ring cl_find_univpoly_ring (const cl_complex_ring& R, const cl_symbol& varname)'
  1919. `cl_univpoly_real_ring cl_find_univpoly_ring (const cl_real_ring& R)'
  1920. `cl_univpoly_real_ring cl_find_univpoly_ring (const cl_real_ring& R, const cl_symbol& varname)'
  1921. `cl_univpoly_rational_ring cl_find_univpoly_ring (const cl_rational_ring& R)'
  1922. `cl_univpoly_rational_ring cl_find_univpoly_ring (const cl_rational_ring& R, const cl_symbol& varname)'
  1923. `cl_univpoly_integer_ring cl_find_univpoly_ring (const cl_integer_ring& R)'
  1924. `cl_univpoly_integer_ring cl_find_univpoly_ring (const cl_integer_ring& R, const cl_symbol& varname)'
  1925. `cl_univpoly_modint_ring cl_find_univpoly_ring (const cl_modint_ring& R)'
  1926. `cl_univpoly_modint_ring cl_find_univpoly_ring (const cl_modint_ring& R, const cl_symbol& varname)'
  1927. These functions are equivalent to the general
  1928. `cl_find_univpoly_ring', only the return type is more specific,
  1929. according to the base ring's type.
  1930. 
  1931. File: cln.info, Node: Functions on univariate polynomials, Next: Special polynomials, Prev: Univariate polynomial rings, Up: Univariate polynomials
  1932. Functions on univariate polynomials
  1933. ===================================
  1934. Given a univariate polynomial ring `R', the following members can be
  1935. used.
  1936. `cl_ring R->basering()'
  1937. This returns the base ring, as passed to `cl_find_univpoly_ring'.
  1938. `cl_UP R->zero()'
  1939. This returns `0 in R', a polynomial of degree -1.
  1940. `cl_UP R->one()'
  1941. This returns `1 in R', a polynomial of degree <= 0.
  1942. `cl_UP R->canonhom (const cl_I& x)'
  1943. This returns `x in R', a polynomial of degree <= 0.
  1944. `cl_UP R->monomial (const cl_ring_element& x, uintL e)'
  1945. This returns a sparse polynomial: `x * X^e', where `X' is the
  1946. indeterminate.
  1947. `cl_UP R->create (sintL degree)'
  1948. Creates a new polynomial with a given degree. The zero polynomial
  1949. has degree `-1'. After creating the polynomial, you should put in
  1950. the coefficients, using the `set_coeff' member function, and then
  1951. call the `finalize' member function.
  1952. The following are the only destructive operations on univariate
  1953. polynomials.
  1954. `void set_coeff (cl_UP& x, uintL index, const cl_ring_element& y)'
  1955. This changes the coefficient of `X^index' in `x' to be `y'. After
  1956. changing a polynomial and before applying any "normal" operation
  1957. on it, you should call its `finalize' member function.
  1958. `void finalize (cl_UP& x)'
  1959. This function marks the endpoint of destructive modifications of a
  1960. polynomial. It normalizes the internal representation so that
  1961. subsequent computations have less overhead. Doing normal
  1962. computations on unnormalized polynomials may produce wrong results
  1963. or crash the program.
  1964. The following operations are defined on univariate polynomials.
  1965. `cl_univpoly_ring x.ring ()'
  1966. Returns the ring to which the univariate polynomial `x' belongs.
  1967. `cl_UP operator+ (const cl_UP&, const cl_UP&)'
  1968. Returns the sum of two univariate polynomials.
  1969. `cl_UP operator- (const cl_UP&, const cl_UP&)'
  1970. Returns the difference of two univariate polynomials.
  1971. `cl_UP operator- (const cl_UP&)'
  1972. Returns the negative of a univariate polynomial.
  1973. `cl_UP operator* (const cl_UP&, const cl_UP&)'
  1974. Returns the product of two univariate polynomials. One of the
  1975. arguments may also be a plain integer or an element of the base
  1976. ring.
  1977. `cl_UP square (const cl_UP&)'
  1978. Returns the square of a univariate polynomial.
  1979. `cl_UP expt_pos (const cl_UP& x, const cl_I& y)'
  1980. `y' must be > 0. Returns `x^y'.
  1981. `bool operator== (const cl_UP&, const cl_UP&)'
  1982. `bool operator!= (const cl_UP&, const cl_UP&)'
  1983. Compares two univariate polynomials, belonging to the same
  1984. univariate polynomial ring, for equality.
  1985. `cl_boolean zerop (const cl_UP& x)'
  1986. Returns true if `x' is `0 in R'.
  1987. `sintL degree (const cl_UP& x)'
  1988. Returns the degree of the polynomial. The zero polynomial has
  1989. degree `-1'.
  1990. `cl_ring_element coeff (const cl_UP& x, uintL index)'
  1991. Returns the coefficient of `X^index' in the polynomial `x'.
  1992. `cl_ring_element x (const cl_ring_element& y)'
  1993. Evaluation: If `x' is a polynomial and `y' belongs to the base
  1994. ring, then `x(y)' returns the value of the substitution of `y' into
  1995. `x'.
  1996. `cl_UP deriv (const cl_UP& x)'
  1997. Returns the derivative of the polynomial `x' with respect to the
  1998. indeterminate `X'.
  1999. The following output functions are defined (see also the chapter on
  2000. input/output).
  2001. `void fprint (cl_ostream stream, const cl_UP& x)'
  2002. `cl_ostream operator<< (cl_ostream stream, const cl_UP& x)'
  2003. Prints the univariate polynomial `x' on the `stream'. The output
  2004. may depend on the global printer settings in the variable
  2005. `cl_default_print_flags'.
  2006. 
  2007. File: cln.info, Node: Special polynomials, Prev: Functions on univariate polynomials, Up: Univariate polynomials
  2008. Special polynomials
  2009. ===================
  2010. The following functions return special polynomials.
  2011. `cl_UP_I cl_tschebychev (sintL n)'
  2012. Returns the n-th Tchebychev polynomial (n >= 0).
  2013. `cl_UP_I cl_hermite (sintL n)'
  2014. Returns the n-th Hermite polynomial (n >= 0).
  2015. `cl_UP_RA cl_legendre (sintL n)'
  2016. Returns the n-th Legendre polynomial (n >= 0).
  2017. `cl_UP_I cl_laguerre (sintL n)'
  2018. Returns the n-th Laguerre polynomial (n >= 0).
  2019. Information how to derive the differential equation satisfied by each
  2020. of these polynomials from their definition can be found in the
  2021. `doc/polynomial/' directory.
  2022. 
  2023. File: cln.info, Node: Internals, Next: Using the library, Prev: Univariate polynomials, Up: Top
  2024. Internals
  2025. *********
  2026. * Menu:
  2027. * Why C++ ?::
  2028. * Memory efficiency::
  2029. * Speed efficiency::
  2030. * Garbage collection::
  2031. 
  2032. File: cln.info, Node: Why C++ ?, Next: Memory efficiency, Prev: Internals, Up: Internals
  2033. Why C++ ?
  2034. =========
  2035. Using C++ as an implementation language provides
  2036. * Efficiency: It compiles to machine code.
  2037. * Portability: It runs on all platforms supporting a C++ compiler.
  2038. Because of the availability of GNU C++, this includes all
  2039. currently used 32-bit and 64-bit platforms, independently of the
  2040. quality of the vendor's C++ compiler.
  2041. * Type safety: The C++ compilers knows about the number types and
  2042. complains if, for example, you try to assign a float to an integer
  2043. variable. However, a drawback is that C++ doesn't know about
  2044. generic types, hence a restriction like that `operator+ (const
  2045. cl_MI&, const cl_MI&)' requires that both arguments belong to the
  2046. same modular ring cannot be expressed as a compile-time
  2047. information.
  2048. * Algebraic syntax: The elementary operations `+', `-', `*', `=',
  2049. `==', ... can be used in infix notation, which is more convenient
  2050. than Lisp notation `(+ x y)' or C notation `add(x,y,&z)'.
  2051. With these language features, there is no need for two separate
  2052. languages, one for the implementation of the library and one in which
  2053. the library's users can program. This means that a prototype
  2054. implementation of an algorithm can be integrated into the library
  2055. immediately after it has been tested and debugged. No need to rewrite
  2056. it in a low-level language after having prototyped in a high-level
  2057. language.
  2058. 
  2059. File: cln.info, Node: Memory efficiency, Next: Speed efficiency, Prev: Why C++ ?, Up: Internals
  2060. Memory efficiency
  2061. =================
  2062. In order to save memory allocations, CLN implements:
  2063. * Object sharing: An operation like `x+0' returns `x' without copying
  2064. it.
  2065. * Garbage collection: A reference counting mechanism makes sure that
  2066. any number object's storage is freed immediately when the last
  2067. reference to the object is gone.
  2068. * Small integers are represented as immediate values instead of
  2069. pointers to heap allocated storage. This means that integers `>
  2070. -2^29', `< 2^29' don't consume heap memory, unless they were
  2071. explicitly allocated on the heap.
  2072. 
  2073. File: cln.info, Node: Speed efficiency, Next: Garbage collection, Prev: Memory efficiency, Up: Internals
  2074. Speed efficiency
  2075. ================
  2076. Speed efficiency is obtained by the combination of the following tricks
  2077. and algorithms:
  2078. * Small integers, being represented as immediate values, don't
  2079. require memory access, just a couple of instructions for each
  2080. elementary operation.
  2081. * The kernel of CLN has been written in assembly language for some
  2082. CPUs (`i386', `m68k', `sparc', `mips', `arm').
  2083. * On all CPUs, CLN may be configured to use the superefficient
  2084. low-level routines from GNU GMP version 3.
  2085. * For large numbers, CLN uses, instead of the standard `O(N^2)'
  2086. algorithm, the Karatsuba multiplication, which is an `O(N^1.6)'
  2087. algorithm.
  2088. * For very large numbers (more than 12000 decimal digits), CLN uses
  2089. Sch�nhage-Strassen multiplication, which is an asymptotically
  2090. optimal multiplication algorithm.
  2091. * These fast multiplication algorithms also give improvements in the
  2092. speed of division and radix conversion.
  2093. 
  2094. File: cln.info, Node: Garbage collection, Prev: Speed efficiency, Up: Internals
  2095. Garbage collection
  2096. ==================
  2097. All the number classes are reference count classes: They only contain a
  2098. pointer to an object in the heap. Upon construction, assignment and
  2099. destruction of number objects, only the objects' reference count are
  2100. manipulated.
  2101. Memory occupied by number objects are automatically reclaimed as soon as
  2102. their reference count drops to zero.
  2103. For number rings, another strategy is implemented: There is a cache of,
  2104. for example, the modular integer rings. A modular integer ring is
  2105. destroyed only if its reference count dropped to zero and the cache is
  2106. about to be resized. The effect of this strategy is that recently used
  2107. rings remain cached, whereas undue memory consumption through cached
  2108. rings is avoided.
  2109. 
  2110. File: cln.info, Node: Using the library, Next: Customizing, Prev: Internals, Up: Top
  2111. Using the library
  2112. *****************
  2113. For the following discussion, we will assume that you have installed
  2114. the CLN source in `$CLN_DIR' and built it in `$CLN_TARGETDIR'. For
  2115. example, for me it's `CLN_DIR="$HOME/cln"' and
  2116. `CLN_TARGETDIR="$HOME/cln/linuxelf"'. You might define these as
  2117. environment variables, or directly substitute the appropriate values.
  2118. * Menu:
  2119. * Compiler options::
  2120. * Include files::
  2121. * An Example::
  2122. * Debugging support::
  2123. 
  2124. File: cln.info, Node: Compiler options, Next: Include files, Prev: Using the library, Up: Using the library
  2125. Compiler options
  2126. ================
  2127. Until you have installed CLN in a public place, the following options
  2128. are needed:
  2129. When you compile CLN application code, add the flags
  2130. -I$CLN_DIR/include -I$CLN_TARGETDIR/include
  2131. to the C++ compiler's command line (`make' variable CFLAGS or CXXFLAGS).
  2132. When you link CLN application code to form an executable, add the flags
  2133. $CLN_TARGETDIR/src/libcln.a
  2134. to the C/C++ compiler's command line (`make' variable LIBS).
  2135. If you did a `make install', the include files are installed in a
  2136. public directory (normally `/usr/local/include'), hence you don't need
  2137. special flags for compiling. The library has been installed to a public
  2138. directory as well (normally `/usr/local/lib'), hence when linking a CLN
  2139. application it is sufficient to give the flag `-lcln'.
  2140. 
  2141. File: cln.info, Node: Include files, Next: An Example, Prev: Compiler options, Up: Using the library
  2142. Include files
  2143. =============
  2144. Here is a summary of the include files and their contents.
  2145. `<cl_object.h>'
  2146. General definitions, reference counting, garbage collection.
  2147. `<cl_number.h>'
  2148. The class cl_number.
  2149. `<cl_complex.h>'
  2150. Functions for class cl_N, the complex numbers.
  2151. `<cl_real.h>'
  2152. Functions for class cl_R, the real numbers.
  2153. `<cl_float.h>'
  2154. Functions for class cl_F, the floats.
  2155. `<cl_sfloat.h>'
  2156. Functions for class cl_SF, the short-floats.
  2157. `<cl_ffloat.h>'
  2158. Functions for class cl_FF, the single-floats.
  2159. `<cl_dfloat.h>'
  2160. Functions for class cl_DF, the double-floats.
  2161. `<cl_lfloat.h>'
  2162. Functions for class cl_LF, the long-floats.
  2163. `<cl_rational.h>'
  2164. Functions for class cl_RA, the rational numbers.
  2165. `<cl_integer.h>'
  2166. Functions for class cl_I, the integers.
  2167. `<cl_io.h>'
  2168. Input/Output.
  2169. `<cl_complex_io.h>'
  2170. Input/Output for class cl_N, the complex numbers.
  2171. `<cl_real_io.h>'
  2172. Input/Output for class cl_R, the real numbers.
  2173. `<cl_float_io.h>'
  2174. Input/Output for class cl_F, the floats.
  2175. `<cl_sfloat_io.h>'
  2176. Input/Output for class cl_SF, the short-floats.
  2177. `<cl_ffloat_io.h>'
  2178. Input/Output for class cl_FF, the single-floats.
  2179. `<cl_dfloat_io.h>'
  2180. Input/Output for class cl_DF, the double-floats.
  2181. `<cl_lfloat_io.h>'
  2182. Input/Output for class cl_LF, the long-floats.
  2183. `<cl_rational_io.h>'
  2184. Input/Output for class cl_RA, the rational numbers.
  2185. `<cl_integer_io.h>'
  2186. Input/Output for class cl_I, the integers.
  2187. `<cl_input.h>'
  2188. Flags for customizing input operations.
  2189. `<cl_output.h>'
  2190. Flags for customizing output operations.
  2191. `<cl_malloc.h>'
  2192. `cl_malloc_hook', `cl_free_hook'.
  2193. `<cl_abort.h>'
  2194. `cl_abort'.
  2195. `<cl_condition.h>'
  2196. Conditions/exceptions.
  2197. `<cl_string.h>'
  2198. Strings.
  2199. `<cl_symbol.h>'
  2200. Symbols.
  2201. `<cl_proplist.h>'
  2202. Property lists.
  2203. `<cl_ring.h>'
  2204. General rings.
  2205. `<cl_null_ring.h>'
  2206. The null ring.
  2207. `<cl_complex_ring.h>'
  2208. The ring of complex numbers.
  2209. `<cl_real_ring.h>'
  2210. The ring of real numbers.
  2211. `<cl_rational_ring.h>'
  2212. The ring of rational numbers.
  2213. `<cl_integer_ring.h>'
  2214. The ring of integers.
  2215. `<cl_numtheory.h>'
  2216. Number threory functions.
  2217. `<cl_modinteger.h>'
  2218. Modular integers.
  2219. `<cl_V.h>'
  2220. Vectors.
  2221. `<cl_GV.h>'
  2222. General vectors.
  2223. `<cl_GV_number.h>'
  2224. General vectors over cl_number.
  2225. `<cl_GV_complex.h>'
  2226. General vectors over cl_N.
  2227. `<cl_GV_real.h>'
  2228. General vectors over cl_R.
  2229. `<cl_GV_rational.h>'
  2230. General vectors over cl_RA.
  2231. `<cl_GV_integer.h>'
  2232. General vectors over cl_I.
  2233. `<cl_GV_modinteger.h>'
  2234. General vectors of modular integers.
  2235. `<cl_SV.h>'
  2236. Simple vectors.
  2237. `<cl_SV_number.h>'
  2238. Simple vectors over cl_number.
  2239. `<cl_SV_complex.h>'
  2240. Simple vectors over cl_N.
  2241. `<cl_SV_real.h>'
  2242. Simple vectors over cl_R.
  2243. `<cl_SV_rational.h>'
  2244. Simple vectors over cl_RA.
  2245. `<cl_SV_integer.h>'
  2246. Simple vectors over cl_I.
  2247. `<cl_SV_ringelt.h>'
  2248. Simple vectors of general ring elements.
  2249. `<cl_univpoly.h>'
  2250. Univariate polynomials.
  2251. `<cl_univpoly_integer.h>'
  2252. Univariate polynomials over the integers.
  2253. `<cl_univpoly_rational.h>'
  2254. Univariate polynomials over the rational numbers.
  2255. `<cl_univpoly_real.h>'
  2256. Univariate polynomials over the real numbers.
  2257. `<cl_univpoly_complex.h>'
  2258. Univariate polynomials over the complex numbers.
  2259. `<cl_univpoly_modint.h>'
  2260. Univariate polynomials over modular integer rings.
  2261. `<cl_timing.h>'
  2262. Timing facilities.
  2263. `<cln.h>'
  2264. Includes all of the above.
  2265. 
  2266. File: cln.info, Node: An Example, Next: Debugging support, Prev: Include files, Up: Using the library
  2267. An Example
  2268. ==========
  2269. A function which computes the nth Fibonacci number can be written as
  2270. follows.
  2271. #include <cl_integer.h>
  2272. #include <cl_real.h>
  2273. // Returns F_n, computed as the nearest integer to
  2274. // ((1+sqrt(5))/2)^n/sqrt(5). Assume n>=0.
  2275. const cl_I fibonacci (int n)
  2276. {
  2277. // Need a precision of ((1+sqrt(5))/2)^-n.
  2278. cl_float_format_t prec = cl_float_format((int)(0.208987641*n+5));
  2279. cl_R sqrt5 = sqrt(cl_float(5,prec));
  2280. cl_R phi = (1+sqrt5)/2;
  2281. return round1( expt(phi,n)/sqrt5 );
  2282. }
  2283. Let's explain what is going on in detail.
  2284. The include file `<cl_integer.h>' is necessary because the type `cl_I'
  2285. is used in the function, and the include file `<cl_real.h>' is needed
  2286. for the type `cl_R' and the floating point number functions. The order
  2287. of the include files does not matter.
  2288. Then comes the function declaration. The argument is an `int', the
  2289. result an integer. The return type is defined as `const cl_I', not
  2290. simply `cl_I', because that allows the compiler to detect typos like
  2291. `fibonacci(n) = 100'. It would be possible to declare the return type
  2292. as `const cl_R' (real number) or even `const cl_N' (complex number). We
  2293. use the most specialized possible return type because functions which
  2294. call `fibonacci' will be able to profit from the compiler's type
  2295. analysis: Adding two integers is slightly more efficient than adding the
  2296. same objects declared as complex numbers, because it needs less type
  2297. dispatch. Also, when linking to CLN as a non-shared library, this
  2298. minimizes the size of the resulting executable program.
  2299. The result will be computed as expt(phi,n)/sqrt(5), rounded to the
  2300. nearest integer. In order to get a correct result, the absolute error
  2301. should be less than 1/2, i.e. the relative error should be less than
  2302. sqrt(5)/(2*expt(phi,n)). To this end, the first line computes a
  2303. floating point precision for sqrt(5) and phi.
  2304. Then sqrt(5) is computed by first converting the integer 5 to a
  2305. floating point number and than taking the square root. The converse,
  2306. first taking the square root of 5, and then converting to the desired
  2307. precision, would not work in CLN: The square root would be computed to
  2308. a default precision (normally single-float precision), and the
  2309. following conversion could not help about the lacking accuracy. This is
  2310. because CLN is not a symbolic computer algebra system and does not
  2311. represent sqrt(5) in a non-numeric way.
  2312. The type `cl_R' for sqrt5 and, in the following line, phi is the only
  2313. possible choice. You cannot write `cl_F' because the C++ compiler can
  2314. only infer that `cl_float(5,prec)' is a real number. You cannot write
  2315. `cl_N' because a `round1' does not exist for general complex numbers.
  2316. When the function returns, all the local variables in the function are
  2317. automatically reclaimed (garbage collected). Only the result survives
  2318. and gets passed to the caller.
  2319. The file `fibonacci.cc' in the subdirectory `examples' contains this
  2320. implementation together with an even faster algorithm.
  2321. 
  2322. File: cln.info, Node: Debugging support, Prev: An Example, Up: Using the library
  2323. Debugging support
  2324. =================
  2325. When debugging a CLN application with GNU `gdb', two facilities are
  2326. available from the library:
  2327. * The library does type checks, range checks, consistency checks at
  2328. many places. When one of these fails, the function `cl_abort()' is
  2329. called. Its default implementation is to perform an `exit(1)', so
  2330. you won't have a core dump. But for debugging, it is best to set a
  2331. breakpoint at this function:
  2332. (gdb) break cl_abort
  2333. When this breakpoint is hit, look at the stack's backtrace:
  2334. (gdb) where
  2335. * The debugger's normal `print' command doesn't know about CLN's
  2336. types and therefore prints mostly useless hexadecimal addresses.
  2337. CLN offers a function `cl_print', callable from the debugger, for
  2338. printing number objects. In order to get this function, you have
  2339. to define the macro `CL_DEBUG' and then include all the header
  2340. files for which you want `cl_print' debugging support. For example:
  2341. #define CL_DEBUG
  2342. #include <cl_string.h>
  2343. Now, if you have in your program a variable `cl_string s', and
  2344. inspect it under `gdb', the output may look like this:
  2345. (gdb) print s
  2346. $7 = {<cl_gcpointer> = { = {pointer = 0x8055b60, heappointer = 0x8055b60,
  2347. word = 134568800}}, }
  2348. (gdb) call cl_print(s)
  2349. (cl_string) ""
  2350. $8 = 134568800
  2351. Note that the output of `cl_print' goes to the program's error
  2352. output, not to gdb's standard output.
  2353. Note, however, that the above facility does not work with all CLN
  2354. types, only with number objects and similar. Therefore CLN offers
  2355. a member function `debug_print()' on all CLN types. The same macro
  2356. `CL_DEBUG' is needed for this member function to be implemented.
  2357. Under `gdb', you call it like this:
  2358. (gdb) print s
  2359. $7 = {<cl_gcpointer> = { = {pointer = 0x8055b60, heappointer = 0x8055b60,
  2360. word = 134568800}}, }
  2361. (gdb) call s.debug_print()
  2362. (cl_string) ""
  2363. (gdb) define cprint
  2364. >call ($1).debug_print()
  2365. >end
  2366. (gdb) cprint s
  2367. (cl_string) ""
  2368. Unfortunately, this feature does not seem to work under all
  2369. circumstances.
  2370. 
  2371. File: cln.info, Node: Customizing, Next: Index, Prev: Using the library, Up: Top
  2372. Customizing
  2373. ***********
  2374. * Menu:
  2375. * Error handling::
  2376. * Floating-point underflow::
  2377. * Customizing I/O::
  2378. * Customizing the memory allocator::
  2379. 
  2380. File: cln.info, Node: Error handling, Next: Floating-point underflow, Prev: Customizing, Up: Customizing
  2381. Error handling
  2382. ==============
  2383. When a fatal error occurs, an error message is output to the standard
  2384. error output stream, and the function `cl_abort' is called. The default
  2385. version of this function (provided in the library) terminates the
  2386. application. To catch such a fatal error, you need to define the
  2387. function `cl_abort' yourself, with the prototype
  2388. #include <cl_abort.h>
  2389. void cl_abort (void);
  2390. This function must not return control to its caller.
  2391. 
  2392. File: cln.info, Node: Floating-point underflow, Next: Customizing I/O, Prev: Error handling, Up: Customizing
  2393. Floating-point underflow
  2394. ========================
  2395. Floating point underflow denotes the situation when a floating-point
  2396. number is to be created which is so close to `0' that its exponent is
  2397. too low to be represented internally. By default, this causes a fatal
  2398. error. If you set the global variable
  2399. cl_boolean cl_inhibit_floating_point_underflow
  2400. to `cl_true', the error will be inhibited, and a floating-point zero
  2401. will be generated instead. The default value of
  2402. `cl_inhibit_floating_point_underflow' is `cl_false'.
  2403. 
  2404. File: cln.info, Node: Customizing I/O, Next: Customizing the memory allocator, Prev: Floating-point underflow, Up: Customizing
  2405. Customizing I/O
  2406. ===============
  2407. The output of the function `fprint' may be customized by changing the
  2408. value of the global variable `cl_default_print_flags'.
  2409. 
  2410. File: cln.info, Node: Customizing the memory allocator, Prev: Customizing I/O, Up: Customizing
  2411. Customizing the memory allocator
  2412. ================================
  2413. Every memory allocation of CLN is done through the function pointer
  2414. `cl_malloc_hook'. Freeing of this memory is done through the function
  2415. pointer `cl_free_hook'. The default versions of these functions,
  2416. provided in the library, call `malloc' and `free' and check the
  2417. `malloc' result against `NULL'. If you want to provide another memory
  2418. allocator, you need to define the variables `cl_malloc_hook' and
  2419. `cl_free_hook' yourself, like this:
  2420. #include <cl_malloc.h>
  2421. void* (*cl_malloc_hook) (size_t size) = ...;
  2422. void (*cl_free_hook) (void* ptr) = ...;
  2423. The `cl_malloc_hook' function must not return a `NULL' pointer.
  2424. It is not possible to change the memory allocator at runtime, because
  2425. it is already called at program startup by the constructors of some
  2426. global variables.
  2427. 
  2428. File: cln.info, Node: Index, Prev: Customizing, Up: Top
  2429. Index
  2430. *****
  2431. * Menu:
  2432. * abs (): Elementary functions.
  2433. * abstract class: Ordinary number types.
  2434. * acos (): Trigonometric functions.
  2435. * acosh (): Hyperbolic functions.
  2436. * advocacy: Why C++ ?.
  2437. * Archimedes' constant: Trigonometric functions.
  2438. * As() (): Conversions.
  2439. * ash (): Logical functions.
  2440. * asin: Trigonometric functions.
  2441. * asin (): Trigonometric functions.
  2442. * asinh (): Hyperbolic functions.
  2443. * atan: Trigonometric functions.
  2444. * atan (): Trigonometric functions.
  2445. * atanh (): Hyperbolic functions.
  2446. * basering (): Functions on univariate polynomials.
  2447. * binomial (): Combinatorial functions.
  2448. * boole (): Logical functions.
  2449. * boole_1: Logical functions.
  2450. * boole_2: Logical functions.
  2451. * boole_and: Logical functions.
  2452. * boole_andc1: Logical functions.
  2453. * boole_andc2: Logical functions.
  2454. * boole_c1: Logical functions.
  2455. * boole_c2: Logical functions.
  2456. * boole_clr: Logical functions.
  2457. * boole_eqv: Logical functions.
  2458. * boole_nand: Logical functions.
  2459. * boole_nor: Logical functions.
  2460. * boole_orc1: Logical functions.
  2461. * boole_orc2: Logical functions.
  2462. * boole_set: Logical functions.
  2463. * boole_xor: Logical functions.
  2464. * canonhom () <1>: Functions on univariate polynomials.
  2465. * canonhom (): Functions on modular integers.
  2466. * Catalan's constant: Euler gamma.
  2467. * ceiling1 (): Rounding functions.
  2468. * ceiling2 (): Rounding functions.
  2469. * cis (): Trigonometric functions.
  2470. * cl_abort (): Error handling.
  2471. * cl_byte: Logical functions.
  2472. * cl_catalanconst (): Euler gamma.
  2473. * cl_compare (): Comparisons.
  2474. * cl_cos_sin (): Trigonometric functions.
  2475. * cl_cos_sin_t: Trigonometric functions.
  2476. * cl_cosh_sinh (): Hyperbolic functions.
  2477. * cl_cosh_sinh_t: Hyperbolic functions.
  2478. * CL_DEBUG: Debugging support.
  2479. * cl_decoded_dfloat: Functions on floating-point numbers.
  2480. * cl_decoded_ffloat: Functions on floating-point numbers.
  2481. * cl_decoded_float: Functions on floating-point numbers.
  2482. * cl_decoded_lfloat: Functions on floating-point numbers.
  2483. * cl_decoded_sfloat: Functions on floating-point numbers.
  2484. * cl_default_float_format: Conversion to floating-point numbers.
  2485. * cl_default_print_flags: Customizing I/O.
  2486. * cl_default_random_state: Random number generators.
  2487. * cl_DF: Floating-point numbers.
  2488. * cl_double_approx (): Conversions.
  2489. * cl_equal_hashcode (): Comparisons.
  2490. * cl_eulerconst (): Euler gamma.
  2491. * cl_F <1>: Floating-point numbers.
  2492. * cl_F: Ordinary number types.
  2493. * cl_FF: Floating-point numbers.
  2494. * cl_find_modint_ring (): Modular integer rings.
  2495. * cl_find_univpoly_ring (): Univariate polynomial rings.
  2496. * cl_float: Conversion to floating-point numbers.
  2497. * cl_float_approx (): Conversions.
  2498. * cl_float_format (): Conversion to floating-point numbers.
  2499. * cl_free_hook (): Customizing the memory allocator.
  2500. * cl_hermite (): Special polynomials.
  2501. * cl_I_to_int (): Conversions.
  2502. * cl_I_to_long (): Conversions.
  2503. * cl_I_to_uint (): Conversions.
  2504. * cl_I_to_ulong (): Conversions.
  2505. * cl_idecoded_float: Functions on floating-point numbers.
  2506. * cl_laguerre (): Special polynomials.
  2507. * cl_legendre (): Special polynomials.
  2508. * cl_LF: Floating-point numbers.
  2509. * cl_malloc_hook (): Customizing the memory allocator.
  2510. * cl_N: Ordinary number types.
  2511. * cl_number: Ordinary number types.
  2512. * cl_pi: Trigonometric functions.
  2513. * cl_R: Ordinary number types.
  2514. * cl_RA: Ordinary number types.
  2515. * cl_SF: Floating-point numbers.
  2516. * cl_string (): Strings.
  2517. * cl_symbol (): Symbols.
  2518. * cl_tschebychev (): Special polynomials.
  2519. * cl_zeta (): Riemann zeta.
  2520. * coeff (): Functions on univariate polynomials.
  2521. * comparison: Comparisons.
  2522. * compiler options: Compiler options.
  2523. * complex (): Elementary complex functions.
  2524. * complex number <1>: Complex numbers.
  2525. * complex number: Ordinary number types.
  2526. * conjugate (): Elementary complex functions.
  2527. * conversion <1>: Conversion functions.
  2528. * conversion: Conversions.
  2529. * cos (): Trigonometric functions.
  2530. * cosh (): Hyperbolic functions.
  2531. * create (): Functions on univariate polynomials.
  2532. * customizing: Customizing.
  2533. * debug_print (): Debugging support.
  2534. * debugging: Debugging support.
  2535. * decode_float (): Functions on floating-point numbers.
  2536. * degree (): Functions on univariate polynomials.
  2537. * denominator (): Elementary rational functions.
  2538. * deposit_field (): Logical functions.
  2539. * deriv (): Functions on univariate polynomials.
  2540. * div (): Functions on modular integers.
  2541. * doublefactorial (): Combinatorial functions.
  2542. * dpb (): Logical functions.
  2543. * equal () <1>: Symbols.
  2544. * equal (): Strings.
  2545. * etract (): Functions on modular integers.
  2546. * Euler's constant: Euler gamma.
  2547. * evenp (): Logical functions.
  2548. * exact number: Exact numbers.
  2549. * exp (): Exponential and logarithmic functions.
  2550. * exp1 (): Exponential and logarithmic functions.
  2551. * expt () <1>: Functions on modular integers.
  2552. * expt () <2>: Exponential and logarithmic functions.
  2553. * expt (): Elementary functions.
  2554. * expt_pos () <1>: Functions on univariate polynomials.
  2555. * expt_pos () <2>: Functions on modular integers.
  2556. * expt_pos (): Elementary functions.
  2557. * exquo (): Elementary functions.
  2558. * factorial (): Combinatorial functions.
  2559. * fceiling (): Rounding functions.
  2560. * fceiling2 (): Rounding functions.
  2561. * ffloor (): Rounding functions.
  2562. * ffloor2 (): Rounding functions.
  2563. * Fibonacci number: An Example.
  2564. * finalize (): Functions on univariate polynomials.
  2565. * float_digits (): Functions on floating-point numbers.
  2566. * float_epsilon (): Conversion to floating-point numbers.
  2567. * float_exponent (): Functions on floating-point numbers.
  2568. * float_negative_epsilon (): Conversion to floating-point numbers.
  2569. * float_precision (): Functions on floating-point numbers.
  2570. * float_radix (): Functions on floating-point numbers.
  2571. * float_sign (): Functions on floating-point numbers.
  2572. * floating-point number: Floating-point numbers.
  2573. * floor1 (): Rounding functions.
  2574. * floor2 (): Rounding functions.
  2575. * fprint () <1>: Functions on univariate polynomials.
  2576. * fprint (): Functions on modular integers.
  2577. * fround (): Rounding functions.
  2578. * fround2 (): Rounding functions.
  2579. * ftruncate (): Rounding functions.
  2580. * ftruncate2 (): Rounding functions.
  2581. * garbage collection <1>: Garbage collection.
  2582. * garbage collection: Memory efficiency.
  2583. * gcd (): Number theoretic functions.
  2584. * GMP: Introduction.
  2585. * header files: Include files.
  2586. * Hermite polynomial: Special polynomials.
  2587. * imagpart (): Elementary complex functions.
  2588. * include files: Include files.
  2589. * Input/Output: Input/Output.
  2590. * installation: Installing the library.
  2591. * integer: Ordinary number types.
  2592. * integer_decode_float (): Functions on floating-point numbers.
  2593. * integer_length (): Logical functions.
  2594. * isqrt (): Roots.
  2595. * Laguerre polynomial: Special polynomials.
  2596. * lcm (): Number theoretic functions.
  2597. * ldb (): Logical functions.
  2598. * ldb_test (): Logical functions.
  2599. * least_negative_float (): Conversion to floating-point numbers.
  2600. * least_positive_float (): Conversion to floating-point numbers.
  2601. * Legende polynomial: Special polynomials.
  2602. * length (): Strings.
  2603. * ln (): Exponential and logarithmic functions.
  2604. * log (): Exponential and logarithmic functions.
  2605. * logand (): Logical functions.
  2606. * logandc1 (): Logical functions.
  2607. * logandc2 (): Logical functions.
  2608. * logbitp (): Logical functions.
  2609. * logcount (): Logical functions.
  2610. * logeqv (): Logical functions.
  2611. * logior (): Logical functions.
  2612. * lognand (): Logical functions.
  2613. * lognor (): Logical functions.
  2614. * lognot (): Logical functions.
  2615. * logorc1 (): Logical functions.
  2616. * logorc2 (): Logical functions.
  2617. * logp (): Number theoretic functions.
  2618. * logtest (): Logical functions.
  2619. * logxor (): Logical functions.
  2620. * make: C++ compiler.
  2621. * mask_field (): Logical functions.
  2622. * max (): Comparisons.
  2623. * min (): Comparisons.
  2624. * minus1 (): Elementary functions.
  2625. * minusp (): Comparisons.
  2626. * mod (): Rounding functions.
  2627. * modifying operators: Obfuscating operators.
  2628. * modular integer: Modular integers.
  2629. * modulus: Functions on modular integers.
  2630. * monomial (): Functions on univariate polynomials.
  2631. * Montgomery multiplication: Modular integer rings.
  2632. * most_negative_float (): Conversion to floating-point numbers.
  2633. * most_positive_float (): Conversion to floating-point numbers.
  2634. * numerator (): Elementary rational functions.
  2635. * oddp (): Logical functions.
  2636. * one () <1>: Functions on univariate polynomials.
  2637. * one (): Functions on modular integers.
  2638. * operator != () <1>: Functions on univariate polynomials.
  2639. * operator != () <2>: Functions on modular integers.
  2640. * operator != () <3>: Modular integer rings.
  2641. * operator != (): Comparisons.
  2642. * operator & (): Logical functions.
  2643. * operator &= (): Obfuscating operators.
  2644. * operator () (): Functions on univariate polynomials.
  2645. * operator * () <1>: Functions on univariate polynomials.
  2646. * operator * () <2>: Functions on modular integers.
  2647. * operator * (): Elementary functions.
  2648. * operator *= (): Obfuscating operators.
  2649. * operator + () <1>: Functions on univariate polynomials.
  2650. * operator + () <2>: Functions on modular integers.
  2651. * operator + (): Elementary functions.
  2652. * operator ++ (): Obfuscating operators.
  2653. * operator += (): Obfuscating operators.
  2654. * operator - () <1>: Functions on univariate polynomials.
  2655. * operator - () <2>: Functions on modular integers.
  2656. * operator - (): Elementary functions.
  2657. * operator -- (): Obfuscating operators.
  2658. * operator -= (): Obfuscating operators.
  2659. * operator / (): Elementary functions.
  2660. * operator /= (): Obfuscating operators.
  2661. * operator < (): Comparisons.
  2662. * operator << () <1>: Functions on univariate polynomials.
  2663. * operator << () <2>: Functions on modular integers.
  2664. * operator << (): Logical functions.
  2665. * operator <<= (): Obfuscating operators.
  2666. * operator <= (): Comparisons.
  2667. * operator == () <1>: Functions on univariate polynomials.
  2668. * operator == () <2>: Functions on modular integers.
  2669. * operator == () <3>: Modular integer rings.
  2670. * operator == (): Comparisons.
  2671. * operator > (): Comparisons.
  2672. * operator >= (): Comparisons.
  2673. * operator >> () <1>: Functions on modular integers.
  2674. * operator >> (): Logical functions.
  2675. * operator >>= (): Obfuscating operators.
  2676. * operator [] (): Strings.
  2677. * operator ^ (): Logical functions.
  2678. * operator ^= (): Obfuscating operators.
  2679. * operator | (): Logical functions.
  2680. * operator |= (): Obfuscating operators.
  2681. * operator ~ (): Logical functions.
  2682. * ord2 (): Logical functions.
  2683. * phase (): Exponential and logarithmic functions.
  2684. * pi: Trigonometric functions.
  2685. * plus1 (): Elementary functions.
  2686. * plusp (): Comparisons.
  2687. * polynomial: Univariate polynomials.
  2688. * portability: Why C++ ?.
  2689. * power2p (): Logical functions.
  2690. * printing: Internal and printed representation.
  2691. * random (): Functions on modular integers.
  2692. * random32 (): Random number generators.
  2693. * random_F (): Random number generators.
  2694. * random_I (): Random number generators.
  2695. * random_R (): Random number generators.
  2696. * rational (): Conversion to rational numbers.
  2697. * rational number: Ordinary number types.
  2698. * rationalize (): Conversion to rational numbers.
  2699. * reading: Internal and printed representation.
  2700. * real number: Ordinary number types.
  2701. * realpart (): Elementary complex functions.
  2702. * recip () <1>: Functions on modular integers.
  2703. * recip (): Elementary functions.
  2704. * reference counting: Memory efficiency.
  2705. * rem (): Rounding functions.
  2706. * representation: Internal and printed representation.
  2707. * Riemann's zeta: Riemann zeta.
  2708. * ring: Modular integer rings.
  2709. * ring (): Functions on univariate polynomials.
  2710. * ring(): Functions on modular integers.
  2711. * rootp (): Roots.
  2712. * round1 (): Rounding functions.
  2713. * round2 (): Rounding functions.
  2714. * rounding: Rounding functions.
  2715. * rounding error: Floating-point numbers.
  2716. * Rubik's cube: Conversions.
  2717. * scale_float (): Functions on floating-point numbers.
  2718. * Sch�nhage-Strassen: Speed efficiency.
  2719. * Sch�nhage-Strassen multiplication: Introduction.
  2720. * sed: Make utility.
  2721. * set_coeff (): Functions on univariate polynomials.
  2722. * signum (): Elementary functions.
  2723. * sin (): Trigonometric functions.
  2724. * sinh (): Hyperbolic functions.
  2725. * sqrt (): Roots.
  2726. * sqrtp (): Roots.
  2727. * square () <1>: Functions on univariate polynomials.
  2728. * square () <2>: Functions on modular integers.
  2729. * square (): Elementary functions.
  2730. * string: Strings.
  2731. * strlen (): Strings.
  2732. * symbol: Symbols.
  2733. * symbolic type: Symbolic data types.
  2734. * tan (): Trigonometric functions.
  2735. * tanh (): Hyperbolic functions.
  2736. * The() (): Conversions.
  2737. * transcendental functions: Transcendental functions.
  2738. * truncate1 (): Rounding functions.
  2739. * truncate2 (): Rounding functions.
  2740. * Tschebychev polynomial: Special polynomials.
  2741. * underflow: Floating-point underflow.
  2742. * univariate polynomial: Univariate polynomials.
  2743. * WANT_OBFUSCATING_OPERATORS: Obfuscating operators.
  2744. * xgcd (): Number theoretic functions.
  2745. * zero () <1>: Functions on univariate polynomials.
  2746. * zero (): Functions on modular integers.
  2747. * zerop () <1>: Functions on univariate polynomials.
  2748. * zerop () <2>: Functions on modular integers.
  2749. * zerop (): Comparisons.
  2750. 
  2751. Tag Table:
  2752. Node: Top957
  2753. Node: Introduction3124
  2754. Node: Installation5646
  2755. Node: Prerequisites5940
  2756. Node: C++ compiler6138
  2757. Node: Make utility6853
  2758. Node: Sed utility7039
  2759. Node: Building the library7359
  2760. Node: Installing the library10541
  2761. Node: Cleaning up11264
  2762. Node: Ordinary number types11589
  2763. Node: Exact numbers13936
  2764. Node: Floating-point numbers15101
  2765. Node: Complex numbers18680
  2766. Node: Conversions19177
  2767. Node: Functions on numbers22643
  2768. Node: Constructing numbers23346
  2769. Node: Constructing integers23718
  2770. Node: Constructing rational numbers24008
  2771. Node: Constructing floating-point numbers24483
  2772. Node: Constructing complex numbers25603
  2773. Node: Elementary functions25967
  2774. Node: Elementary rational functions28434
  2775. Node: Elementary complex functions29006
  2776. Node: Comparisons29834
  2777. Node: Rounding functions31733
  2778. Node: Roots37510
  2779. Node: Transcendental functions39391
  2780. Node: Exponential and logarithmic functions39947
  2781. Node: Trigonometric functions41964
  2782. Node: Hyperbolic functions45315
  2783. Node: Euler gamma47388
  2784. Node: Riemann zeta48304
  2785. Node: Functions on integers48860
  2786. Node: Logical functions49148
  2787. Node: Number theoretic functions55101
  2788. Node: Combinatorial functions56468
  2789. Node: Functions on floating-point numbers57146
  2790. Node: Conversion functions60377
  2791. Node: Conversion to floating-point numbers60657
  2792. Node: Conversion to rational numbers62880
  2793. Node: Random number generators63934
  2794. Node: Obfuscating operators65608
  2795. Node: Input/Output67338
  2796. Node: Internal and printed representation67548
  2797. Node: Input functions70090
  2798. Node: Output functions74641
  2799. Node: Rings78377
  2800. Node: Modular integers80301
  2801. Node: Modular integer rings80501
  2802. Node: Functions on modular integers82591
  2803. Node: Symbolic data types85601
  2804. Node: Strings85864
  2805. Node: Symbols86929
  2806. Node: Univariate polynomials87831
  2807. Node: Univariate polynomial rings88089
  2808. Node: Functions on univariate polynomials93043
  2809. Node: Special polynomials96824
  2810. Node: Internals97544
  2811. Node: Why C++ ?97758
  2812. Node: Memory efficiency99258
  2813. Node: Speed efficiency99956
  2814. Node: Garbage collection101040
  2815. Node: Using the library101867
  2816. Node: Compiler options102401
  2817. Node: Include files103319
  2818. Node: An Example106960
  2819. Node: Debugging support110110
  2820. Node: Customizing112460
  2821. Node: Error handling112688
  2822. Node: Floating-point underflow113262
  2823. Node: Customizing I/O113901
  2824. Node: Customizing the memory allocator114194
  2825. Node: Index115151
  2826. 
  2827. End Tag Table