Browse Source

* All Files have been modified for inclusion of namespace cln;

I am too lazy for a detailed discussion of all the changes.
          Many identifiers got their `cl_' stripped off.  Ok, this is a
          clumpsy CVS log-entry.  Promise: more will soon go into the
          file ChangeLog.  I apologize for the inconvenience.   :-(
master
Richard Kreckel 26 years ago
parent
commit
850abfde7f
  1. 2
      FILES
  2. 12
      INSTALL
  3. 2
      Makefile.devel
  4. 15
      Makefile.in
  5. 14
      NEWS
  6. 18
      README
  7. 2
      autoconf/aclocal.m4
  8. 24
      autoconf/config.guess
  9. 45
      autoconf/config.sub
  10. 84
      benchmarks/timebench1.cc
  11. 39
      benchmarks/timebench2a.cc
  12. 19
      benchmarks/timebench2ap.cc
  13. 73
      benchmarks/timebench2b.cc
  14. 57
      cln-config.in
  15. 209
      configure
  16. 31
      configure.in
  17. BIN
      doc/cln.dvi
  18. 1106
      doc/cln.html
  19. 704
      doc/cln.info
  20. 4106
      doc/cln.ps
  21. 516
      doc/cln.tex
  22. 525
      doc/cln.texi
  23. 7
      doc/cln_1.html
  24. 14
      doc/cln_10.html
  25. 201
      doc/cln_11.html
  26. 42
      doc/cln_12.html
  27. 4
      doc/cln_13.html
  28. 44
      doc/cln_2.html
  29. 74
      doc/cln_3.html
  30. 431
      doc/cln_4.html
  31. 42
      doc/cln_5.html
  32. 18
      doc/cln_6.html
  33. 74
      doc/cln_7.html
  34. 24
      doc/cln_8.html
  35. 134
      doc/cln_9.html
  36. 23
      doc/cln_toc.html
  37. 1
      examples/Makefile.in
  38. 19
      examples/atan_recip.cc
  39. 22
      examples/atanh_recip.cc
  40. 24
      examples/contfrac.cc
  41. 40
      examples/e.cc
  42. 84
      examples/fibonacci.cc
  43. 34
      examples/legendre.cc
  44. 26
      examples/lucaslehmer.cc
  45. 22
      examples/nextprime.cc
  46. 12
      examples/perfnum.cc
  47. 127
      include/cl_config.h.in
  48. 16
      include/cl_floatformat.h
  49. 141
      include/cln.h
  50. 8
      include/cln/GV.h
  51. 16
      include/cln/GV_complex.h
  52. 16
      include/cln/GV_integer.h
  53. 7
      include/cln/GV_modinteger.h
  54. 8
      include/cln/GV_number.h
  55. 16
      include/cln/GV_rational.h
  56. 16
      include/cln/GV_real.h
  57. 8
      include/cln/SV.h
  58. 16
      include/cln/SV_complex.h
  59. 16
      include/cln/SV_integer.h
  60. 10
      include/cln/SV_number.h
  61. 16
      include/cln/SV_rational.h
  62. 16
      include/cln/SV_real.h
  63. 10
      include/cln/SV_ringelt.h
  64. 6
      include/cln/V.h
  65. 4
      include/cln/abort.h
  66. 141
      include/cln/cln.h
  67. 22
      include/cln/complex.h
  68. 8
      include/cln/complex_class.h
  69. 10
      include/cln/complex_io.h
  70. 8
      include/cln/complex_ring.h
  71. 23
      include/cln/condition.h
  72. 42
      include/cln/dfloat.h
  73. 10
      include/cln/dfloat_class.h
  74. 14
      include/cln/dfloat_io.h
  75. 42
      include/cln/ffloat.h
  76. 10
      include/cln/ffloat_class.h
  77. 14
      include/cln/ffloat_io.h
  78. 172
      include/cln/float.h
  79. 10
      include/cln/float_class.h
  80. 12
      include/cln/float_io.h
  81. 20
      include/cln/floatformat.h
  82. 14
      include/cln/input.h
  83. 44
      include/cln/integer.h
  84. 10
      include/cln/integer_class.h
  85. 14
      include/cln/integer_io.h
  86. 8
      include/cln/integer_ring.h
  87. 84
      include/cln/io.h
  88. 42
      include/cln/lfloat.h
  89. 10
      include/cln/lfloat_class.h
  90. 14
      include/cln/lfloat_io.h
  91. 8
      include/cln/malloc.h
  92. 46
      include/cln/modinteger.h
  93. 0
      include/cln/modules.h
  94. 6
      include/cln/null_ring.h
  95. 8
      include/cln/number.h
  96. 8
      include/cln/number_io.h
  97. 12
      include/cln/numtheory.h
  98. 19
      include/cln/object.h
  99. 18
      include/cln/output.h
  100. 16
      include/cln/proplist.h

2
FILES

@ -35,7 +35,7 @@ Files in this package:
(standalone)
Include files
include/
include/cln/
Sample programs
examples/

12
INSTALL

@ -11,18 +11,12 @@ $ make install
You need GNU make. On HP-UX, you also need GNU sed.
Known to work with:
- Linux/x86, gcc-2.7.0, gcc-2.7.2, gcc-2.8.0, egcs-1.1, gcc-2.95
- Solaris 2.4 (sparc), gcc-2.7.0, gcc-2.7.2, egcs-1.1, gcc-2.95
- Linux/x86, gcc-2.8.0, egcs-1.1, gcc-2.95.x
- Solaris 2.4 (sparc), egcs-1.1, gcc-2.95
- OSF/1 V4.0 (alpha), egcs-1.1, gcc-2.95
- Irix 5.3, CC 4
The "make" step takes about 4 hours, on a 486 DX / 33 MHz / 8 MB.
On Linux, g++ needs 15 MB to compile the tests. So better have
17 MB swap space and 1 MB room in $TMPDIR.
If you use gcc and g++ version 2.7.x, don't add -O2 to the CXXFLAGS, because
"g++ -O" generates better code for libcln.a than "g++ -O2".
The "make" step takes about 1 hour, on a P-II / 400 MHz / 64 MB.
If you use g++ version 2.8.x or egcs-2.91.x (a.k.a. egcs-1.1) or gcc-2.95.x,
I recommend adding "-fno-exceptions" to the CXXFLAGS. This will likely

2
Makefile.devel

@ -24,7 +24,7 @@ AUTOCONF_FILES = autoconf/aclocal.m4 autoconf/acgeneral.m4 autoconf/acspecific.m
configures : $(CONFIGURES)
configure : configure.in $(AUTOCONF_FILES)
autoconf/autoconf -m autoconf
./autoconf/autoconf -m autoconf
# # ACLOCAL = /home/bruno/clisp/src/autoconf/aclocal.m4
# # ACSELECT = /home/bruno/clisp/src/autoconf/acselect

15
Makefile.in

@ -6,6 +6,7 @@
prefix = @prefix@
local_prefix = /usr/local
exec_prefix = @exec_prefix@
bindir = @bindir@
datadir = @datadir@
libdir = @libdir@
includedir = @includedir@
@ -16,6 +17,9 @@ CC = @CC@
CFLAGS = @CFLAGS@
RM = rm -f
@SET_MAKE@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
UNINSTALL_PROGRAM = @UNINSTALL_PROGRAM@
#### End of system configuration section. ####
@ -26,12 +30,16 @@ all : force
install : force
cd @subdir@; $(MAKE) install
if [ ! -d $(bindir) ] ; then mkdir $(bindir) ; fi
$(INSTALL_PROGRAM) cln-config $(bindir)/cln-config
installdirs : force
cd @subdir@; $(MAKE) installdirs
if [ ! -d $(bindir) ] ; then mkdir $(bindir) ; fi
uninstall : force
cd @subdir@; $(MAKE) uninstall
$(RM) $(bindir)/cln-config
check : force
cd @subdir@; $(MAKE) check
@ -45,14 +53,15 @@ clean : force
distclean : force
cd @subdir@; if test -f Makefile; then $(MAKE) distclean; fi
$(RM) config.status config.log config.cache Makefile
$(RM) cln-config
$(RM) libtool
$(RM) include/cl_config.h include/cl_intparam.h include/cl_floatparam.h src/base/cl_base_config.h src/base/cl_gmpconfig.h src/float/cl_float_config.h src/timing/cl_t_config.h
$(RM) include/cln/config.h include/cln/intparam.h include/cln/floatparam.h src/base/cl_base_config.h src/base/cl_gmpconfig.h src/float/cl_float_config.h src/timing/cl_t_config.h
maintainer-clean : force
cd @subdir@; if test -f Makefile; then $(MAKE) maintainer-clean; fi
$(RM) config.status config.log config.cache Makefile
$(RM) cln-config
$(RM) libtool
$(RM) include/cl_config.h include/cl_intparam.h include/cl_floatparam.h src/base/cl_base_config.h src/base/cl_gmpconfig.h src/float/cl_float_config.h src/timing/cl_t_config.h
$(RM) include/cln/config.h include/cln/intparam.h include/cln/floatparam.h src/base/cl_base_config.h src/base/cl_gmpconfig.h src/float/cl_float_config.h src/timing/cl_t_config.h
force :

14
NEWS

@ -1,6 +1,18 @@
2000-06-xx, version 1.1.0
=========================
Functional changes
------------------
* ISO/IEC 14882 fashion adjustments:
Put everything into namespace cln. All funcamental data types still
carry their old names. Other non-macro identifiers are now written as
cln::foo instead of cl_foo, except where the cl_ comes from a data type
(as in cl_I_to_int()). Headers are installed into a separate
directory, #include <cln/foo.h> instead of <cl_foo.h>. Applications
must be manually ported to the new style. We apologizes for the
inconvenience.
Implementation changes
----------------------
@ -10,6 +22,8 @@ Implementation changes
* Adjusted several break-even points to make better use of a faster libgmp and
better match present-day CPUs.
* Fix compilation errors with gcc-2.96.
2000-01-13, version 1.0.3
=========================

18
README

@ -6,10 +6,9 @@ GPL
Features:
- Rich set of number classes:
Integer (unlimited precision), rational,
short float, single float, double float,
long float (unlimited precision), complex,
modular integer, univariate polynomial.
Integer (unlimited precision), rational, short float,
single float, double float, long float (unlimited
precision), complex, modular integer, univariate polynomial.
- Elementary, logical, transcendental functions.
- C++ as implementation language brings
- efficiency,
@ -29,13 +28,10 @@ Features:
Requires: C++ compiler g++.
The following C++ features are used:
classes, member functions,
overloading of functions and operators,
constructors and destructors, inline, const,
multiple inheritance, templates.
classes, member functions, overloading of functions and operators,
constructors and destructors, inline, const, multiple inheritance,
templates and namespaces.
The following C++ features are not used:
new, delete, virtual inheritance,
exceptions.
new, delete, virtual inheritance, exceptions.
Homepage: http://clisp.cons.org/~haible/packages-cln.html

2
autoconf/aclocal.m4

@ -948,7 +948,7 @@ AC_DEFUN(CL_GMP_H_VERSION,
cl_cv_new_gmp_h="yes", cl_cv_new_gmp_h="no")
])])dnl
# Does libgmp feature 3.0 functionality?
# Does libgmp provide some functionality introduced in version 3.0?
AC_DEFUN(CL_GMP_CHECK,
[AC_CACHE_CHECK([for working libgmp], cl_cv_new_libgmp, [
SAVELIBS=$LIBS

24
autoconf/config.guess

@ -3,7 +3,7 @@
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
# Free Software Foundation, Inc.
version='2000-05-30'
version='2000-07-27'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@ -119,7 +119,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# object file format.
# Determine the machine/vendor (is the vendor relevant).
case "${UNAME_MACHINE}" in
amiga) machine=m68k-cbm ;;
amiga) machine=m68k-unknown ;;
arm32) machine=arm-unknown ;;
atari*) machine=m68k-atari ;;
sun3*) machine=m68k-sun ;;
@ -215,7 +215,7 @@ EOF
echo alpha-dec-winnt3.5
exit 0 ;;
Amiga*:UNIX_System_V:4.0:*)
echo m68k-cbm-sysv4
echo m68k-unknown-sysv4
exit 0;;
amiga:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
@ -687,6 +687,9 @@ EOF
*:GNU:*:*)
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit 0 ;;
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit 0 ;;
*:Linux:*:*)
# The BFD linker knows what the default object file format is, so
@ -709,8 +712,7 @@ EOF
exit 0
;;
elf_i?86)
echo "${UNAME_MACHINE}-pc-linux"
exit 0
TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
;;
i?86coff)
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
@ -897,6 +899,7 @@ EOF
EOF
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
fi ;;
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
# are messed up and put the nodename in both sysname and nodename.
@ -1085,6 +1088,17 @@ EOF
DS/*:UNIX_System_V:*:*)
echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
exit 0 ;;
*:Plan9:*:*)
# "uname -m" is not consistent, so use $cputype instead. 386
# is converted to i386 for consistency with other x86
# operating systems.
if test "$cputype" = "386"; then
UNAME_MACHINE=i386
else
UNAME_MACHINE="$cputype"
fi
echo ${UNAME_MACHINE}-unknown-plan9
exit 0 ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2

45
autoconf/config.sub

@ -3,7 +3,7 @@
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
# Free Software Foundation, Inc.
version='2000-05-30'
version='2000-08-07'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@ -29,7 +29,6 @@ version='2000-05-30'
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Written by Per Bothner <bothner@cygnus.com>.
# Please send patches to <config-patches@gnu.org>.
#
# Configuration subroutine to validate and canonicalize a configuration type.
@ -132,7 +131,7 @@ case $os in
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple)
-apple | -axis)
os=
basic_machine=$1
;;
@ -205,29 +204,35 @@ case $basic_machine in
# Recognize the basic CPU types without company name.
# Some are omitted here because they have special meanings below.
tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
| arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \
| arme[lb] | armv* | pyramid | mn10200 | mn10300 | tron | a29k \
| 580 | i960 | h8300 \
| x86 | ppcbe | mipsbe | mipsle | shbe | shle | armbe | armle \
| hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
| hppa64 \
| alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \
| alphaev6[78] \
| we32k | ns16k | clipper | i370 | sh | powerpc | powerpcle \
| we32k | ns16k | clipper | i370 | sh | sh[34] \
| powerpc | powerpcle \
| 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \
| mips64orion | mips64orionel | mipstx39 | mipstx39el \
| mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
| mips64vr5000 | miprs64vr5000el | mcore \
| sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \
| thumb | d10v | fr30 | avr)
| thumb | d10v | d30v | fr30 | avr)
basic_machine=$basic_machine-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12)
# Motorola 68HC11/12.
basic_machine=$basic_machine-unknown
os=-none
;;
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65 | pj | pjl)
;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
i[34567]86)
i[234567]86)
basic_machine=$basic_machine-pc
;;
# Object if more than one company name word.
@ -237,7 +242,7 @@ case $basic_machine in
;;
# Recognize the basic CPU types with company name.
# FIXME: clean up the formatting here.
vax-* | tahoe-* | i[34567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
vax-* | tahoe-* | i[234567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
| m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
| mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
| power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
@ -257,7 +262,7 @@ case $basic_machine in
| f301-* | armv*-* | s390-* | sv1-* | t3e-* \
| m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
| thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* \
| bs2000-*)
| bs2000-* | tic54x-* | c54x-*)
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
@ -294,14 +299,14 @@ case $basic_machine in
os=-sysv
;;
amiga | amiga-*)
basic_machine=m68k-cbm
basic_machine=m68k-unknown
;;
amigaos | amigados)
basic_machine=m68k-cbm
basic_machine=m68k-unknown
os=-amigaos
;;
amigaunix | amix)
basic_machine=m68k-cbm
basic_machine=m68k-unknown
os=-sysv4
;;
apollo68)
@ -355,6 +360,9 @@ case $basic_machine in
crds | unos)
basic_machine=m68k-crds
;;
cris | cris-* | etrax*)
basic_machine=cris-axis
;;
da30 | da30-*)
basic_machine=m68k-da30
;;
@ -666,7 +674,7 @@ case $basic_machine in
pentium | p5 | k5 | k6 | nexen)
basic_machine=i586-pc
;;
pentiumpro | p6 | 6x86)
pentiumpro | p6 | 6x86 | athlon)
basic_machine=i686-pc
;;
pentiumii | pentium2)
@ -675,7 +683,7 @@ case $basic_machine in
pentium-* | p5-* | k5-* | k6-* | nexen-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumpro-* | p6-* | 6x86-*)
pentiumpro-* | p6-* | 6x86-* | athlon-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumii-* | pentium2-*)
@ -790,6 +798,10 @@ case $basic_machine in
basic_machine=t3e-cray
os=-unicos
;;
tic54x | c54x*)
basic_machine=tic54x-unknown
os=-coff
;;
tx39)
basic_machine=mipstx39-unknown
;;
@ -891,6 +903,9 @@ case $basic_machine in
we32k)
basic_machine=we32k-att
;;
sh3 | sh4)
base_machine=sh-unknown
;;
sparc | sparcv9)
basic_machine=sparc-sun
;;
@ -972,7 +987,7 @@ case $os in
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit*)
| -openstep* | -oskit* | -conix*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)

84
benchmarks/timebench1.cc

@ -1,17 +1,17 @@
// Benchmarks from the LiDIA home page
#include <cl_number.h>
#include <cl_io.h>
#include <cl_integer.h>
#include <cl_float.h>
#include <cl_float_io.h>
#include <cl_real.h>
#include <cl_real_io.h>
#include <cl_complex.h>
#include <cl_complex_io.h>
#include <cln/number.h>
#include <cln/io.h>
#include <cln/integer.h>
#include <cln/float.h>
#include <cln/float_io.h>
#include <cln/real.h>
#include <cln/real_io.h>
#include <cln/complex.h>
#include <cln/complex_io.h>
#include <stdlib.h>
#include <string.h>
#include <cl_timing.h>
#include <cln/timing.h>
// Timings on Linux i486 33 MHz, 1000 decimal places = 104 32-bit words.
// Function LiDIA Pari CLISP CLN
@ -61,42 +61,42 @@ int main (int argc, char * argv[])
if (argc < 1)
exit(1);
fprint(cl_stderr, "Number of repetitions: ");
fprintdecimal(cl_stderr, repetitions);
fprint(cl_stderr, "\n");
fprint(stderr, "Number of repetitions: ");
fprintdecimal(stderr, repetitions);
fprint(stderr, "\n");
cl_float_format_t prec = cl_float_format(1000);
float_format_t prec = float_format(1000);
fprint(cl_stderr, "pi\n");
fprint(stderr, "pi\n");
{ cl_F p;
{ CL_TIMING; p = cl_pi(prec); }
{ CL_TIMING; p = pi(prec); }
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
{ cl_F p = cl_pi(prec); }
{ cl_F p = pi(prec); }
}
cout << p << endl << endl;
}
fprint(cl_stderr, "gamma\n");
fprint(stderr, "gamma\n");
{ cl_F p;
{ CL_TIMING; p = cl_eulerconst(prec); }
{ CL_TIMING; p = eulerconst(prec); }
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
{ cl_F p = cl_eulerconst(prec); }
{ cl_F p = eulerconst(prec); }
}
cout << p << endl << endl;
}
fprint(cl_stderr, "e\n");
{ cl_F p = cl_exp1(prec);
fprint(stderr, "e\n");
{ cl_F p = exp1(prec);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
{ cl_F p = cl_exp1(prec); }
{ cl_F p = exp1(prec); }
}
cout << p << endl << endl;
}
fprint(cl_stderr, "sqrt(3)\n");
fprint(stderr, "sqrt(3)\n");
{ cl_R p = sqrt(cl_float(3,prec));
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -105,7 +105,7 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(cl_stderr, "exp(log(2))\n");
fprint(stderr, "exp(log(2))\n");
{ cl_N p = exp(log(cl_float(2,prec)));
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -114,7 +114,7 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(cl_stderr, "log(exp(2))\n");
fprint(stderr, "log(exp(2))\n");
{ cl_N p = log(exp(cl_float(2,prec)));
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -123,25 +123,25 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(cl_stderr, "sin(pi/3)\n");
{ cl_R p = sin(cl_pi(prec)/3);
fprint(stderr, "sin(pi/3)\n");
{ cl_R p = sin(pi(prec)/3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
{ cl_R p = sin(cl_pi(prec)/3); }
{ cl_R p = sin(pi(prec)/3); }
}
cout << p << endl << endl;
}
fprint(cl_stderr, "cos(pi/3)\n");
{ cl_R p = cos(cl_pi(prec)/3);
fprint(stderr, "cos(pi/3)\n");
{ cl_R p = cos(pi(prec)/3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
{ cl_R p = cos(cl_pi(prec)/3); }
{ cl_R p = cos(pi(prec)/3); }
}
cout << p << endl << endl;
}
fprint(cl_stderr, "arcsin(sqrt(3)/2)\n");
fprint(stderr, "arcsin(sqrt(3)/2)\n");
{ cl_N p = asin(sqrt(cl_float(3,prec))/2);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -150,7 +150,7 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(cl_stderr, "arccos(sqrt(3)/2)\n");
fprint(stderr, "arccos(sqrt(3)/2)\n");
{ cl_N p = acos(sqrt(cl_float(3,prec))/2);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -159,7 +159,7 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(cl_stderr, "sinh(log(2))\n");
fprint(stderr, "sinh(log(2))\n");
{ cl_N p = sinh(log(cl_float(2,prec)));
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -168,7 +168,7 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(cl_stderr, "cosh(log(2))\n");
fprint(stderr, "cosh(log(2))\n");
{ cl_N p = cosh(log(cl_float(2,prec)));
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -177,20 +177,20 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(cl_stderr, "arsinh(pi)\n");
{ cl_N p = asinh(cl_pi(prec));
fprint(stderr, "arsinh(pi)\n");
{ cl_N p = asinh(pi(prec));
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
{ cl_N p = asinh(cl_pi(prec)); }
{ cl_N p = asinh(pi(prec)); }
}
cout << p << endl << endl;
}
fprint(cl_stderr, "arcosh(pi)\n");
{ cl_N p = acosh(cl_pi(prec));
fprint(stderr, "arcosh(pi)\n");
{ cl_N p = acosh(pi(prec));
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
{ cl_N p = acosh(cl_pi(prec)); }
{ cl_N p = acosh(pi(prec)); }
}
cout << p << endl << endl;
}

39
benchmarks/timebench2a.cc

@ -1,12 +1,15 @@
#include <cl_number.h>
#include <cl_io.h>
#include <cl_integer.h>
#include <cl_integer_io.h>
#include <cl_float.h>
#include <cl_real.h>
#include <cln/number.h>
#include <cln/io.h>
#include <cln/integer.h>
#include <cln/integer_io.h>
#include <cln/float.h>
#include <cln/real.h>
#include <stdlib.h>
#include <string.h>
#include <cl_timing.h>
#include <cln/timing.h>
using namespace std;
using namespace cln;
int main (int argc, char * argv[])
{
@ -27,22 +30,18 @@ int main (int argc, char * argv[])
}
if (argc < 1)
exit(1);
stderr << "Number of digits: " << digits << endl;
stderr << "Number of repetitions: " << repetitions << endl;
fprint(cl_stderr, "Number of digits: ");
fprintdecimal(cl_stderr, digits);
fprint(cl_stderr, "\n");
fprint(cl_stderr, "Number of repetitions: ");
fprintdecimal(cl_stderr, repetitions);
fprint(cl_stderr, "\n");
cl_float_format_t prec = cl_float_format(digits);
cl_float_format_t prec2 = cl_float_format(digits*2);
float_format_t prec = float_format(digits);
float_format_t prec2 = float_format(digits*2);
cl_I pow = expt_pos(10,digits);
cl_I x1 = floor1((sqrt(cl_float(5,prec2))+1)/2 * expt_pos(pow,2));
cl_I x2 = floor1(sqrt(cl_float(3,prec)) * pow);
cl_I x3 = pow+1;
fprint(cl_stderr, "multiplication\n");
stderr << "multiplication" << endl;
{ cl_I r = x1*x2;
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -51,7 +50,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
fprint(cl_stderr, "division\n");
stderr << "division" << endl;
{ cl_I_div_t qr = floor2(x1,x2);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -60,7 +59,7 @@ int main (int argc, char * argv[])
cout << qr.quotient << endl << qr.remainder << endl << endl;
}
fprint(cl_stderr, "isqrt\n");
stderr << "isqrt" << endl;
{ cl_I r = isqrt(x3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -69,7 +68,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
fprint(cl_stderr, "gcd\n");
stderr << "gcd" << endl;
{ cl_I r = gcd(x1,x2);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)

19
benchmarks/timebench2ap.cc

@ -1,9 +1,12 @@
#include <cl_number.h>
#include <cl_io.h>
#include <cl_integer.h>
#include <cln/number.h>
#include <cln/io.h>
#include <cln/integer.h>
#include <stdlib.h>
#include <string.h>
#include <cl_timing.h>
#include <cln/timing.h>
using namespace std;
using namespace cln;
int main (int argc, char * argv[])
{
@ -25,12 +28,8 @@ int main (int argc, char * argv[])
if (argc < 1)
exit(1);
fprint(cl_stderr, "Limit: ");
fprintdecimal(cl_stderr, limit);
fprint(cl_stderr, "\n");
fprint(cl_stderr, "Number of repetitions: ");
fprintdecimal(cl_stderr, repetitions);
fprint(cl_stderr, "\n");
stderr << "Limit: " << limit << endl;
stderr << "Number of repetitions: " << repetitions << endl;
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)

73
benchmarks/timebench2b.cc

@ -1,15 +1,18 @@
#include <cl_number.h>
#include <cl_io.h>
#include <cl_integer.h>
#include <cl_float.h>
#include <cl_float_io.h>
#include <cl_real.h>
#include <cl_real_io.h>
#include <cl_complex.h>
#include <cl_complex_io.h>
#include <cln/number.h>
#include <cln/io.h>
#include <cln/integer.h>
#include <cln/float.h>
#include <cln/float_io.h>
#include <cln/real.h>
#include <cln/real_io.h>
#include <cln/complex.h>
#include <cln/complex_io.h>
#include <stdlib.h>
#include <string.h>
#include <cl_timing.h>
#include <cln/timing.h>
using namespace std;
using namespace cln;
int main (int argc, char * argv[])
{
@ -31,19 +34,15 @@ int main (int argc, char * argv[])
if (argc < 1)
exit(1);
fprint(cl_stderr, "Number of digits: ");
fprintdecimal(cl_stderr, digits);
fprint(cl_stderr, "\n");
fprint(cl_stderr, "Number of repetitions (except for pi,euler,e): ");
fprintdecimal(cl_stderr, repetitions);
fprint(cl_stderr, "\n");
stderr << "Number of digits: " << digits << endl;
stderr << "Number of repetitions (except for pi,euler,e): " << repetitions << endl;
cl_float_format_t prec = cl_float_format(digits);
float_format_t prec = float_format(digits);
cl_F x1 = sqrt(cl_float(2,prec));
cl_F x2 = sqrt(cl_float(3,prec));
cl_F x3 = The(cl_F)(log(cl_float(2,prec)));
fprint(cl_stderr, "multiplication\n");
stderr << "multiplication" << endl;
{ cl_F r = x1*x2;
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -52,7 +51,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
fprint(cl_stderr, "sqrt\n");
stderr << "sqrt" << endl;
{ cl_F r = sqrt(x3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -61,25 +60,25 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
fprint(cl_stderr, "pi\n");
stderr << "pi" << endl;
{ cl_F r;
{ CL_TIMING; r = cl_pi(prec); }
{ CL_TIMING; r = pi(prec); }
cout << r << endl << endl;
}
fprint(cl_stderr, "eulerconst\n");
stderr << "eulerconst" << endl;
{ cl_F r;
{ CL_TIMING; r = cl_eulerconst(prec); }
{ CL_TIMING; r = eulerconst(prec); }
cout << r << endl << endl;
}
fprint(cl_stderr, "e\n");
stderr << "e" << endl;
{ cl_F r;
{ CL_TIMING; r = cl_exp1(prec); }
{ CL_TIMING; r = exp1(prec); }
cout << r << endl << endl;
}
fprint(cl_stderr, "exp\n");
stderr << "exp" << endl;
{ cl_F r = exp(-x1);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -88,7 +87,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
fprint(cl_stderr, "log\n");
stderr << "log" << endl;
{ cl_N r = log(x2);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -97,7 +96,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
fprint(cl_stderr, "sin\n");
stderr << "sin" << endl;
{ cl_R r = sin(5*x1);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -106,7 +105,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
fprint(cl_stderr, "cos\n");
stderr << "cos" << endl;
{ cl_R r = cos(5*x1);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -115,7 +114,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
fprint(cl_stderr, "asin\n");
stderr << "asin" << endl;
{ cl_N r = asin(x3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -124,7 +123,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
fprint(cl_stderr, "acos\n");
stderr << "acos" << endl;
{ cl_N r = acos(x3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -133,7 +132,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
fprint(cl_stderr, "atan\n");
stderr << "atan" << endl;
{ cl_F r = atan(x3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -142,7 +141,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
fprint(cl_stderr, "sinh\n");
stderr << "sinh" << endl;
{ cl_F r = sinh(x2);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -151,7 +150,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
fprint(cl_stderr, "cosh\n");
stderr << "cosh" << endl;
{ cl_F r = cosh(x2);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -160,7 +159,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
fprint(cl_stderr, "asinh\n");
stderr << "asinh" << endl;
{ cl_N r = asinh(x3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -169,7 +168,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
fprint(cl_stderr, "acosh\n");
stderr << "acosh" << endl;
{ cl_N r = acosh(1+x3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -178,7 +177,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
fprint(cl_stderr, "atanh\n");
stderr << "atanh" << endl;
{ cl_N r = atanh(x3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)

57
cln-config.in

@ -0,0 +1,57 @@
#!/bin/sh
prefix=@prefix@
exec_prefix=@exec_prefix@
exec_prefix_set=no
usage="\
Usage: cln-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--libs] [--cppflags]"
if test $# -eq 0; then
echo "${usage}" 1>&2
exit 1
fi
while test $# -gt 0; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case $1 in
--prefix=*)
prefix=$optarg
if test $exec_prefix_set = no ; then
exec_prefix=$optarg
fi
;;
--prefix)
echo $prefix
;;
--exec-prefix=*)
exec_prefix=$optarg
exec_prefix_set=yes
;;
--exec-prefix)
echo $exec_prefix
;;
--version)
echo @CL_VERSION@
;;
--cppflags)
if test @includedir@ != /usr/include ; then
includes=-I@includedir@
fi
echo $includes @CPPFLAGS@
;;
--libs)
libdirs=-L@libdir@
echo $libdirs -lcln @LIBS@
;;
*)
echo "${usage}" 1>&2
exit 1
;;
esac
shift
done

209
configure

@ -22,7 +22,7 @@ ac_help="$ac_help
ac_help="$ac_help
--with-gnu-ld assume the C compiler uses GNU ld [default=no]"
ac_help="$ac_help
--with-gmp use external fast low-level functions from GNU gmp3.
--with-gmp use external fast low-level functions from GNU MP 3.
[default=yes]"
# Initialize some variables set by options.
@ -1310,8 +1310,9 @@ cat >> confdefs.h <<EOF
#endif
EOF
LIBS=-lm
PACKAGE=cln
# Check whether --enable-shared or --disable-shared was given.
# Check whether --enable-shared or --disable-shared was given.
if test "${enable_shared+set}" = set; then
enableval="$enable_shared"
p=${PACKAGE-default}
@ -1370,7 +1371,7 @@ ac_prog=ld
if test "$ac_cv_prog_gcc" = yes; then
# Check if gcc -print-prog-name=ld gives a path.
echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6
echo "configure:1374: checking for ld used by GCC" >&5
echo "configure:1375: checking for ld used by GCC" >&5
ac_prog=`($CC -print-prog-name=ld) 2>&5`
case "$ac_prog" in
# Accept absolute paths.
@ -1388,10 +1389,10 @@ echo "configure:1374: checking for ld used by GCC" >&5
esac
elif test "$with_gnu_ld" = yes; then
echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
echo "configure:1392: checking for GNU ld" >&5
echo "configure:1393: checking for GNU ld" >&5
else
echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
echo "configure:1395: checking for non-GNU ld" >&5
echo "configure:1396: checking for non-GNU ld" >&5
fi
if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -1427,7 +1428,7 @@ fi
test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; }
echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6
echo "configure:1431: checking if the linker ($LD) is GNU ld" >&5
echo "configure:1432: checking if the linker ($LD) is GNU ld" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gnu_ld'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1442,7 +1443,7 @@ echo "$ac_t""$ac_cv_prog_gnu_ld" 1>&6
echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6
echo "configure:1446: checking for BSD-compatible nm" >&5
echo "configure:1447: checking for BSD-compatible nm" >&5
if eval "test \"`echo '$''{'ac_cv_path_NM'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1479,7 +1480,7 @@ echo "$ac_t""$NM" 1>&6
echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
echo "configure:1483: checking whether ln -s works" >&5
echo "configure:1484: checking whether ln -s works" >&5
if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1515,8 +1516,8 @@ test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
case "$host" in
*-*-irix6*)
# Find out which ABI we are using.
echo '#line 1519 "configure"' > conftest.$ac_ext
if { (eval echo configure:1520: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
echo '#line 1520 "configure"' > conftest.$ac_ext
if { (eval echo configure:1521: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
case "`/usr/bin/file conftest.o`" in
*32-bit*)
LD="${LD-ld} -32"
@ -1545,17 +1546,18 @@ ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig \
$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
|| { echo "configure: error: libtool configure failed" 1>&2; exit 1; }
CL_CURRENT=1
CL_REVISION=0
CL_AGE=0
CL_VERSION=1
CL_VERSION_MAJOR=1
CL_VERSION_MINOR=1
CL_VERSION_PATCHLEVEL=0
cat >> confdefs.h <<EOF
#define CL_VERSION $CL_VERSION
#define CL_VERSION_MAJOR $CL_VERSION_MAJOR
EOF
cat >> confdefs.h <<EOF
@ -1566,8 +1568,14 @@ cat >> confdefs.h <<EOF
#define CL_VERSION_PATCHLEVEL $CL_VERSION_PATCHLEVEL
EOF
CL_VERSION=$CL_VERSION_MAJOR.$CL_VERSION_MINOR.$CL_VERSION_PATCHLEVEL
cat >> confdefs.h <<EOF
#define CL_VERSION $CL_VERSION
EOF
ac_ext=C
ac_ext=C
# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
@ -1583,20 +1591,20 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes
cross_compiling=$ac_cv_prog_cxx_cross
echo $ac_n "checking for bool type""... $ac_c" 1>&6
echo "configure:1587: checking for bool type" >&5
echo "configure:1595: checking for bool type" >&5
if eval "test \"`echo '$''{'cl_cv_cplusplus_bool'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1593 "configure"
#line 1601 "configure"
#include "confdefs.h"
int main() {
bool x;
; return 0; }
EOF
if { (eval echo configure:1600: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1608: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
cl_cv_cplusplus_bool=yes
else
@ -1630,7 +1638,7 @@ cross_compiling=$ac_cv_prog_cxx_cross
echo $ac_n "checking for long long type""... $ac_c" 1>&6
echo "configure:1634: checking for long long type" >&5
echo "configure:1642: checking for long long type" >&5
if eval "test \"`echo '$''{'cl_cv_c_longlong'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1639,7 +1647,7 @@ if test "$cross_compiling" = yes; then
cl_cv_c_longlong="guessing no"
else
cat > conftest.$ac_ext <<EOF
#line 1643 "configure"
#line 1651 "configure"
#include "confdefs.h"
#ifdef __cplusplus
extern "C" void exit(int);
@ -1663,7 +1671,7 @@ int main()
}
}
EOF
if { (eval echo configure:1667: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:1675: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
cl_cv_c_longlong=yes
else
@ -1696,7 +1704,7 @@ EOF
esac
echo $ac_n "checking for long double type""... $ac_c" 1>&6
echo "configure:1700: checking for long double type" >&5
echo "configure:1708: checking for long double type" >&5
if eval "test \"`echo '$''{'cl_cv_c_longdouble'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1705,7 +1713,7 @@ if test "$cross_compiling" = yes; then
cl_cv_c_longdouble="guessing no"
else
cat > conftest.$ac_ext <<EOF
#line 1709 "configure"
#line 1717 "configure"
#include "confdefs.h"
#ifdef __cplusplus
extern "C" void exit(int);
@ -1713,7 +1721,7 @@ extern "C" void exit(int);
int main()
{ long double x = 2.7182818284590452354L; x = x*x; exit (x==0.0L); }
EOF
if { (eval echo configure:1717: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:1725: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
cl_cv_c_longdouble=yes
else
@ -1746,20 +1754,20 @@ EOF
esac
echo $ac_n "checking for working template<>""... $ac_c" 1>&6
echo "configure:1750: checking for working template<>" >&5
echo "configure:1758: checking for working template<>" >&5
if eval "test \"`echo '$''{'cl_cv_c_templatenull'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1756 "configure"
#line 1764 "configure"
#include "confdefs.h"
template <class T> class c {}; template <> class c<int> { int x; };
int main() {
; return 0; }
EOF
if { (eval echo configure:1763: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1771: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
cl_cv_c_templatenull=yes
else
@ -1783,7 +1791,7 @@ fi
if test -n "$GCC"; then
echo $ac_n "checking for the global constructors function prefix""... $ac_c" 1>&6
echo "configure:1787: checking for the global constructors function prefix" >&5
echo "configure:1795: checking for the global constructors function prefix" >&5
if eval "test \"`echo '$''{'cl_cv_cplusplus_ctorprefix'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1793,7 +1801,7 @@ struct foo { foo (); };
foo foobar;
EOF
# look for the assembly language name in the .s file
{ ac_try='${CXX-g++} $CXXFLAGS -S conftest.cc'; { (eval echo configure:1797: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } >/dev/null 2>&1
{ ac_try='${CXX-g++} $CXXFLAGS -S conftest.cc'; { (eval echo configure:1805: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } >/dev/null 2>&1
if grep '_GLOBAL_\$I\$foobar' conftest.s >/dev/null ; then
cl_cv_cplusplus_ctorprefix='_GLOBAL_$I$'
else
@ -1823,7 +1831,7 @@ EOF
EOF
echo $ac_n "checking whether the global constructors function need to be exported""... $ac_c" 1>&6
echo "configure:1827: checking whether the global constructors function need to be exported" >&5
echo "configure:1835: checking whether the global constructors function need to be exported" >&5
if eval "test \"`echo '$''{'cl_cv_cplusplus_ctorexport'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1844,7 +1852,7 @@ foo::foo () {}
extern "C" void ctor (void) __asm__ (ASM_UNDERSCORE_PREFIX CL_GLOBAL_CONSTRUCTOR_PREFIX "foobar");
int main() { ctor(); return 0; }
EOF
if { ac_try='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest1.cc conftest2.cc $LIBS 1>&5'; { (eval echo configure:1848: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } >/dev/null 2>&1 && test -s conftest${ac_exeext}; then
if { ac_try='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest1.cc conftest2.cc $LIBS 1>&5'; { (eval echo configure:1856: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } >/dev/null 2>&1 && test -s conftest${ac_exeext}; then
cl_cv_cplusplus_ctorexport=no
else
cl_cv_cplusplus_ctorexport=yes
@ -1866,17 +1874,17 @@ fi
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1870: checking for $ac_hdr" >&5
echo "configure:1878: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1875 "configure"
#line 1883 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1880: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1888: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@ -1906,20 +1914,20 @@ done
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
# for constant arguments. Useless!
echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
echo "configure:1910: checking for working alloca.h" >&5
echo "configure:1918: checking for working alloca.h" >&5
if eval "test \"`echo '$''{'cl_cv_header_alloca_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1916 "configure"
#line 1924 "configure"
#include "confdefs.h"
#include <alloca.h>
int main() {
char *p = (char *) alloca(2 * sizeof(int));
; return 0; }
EOF
if { (eval echo configure:1923: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1931: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
cl_cv_header_alloca_h=yes
else
@ -1961,20 +1969,20 @@ char *alloca ();
#endif
"
echo $ac_n "checking for alloca""... $ac_c" 1>&6
echo "configure:1965: checking for alloca" >&5
echo "configure:1973: checking for alloca" >&5
if eval "test \"`echo '$''{'cl_cv_func_alloca'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1971 "configure"
#line 1979 "configure"
#include "confdefs.h"
$decl
int main() {
char *p = (char *) alloca(1);
; return 0; }
EOF
if { (eval echo configure:1978: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1986: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
cl_cv_func_alloca=yes
else
@ -2006,20 +2014,20 @@ EOF
fi
echo $ac_n "checking for fpu_control_t""... $ac_c" 1>&6
echo "configure:2010: checking for fpu_control_t" >&5
echo "configure:2018: checking for fpu_control_t" >&5
if eval "test \"`echo '$''{'cl_cv_type_fpu_control_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2016 "configure"
#line 2024 "configure"
#include "confdefs.h"
#include <fpu_control.h>
int main() {
fpu_control_t x;
; return 0; }
EOF
if { (eval echo configure:2023: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2031: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
cl_cv_type_fpu_control_t=yes
else
@ -2041,20 +2049,20 @@ EOF
fi
echo $ac_n "checking for __setfpucw""... $ac_c" 1>&6
echo "configure:2045: checking for __setfpucw" >&5
echo "configure:2053: checking for __setfpucw" >&5
if eval "test \"`echo '$''{'cl_cv_func_setfpucw'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2051 "configure"
#line 2059 "configure"
#include "confdefs.h"
#include <fpu_control.h>
int main() {
__setfpucw(_FPU_IEEE);
; return 0; }
EOF
if { (eval echo configure:2058: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2066: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
cl_cv_func_setfpucw=yes
else
@ -2080,12 +2088,12 @@ fi
for ac_func in gettimeofday
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:2084: checking for $ac_func" >&5
echo "configure:2092: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2089 "configure"
#line 2097 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -2111,7 +2119,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:2115: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2123: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -2136,13 +2144,13 @@ fi
done
if test $ac_cv_func_gettimeofday = yes; then
echo $ac_n "checking for gettimeofday declaration""... $ac_c" 1>&6
echo "configure:2140: checking for gettimeofday declaration" >&5
echo "configure:2148: checking for gettimeofday declaration" >&5
if eval "test \"`echo '$''{'cl_cv_proto_gettimeofday'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2146 "configure"
#line 2154 "configure"
#include "confdefs.h"
#include <sys/types.h>
@ -2163,7 +2171,7 @@ int main() {
; return 0; }
EOF
if { (eval echo configure:2167: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2175: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
cl_cv_proto_gettimeofday_dots=no
cl_cv_proto_gettimeofday_arg2="struct timezone *"
@ -2172,7 +2180,7 @@ else
cat conftest.$ac_ext >&5
rm -rf conftest*
cat > conftest.$ac_ext <<EOF
#line 2176 "configure"
#line 2184 "configure"
#include "confdefs.h"
#include <sys/types.h>
@ -2193,7 +2201,7 @@ int main() {
; return 0; }
EOF
if { (eval echo configure:2197: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2205: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
cl_cv_proto_gettimeofday_dots=no
cl_cv_proto_gettimeofday_arg2="void *"
@ -2234,12 +2242,12 @@ fi
for ac_func in ftime
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:2238: checking for $ac_func" >&5
echo "configure:2246: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2243 "configure"
#line 2251 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -2265,7 +2273,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:2269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2277: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -2291,12 +2299,12 @@ done
if test $ac_cv_func_gettimeofday = no -a $ac_cv_func_ftime = no; then
echo $ac_n "checking for times""... $ac_c" 1>&6
echo "configure:2295: checking for times" >&5
echo "configure:2303: checking for times" >&5
if eval "test \"`echo '$''{'ac_cv_func_times'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2300 "configure"
#line 2308 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char times(); below. */
@ -2322,7 +2330,7 @@ times();
; return 0; }
EOF
if { (eval echo configure:2326: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2334: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_times=yes"
else
@ -2343,7 +2351,7 @@ no_times=1
fi
if test -z "$no_times"; then
echo $ac_n "checking for times return value""... $ac_c" 1>&6
echo "configure:2347: checking for times return value" >&5
echo "configure:2355: checking for times return value" >&5
if eval "test \"`echo '$''{'cl_cv_func_times_return'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -2352,7 +2360,7 @@ if test "$cross_compiling" = yes; then
cl_cv_func_times_return="guessing no"
else
cat > conftest.$ac_ext <<EOF
#line 2356 "configure"
#line 2364 "configure"
#include "confdefs.h"
#ifdef __cplusplus
extern "C" void exit(int);
@ -2378,7 +2386,7 @@ int main ()
exit(!((ticks >= CLK_TCK/2) && (ticks <= 3*CLK_TCK/2)));
}
EOF
if { (eval echo configure:2382: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:2390: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
cl_cv_func_times_return=yes
else
@ -2416,17 +2424,17 @@ fi
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:2420: checking for $ac_hdr" >&5
echo "configure:2428: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2425 "configure"
#line 2433 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2430: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2438: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@ -2453,13 +2461,13 @@ fi
done
if test $ac_cv_header_sys_resource_h = yes; then
echo $ac_n "checking for getrusage""... $ac_c" 1>&6
echo "configure:2457: checking for getrusage" >&5
echo "configure:2465: checking for getrusage" >&5
if eval "test \"`echo '$''{'cl_cv_func_getrusage'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2463 "configure"
#line 2471 "configure"
#include "confdefs.h"
#include <sys/types.h> /* NetBSD 1.0 needs this */
#include <sys/time.h>
@ -2468,7 +2476,7 @@ int main() {
struct rusage x; int y = RUSAGE_SELF; getrusage(y,&x); x.ru_utime.tv_sec;
; return 0; }
EOF
if { (eval echo configure:2472: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2480: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
cl_cv_func_getrusage=yes
else
@ -2490,13 +2498,13 @@ EOF
fi
if test $cl_cv_func_getrusage = yes; then
echo $ac_n "checking for getrusage declaration""... $ac_c" 1>&6
echo "configure:2494: checking for getrusage declaration" >&5
echo "configure:2502: checking for getrusage declaration" >&5
if eval "test \"`echo '$''{'cl_cv_proto_getrusage'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2500 "configure"
#line 2508 "configure"
#include "confdefs.h"
#include <stdlib.h>
@ -2522,7 +2530,7 @@ int main() {
; return 0; }
EOF
if { (eval echo configure:2526: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2534: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
cl_cv_proto_getrusage_arg1="int"
else
@ -2549,13 +2557,13 @@ EOF
fi
echo $ac_n "checking for perror declaration""... $ac_c" 1>&6
echo "configure:2553: checking for perror declaration" >&5
echo "configure:2561: checking for perror declaration" >&5
if eval "test \"`echo '$''{'cl_cv_proto_perror'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2559 "configure"
#line 2567 "configure"
#include "confdefs.h"
/* Some systems declare perror() in <errno.h>, some in <stdio.h>, some don't
@ -2571,7 +2579,7 @@ int main() {
; return 0; }
EOF
if { (eval echo configure:2575: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2583: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
cl_cv_proto_perror=no
else
@ -2593,7 +2601,7 @@ EOF
fi
echo $ac_n "checking whether characters are unsigned""... $ac_c" 1>&6
echo "configure:2597: checking whether characters are unsigned" >&5
echo "configure:2605: checking whether characters are unsigned" >&5
if eval "test \"`echo '$''{'ac_cv_c_char_unsigned'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -2601,7 +2609,7 @@ else
if test $ac_cv_prog_gcc = yes; then
# GCC predefines this symbol on systems where it applies.
cat > conftest.$ac_ext <<EOF
#line 2605 "configure"
#line 2613 "configure"
#include "confdefs.h"
#ifdef __CHAR_UNSIGNED__
yes
@ -2623,7 +2631,7 @@ if test "$cross_compiling" = yes; then
ac_cv_c_char_unsigned="guessing no"
else
cat > conftest.$ac_ext <<EOF
#line 2627 "configure"
#line 2635 "configure"
#include "confdefs.h"
#ifdef __cplusplus
extern "C" void exit(int);
@ -2636,7 +2644,7 @@ int main() {
volatile char c = 255; exit(c < 0);
}
EOF
if { (eval echo configure:2640: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:2648: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_char_unsigned=yes
else
@ -2673,11 +2681,11 @@ fi
test -d 'include' || mkdir 'include'
cl_machine_file_c=${srcdir}/autoconf/intparam.c
cl_machine_file_h=include/cl_intparam.h
cl_machine_file_h=include/cln/intparam.h
if test $cross_compiling = no; then
if test -z "$cl_cv_file_intparam_h"; then
echo "checking for integer types and behaviour" 1>&6
echo "configure:2681: checking for integer types and behaviour" >&5
echo "configure:2689: checking for integer types and behaviour" >&5
cat > conftest.$ac_ext <<EOF
#include "confdefs.h"
EOF
@ -2688,7 +2696,7 @@ if test $ac_cv_prog_gcc = yes; then
# target 80386. Strip "-O".
CC=`echo "$CC " | sed -e 's/-O //g'`
fi
{ (eval echo configure:2692: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
{ (eval echo configure:2700: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
CC="$ORIGCC"
if test -s conftest; then
echo "creating $cl_machine_file_h"
@ -2711,11 +2719,11 @@ echo "cross-compiling - cannot create $cl_machine_file_h"
fi
cl_machine_file_c=${srcdir}/autoconf/floatparam.c
cl_machine_file_h=include/cl_floatparam.h
cl_machine_file_h=include/cln/floatparam.h
if test $cross_compiling = no; then
if test -z "$cl_cv_file_floatparam_h"; then
echo "checking for floating-point types and behaviour" 1>&6
echo "configure:2719: checking for floating-point types and behaviour" >&5
echo "configure:2727: checking for floating-point types and behaviour" >&5
cat > conftest.$ac_ext <<EOF
#include "confdefs.h"
EOF
@ -2726,7 +2734,7 @@ if test $ac_cv_prog_gcc = yes; then
# target 80386. Strip "-O".
CC=`echo "$CC " | sed -e 's/-O //g'`
fi
{ (eval echo configure:2730: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
{ (eval echo configure:2738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }
CC="$ORIGCC"
if test -s conftest; then
echo "creating $cl_machine_file_h"
@ -2757,14 +2765,14 @@ else
fi
if test "$with_gmp" = yes; then
echo $ac_n "checking for recent enough gmp.h""... $ac_c" 1>&6
echo "configure:2762: checking for recent enough gmp.h" >&5
echo $ac_n "checking for recent enough gmp.h""... $ac_c" 1>&6
echo "configure:2770: checking for recent enough gmp.h" >&5
if eval "test \"`echo '$''{'cl_cv_new_gmp_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2768 "configure"
#line 2776 "configure"
#include "confdefs.h"
#include <gmp.h>
#if !defined(__GNU_MP_VERSION) || (__GNU_MP_VERSION < 3)
@ -2772,7 +2780,7 @@ else
#endif
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2776: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2784: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@ -2788,10 +2796,10 @@ rm -f conftest*
fi
echo "$ac_t""$cl_cv_new_gmp_h" 1>&6
if test "$cl_cv_new_gmp_h" = no; then with_gmp="no"; fi
if test "$with_gmp" = yes; then
echo $ac_n "checking for working libgmp""... $ac_c" 1>&6
echo "configure:2795: checking for working libgmp" >&5
if test "$cl_cv_new_gmp_h" = no; then with_gmp="no"; fi
if test "$with_gmp" = yes; then
echo $ac_n "checking for working libgmp""... $ac_c" 1>&6
echo "configure:2803: checking for working libgmp" >&5
if eval "test \"`echo '$''{'cl_cv_new_libgmp'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -2799,14 +2807,14 @@ else
SAVELIBS=$LIBS
LIBS="$LIBS -lgmp"
cat > conftest.$ac_ext <<EOF
#line 2803 "configure"
#line 2811 "configure"
#include "confdefs.h"
#include <gmp.h>
int main() {
mpn_divexact_by3(0,0,0)
; return 0; }
EOF
if { (eval echo configure:2810: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2818: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
cl_cv_new_libgmp="yes"
else
@ -2819,8 +2827,8 @@ rm -f conftest*
fi
echo "$ac_t""$cl_cv_new_libgmp" 1>&6
if test "$cl_cv_new_libgmp" = no; then with_gmp="no"; fi
fi
if test "$cl_cv_new_libgmp" = no; then with_gmp="no"; fi
fi
fi
if test "$with_gmp" = yes; then
cat >> confdefs.h <<\EOF
@ -2890,7 +2898,7 @@ trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 2 15
test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='$(prefix)'
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
# Any assignment to VPATH causes Sun make to only execute
# the first set of double-colon rules, so remove it if not needed.
@ -2938,7 +2946,7 @@ done
ac_given_srcdir=$srcdir
trap 'rm -fr `echo "Makefile src/Makefile tests/Makefile benchmarks/Makefile examples/Makefile doc/Makefile include/cl_config.h src/base/cl_base_config.h src/base/cl_gmpconfig.h src/float/cl_float_config.h src/timing/cl_t_config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
trap 'rm -fr `echo "Makefile src/Makefile tests/Makefile benchmarks/Makefile examples/Makefile doc/Makefile cln-config include/cln/config.h src/base/cl_base_config.h src/base/cl_gmpconfig.h src/float/cl_float_config.h src/timing/cl_t_config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
EOF
cat >> $CONFIG_STATUS <<EOF
@ -2991,6 +2999,7 @@ s%@LIBTOOL@%$LIBTOOL%g
s%@CL_CURRENT@%$CL_CURRENT%g
s%@CL_REVISION@%$CL_REVISION%g
s%@CL_AGE@%$CL_AGE%g
s%@CL_VERSION@%$CL_VERSION%g
s%@ALLOCA@%$ALLOCA%g
CEOF
@ -3033,7 +3042,7 @@ EOF
cat >> $CONFIG_STATUS <<EOF
CONFIG_FILES=\${CONFIG_FILES-"Makefile src/Makefile tests/Makefile benchmarks/Makefile examples/Makefile doc/Makefile"}
CONFIG_FILES=\${CONFIG_FILES-"Makefile src/Makefile tests/Makefile benchmarks/Makefile examples/Makefile doc/Makefile cln-config"}
EOF
cat >> $CONFIG_STATUS <<\EOF
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
@ -3114,7 +3123,7 @@ ac_fD='%g'
if test "${CONFIG_HEADERS+set}" != set; then
EOF
cat >> $CONFIG_STATUS <<EOF
CONFIG_HEADERS="include/cl_config.h src/base/cl_base_config.h src/base/cl_gmpconfig.h src/float/cl_float_config.h src/timing/cl_t_config.h"
CONFIG_HEADERS="include/cln/config.h src/base/cl_base_config.h src/base/cl_gmpconfig.h src/float/cl_float_config.h src/timing/cl_t_config.h"
EOF
cat >> $CONFIG_STATUS <<\EOF
fi
@ -3199,7 +3208,7 @@ cat >> $CONFIG_STATUS <<EOF
EOF
cat >> $CONFIG_STATUS <<\EOF
chmod +x cln-config
exit 0
EOF
chmod +x $CONFIG_STATUS

31
configure.in

@ -4,7 +4,8 @@ dnl
dnl configure.in ---<autoconf>--->> configure
dnl
dnl configure ---<sh>--->> config.status
dnl --->> include/cl_config.h
dnl --->> include/cln/config.h
dnl cln-config.in --->> cln-config
dnl Makefile.in --->> Makefile
dnl src/Makefile.in --->> src/Makefile
dnl
@ -12,7 +13,7 @@ dnl Makefile ---<make>--->> libcln.a
dnl
dnl
AC_INIT(src/integer/gcd/cl_I_gcd.cc)
AC_CONFIG_HEADER(include/cl_config.h src/base/cl_base_config.h src/base/cl_gmpconfig.h src/float/cl_float_config.h src/timing/cl_t_config.h)
AC_CONFIG_HEADER(include/cln/config.h src/base/cl_base_config.h src/base/cl_gmpconfig.h src/float/cl_float_config.h src/timing/cl_t_config.h)
AC_PROG_MAKE_SET
dnl This piece of sed script replaces every line containing '@subdir@'
dnl by several consecutive lines, each referencing one subdir.
@ -64,8 +65,13 @@ CL_CANONICAL_HOST_CPU
dnl
dnl check for build configuration
dnl
LIBS=-lm
dnl libcln depends on libm
PACKAGE=cln
dnl libtool wants PACKAGE
AM_PROG_LIBTOOL
dnl sets variable LIBTOOL
dnl Libtool's library version information for CLN.
dnl (Not to be confused with CLN's release version.)
dnl Making new releases:
@ -82,15 +88,18 @@ AC_SUBST(CL_CURRENT)
AC_SUBST(CL_REVISION)
AC_SUBST(CL_AGE)
dnl release version
CL_VERSION=1
CL_VERSION_MAJOR=1
CL_VERSION_MINOR=1
CL_VERSION_PATCHLEVEL=0
dnl release version for cl_config.h, so it can be tested by the preprocessor
AC_DEFINE_UNQUOTED(CL_VERSION, $CL_VERSION)
dnl release version for cln/config.h, so it can be tested by the preprocessor
AC_DEFINE_UNQUOTED(CL_VERSION_MAJOR, $CL_VERSION_MAJOR)
AC_DEFINE_UNQUOTED(CL_VERSION_MINOR, $CL_VERSION_MINOR)
AC_DEFINE_UNQUOTED(CL_VERSION_PATCHLEVEL, $CL_VERSION_PATCHLEVEL)
dnl concateneted release version
CL_VERSION=$CL_VERSION_MAJOR.$CL_VERSION_MINOR.$CL_VERSION_PATCHLEVEL
AC_DEFINE_UNQUOTED(CL_VERSION, $CL_VERSION)
AC_SUBST(CL_VERSION)
dnl sets variable LIBTOOL
dnl
dnl checks for compiler characteristics
dnl
@ -137,10 +146,10 @@ dnl
CL_CHAR_UNSIGNED
dnl DEFS __CHAR_UNSIGNED__ if char is unsigned
test -d 'include' || mkdir 'include'
CL_MACHINE([integer types and behaviour],${srcdir}/autoconf/intparam.c,include/cl_intparam.h,cl_cv_file_intparam_h)
dnl builds include/cl_intparam.h
CL_MACHINE([floating-point types and behaviour],${srcdir}/autoconf/floatparam.c,include/cl_floatparam.h,cl_cv_file_floatparam_h)
dnl builds include/cl_floatparam.h
CL_MACHINE([integer types and behaviour],${srcdir}/autoconf/intparam.c,include/cln/intparam.h,cl_cv_file_intparam_h)
dnl builds include/cln/intparam.h
CL_MACHINE([floating-point types and behaviour],${srcdir}/autoconf/floatparam.c,include/cln/floatparam.h,cl_cv_file_floatparam_h)
dnl builds include/cln/floatparam.h
dnl
dnl interfacing to GNU gmp (must be at least version 3)
dnl
@ -172,4 +181,4 @@ changequote([,])dnl
cp "$srcdir/$f" "$f"
fi
done
AC_OUTPUT(Makefile src/Makefile tests/Makefile benchmarks/Makefile examples/Makefile doc/Makefile)
AC_OUTPUT([Makefile src/Makefile tests/Makefile benchmarks/Makefile examples/Makefile doc/Makefile cln-config], [chmod +x cln-config])

BIN
doc/cln.dvi

1106
doc/cln.html
File diff suppressed because it is too large
View File

704
doc/cln.info
File diff suppressed because it is too large
View File

4106
doc/cln.ps
File diff suppressed because it is too large
View File

516
doc/cln.tex
File diff suppressed because it is too large
View File

525
doc/cln.texi
File diff suppressed because it is too large
View File

7
doc/cln_1.html

@ -1,6 +1,6 @@
<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from cln.texi on 2 June 2000 -->
<!-- Created by texi2html 1.56k from cln.texi on 28 August 2000 -->
<TITLE>CLN, a Class Library for Numbers - 1. Introduction</TITLE>
</HEAD>
@ -162,6 +162,11 @@ The garbage collection imposes no burden on the main application.
<LI>
The library provides hooks for memory allocation and exceptions.
<LI>
<A NAME="IDX3"></A>
All non-macro identifiers are hidden in namespace <CODE>cln</CODE> in
order to avoid name clashes.
</UL>
<P><HR><P>

14
doc/cln_10.html

@ -1,6 +1,6 @@
<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from cln.texi on 2 June 2000 -->
<!-- Created by texi2html 1.56k from cln.texi on 28 August 2000 -->
<TITLE>CLN, a Class Library for Numbers - 10. Internals</TITLE>
</HEAD>
@ -15,7 +15,7 @@ Go to the <A HREF="cln_1.html">first</A>, <A HREF="cln_9.html">previous</A>, <A
<H2><A NAME="SEC60" HREF="cln_toc.html#TOC60">10.1 Why C++ ?</A></H2>
<P>
<A NAME="IDX314"></A>
<A NAME="IDX327"></A>
<P>
@ -30,7 +30,7 @@ Efficiency: It compiles to machine code.
<LI>
<A NAME="IDX315"></A>
<A NAME="IDX328"></A>
Portability: It runs on all platforms supporting a C++ compiler. Because
of the availability of GNU C++, this includes all currently used 32-bit and
64-bit platforms, independently of the quality of the vendor's C++ compiler.
@ -76,8 +76,8 @@ Object sharing: An operation like <CODE>x+0</CODE> returns <CODE>x</CODE> withou
it.
<LI>
<A NAME="IDX316"></A>
<A NAME="IDX317"></A>
<A NAME="IDX329"></A>
<A NAME="IDX330"></A>
Garbage collection: A reference counting mechanism makes sure that any
number object's storage is freed immediately when the last reference to the
object is gone.
@ -122,7 +122,7 @@ algorithm.
For very large numbers (more than 12000 decimal digits), CLN uses
Schönhage-Strassen
<A NAME="IDX318"></A>
<A NAME="IDX331"></A>
multiplication, which is an asymptotically optimal multiplication
algorithm.
<LI>
@ -135,7 +135,7 @@ of division and radix conversion.
<H2><A NAME="SEC63" HREF="cln_toc.html#TOC63">10.4 Garbage collection</A></H2>
<P>
<A NAME="IDX319"></A>
<A NAME="IDX332"></A>
<P>

201
doc/cln_11.html

@ -1,6 +1,6 @@
<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from cln.texi on 2 June 2000 -->
<!-- Created by texi2html 1.56k from cln.texi on 28 August 2000 -->
<TITLE>CLN, a Class Library for Numbers - 11. Using the library</TITLE>
</HEAD>
@ -23,7 +23,7 @@ environment variables, or directly substitute the appropriate values.
<H2><A NAME="SEC65" HREF="cln_toc.html#TOC65">11.1 Compiler options</A></H2>
<P>
<A NAME="IDX320"></A>
<A NAME="IDX333"></A>
<P>
@ -60,10 +60,53 @@ linking a CLN application it is sufficient to give the flag <CODE>-lcln</CODE>.
<H2><A NAME="SEC66" HREF="cln_toc.html#TOC66">11.2 Include files</A></H2>
<H2><A NAME="SEC66" HREF="cln_toc.html#TOC66">11.2 Compatibility to old CLN versions</A></H2>
<P>
<A NAME="IDX321"></A>
<A NAME="IDX322"></A>
<A NAME="IDX334"></A>
<A NAME="IDX335"></A>
<P>
As of CLN version 1.1 all non-macro identifiers were hidden in namespace
<CODE>cln</CODE> in order to avoid potential name clashes with other C++
libraries. If you have an old application, you will have to manually
port it to the new scheme. The following principles will help during
the transition:
<UL>
<LI>
All headers are now in a separate subdirectory. Instead of including
<CODE>cl_</CODE><VAR>something</VAR><CODE>.h</CODE>, include
<CODE>cln/</CODE><VAR>something</VAR><CODE>.h</CODE> now.
<LI>
All public identifiers (typenames and functions) have lost their
<CODE>cl_</CODE> prefix. Exceptions are all the typenames of number types,
(cl_N, cl_I, cl_MI, ...), rings, symbolic types (cl_string,
cl_symbol) and polynomials (cl_UP_<VAR>type</VAR>). (This is because their
names would not be mnemonic enough once the namespace <CODE>cln</CODE> is
imported. Even in a namespace we favor <CODE>cl_N</CODE> over <CODE>N</CODE>.)
<LI>
All public <EM>functions</EM> that had by a <CODE>cl_</CODE> in their name still
carry that <CODE>cl_</CODE> if it is intrinsic part of a typename (as in
<CODE>cl_I_to_int ()</CODE>).
</UL>
<P>
When developing other libraries, please keep in mind not to import the
namespace <CODE>cln</CODE> in one of your public header files by saying
<CODE>using namespace cln;</CODE>. This would propagate to other applications
and can cause name clashes there.
<H2><A NAME="SEC67" HREF="cln_toc.html#TOC67">11.3 Include files</A></H2>
<P>
<A NAME="IDX336"></A>
<A NAME="IDX337"></A>
<P>
@ -72,201 +115,202 @@ Here is a summary of the include files and their contents.
<DL COMPACT>
<DT><CODE>&#60;cl_object.h&#62;</CODE>
<DT><CODE>&#60;cln/object.h&#62;</CODE>
<DD>
General definitions, reference counting, garbage collection.
<DT><CODE>&#60;cl_number.h&#62;</CODE>
<DT><CODE>&#60;cln/number.h&#62;</CODE>
<DD>
The class cl_number.
<DT><CODE>&#60;cl_complex.h&#62;</CODE>
<DT><CODE>&#60;cln/complex.h&#62;</CODE>
<DD>
Functions for class cl_N, the complex numbers.
<DT><CODE>&#60;cl_real.h&#62;</CODE>
<DT><CODE>&#60;cln/real.h&#62;</CODE>
<DD>
Functions for class cl_R, the real numbers.
<DT><CODE>&#60;cl_float.h&#62;</CODE>
<DT><CODE>&#60;cln/float.h&#62;</CODE>
<DD>
Functions for class cl_F, the floats.
<DT><CODE>&#60;cl_sfloat.h&#62;</CODE>
<DT><CODE>&#60;cln/sfloat.h&#62;</CODE>
<DD>
Functions for class cl_SF, the short-floats.
<DT><CODE>&#60;cl_ffloat.h&#62;</CODE>
<DT><CODE>&#60;cln/ffloat.h&#62;</CODE>
<DD>
Functions for class cl_FF, the single-floats.
<DT><CODE>&#60;cl_dfloat.h&#62;</CODE>
<DT><CODE>&#60;cln/dfloat.h&#62;</CODE>
<DD>
Functions for class cl_DF, the double-floats.
<DT><CODE>&#60;cl_lfloat.h&#62;</CODE>
<DT><CODE>&#60;cln/lfloat.h&#62;</CODE>
<DD>
Functions for class cl_LF, the long-floats.
<DT><CODE>&#60;cl_rational.h&#62;</CODE>
<DT><CODE>&#60;cln/rational.h&#62;</CODE>
<DD>
Functions for class cl_RA, the rational numbers.
<DT><CODE>&#60;cl_integer.h&#62;</CODE>
<DT><CODE>&#60;cln/integer.h&#62;</CODE>
<DD>
Functions for class cl_I, the integers.
<DT><CODE>&#60;cl_io.h&#62;</CODE>
<DT><CODE>&#60;cln/io.h&#62;</CODE>
<DD>
Input/Output.
<DT><CODE>&#60;cl_complex_io.h&#62;</CODE>
<DT><CODE>&#60;cln/complex_io.h&#62;</CODE>
<DD>
Input/Output for class cl_N, the complex numbers.
<DT><CODE>&#60;cl_real_io.h&#62;</CODE>
<DT><CODE>&#60;cln/real_io.h&#62;</CODE>
<DD>
Input/Output for class cl_R, the real numbers.
<DT><CODE>&#60;cl_float_io.h&#62;</CODE>
<DT><CODE>&#60;cln/float_io.h&#62;</CODE>
<DD>
Input/Output for class cl_F, the floats.
<DT><CODE>&#60;cl_sfloat_io.h&#62;</CODE>
<DT><CODE>&#60;cln/sfloat_io.h&#62;</CODE>
<DD>
Input/Output for class cl_SF, the short-floats.
<DT><CODE>&#60;cl_ffloat_io.h&#62;</CODE>
<DT><CODE>&#60;cln/ffloat_io.h&#62;</CODE>
<DD>
Input/Output for class cl_FF, the single-floats.
<DT><CODE>&#60;cl_dfloat_io.h&#62;</CODE>
<DT><CODE>&#60;cln/dfloat_io.h&#62;</CODE>
<DD>
Input/Output for class cl_DF, the double-floats.
<DT><CODE>&#60;cl_lfloat_io.h&#62;</CODE>
<DT><CODE>&#60;cln/lfloat_io.h&#62;</CODE>
<DD>
Input/Output for class cl_LF, the long-floats.
<DT><CODE>&#60;cl_rational_io.h&#62;</CODE>
<DT><CODE>&#60;cln/rational_io.h&#62;</CODE>
<DD>
Input/Output for class cl_RA, the rational numbers.
<DT><CODE>&#60;cl_integer_io.h&#62;</CODE>
<DT><CODE>&#60;cln/integer_io.h&#62;</CODE>
<DD>
Input/Output for class cl_I, the integers.
<DT><CODE>&#60;cl_input.h&#62;</CODE>
<DT><CODE>&#60;cln/input.h&#62;</CODE>
<DD>
Flags for customizing input operations.
<DT><CODE>&#60;cl_output.h&#62;</CODE>
<DT><CODE>&#60;cln/output.h&#62;</CODE>
<DD>
Flags for customizing output operations.
<DT><CODE>&#60;cl_malloc.h&#62;</CODE>
<DT><CODE>&#60;cln/malloc.h&#62;</CODE>
<DD>
<CODE>cl_malloc_hook</CODE>, <CODE>cl_free_hook</CODE>.
<DT><CODE>&#60;cl_abort.h&#62;</CODE>
<CODE>malloc_hook</CODE>, <CODE>free_hook</CODE>.
<DT><CODE>&#60;cln/abort.h&#62;</CODE>
<DD>
<CODE>cl_abort</CODE>.
<DT><CODE>&#60;cl_condition.h&#62;</CODE>
<DT><CODE>&#60;cln/condition.h&#62;</CODE>
<DD>
Conditions/exceptions.
<DT><CODE>&#60;cl_string.h&#62;</CODE>
<DT><CODE>&#60;cln/string.h&#62;</CODE>
<DD>
Strings.
<DT><CODE>&#60;cl_symbol.h&#62;</CODE>
<DT><CODE>&#60;cln/symbol.h&#62;</CODE>
<DD>
Symbols.
<DT><CODE>&#60;cl_proplist.h&#62;</CODE>
<DT><CODE>&#60;cln/proplist.h&#62;</CODE>
<DD>
Property lists.
<DT><CODE>&#60;cl_ring.h&#62;</CODE>
<DT><CODE>&#60;cln/ring.h&#62;</CODE>
<DD>
General rings.
<DT><CODE>&#60;cl_null_ring.h&#62;</CODE>
<DT><CODE>&#60;cln/null_ring.h&#62;</CODE>
<DD>
The null ring.
<DT><CODE>&#60;cl_complex_ring.h&#62;</CODE>
<DT><CODE>&#60;cln/complex_ring.h&#62;</CODE>
<DD>
The ring of complex numbers.
<DT><CODE>&#60;cl_real_ring.h&#62;</CODE>
<DT><CODE>&#60;cln/real_ring.h&#62;</CODE>
<DD>
The ring of real numbers.
<DT><CODE>&#60;cl_rational_ring.h&#62;</CODE>
<DT><CODE>&#60;cln/rational_ring.h&#62;</CODE>
<DD>
The ring of rational numbers.
<DT><CODE>&#60;cl_integer_ring.h&#62;</CODE>
<DT><CODE>&#60;cln/integer_ring.h&#62;</CODE>
<DD>
The ring of integers.
<DT><CODE>&#60;cl_numtheory.h&#62;</CODE>
<DT><CODE>&#60;cln/numtheory.h&#62;</CODE>
<DD>
Number threory functions.
<DT><CODE>&#60;cl_modinteger.h&#62;</CODE>
<DT><CODE>&#60;cln/modinteger.h&#62;</CODE>
<DD>
Modular integers.
<DT><CODE>&#60;cl_V.h&#62;</CODE>
<DT><CODE>&#60;cln/V.h&#62;</CODE>
<DD>
Vectors.
<DT><CODE>&#60;cl_GV.h&#62;</CODE>
<DT><CODE>&#60;cln/GV.h&#62;</CODE>
<DD>
General vectors.
<DT><CODE>&#60;cl_GV_number.h&#62;</CODE>
<DT><CODE>&#60;cln/GV_number.h&#62;</CODE>
<DD>
General vectors over cl_number.
<DT><CODE>&#60;cl_GV_complex.h&#62;</CODE>
<DT><CODE>&#60;cln/GV_complex.h&#62;</CODE>
<DD>
General vectors over cl_N.
<DT><CODE>&#60;cl_GV_real.h&#62;</CODE>
<DT><CODE>&#60;cln/GV_real.h&#62;</CODE>
<DD>
General vectors over cl_R.
<DT><CODE>&#60;cl_GV_rational.h&#62;</CODE>
<DT><CODE>&#60;cln/GV_rational.h&#62;</CODE>
<DD>
General vectors over cl_RA.
<DT><CODE>&#60;cl_GV_integer.h&#62;</CODE>
<DT><CODE>&#60;cln/GV_integer.h&#62;</CODE>
<DD>
General vectors over cl_I.
<DT><CODE>&#60;cl_GV_modinteger.h&#62;</CODE>
<DT><CODE>&#60;cln/GV_modinteger.h&#62;</CODE>
<DD>
General vectors of modular integers.
<DT><CODE>&#60;cl_SV.h&#62;</CODE>
<DT><CODE>&#60;cln/SV.h&#62;</CODE>
<DD>
Simple vectors.
<DT><CODE>&#60;cl_SV_number.h&#62;</CODE>
<DT><CODE>&#60;cln/SV_number.h&#62;</CODE>
<DD>
Simple vectors over cl_number.
<DT><CODE>&#60;cl_SV_complex.h&#62;</CODE>
<DT><CODE>&#60;cln/SV_complex.h&#62;</CODE>
<DD>
Simple vectors over cl_N.
<DT><CODE>&#60;cl_SV_real.h&#62;</CODE>
<DT><CODE>&#60;cln/SV_real.h&#62;</CODE>
<DD>
Simple vectors over cl_R.
<DT><CODE>&#60;cl_SV_rational.h&#62;</CODE>
<DT><CODE>&#60;cln/SV_rational.h&#62;</CODE>
<DD>
Simple vectors over cl_RA.
<DT><CODE>&#60;cl_SV_integer.h&#62;</CODE>
<DT><CODE>&#60;cln/SV_integer.h&#62;</CODE>
<DD>
Simple vectors over cl_I.
<DT><CODE>&#60;cl_SV_ringelt.h&#62;</CODE>
<DT><CODE>&#60;cln/SV_ringelt.h&#62;</CODE>
<DD>
Simple vectors of general ring elements.
<DT><CODE>&#60;cl_univpoly.h&#62;</CODE>
<DT><CODE>&#60;cln/univpoly.h&#62;</CODE>
<DD>
Univariate polynomials.
<DT><CODE>&#60;cl_univpoly_integer.h&#62;</CODE>
<DT><CODE>&#60;cln/univpoly_integer.h&#62;</CODE>
<DD>
Univariate polynomials over the integers.
<DT><CODE>&#60;cl_univpoly_rational.h&#62;</CODE>
<DT><CODE>&#60;cln/univpoly_rational.h&#62;</CODE>
<DD>
Univariate polynomials over the rational numbers.
<DT><CODE>&#60;cl_univpoly_real.h&#62;</CODE>
<DT><CODE>&#60;cln/univpoly_real.h&#62;</CODE>
<DD>
Univariate polynomials over the real numbers.
<DT><CODE>&#60;cl_univpoly_complex.h&#62;</CODE>
<DT><CODE>&#60;cln/univpoly_complex.h&#62;</CODE>
<DD>
Univariate polynomials over the complex numbers.
<DT><CODE>&#60;cl_univpoly_modint.h&#62;</CODE>
<DT><CODE>&#60;cln/univpoly_modint.h&#62;</CODE>
<DD>
Univariate polynomials over modular integer rings.
<DT><CODE>&#60;cl_timing.h&#62;</CODE>
<DT><CODE>&#60;cln/timing.h&#62;</CODE>
<DD>
Timing facilities.
<DT><CODE>&#60;cln.h&#62;</CODE>
<DT><CODE>&#60;cln/cln.h&#62;</CODE>
<DD>
Includes all of the above.
</DL>
<H2><A NAME="SEC67" HREF="cln_toc.html#TOC67">11.3 An Example</A></H2>
<H2><A NAME="SEC68" HREF="cln_toc.html#TOC68">11.4 An Example</A></H2>
<P>
A function which computes the nth Fibonacci number can be written as follows.
<A NAME="IDX323"></A>
<A NAME="IDX338"></A>
<PRE>
#include &#60;cl_integer.h&#62;
#include &#60;cl_real.h&#62;
#include &#60;cln/integer.h&#62;
#include &#60;cln/real.h&#62;
using namespace cln;
// Returns F_n, computed as the nearest integer to
// ((1+sqrt(5))/2)^n/sqrt(5). Assume n&#62;=0.
@ -285,10 +329,11 @@ Let's explain what is going on in detail.
<P>
The include file <CODE>&#60;cl_integer.h&#62;</CODE> is necessary because the type
<CODE>cl_I</CODE> is used in the function, and the include file <CODE>&#60;cl_real.h&#62;</CODE>
The include file <CODE>&#60;cln/integer.h&#62;</CODE> is necessary because the type
<CODE>cl_I</CODE> is used in the function, and the include file <CODE>&#60;cln/real.h&#62;</CODE>
is needed for the type <CODE>cl_R</CODE> and the floating point number functions.
The order of the include files does not matter.
The order of the include files does not matter. In order not to write out
<CODE>cln::</CODE><VAR>foo</VAR> we can safely import the whole namespace <CODE>cln</CODE>.
<P>
@ -344,9 +389,9 @@ contains this implementation together with an even faster algorithm.
<H2><A NAME="SEC68" HREF="cln_toc.html#TOC68">11.4 Debugging support</A></H2>
<H2><A NAME="SEC69" HREF="cln_toc.html#TOC69">11.5 Debugging support</A></H2>
<P>
<A NAME="IDX324"></A>
<A NAME="IDX339"></A>
<P>
@ -380,11 +425,11 @@ CLN offers a function <CODE>cl_print</CODE>, callable from the debugger,
for printing number objects. In order to get this function, you have
to define the macro <SAMP>`CL_DEBUG'</SAMP> and then include all the header files
for which you want <CODE>cl_print</CODE> debugging support. For example:
<A NAME="IDX325"></A>
<A NAME="IDX340"></A>
<PRE>
#define CL_DEBUG
#include &#60;cl_string.h&#62;
#include &#60;cln/string.h&#62;
</PRE>
Now, if you have in your program a variable <CODE>cl_string s</CODE>, and
@ -407,7 +452,7 @@ only with number objects and similar. Therefore CLN offers a member function
<CODE>debug_print()</CODE> on all CLN types. The same macro <SAMP>`CL_DEBUG'</SAMP>
is needed for this member function to be implemented. Under <CODE>gdb</CODE>,
you call it like this:
<A NAME="IDX326"></A>
<A NAME="IDX341"></A>
<PRE>
(gdb) print s

42
doc/cln_12.html

@ -1,6 +1,6 @@
<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from cln.texi on 2 June 2000 -->
<!-- Created by texi2html 1.56k from cln.texi on 28 August 2000 -->
<TITLE>CLN, a Class Library for Numbers - 12. Customizing</TITLE>
</HEAD>
@ -9,14 +9,14 @@ Go to the <A HREF="cln_1.html">first</A>, <A HREF="cln_11.html">previous</A>, <A
<P><HR><P>
<H1><A NAME="SEC69" HREF="cln_toc.html#TOC69">12. Customizing</A></H1>
<H1><A NAME="SEC70" HREF="cln_toc.html#TOC70">12. Customizing</A></H1>
<P>
<A NAME="IDX327"></A>
<A NAME="IDX342"></A>
<H2><A NAME="SEC70" HREF="cln_toc.html#TOC70">12.1 Error handling</A></H2>
<H2><A NAME="SEC71" HREF="cln_toc.html#TOC71">12.1 Error handling</A></H2>
<P>
When a fatal error occurs, an error message is output to the standard error
@ -26,20 +26,20 @@ To catch such a fatal error, you need to define the function <CODE>cl_abort</COD
yourself, with the prototype
<PRE>
#include &#60;cl_abort.h&#62;
#include &#60;cln/abort.h&#62;
void cl_abort (void);
</PRE>
<P>
<A NAME="IDX328"></A>
<A NAME="IDX343"></A>
This function must not return control to its caller.
<H2><A NAME="SEC71" HREF="cln_toc.html#TOC71">12.2 Floating-point underflow</A></H2>
<H2><A NAME="SEC72" HREF="cln_toc.html#TOC72">12.2 Floating-point underflow</A></H2>
<P>
<A NAME="IDX329"></A>
<A NAME="IDX344"></A>
<P>
@ -60,37 +60,39 @@ will be generated instead. The default value of
<H2><A NAME="SEC72" HREF="cln_toc.html#TOC72">12.3 Customizing I/O</A></H2>
<H2><A NAME="SEC73" HREF="cln_toc.html#TOC73">12.3 Customizing I/O</A></H2>
<P>
The output of the function <CODE>fprint</CODE> may be customized by changing the
value of the global variable <CODE>cl_default_print_flags</CODE>.
<A NAME="IDX330"></A>
value of the global variable <CODE>default_print_flags</CODE>.
<A NAME="IDX345"></A>
<H2><A NAME="SEC73" HREF="cln_toc.html#TOC73">12.4 Customizing the memory allocator</A></H2>
<H2><A NAME="SEC74" HREF="cln_toc.html#TOC74">12.4 Customizing the memory allocator</A></H2>
<P>
Every memory allocation of CLN is done through the function pointer
<CODE>cl_malloc_hook</CODE>. Freeing of this memory is done through the function
pointer <CODE>cl_free_hook</CODE>. The default versions of these functions,
<CODE>malloc_hook</CODE>. Freeing of this memory is done through the function
pointer <CODE>free_hook</CODE>. The default versions of these functions,
provided in the library, call <CODE>malloc</CODE> and <CODE>free</CODE> and check
the <CODE>malloc</CODE> result against <CODE>NULL</CODE>.
If you want to provide another memory allocator, you need to define
the variables <CODE>cl_malloc_hook</CODE> and <CODE>cl_free_hook</CODE> yourself,
the variables <CODE>malloc_hook</CODE> and <CODE>free_hook</CODE> yourself,
like this:
<PRE>
#include &#60;cl_malloc.h&#62;
void* (*cl_malloc_hook) (size_t size) = ...;
void (*cl_free_hook) (void* ptr) = ...;
#include &#60;cln/malloc.h&#62;
namespace cln {
void* (*malloc_hook) (size_t size) = ...;
void (*free_hook) (void* ptr) = ...;
}
</PRE>
<P>
<A NAME="IDX331"></A>
<A NAME="IDX332"></A>
<A NAME="IDX346"></A>
<A NAME="IDX347"></A>
The <CODE>cl_malloc_hook</CODE> function must not return a <CODE>NULL</CODE> pointer.

4
doc/cln_13.html

@ -1,6 +1,6 @@
<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from cln.texi on 2 June 2000 -->
<!-- Created by texi2html 1.56k from cln.texi on 28 August 2000 -->
<TITLE>CLN, a Class Library for Numbers - Index</TITLE>
</HEAD>
@ -9,7 +9,7 @@ Go to the <A HREF="cln_1.html">first</A>, <A HREF="cln_12.html">previous</A>, ne
<P><HR><P>
<H1><A NAME="SEC74" HREF="cln_toc.html#TOC74">Index</A></H1>
<H1><A NAME="SEC75" HREF="cln_toc.html#TOC75">Index</A></H1>
<P>
Jump to:

44
doc/cln_2.html

@ -1,6 +1,6 @@
<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from cln.texi on 2 June 2000 -->
<!-- Created by texi2html 1.56k from cln.texi on 28 August 2000 -->
<TITLE>CLN, a Class Library for Numbers - 2. Installation</TITLE>
</HEAD>
@ -25,23 +25,21 @@ This section describes how to install the CLN package on your system.
<P>
To build CLN, you need a C++ compiler.
Actually, you need GNU <CODE>g++ 2.7.0</CODE> or newer.
On HPPA, you need GNU <CODE>g++ 2.8.0</CODE> or newer.
Actually, you need GNU <CODE>g++ 2.90</CODE> or newer, the EGCS compilers will
do.
I recommend GNU <CODE>g++ 2.95</CODE> or newer.
<P>
The following C++ features are used:
classes, member functions,
overloading of functions and operators,
constructors and destructors, inline, const,
multiple inheritance, templates.
classes, member functions, overloading of functions and operators,
constructors and destructors, inline, const, multiple inheritance,
templates and namespaces.
<P>
The following C++ features are not used:
<CODE>new</CODE>, <CODE>delete</CODE>, virtual inheritance,
exceptions.
<CODE>new</CODE>, <CODE>delete</CODE>, virtual inheritance, exceptions.
<P>
@ -54,7 +52,7 @@ implement for GNU g++ only.
<H3><A NAME="SEC5" HREF="cln_toc.html#TOC5">2.1.2 Make utility</A></H3>
<P>
<A NAME="IDX3"></A>
<A NAME="IDX4"></A>
<P>
@ -65,7 +63,7 @@ To build CLN, you also need to have GNU <CODE>make</CODE> installed.
<H3><A NAME="SEC6" HREF="cln_toc.html#TOC6">2.1.3 Sed utility</A></H3>
<P>
<A NAME="IDX4"></A>
<A NAME="IDX5"></A>
<P>
@ -147,12 +145,10 @@ Examples:
<PRE>
$ CC="gcc" CFLAGS="-O" CXX="g++" CXXFLAGS="-O" ./configure
$ CC="gcc -V 2.7.2" CFLAGS="-O -g" \
CXX="g++ -V 2.7.2" CXXFLAGS="-O -g" ./configure
$ CC="gcc -V 2.8.1" CFLAGS="-O -fno-exceptions" \
CXX="g++ -V 2.8.1" CXXFLAGS="-O -fno-exceptions" ./configure
$ CC="gcc -V egcs-2.91.60" CFLAGS="-O2 -fno-exceptions" \
CXX="g++ -V egcs-2.91.60" CFLAGS="-O2 -fno-exceptions" ./configure
$ CC="gcc -V egcs-2.91.60" CFLAGS="-O -g" \
CXX="g++ -V egcs-2.91.60" CXXFLAGS="-O -g" ./configure
$ CC="gcc -V 2.95.2" CFLAGS="-O2 -fno-exceptions" \
CXX="g++ -V 2.95.2" CFLAGS="-O2 -fno-exceptions" ./configure
</PRE>
<P>
@ -165,13 +161,9 @@ calling <CODE>configure</CODE>. In a <CODE>csh</CODE> shell, you have to use the
<P>
On Linux, <CODE>g++</CODE> needs 15 MB to compile the tests. So you should better
have 17 MB swap space and 1 MB room in $TMPDIR.
<P>
If you use <CODE>g++</CODE> version 2.7.x, don't add <SAMP>`-O2'</SAMP> to the CXXFLAGS,
because <SAMP>`g++ -O'</SAMP> generates better code for CLN than <SAMP>`g++ -O2'</SAMP>.
Currently CLN works only with the GNU <CODE>g++</CODE> compiler, and only in
optimizing mode. So you should specify at least <CODE>-O</CODE> in the CXXFLAGS,
or no CXXFLAGS at all. (If CXXFLAGS is not set, CLN will use <CODE>-O</CODE>.)
<P>
@ -203,7 +195,7 @@ libraries so runtime-critical applications should be linked statically.
<H3><A NAME="SEC8" HREF="cln_toc.html#TOC8">2.2.1 Using the GNU MP Library</A></H3>
<P>
<A NAME="IDX5"></A>
<A NAME="IDX6"></A>
<P>
@ -232,7 +224,7 @@ $ CC="gcc" CFLAGS="-O2" CXX="g++" CXXFLAGS="-O2 -fno-exceptions" \
<H2><A NAME="SEC9" HREF="cln_toc.html#TOC9">2.3 Installing the library</A></H2>
<P>
<A NAME="IDX6"></A>
<A NAME="IDX7"></A>
<P>

74
doc/cln_3.html

@ -1,6 +1,6 @@
<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from cln.texi on 2 June 2000 -->
<!-- Created by texi2html 1.56k from cln.texi on 28 August 2000 -->
<TITLE>CLN, a Class Library for Numbers - 3. Ordinary number types</TITLE>
</HEAD>
@ -18,35 +18,35 @@ CLN implements the following class hierarchy:
<PRE>
Number
cl_number
&#60;cl_number.h&#62;
cl_number
&#60;cln/number.h&#62;
|
|
Real or complex number
cl_N
&#60;cl_complex.h&#62;
&#60;cln/complex.h&#62;
|
|
Real number
cl_R
&#60;cl_real.h&#62;
&#60;cln/real.h&#62;
|
+-------------------+-------------------+
| |
Rational number Floating-point number
cl_RA cl_F
&#60;cl_rational.h&#62; &#60;cl_float.h&#62;
&#60;cln/rational.h&#62; &#60;cln/float.h&#62;
| |
| +-------------+-------------+-------------+
Integer | | | |
cl_I Short-Float Single-Float Double-Float Long-Float
&#60;cl_integer.h&#62; cl_SF cl_FF cl_DF cl_LF
&#60;cl_sfloat.h&#62; &#60;cl_ffloat.h&#62; &#60;cl_dfloat.h&#62; &#60;cl_lfloat.h&#62;
| +--------------+--------------+--------------+
Integer | | | |
cl_I Short-Float Single-Float Double-Float Long-Float
&#60;cln/integer.h&#62; cl_SF cl_FF cl_DF cl_LF
&#60;cln/sfloat.h&#62; &#60;cln/ffloat.h&#62; &#60;cln/dfloat.h&#62; &#60;cln/lfloat.h&#62;
</PRE>
<P>
<A NAME="IDX7"></A>
<A NAME="IDX8"></A>
<A NAME="IDX9"></A>
The base class <CODE>cl_number</CODE> is an abstract base class.
It is not useful to declare a variable of this type except if you want
to completely disable compile-time type checking and use run-time type
@ -54,24 +54,24 @@ checking instead.
<P>
<A NAME="IDX9"></A>
<A NAME="IDX10"></A>
<A NAME="IDX11"></A>
<A NAME="IDX12"></A>
The class <CODE>cl_N</CODE> comprises real and complex numbers. There is
no special class for complex numbers since complex numbers with imaginary
part <CODE>0</CODE> are automatically converted to real numbers.
<P>
<A NAME="IDX12"></A>
<A NAME="IDX13"></A>
The class <CODE>cl_R</CODE> comprises real numbers of different kinds. It is an
abstract class.
<P>
<A NAME="IDX13"></A>
<A NAME="IDX14"></A>
<A NAME="IDX15"></A>
<A NAME="IDX16"></A>
The class <CODE>cl_RA</CODE> comprises exact real numbers: rational numbers, including
integers. There is no special class for non-integral rational numbers
since rational numbers with denominator <CODE>1</CODE> are automatically converted
@ -79,7 +79,7 @@ to integers.
<P>
<A NAME="IDX16"></A>
<A NAME="IDX17"></A>
The class <CODE>cl_F</CODE> implements floating-point approximations to real numbers.
It is an abstract class.
@ -88,7 +88,7 @@ It is an abstract class.
<H2><A NAME="SEC12" HREF="cln_toc.html#TOC12">3.1 Exact numbers</A></H2>
<P>
<A NAME="IDX17"></A>
<A NAME="IDX18"></A>
<P>
@ -132,7 +132,7 @@ is completely transparent.
<H2><A NAME="SEC13" HREF="cln_toc.html#TOC13">3.2 Floating-point numbers</A></H2>
<P>
<A NAME="IDX18"></A>
<A NAME="IDX19"></A>
<P>
@ -144,7 +144,7 @@ CLN implements ordinary floating-point numbers, with mantissa and exponent.
<P>
<A NAME="IDX19"></A>
<A NAME="IDX20"></A>
The elementary operations (<CODE>+</CODE>, <CODE>-</CODE>, <CODE>*</CODE>, <CODE>/</CODE>, ...)
only return approximate results. For example, the value of the expression
<CODE>(cl_F) 0.3 + (cl_F) 0.4</CODE> prints as <SAMP>`0.70000005'</SAMP>, not as
@ -175,7 +175,7 @@ Floating point numbers come in four flavors:
<UL>
<LI>
<A NAME="IDX20"></A>
<A NAME="IDX21"></A>
Short floats, type <CODE>cl_SF</CODE>.
They have 1 sign bit, 8 exponent bits (including the exponent's sign),
and 17 mantissa bits (including the "hidden" bit).
@ -183,7 +183,7 @@ They don't consume heap allocation.
<LI>
<A NAME="IDX21"></A>
<A NAME="IDX22"></A>
Single floats, type <CODE>cl_FF</CODE>.
They have 1 sign bit, 8 exponent bits (including the exponent's sign),
and 24 mantissa bits (including the "hidden" bit).
@ -192,7 +192,7 @@ This corresponds closely to the C/C++ type <SAMP>`float'</SAMP>.
<LI>
<A NAME="IDX22"></A>
<A NAME="IDX23"></A>
Double floats, type <CODE>cl_DF</CODE>.
They have 1 sign bit, 11 exponent bits (including the exponent's sign),
and 53 mantissa bits (including the "hidden" bit).
@ -201,7 +201,7 @@ This corresponds closely to the C/C++ type <SAMP>`double'</SAMP>.
<LI>
<A NAME="IDX23"></A>
<A NAME="IDX24"></A>
Long floats, type <CODE>cl_LF</CODE>.
They have 1 sign bit, 32 exponent bits (including the exponent's sign),
and n mantissa bits (including the "hidden" bit), where n &#62;= 64.
@ -222,7 +222,7 @@ with larger exponent range.
<P>
<A NAME="IDX24"></A>
<A NAME="IDX25"></A>
As a user of CLN, you can forget about the differences between the
four floating-point types and just declare all your floating-point
variables as being of type <CODE>cl_F</CODE>. This has the advantage that
@ -239,7 +239,7 @@ the floating point contagion rule happened to change in the future.)
<H2><A NAME="SEC14" HREF="cln_toc.html#TOC14">3.3 Complex numbers</A></H2>
<P>
<A NAME="IDX25"></A>
<A NAME="IDX26"></A>
<P>
@ -258,7 +258,7 @@ through application of <CODE>sqrt</CODE> or transcendental functions.
<H2><A NAME="SEC15" HREF="cln_toc.html#TOC15">3.4 Conversions</A></H2>
<P>
<A NAME="IDX26"></A>
<A NAME="IDX27"></A>
<P>
@ -317,7 +317,7 @@ Conversions from <SAMP>`const char *'</SAMP> are provided for the classes
<CODE>cl_R</CODE>, <CODE>cl_N</CODE>.
The easiest way to specify a value which is outside of the range of the
C++ built-in types is therefore to specify it as a string, like this:
<A NAME="IDX27"></A>
<A NAME="IDX28"></A>
<PRE>
cl_I order_of_rubiks_cube_group = "43252003274489856000";
@ -337,16 +337,16 @@ the functions
<DT><CODE>int cl_I_to_int (const cl_I&#38; x)</CODE>
<DD>
<A NAME="IDX28"></A>
<A NAME="IDX29"></A>
<DT><CODE>unsigned int cl_I_to_uint (const cl_I&#38; x)</CODE>
<DD>
<A NAME="IDX29"></A>
<A NAME="IDX30"></A>
<DT><CODE>long cl_I_to_long (const cl_I&#38; x)</CODE>
<DD>
<A NAME="IDX30"></A>
<A NAME="IDX31"></A>
<DT><CODE>unsigned long cl_I_to_ulong (const cl_I&#38; x)</CODE>
<DD>
<A NAME="IDX31"></A>
<A NAME="IDX32"></A>
Returns <CODE>x</CODE> as element of the C type <VAR>ctype</VAR>. If <CODE>x</CODE> is not
representable in the range of <VAR>ctype</VAR>, a runtime error occurs.
</DL>
@ -361,12 +361,12 @@ the functions
<DL COMPACT>
<DT><CODE>float cl_float_approx (const <VAR>type</VAR>&#38; x)</CODE>
<DD>
<A NAME="IDX32"></A>
<DT><CODE>double cl_double_approx (const <VAR>type</VAR>&#38; x)</CODE>
<DT><CODE>float float_approx (const <VAR>type</VAR>&#38; x)</CODE>
<DD>
<A NAME="IDX33"></A>
<DT><CODE>double double_approx (const <VAR>type</VAR>&#38; x)</CODE>
<DD>
<A NAME="IDX34"></A>
Returns an approximation of <CODE>x</CODE> of C type <VAR>ctype</VAR>.
If <CODE>abs(x)</CODE> is too close to 0 (underflow), 0 is returned.
If <CODE>abs(x)</CODE> is too large (overflow), an IEEE infinity is returned.
@ -377,10 +377,10 @@ Conversions from any class to any of its subclasses ("derived classes" in
C++ terminology) are not provided. Instead, you can assert and check
that a value belongs to a certain subclass, and return it as element of that
class, using the <SAMP>`As'</SAMP> and <SAMP>`The'</SAMP> macros.
<A NAME="IDX34"></A>
<A NAME="IDX35"></A>
<CODE>As(<VAR>type</VAR>)(<VAR>value</VAR>)</CODE> checks that <VAR>value</VAR> belongs to
<VAR>type</VAR> and returns it as such.
<A NAME="IDX35"></A>
<A NAME="IDX36"></A>
<CODE>The(<VAR>type</VAR>)(<VAR>value</VAR>)</CODE> assumes that <VAR>value</VAR> belongs to
<VAR>type</VAR> and returns it as such. It is your responsibility to ensure
that this assumption is valid.

431
doc/cln_4.html
File diff suppressed because it is too large
View File

42
doc/cln_5.html

@ -1,6 +1,6 @@
<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from cln.texi on 2 June 2000 -->
<!-- Created by texi2html 1.56k from cln.texi on 28 August 2000 -->
<TITLE>CLN, a Class Library for Numbers - 5. Input/Output</TITLE>
</HEAD>
@ -11,14 +11,14 @@ Go to the <A HREF="cln_1.html">first</A>, <A HREF="cln_4.html">previous</A>, <A
<H1><A NAME="SEC44" HREF="cln_toc.html#TOC44">5. Input/Output</A></H1>
<P>
<A NAME="IDX236"></A>
<A NAME="IDX237"></A>
<H2><A NAME="SEC45" HREF="cln_toc.html#TOC45">5.1 Internal and printed representation</A></H2>
<P>
<A NAME="IDX237"></A>
<A NAME="IDX238"></A>
<P>
@ -33,9 +33,9 @@ Several external representations may denote the same number, for example,
<P>
Converting an internal to an external representation is called "printing",
<A NAME="IDX238"></A>
converting an external to an internal representation is called "reading".
<A NAME="IDX239"></A>
converting an external to an internal representation is called "reading".
<A NAME="IDX240"></A>
In CLN, it is always true that conversion of an internal to an external
representation and then back to an internal representation will yield the
same internal representation. Symbolically: <CODE>read(print(x)) == x</CODE>.
@ -118,10 +118,9 @@ In Common Lisp notation: <CODE>#C(<VAR>realpart</VAR> <VAR>imagpart</VAR>)</CODE
<H2><A NAME="SEC46" HREF="cln_toc.html#TOC46">5.2 Input functions</A></H2>
<P>
Including <CODE>&#60;cl_io.h&#62;</CODE> defines a type <CODE>cl_istream</CODE>, which is
the type of the first argument to all input functions. Unless you build
and use CLN with the macro CL_IO_STDIO being defined, <CODE>cl_istream</CODE>
is the same as <CODE>istream&#38;</CODE>.
Including <CODE>&#60;cln/io.h&#62;</CODE> defines a type <CODE>cl_istream</CODE>, which is
the type of the first argument to all input functions. <CODE>cl_istream</CODE>
is the same as <CODE>std::istream&#38;</CODE>.
<P>
@ -130,7 +129,7 @@ The variable
<UL>
<LI>
<CODE>cl_istream cl_stdin</CODE>
<CODE>cl_istream stdin</CODE>
</UL>
<P>
@ -157,7 +156,7 @@ last <CODE>freadchar</CODE> operation on <CODE>stream</CODE>.
<P>
Each of the classes <CODE>cl_N</CODE>, <CODE>cl_R</CODE>, <CODE>cl_RA</CODE>, <CODE>cl_I</CODE>,
<CODE>cl_F</CODE>, <CODE>cl_SF</CODE>, <CODE>cl_FF</CODE>, <CODE>cl_DF</CODE>, <CODE>cl_LF</CODE>
defines, in <CODE>&#60;cl_<VAR>type</VAR>_io.h&#62;</CODE>, the following input function:
defines, in <CODE>&#60;cln/<VAR>type</VAR>_io.h&#62;</CODE>, the following input function:
<DL COMPACT>
@ -168,7 +167,7 @@ Reads a number from <CODE>stream</CODE> and stores it in the <CODE>result</CODE>
</DL>
<P>
The most flexible input functions, defined in <CODE>&#60;cl_<VAR>type</VAR>_io.h&#62;</CODE>,
The most flexible input functions, defined in <CODE>&#60;cln/<VAR>type</VAR>_io.h&#62;</CODE>,
are the following:
@ -270,10 +269,9 @@ precision corresponding to their number of significant digits.
<H2><A NAME="SEC47" HREF="cln_toc.html#TOC47">5.3 Output functions</A></H2>
<P>
Including <CODE>&#60;cl_io.h&#62;</CODE> defines a type <CODE>cl_ostream</CODE>, which is
the type of the first argument to all output functions. Unless you build
and use CLN with the macro CL_IO_STDIO being defined, <CODE>cl_ostream</CODE>
is the same as <CODE>ostream&#38;</CODE>.
Including <CODE>&#60;cln/io.h&#62;</CODE> defines a type <CODE>cl_ostream</CODE>, which is
the type of the first argument to all output functions. <CODE>cl_ostream</CODE>
is the same as <CODE>std::ostream&#38;</CODE>.
<P>
@ -282,7 +280,7 @@ The variable
<UL>
<LI>
<CODE>cl_ostream cl_stdout</CODE>
<CODE>cl_ostream stdout</CODE>
</UL>
<P>
@ -295,7 +293,7 @@ The variable
<UL>
<LI>
<CODE>cl_ostream cl_stderr</CODE>
<CODE>cl_ostream stderr</CODE>
</UL>
<P>
@ -341,7 +339,7 @@ on the <CODE>stream</CODE>.
<P>
Each of the classes <CODE>cl_N</CODE>, <CODE>cl_R</CODE>, <CODE>cl_RA</CODE>, <CODE>cl_I</CODE>,
<CODE>cl_F</CODE>, <CODE>cl_SF</CODE>, <CODE>cl_FF</CODE>, <CODE>cl_DF</CODE>, <CODE>cl_LF</CODE>
defines, in <CODE>&#60;cl_<VAR>type</VAR>_io.h&#62;</CODE>, the following output functions:
defines, in <CODE>&#60;cln/<VAR>type</VAR>_io.h&#62;</CODE>, the following output functions:
<DL COMPACT>
@ -351,13 +349,13 @@ defines, in <CODE>&#60;cl_<VAR>type</VAR>_io.h&#62;</CODE>, the following output
<DT><CODE>cl_ostream operator&#60;&#60; (cl_ostream stream, const <VAR>type</VAR>&#38; x)</CODE>
<DD>
Prints the number <CODE>x</CODE> on the <CODE>stream</CODE>. The output may depend
on the global printer settings in the variable <CODE>cl_default_print_flags</CODE>.
on the global printer settings in the variable <CODE>default_print_flags</CODE>.
The <CODE>ostream</CODE> flags and settings (flags, width and locale) are
ignored.
</DL>
<P>
The most flexible output function, defined in <CODE>&#60;cl_<VAR>type</VAR>_io.h&#62;</CODE>,
The most flexible output function, defined in <CODE>&#60;cln/<VAR>type</VAR>_io.h&#62;</CODE>,
are the following:
<PRE>
@ -416,7 +414,7 @@ using this variable name. Default is <CODE>"x"</CODE>.
</DL>
<P>
The global variable <CODE>cl_default_print_flags</CODE> contains the default values,
The global variable <CODE>default_print_flags</CODE> contains the default values,
used by the function <CODE>fprint</CODE>.

18
doc/cln_6.html

@ -1,6 +1,6 @@
<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from cln.texi on 2 June 2000 -->
<!-- Created by texi2html 1.56k from cln.texi on 28 August 2000 -->
<TITLE>CLN, a Class Library for Numbers - 6. Rings</TITLE>
</HEAD>
@ -19,7 +19,7 @@ CLN has a class of abstract rings.
<PRE>
Ring
cl_ring
&#60;cl_ring.h&#62;
&#60;cln/ring.h&#62;
</PRE>
<P>
@ -43,28 +43,40 @@ Given a ring <CODE>R</CODE>, the following members can be used.
<DT><CODE>void R-&#62;fprint (cl_ostream stream, const cl_ring_element&#38; x)</CODE>
<DD>
<A NAME="IDX241"></A>
<DT><CODE>cl_boolean R-&#62;equal (const cl_ring_element&#38; x, const cl_ring_element&#38; y)</CODE>
<DD>
<A NAME="IDX242"></A>
<DT><CODE>cl_ring_element R-&#62;zero ()</CODE>
<DD>
<A NAME="IDX243"></A>
<DT><CODE>cl_boolean R-&#62;zerop (const cl_ring_element&#38; x)</CODE>
<DD>
<A NAME="IDX244"></A>
<DT><CODE>cl_ring_element R-&#62;plus (const cl_ring_element&#38; x, const cl_ring_element&#38; y)</CODE>
<DD>
<A NAME="IDX245"></A>
<DT><CODE>cl_ring_element R-&#62;minus (const cl_ring_element&#38; x, const cl_ring_element&#38; y)</CODE>
<DD>
<A NAME="IDX246"></A>
<DT><CODE>cl_ring_element R-&#62;uminus (const cl_ring_element&#38; x)</CODE>
<DD>
<A NAME="IDX247"></A>
<DT><CODE>cl_ring_element R-&#62;one ()</CODE>
<DD>
<A NAME="IDX248"></A>
<DT><CODE>cl_ring_element R-&#62;canonhom (const cl_I&#38; x)</CODE>
<DD>
<A NAME="IDX249"></A>
<DT><CODE>cl_ring_element R-&#62;mul (const cl_ring_element&#38; x, const cl_ring_element&#38; y)</CODE>
<DD>
<A NAME="IDX250"></A>
<DT><CODE>cl_ring_element R-&#62;square (const cl_ring_element&#38; x)</CODE>
<DD>
<A NAME="IDX251"></A>
<DT><CODE>cl_ring_element R-&#62;expt_pos (const cl_ring_element&#38; x, const cl_I&#38; y)</CODE>
<DD>
<A NAME="IDX252"></A>
</DL>
<P>
@ -103,7 +115,7 @@ Type tests can be performed for any of <CODE>cl_C_ring</CODE>, <CODE>cl_R_ring</
<DT><CODE>cl_boolean instanceof (const cl_number&#38; x, const cl_number_ring&#38; R)</CODE>
<DD>
<A NAME="IDX240"></A>
<A NAME="IDX253"></A>
Tests whether the given number is an element of the number ring R.
</DL>

74
doc/cln_7.html

@ -1,6 +1,6 @@
<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from cln.texi on 2 June 2000 -->
<!-- Created by texi2html 1.56k from cln.texi on 28 August 2000 -->
<TITLE>CLN, a Class Library for Numbers - 7. Modular integers</TITLE>
</HEAD>
@ -11,14 +11,14 @@ Go to the <A HREF="cln_1.html">first</A>, <A HREF="cln_6.html">previous</A>, <A
<H1><A NAME="SEC49" HREF="cln_toc.html#TOC49">7. Modular integers</A></H1>
<P>
<A NAME="IDX241"></A>
<A NAME="IDX254"></A>
<H2><A NAME="SEC50" HREF="cln_toc.html#TOC50">7.1 Modular integer rings</A></H2>
<P>
<A NAME="IDX242"></A>
<A NAME="IDX255"></A>
<P>
@ -38,16 +38,16 @@ The class of modular integer rings is
<PRE>
Ring
cl_ring
&#60;cl_ring.h&#62;
&#60;cln/ring.h&#62;
|
|
Modular integer ring
cl_modint_ring
&#60;cl_modinteger.h&#62;
&#60;cln/modinteger.h&#62;
</PRE>
<P>
<A NAME="IDX243"></A>
<A NAME="IDX256"></A>
<P>
@ -58,7 +58,7 @@ and the class of all modular integers (elements of modular integer rings) is
<PRE>
Modular integer
cl_MI
&#60;cl_modinteger.h&#62;
&#60;cln/modinteger.h&#62;
</PRE>
<P>
@ -67,13 +67,13 @@ Modular integer rings are constructed using the function
<DL COMPACT>
<DT><CODE>cl_modint_ring cl_find_modint_ring (const cl_I&#38; N)</CODE>
<DT><CODE>cl_modint_ring find_modint_ring (const cl_I&#38; N)</CODE>
<DD>
<A NAME="IDX244"></A>
<A NAME="IDX257"></A>
This function returns the modular ring <SAMP>`Z/NZ'</SAMP>. It takes care
of finding out about special cases of <CODE>N</CODE>, like powers of two
and odd numbers for which Montgomery multiplication will be a win,
<A NAME="IDX245"></A>
<A NAME="IDX258"></A>
and precomputes any necessary auxiliary data for computing modulo <CODE>N</CODE>.
There is a cache table of rings, indexed by <CODE>N</CODE> (or, more precisely,
by <CODE>abs(N)</CODE>). This ensures that the precomputation costs are reduced
@ -88,12 +88,12 @@ Modular integer rings can be compared for equality:
<DT><CODE>bool operator== (const cl_modint_ring&#38;, const cl_modint_ring&#38;)</CODE>
<DD>
<A NAME="IDX246"></A>
<A NAME="IDX259"></A>
<DT><CODE>bool operator!= (const cl_modint_ring&#38;, const cl_modint_ring&#38;)</CODE>
<DD>
<A NAME="IDX247"></A>
<A NAME="IDX260"></A>
These compare two modular integer rings for equality. Two different calls
to <CODE>cl_find_modint_ring</CODE> with the same argument necessarily return the
to <CODE>find_modint_ring</CODE> with the same argument necessarily return the
same ring because it is memoized in the cache table.
</DL>
@ -109,35 +109,35 @@ Given a modular integer ring <CODE>R</CODE>, the following members can be used.
<DT><CODE>cl_I R-&#62;modulus</CODE>
<DD>
<A NAME="IDX248"></A>
<A NAME="IDX261"></A>
This is the ring's modulus, normalized to be nonnegative: <CODE>abs(N)</CODE>.
<DT><CODE>cl_MI R-&#62;zero()</CODE>
<DD>
<A NAME="IDX249"></A>
<A NAME="IDX262"></A>
This returns <CODE>0 mod N</CODE>.
<DT><CODE>cl_MI R-&#62;one()</CODE>
<DD>
<A NAME="IDX250"></A>
<A NAME="IDX263"></A>
This returns <CODE>1 mod N</CODE>.
<DT><CODE>cl_MI R-&#62;canonhom (const cl_I&#38; x)</CODE>
<DD>
<A NAME="IDX251"></A>
<A NAME="IDX264"></A>
This returns <CODE>x mod N</CODE>.
<DT><CODE>cl_I R-&#62;retract (const cl_MI&#38; x)</CODE>
<DD>
<A NAME="IDX252"></A>
<A NAME="IDX265"></A>
This is a partial inverse function to <CODE>R-&#62;canonhom</CODE>. It returns the
standard representative (<CODE>&#62;=0</CODE>, <CODE>&#60;N</CODE>) of <CODE>x</CODE>.
<DT><CODE>cl_MI R-&#62;random(cl_random_state&#38; randomstate)</CODE>
<DT><CODE>cl_MI R-&#62;random(random_state&#38; randomstate)</CODE>
<DD>
<DT><CODE>cl_MI R-&#62;random()</CODE>
<DD>
<A NAME="IDX253"></A>
<A NAME="IDX266"></A>
This returns a random integer modulo <CODE>N</CODE>.
</DL>
@ -149,18 +149,18 @@ The following operations are defined on modular integers.
<DT><CODE>cl_modint_ring x.ring ()</CODE>
<DD>
<A NAME="IDX254"></A>
<A NAME="IDX267"></A>
Returns the ring to which the modular integer <CODE>x</CODE> belongs.
<DT><CODE>cl_MI operator+ (const cl_MI&#38;, const cl_MI&#38;)</CODE>
<DD>
<A NAME="IDX255"></A>
<A NAME="IDX268"></A>
Returns the sum of two modular integers. One of the arguments may also
be a plain integer.
<DT><CODE>cl_MI operator- (const cl_MI&#38;, const cl_MI&#38;)</CODE>
<DD>
<A NAME="IDX256"></A>
<A NAME="IDX269"></A>
Returns the difference of two modular integers. One of the arguments may also
be a plain integer.
@ -170,61 +170,61 @@ Returns the negative of a modular integer.
<DT><CODE>cl_MI operator* (const cl_MI&#38;, const cl_MI&#38;)</CODE>
<DD>
<A NAME="IDX257"></A>
<A NAME="IDX270"></A>
Returns the product of two modular integers. One of the arguments may also
be a plain integer.
<DT><CODE>cl_MI square (const cl_MI&#38;)</CODE>
<DD>
<A NAME="IDX258"></A>
<A NAME="IDX271"></A>
Returns the square of a modular integer.
<DT><CODE>cl_MI recip (const cl_MI&#38; x)</CODE>
<DD>
<A NAME="IDX259"></A>
<A NAME="IDX272"></A>
Returns the reciprocal <CODE>x^-1</CODE> of a modular integer <CODE>x</CODE>. <CODE>x</CODE>
must be coprime to the modulus, otherwise an error message is issued.
<DT><CODE>cl_MI div (const cl_MI&#38; x, const cl_MI&#38; y)</CODE>
<DD>
<A NAME="IDX260"></A>
<A NAME="IDX273"></A>
Returns the quotient <CODE>x*y^-1</CODE> of two modular integers <CODE>x</CODE>, <CODE>y</CODE>.
<CODE>y</CODE> must be coprime to the modulus, otherwise an error message is issued.
<DT><CODE>cl_MI expt_pos (const cl_MI&#38; x, const cl_I&#38; y)</CODE>
<DD>
<A NAME="IDX261"></A>
<A NAME="IDX274"></A>
<CODE>y</CODE> must be &#62; 0. Returns <CODE>x^y</CODE>.
<DT><CODE>cl_MI expt (const cl_MI&#38; x, const cl_I&#38; y)</CODE>
<DD>
<A NAME="IDX262"></A>
<A NAME="IDX275"></A>
Returns <CODE>x^y</CODE>. If <CODE>y</CODE> is negative, <CODE>x</CODE> must be coprime to the
modulus, else an error message is issued.
<DT><CODE>cl_MI operator&#60;&#60; (const cl_MI&#38; x, const cl_I&#38; y)</CODE>
<DD>
<A NAME="IDX263"></A>
<A NAME="IDX276"></A>
Returns <CODE>x*2^y</CODE>.
<DT><CODE>cl_MI operator&#62;&#62; (const cl_MI&#38; x, const cl_I&#38; y)</CODE>
<DD>
<A NAME="IDX264"></A>
<A NAME="IDX277"></A>
Returns <CODE>x*2^-y</CODE>. When <CODE>y</CODE> is positive, the modulus must be odd,
or an error message is issued.
<DT><CODE>bool operator== (const cl_MI&#38;, const cl_MI&#38;)</CODE>
<DD>
<A NAME="IDX265"></A>
<A NAME="IDX278"></A>
<DT><CODE>bool operator!= (const cl_MI&#38;, const cl_MI&#38;)</CODE>
<DD>
<A NAME="IDX266"></A>
<A NAME="IDX279"></A>
Compares two modular integers, belonging to the same modular integer ring,
for equality.
<DT><CODE>cl_boolean zerop (const cl_MI&#38; x)</CODE>
<DD>
<A NAME="IDX267"></A>
<A NAME="IDX280"></A>
Returns true if <CODE>x</CODE> is <CODE>0 mod N</CODE>.
</DL>
@ -237,12 +237,12 @@ input/output).
<DT><CODE>void fprint (cl_ostream stream, const cl_MI&#38; x)</CODE>
<DD>
<A NAME="IDX268"></A>
<A NAME="IDX281"></A>
<DT><CODE>cl_ostream operator&#60;&#60; (cl_ostream stream, const cl_MI&#38; x)</CODE>
<DD>
<A NAME="IDX269"></A>
<A NAME="IDX282"></A>
Prints the modular integer <CODE>x</CODE> on the <CODE>stream</CODE>. The output may depend
on the global printer settings in the variable <CODE>cl_default_print_flags</CODE>.
on the global printer settings in the variable <CODE>default_print_flags</CODE>.
</DL>
<P><HR><P>

24
doc/cln_8.html

@ -1,6 +1,6 @@
<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from cln.texi on 2 June 2000 -->
<!-- Created by texi2html 1.56k from cln.texi on 28 August 2000 -->
<TITLE>CLN, a Class Library for Numbers - 8. Symbolic data types</TITLE>
</HEAD>
@ -11,7 +11,7 @@ Go to the <A HREF="cln_1.html">first</A>, <A HREF="cln_7.html">previous</A>, <A
<H1><A NAME="SEC52" HREF="cln_toc.html#TOC52">8. Symbolic data types</A></H1>
<P>
<A NAME="IDX270"></A>
<A NAME="IDX283"></A>
<P>
@ -22,7 +22,8 @@ CLN implements two symbolic (non-numeric) data types: strings and symbols.
<H2><A NAME="SEC53" HREF="cln_toc.html#TOC53">8.1 Strings</A></H2>
<P>
<A NAME="IDX271"></A>
<A NAME="IDX284"></A>
<A NAME="IDX285"></A>
<P>
@ -33,7 +34,7 @@ The class
<PRE>
String
cl_string
&#60;cl_string.h&#62;
&#60;cln/string.h&#62;
</PRE>
<P>
@ -48,7 +49,6 @@ Strings are constructed through the following constructors:
<DT><CODE>cl_string (const char * s)</CODE>
<DD>
<A NAME="IDX272"></A>
Returns an immutable copy of the (zero-terminated) C string <CODE>s</CODE>.
<DT><CODE>cl_string (const char * ptr, unsigned long len)</CODE>
@ -69,21 +69,21 @@ Assignment from <CODE>cl_string</CODE> and <CODE>const char *</CODE>.
<DT><CODE>s.length()</CODE>
<DD>
<A NAME="IDX273"></A>
<A NAME="IDX286"></A>
<DT><CODE>strlen(s)</CODE>
<DD>
<A NAME="IDX274"></A>
<A NAME="IDX287"></A>
Returns the length of the string <CODE>s</CODE>.
<DT><CODE>s[i]</CODE>
<DD>
<A NAME="IDX275"></A>
<A NAME="IDX288"></A>
Returns the <CODE>i</CODE>th character of the string <CODE>s</CODE>.
<CODE>i</CODE> must be in the range <CODE>0 &#60;= i &#60; s.length()</CODE>.
<DT><CODE>bool equal (const cl_string&#38; s1, const cl_string&#38; s2)</CODE>
<DD>
<A NAME="IDX276"></A>
<A NAME="IDX289"></A>
Compares two strings for equality. One of the arguments may also be a
plain <CODE>const char *</CODE>.
</DL>
@ -92,7 +92,8 @@ plain <CODE>const char *</CODE>.
<H2><A NAME="SEC54" HREF="cln_toc.html#TOC54">8.2 Symbols</A></H2>
<P>
<A NAME="IDX277"></A>
<A NAME="IDX290"></A>
<A NAME="IDX291"></A>
<P>
@ -112,7 +113,6 @@ Symbols are constructed through the following constructor:
<DT><CODE>cl_symbol (const cl_string&#38; s)</CODE>
<DD>
<A NAME="IDX278"></A>
Looks up or creates a new symbol with a given name.
</DL>
@ -129,7 +129,7 @@ Conversion to <CODE>cl_string</CODE>: Returns the string which names the symbol
<DT><CODE>bool equal (const cl_symbol&#38; sym1, const cl_symbol&#38; sym2)</CODE>
<DD>
<A NAME="IDX279"></A>
<A NAME="IDX292"></A>
Compares two symbols for equality. This is very fast.
</DL>

134
doc/cln_9.html

@ -1,6 +1,6 @@
<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from cln.texi on 2 June 2000 -->
<!-- Created by texi2html 1.56k from cln.texi on 28 August 2000 -->
<TITLE>CLN, a Class Library for Numbers - 9. Univariate polynomials</TITLE>
</HEAD>
@ -11,8 +11,8 @@ Go to the <A HREF="cln_1.html">first</A>, <A HREF="cln_8.html">previous</A>, <A
<H1><A NAME="SEC55" HREF="cln_toc.html#TOC55">9. Univariate polynomials</A></H1>
<P>
<A NAME="IDX280"></A>
<A NAME="IDX281"></A>
<A NAME="IDX293"></A>
<A NAME="IDX294"></A>
@ -22,7 +22,7 @@ Go to the <A HREF="cln_1.html">first</A>, <A HREF="cln_8.html">previous</A>, <A
<P>
CLN implements univariate polynomials (polynomials in one variable) over an
arbitrary ring. The indeterminate variable may be either unnamed (and will be
printed according to <CODE>cl_default_print_flags.univpoly_varname</CODE>, which
printed according to <CODE>default_print_flags.univpoly_varname</CODE>, which
defaults to <SAMP>`x'</SAMP>) or carry a given name. The base ring and the
indeterminate are explicitly part of every polynomial. CLN doesn't allow you to
(accidentally) mix elements of different polynomial rings, e.g.
@ -38,36 +38,36 @@ The classes of univariate polynomial rings are
<PRE>
Ring
cl_ring
&#60;cl_ring.h&#62;
&#60;cln/ring.h&#62;
|
|
Univariate polynomial ring
cl_univpoly_ring
&#60;cl_univpoly.h&#62;
&#60;cln/univpoly.h&#62;
|
+----------------+-------------------+
| | |
Complex polynomial ring | Modular integer polynomial ring
cl_univpoly_complex_ring | cl_univpoly_modint_ring
&#60;cl_univpoly_complex.h&#62; | &#60;cl_univpoly_modint.h&#62;
&#60;cln/univpoly_complex.h&#62; | &#60;cln/univpoly_modint.h&#62;
|
+----------------+
| |
Real polynomial ring |
cl_univpoly_real_ring |
&#60;cl_univpoly_real.h&#62; |
&#60;cln/univpoly_real.h&#62; |
|
+----------------+
| |
Rational polynomial ring |
cl_univpoly_rational_ring |
&#60;cl_univpoly_rational.h&#62; |
&#60;cln/univpoly_rational.h&#62; |
|
+----------------+
|
Integer polynomial ring
cl_univpoly_integer_ring
&#60;cl_univpoly_integer.h&#62;
&#60;cln/univpoly_integer.h&#62;
</PRE>
<P>
@ -78,31 +78,31 @@ and the corresponding classes of univariate polynomials are
<PRE>
Univariate polynomial
cl_UP
&#60;cl_univpoly.h&#62;
&#60;cln/univpoly.h&#62;
|
+----------------+-------------------+
| | |
Complex polynomial | Modular integer polynomial
cl_UP_N | cl_UP_MI
&#60;cl_univpoly_complex.h&#62; | &#60;cl_univpoly_modint.h&#62;
&#60;cln/univpoly_complex.h&#62; | &#60;cln/univpoly_modint.h&#62;
|
+----------------+
| |
Real polynomial |
cl_UP_R |
&#60;cl_univpoly_real.h&#62; |
&#60;cln/univpoly_real.h&#62; |
|
+----------------+
| |
Rational polynomial |
cl_UP_RA |
&#60;cl_univpoly_rational.h&#62; |
&#60;cln/univpoly_rational.h&#62; |
|
+----------------+
|
Integer polynomial
cl_UP_I
&#60;cl_univpoly_integer.h&#62;
&#60;cln/univpoly_integer.h&#62;
</PRE>
<P>
@ -111,9 +111,9 @@ Univariate polynomial rings are constructed using the functions
<DL COMPACT>
<DT><CODE>cl_univpoly_ring cl_find_univpoly_ring (const cl_ring&#38; R)</CODE>
<DT><CODE>cl_univpoly_ring find_univpoly_ring (const cl_ring&#38; R)</CODE>
<DD>
<DT><CODE>cl_univpoly_ring cl_find_univpoly_ring (const cl_ring&#38; R, const cl_symbol&#38; varname)</CODE>
<DT><CODE>cl_univpoly_ring find_univpoly_ring (const cl_ring&#38; R, const cl_symbol&#38; varname)</CODE>
<DD>
This function returns the polynomial ring <SAMP>`R[X]'</SAMP>, unnamed or named.
<CODE>R</CODE> may be an arbitrary ring. This function takes care of finding out
@ -123,28 +123,28 @@ There is a cache table of rings, indexed by <CODE>R</CODE> and <CODE>varname</CO
This ensures that two calls of this function with the same arguments will
return the same polynomial ring.
<DT><CODE>cl_univpoly_complex_ring cl_find_univpoly_ring (const cl_complex_ring&#38; R)</CODE>
<DT><CODE>cl_univpoly_complex_ring find_univpoly_ring (const cl_complex_ring&#38; R)</CODE>
<DD>
<A NAME="IDX282"></A>
<DT><CODE>cl_univpoly_complex_ring cl_find_univpoly_ring (const cl_complex_ring&#38; R, const cl_symbol&#38; varname)</CODE>
<A NAME="IDX295"></A>
<DT><CODE>cl_univpoly_complex_ring find_univpoly_ring (const cl_complex_ring&#38; R, const cl_symbol&#38; varname)</CODE>
<DD>
<DT><CODE>cl_univpoly_real_ring cl_find_univpoly_ring (const cl_real_ring&#38; R)</CODE>
<DT><CODE>cl_univpoly_real_ring find_univpoly_ring (const cl_real_ring&#38; R)</CODE>
<DD>
<DT><CODE>cl_univpoly_real_ring cl_find_univpoly_ring (const cl_real_ring&#38; R, const cl_symbol&#38; varname)</CODE>
<DT><CODE>cl_univpoly_real_ring find_univpoly_ring (const cl_real_ring&#38; R, const cl_symbol&#38; varname)</CODE>
<DD>
<DT><CODE>cl_univpoly_rational_ring cl_find_univpoly_ring (const cl_rational_ring&#38; R)</CODE>
<DT><CODE>cl_univpoly_rational_ring find_univpoly_ring (const cl_rational_ring&#38; R)</CODE>
<DD>
<DT><CODE>cl_univpoly_rational_ring cl_find_univpoly_ring (const cl_rational_ring&#38; R, const cl_symbol&#38; varname)</CODE>
<DT><CODE>cl_univpoly_rational_ring find_univpoly_ring (const cl_rational_ring&#38; R, const cl_symbol&#38; varname)</CODE>
<DD>
<DT><CODE>cl_univpoly_integer_ring cl_find_univpoly_ring (const cl_integer_ring&#38; R)</CODE>
<DT><CODE>cl_univpoly_integer_ring find_univpoly_ring (const cl_integer_ring&#38; R)</CODE>
<DD>
<DT><CODE>cl_univpoly_integer_ring cl_find_univpoly_ring (const cl_integer_ring&#38; R, const cl_symbol&#38; varname)</CODE>
<DT><CODE>cl_univpoly_integer_ring find_univpoly_ring (const cl_integer_ring&#38; R, const cl_symbol&#38; varname)</CODE>
<DD>
<DT><CODE>cl_univpoly_modint_ring cl_find_univpoly_ring (const cl_modint_ring&#38; R)</CODE>
<DT><CODE>cl_univpoly_modint_ring find_univpoly_ring (const cl_modint_ring&#38; R)</CODE>
<DD>
<DT><CODE>cl_univpoly_modint_ring cl_find_univpoly_ring (const cl_modint_ring&#38; R, const cl_symbol&#38; varname)</CODE>
<DT><CODE>cl_univpoly_modint_ring find_univpoly_ring (const cl_modint_ring&#38; R, const cl_symbol&#38; varname)</CODE>
<DD>
These functions are equivalent to the general <CODE>cl_find_univpoly_ring</CODE>,
These functions are equivalent to the general <CODE>find_univpoly_ring</CODE>,
only the return type is more specific, according to the base ring's type.
</DL>
@ -160,33 +160,33 @@ Given a univariate polynomial ring <CODE>R</CODE>, the following members can be
<DT><CODE>cl_ring R-&#62;basering()</CODE>
<DD>
<A NAME="IDX283"></A>
This returns the base ring, as passed to <SAMP>`cl_find_univpoly_ring'</SAMP>.
<A NAME="IDX296"></A>
This returns the base ring, as passed to <SAMP>`find_univpoly_ring'</SAMP>.
<DT><CODE>cl_UP R-&#62;zero()</CODE>
<DD>
<A NAME="IDX284"></A>
<A NAME="IDX297"></A>
This returns <CODE>0 in R</CODE>, a polynomial of degree -1.
<DT><CODE>cl_UP R-&#62;one()</CODE>
<DD>
<A NAME="IDX285"></A>
<A NAME="IDX298"></A>
This returns <CODE>1 in R</CODE>, a polynomial of degree &#60;= 0.
<DT><CODE>cl_UP R-&#62;canonhom (const cl_I&#38; x)</CODE>
<DD>
<A NAME="IDX286"></A>
<A NAME="IDX299"></A>
This returns <CODE>x in R</CODE>, a polynomial of degree &#60;= 0.
<DT><CODE>cl_UP R-&#62;monomial (const cl_ring_element&#38; x, uintL e)</CODE>
<DD>
<A NAME="IDX287"></A>
<A NAME="IDX300"></A>
This returns a sparse polynomial: <CODE>x * X^e</CODE>, where <CODE>X</CODE> is the
indeterminate.
<DT><CODE>cl_UP R-&#62;create (sintL degree)</CODE>
<DD>
<A NAME="IDX288"></A>
<A NAME="IDX301"></A>
Creates a new polynomial with a given degree. The zero polynomial has degree
<CODE>-1</CODE>. After creating the polynomial, you should put in the coefficients,
using the <CODE>set_coeff</CODE> member function, and then call the <CODE>finalize</CODE>
@ -201,14 +201,14 @@ The following are the only destructive operations on univariate polynomials.
<DT><CODE>void set_coeff (cl_UP&#38; x, uintL index, const cl_ring_element&#38; y)</CODE>
<DD>
<A NAME="IDX289"></A>
<A NAME="IDX302"></A>
This changes the coefficient of <CODE>X^index</CODE> in <CODE>x</CODE> to be <CODE>y</CODE>.
After changing a polynomial and before applying any "normal" operation on it,
you should call its <CODE>finalize</CODE> member function.
<DT><CODE>void finalize (cl_UP&#38; x)</CODE>
<DD>
<A NAME="IDX290"></A>
<A NAME="IDX303"></A>
This function marks the endpoint of destructive modifications of a polynomial.
It normalizes the internal representation so that subsequent computations have
less overhead. Doing normal computations on unnormalized polynomials may
@ -223,17 +223,17 @@ The following operations are defined on univariate polynomials.
<DT><CODE>cl_univpoly_ring x.ring ()</CODE>
<DD>
<A NAME="IDX291"></A>
<A NAME="IDX304"></A>
Returns the ring to which the univariate polynomial <CODE>x</CODE> belongs.
<DT><CODE>cl_UP operator+ (const cl_UP&#38;, const cl_UP&#38;)</CODE>
<DD>
<A NAME="IDX292"></A>
<A NAME="IDX305"></A>
Returns the sum of two univariate polynomials.
<DT><CODE>cl_UP operator- (const cl_UP&#38;, const cl_UP&#38;)</CODE>
<DD>
<A NAME="IDX293"></A>
<A NAME="IDX306"></A>
Returns the difference of two univariate polynomials.
<DT><CODE>cl_UP operator- (const cl_UP&#38;)</CODE>
@ -242,54 +242,54 @@ Returns the negative of a univariate polynomial.
<DT><CODE>cl_UP operator* (const cl_UP&#38;, const cl_UP&#38;)</CODE>
<DD>
<A NAME="IDX294"></A>
<A NAME="IDX307"></A>
Returns the product of two univariate polynomials. One of the arguments may
also be a plain integer or an element of the base ring.
<DT><CODE>cl_UP square (const cl_UP&#38;)</CODE>
<DD>
<A NAME="IDX295"></A>
<A NAME="IDX308"></A>
Returns the square of a univariate polynomial.
<DT><CODE>cl_UP expt_pos (const cl_UP&#38; x, const cl_I&#38; y)</CODE>
<DD>
<A NAME="IDX296"></A>
<A NAME="IDX309"></A>
<CODE>y</CODE> must be &#62; 0. Returns <CODE>x^y</CODE>.
<DT><CODE>bool operator== (const cl_UP&#38;, const cl_UP&#38;)</CODE>
<DD>
<A NAME="IDX297"></A>
<A NAME="IDX310"></A>
<DT><CODE>bool operator!= (const cl_UP&#38;, const cl_UP&#38;)</CODE>
<DD>
<A NAME="IDX298"></A>
<A NAME="IDX311"></A>
Compares two univariate polynomials, belonging to the same univariate
polynomial ring, for equality.
<DT><CODE>cl_boolean zerop (const cl_UP&#38; x)</CODE>
<DD>
<A NAME="IDX299"></A>
<A NAME="IDX312"></A>
Returns true if <CODE>x</CODE> is <CODE>0 in R</CODE>.
<DT><CODE>sintL degree (const cl_UP&#38; x)</CODE>
<DD>
<A NAME="IDX300"></A>
<A NAME="IDX313"></A>
Returns the degree of the polynomial. The zero polynomial has degree <CODE>-1</CODE>.
<DT><CODE>cl_ring_element coeff (const cl_UP&#38; x, uintL index)</CODE>
<DD>
<A NAME="IDX301"></A>
<A NAME="IDX314"></A>
Returns the coefficient of <CODE>X^index</CODE> in the polynomial <CODE>x</CODE>.
<DT><CODE>cl_ring_element x (const cl_ring_element&#38; y)</CODE>
<DD>
<A NAME="IDX302"></A>
<A NAME="IDX315"></A>
Evaluation: If <CODE>x</CODE> is a polynomial and <CODE>y</CODE> belongs to the base ring,
then <SAMP>`x(y)'</SAMP> returns the value of the substitution of <CODE>y</CODE> into
<CODE>x</CODE>.
<DT><CODE>cl_UP deriv (const cl_UP&#38; x)</CODE>
<DD>
<A NAME="IDX303"></A>
<A NAME="IDX316"></A>
Returns the derivative of the polynomial <CODE>x</CODE> with respect to the
indeterminate <CODE>X</CODE>.
</DL>
@ -303,13 +303,13 @@ input/output).
<DT><CODE>void fprint (cl_ostream stream, const cl_UP&#38; x)</CODE>
<DD>
<A NAME="IDX304"></A>
<A NAME="IDX317"></A>
<DT><CODE>cl_ostream operator&#60;&#60; (cl_ostream stream, const cl_UP&#38; x)</CODE>
<DD>
<A NAME="IDX305"></A>
<A NAME="IDX318"></A>
Prints the univariate polynomial <CODE>x</CODE> on the <CODE>stream</CODE>. The output may
depend on the global printer settings in the variable
<CODE>cl_default_print_flags</CODE>.
<CODE>default_print_flags</CODE>.
</DL>
@ -322,28 +322,28 @@ The following functions return special polynomials.
<DL COMPACT>
<DT><CODE>cl_UP_I cl_tschebychev (sintL n)</CODE>
<DT><CODE>cl_UP_I tschebychev (sintL n)</CODE>
<DD>
<A NAME="IDX306"></A>
<A NAME="IDX307"></A>
Returns the n-th Tchebychev polynomial (n &#62;= 0).
<A NAME="IDX319"></A>
<A NAME="IDX320"></A>
Returns the n-th Chebyshev polynomial (n &#62;= 0).
<DT><CODE>cl_UP_I cl_hermite (sintL n)</CODE>
<DT><CODE>cl_UP_I hermite (sintL n)</CODE>
<DD>
<A NAME="IDX308"></A>
<A NAME="IDX309"></A>
<A NAME="IDX321"></A>
<A NAME="IDX322"></A>
Returns the n-th Hermite polynomial (n &#62;= 0).
<DT><CODE>cl_UP_RA cl_legendre (sintL n)</CODE>
<DT><CODE>cl_UP_RA legendre (sintL n)</CODE>
<DD>
<A NAME="IDX310"></A>
<A NAME="IDX311"></A>
<A NAME="IDX323"></A>
<A NAME="IDX324"></A>
Returns the n-th Legendre polynomial (n &#62;= 0).
<DT><CODE>cl_UP_I cl_laguerre (sintL n)</CODE>
<DT><CODE>cl_UP_I laguerre (sintL n)</CODE>
<DD>
<A NAME="IDX312"></A>
<A NAME="IDX313"></A>
<A NAME="IDX325"></A>
<A NAME="IDX326"></A>
Returns the n-th Laguerre polynomial (n &#62;= 0).
</DL>

23
doc/cln_toc.html

@ -1,6 +1,6 @@
<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from cln.texi on 2 June 2000 -->
<!-- Created by texi2html 1.56k from cln.texi on 28 August 2000 -->
<TITLE>CLN, a Class Library for Numbers - Table of Contents</TITLE>
</HEAD>
@ -104,21 +104,22 @@
<LI><A NAME="TOC64" HREF="cln_11.html#SEC64">11. Using the library</A>
<UL>
<LI><A NAME="TOC65" HREF="cln_11.html#SEC65">11.1 Compiler options</A>
<LI><A NAME="TOC66" HREF="cln_11.html#SEC66">11.2 Include files</A>
<LI><A NAME="TOC67" HREF="cln_11.html#SEC67">11.3 An Example</A>
<LI><A NAME="TOC68" HREF="cln_11.html#SEC68">11.4 Debugging support</A>
<LI><A NAME="TOC66" HREF="cln_11.html#SEC66">11.2 Compatibility to old CLN versions</A>
<LI><A NAME="TOC67" HREF="cln_11.html#SEC67">11.3 Include files</A>
<LI><A NAME="TOC68" HREF="cln_11.html#SEC68">11.4 An Example</A>
<LI><A NAME="TOC69" HREF="cln_11.html#SEC69">11.5 Debugging support</A>
</UL>
<LI><A NAME="TOC69" HREF="cln_12.html#SEC69">12. Customizing</A>
<LI><A NAME="TOC70" HREF="cln_12.html#SEC70">12. Customizing</A>
<UL>
<LI><A NAME="TOC70" HREF="cln_12.html#SEC70">12.1 Error handling</A>
<LI><A NAME="TOC71" HREF="cln_12.html#SEC71">12.2 Floating-point underflow</A>
<LI><A NAME="TOC72" HREF="cln_12.html#SEC72">12.3 Customizing I/O</A>
<LI><A NAME="TOC73" HREF="cln_12.html#SEC73">12.4 Customizing the memory allocator</A>
<LI><A NAME="TOC71" HREF="cln_12.html#SEC71">12.1 Error handling</A>
<LI><A NAME="TOC72" HREF="cln_12.html#SEC72">12.2 Floating-point underflow</A>
<LI><A NAME="TOC73" HREF="cln_12.html#SEC73">12.3 Customizing I/O</A>
<LI><A NAME="TOC74" HREF="cln_12.html#SEC74">12.4 Customizing the memory allocator</A>
</UL>
<LI><A NAME="TOC74" HREF="cln_13.html#SEC74">Index</A>
<LI><A NAME="TOC75" HREF="cln_13.html#SEC75">Index</A>
</UL>
<P><HR><P>
This document was generated on 2 June 2000 using
This document was generated on 28 August 2000 using
<A HREF="http://wwwinfo.cern.ch/dis/texi2html/">texi2html</A>&nbsp;1.56k.
</BODY>
</HTML>

1
examples/Makefile.in

@ -102,6 +102,7 @@ mostlyclean : clean
clean : force
$(RM) *.s *.o *.a $(PROGRAMS) a.out core
$(RM) -r .libs _libs
distclean : clean
$(RM) config.status config.log config.cache Makefile

19
examples/atan_recip.cc

@ -1,20 +1,21 @@
// Computation of arctan(1/m) (m integer) to high precision.
#include "cl_integer.h"
#include "cl_rational.h"
#include "cl_real.h"
#include "cl_lfloat.h"
#include "cln/integer.h"
#include "cln/rational.h"
#include "cln/real.h"
#include "cln/lfloat.h"
#include "cl_LF.h"
#include "cl_LF_tran.h"
#include "cl_alloca.h"
#include <stdlib.h>
#include <string.h>
#include "cl_timing.h"
#include "cln/timing.h"
#undef floor
#include <math.h>
#define floor cln_floor
using namespace cln;
// Method 1: atan(1/m) = sum(n=0..infty, (-1)^n/(2n+1) * 1/m^(2n+1))
// Method 2: atan(1/m) = sum(n=0..infty, 4^n*n!^2/(2n+1)! * m/(m^2+1)^(n+1))
@ -65,7 +66,7 @@ const cl_LF atan_recip_1c (cl_I m, uintC len)
{
var uintC actuallen = len + 1;
var cl_I m2 = m*m;
var sintL N = (sintL)(0.69314718*intDsize/2*actuallen/log(cl_double_approx(m))) + 1;
var sintL N = (sintL)(0.69314718*intDsize/2*actuallen/log(double_approx(m))) + 1;
var cl_I num = 0, den = 1; // "lazy rational number"
for (sintL n = N-1; n>=0; n--) {
// Multiply sum with 1/m^2:
@ -86,7 +87,7 @@ const cl_LF atan_recip_1d (cl_I m, uintC len)
{
var uintC actuallen = len + 1;
var cl_I m2 = m*m;
var uintL N = (uintL)(0.69314718*intDsize/2*actuallen/log(cl_double_approx(m))) + 1;
var uintL N = (uintL)(0.69314718*intDsize/2*actuallen/log(double_approx(m))) + 1;
CL_ALLOCA_STACK;
var cl_I* bv = (cl_I*) cl_alloca(N*sizeof(cl_I));
var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I));
@ -141,7 +142,7 @@ const cl_LF atan_recip_2c (cl_I m, uintC len)
{
var uintC actuallen = len + 1;
var cl_I m2 = m*m+1;
var uintL N = (uintL)(0.69314718*intDsize*actuallen/log(cl_double_approx(m2))) + 1;
var uintL N = (uintL)(0.69314718*intDsize*actuallen/log(double_approx(m2))) + 1;
var cl_I num = 0, den = 1; // "lazy rational number"
for (uintL n = N; n>0; n--) {
// Multiply sum with (2n)/(2n+1)(m^2+1):
@ -160,7 +161,7 @@ const cl_LF atan_recip_2d (cl_I m, uintC len)
{
var uintC actuallen = len + 1;
var cl_I m2 = m*m+1;
var uintL N = (uintL)(0.69314718*intDsize*actuallen/log(cl_double_approx(m2))) + 1;
var uintL N = (uintL)(0.69314718*intDsize*actuallen/log(double_approx(m2))) + 1;
CL_ALLOCA_STACK;
var cl_I* pv = (cl_I*) cl_alloca(N*sizeof(cl_I));
var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I));

22
examples/atanh_recip.cc

@ -1,19 +1,19 @@
// Computation of artanh(1/m) (m integer) to high precision.
#include "cl_integer.h"
#include "cl_rational.h"
#include "cl_real.h"
#include "cl_complex.h"
#include "cl_lfloat.h"
#include "cln/integer.h"
#include "cln/rational.h"
#include "cln/real.h"
#include "cln/complex.h"
#include "cln/lfloat.h"
#include "cl_LF.h"
#include "cl_LF_tran.h"
#include "cl_alloca.h"
#include <stdlib.h>
#include <string.h>
#include "cl_timing.h"
#include "cln/timing.h"
#undef floor
#include <math.h>
#include <cmath>
#define floor cln_floor
@ -62,7 +62,7 @@ const cl_LF atanh_recip_1c (cl_I m, uintC len)
{
var uintC actuallen = len + 1;
var cl_I m2 = m*m;
var sintL N = (sintL)(0.69314718*intDsize/2*actuallen/log(cl_double_approx(m))) + 1;
var sintL N = (sintL)(0.69314718*intDsize/2*actuallen/log(double_approx(m))) + 1;
var cl_I num = 0, den = 1; // "lazy rational number"
for (sintL n = N-1; n>=0; n--) {
// Multiply sum with 1/m^2:
@ -80,7 +80,7 @@ const cl_LF atanh_recip_1d (cl_I m, uintC len)
{
var uintC actuallen = len + 1;
var cl_I m2 = m*m;
var uintL N = (uintL)(0.69314718*intDsize/2*actuallen/log(cl_double_approx(m))) + 1;
var uintL N = (uintL)(0.69314718*intDsize/2*actuallen/log(double_approx(m))) + 1;
CL_ALLOCA_STACK;
var cl_I* bv = (cl_I*) cl_alloca(N*sizeof(cl_I));
var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I));
@ -141,7 +141,7 @@ const cl_LF atanh_recip_2c (cl_I m, uintC len)
{
var uintC actuallen = len + 1;
var cl_I m2 = m*m-1;
var uintL N = (uintL)(0.69314718*intDsize*actuallen/log(cl_double_approx(m2))) + 1;
var uintL N = (uintL)(0.69314718*intDsize*actuallen/log(double_approx(m2))) + 1;
var cl_I num = 0, den = 1; // "lazy rational number"
for (uintL n = N; n>0; n--) {
// Multiply sum with -(2n)/(2n+1)(m^2+1):
@ -160,7 +160,7 @@ const cl_LF atanh_recip_2d (cl_I m, uintC len)
{
var uintC actuallen = len + 1;
var cl_I m2 = m*m-1;
var uintL N = (uintL)(0.69314718*intDsize*actuallen/log(cl_double_approx(m2))) + 1;
var uintL N = (uintL)(0.69314718*intDsize*actuallen/log(double_approx(m2))) + 1;
CL_ALLOCA_STACK;
var cl_I* pv = (cl_I*) cl_alloca(N*sizeof(cl_I));
var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I));

24
examples/contfrac.cc

@ -1,17 +1,21 @@
// Print the continued fraction of a real number.
// We work with real numbers and integers.
#include <cl_real.h>
#include <cl_integer.h>
#include <cln/real.h>
#include <cln/integer.h>
// We do I/O.
#include <cl_io.h>
#include <cl_integer_io.h>
#include <cln/io.h>
#include <cln/integer_io.h>
using namespace cln;
// Our private error handling: return to the main program.
#include <setjmp.h>
jmp_buf restartpoint;
void cl_abort (void) { longjmp(restartpoint,1); }
namespace cln {
void cl_abort (void) { longjmp(restartpoint,1); }
}
int main (int argc, char* argv[])
{
@ -23,23 +27,23 @@ int main (int argc, char* argv[])
cl_R x = arg;
// Check sign.
if (minusp(x)) {
fprint(cl_stdout, "-");
stdout << '-';
x = -x;
}
fprint(cl_stdout, "[");
fprint(stdout, "[");
const char* separator = "; ";
for (;;) {
// Split x into integral and fractional part.
cl_R_div_t x_split = floor2(x);
fprint(cl_stdout, x_split.quotient);
stdout << x_split.quotient;
x = x_split.remainder;
if (zerop(x))
break;
fprint(cl_stdout, separator);
stdout << separator;
separator = ", ";
// Invert x.
x = recip(x);
}
fprint(cl_stdout, "]\n");
stdout << ']' << std::endl;
}
}

40
examples/e.cc

@ -27,18 +27,20 @@
* conversion to decimal: real time: 54507.003 s, run time: 40063.510 s
*/
#include <cl_number.h>
#include <cl_io.h>
#include <cl_integer.h>
#include <cl_integer_io.h>
#include <cl_float.h>
#include <cl_float_io.h>
#include <cl_real.h>
#include <cl_complex.h>
#include <stdlib.h>
#include <cln/number.h>
#include <cln/io.h>
#include <cln/integer.h>
#include <cln/integer_io.h>
#include <cln/float.h>
#include <cln/float_io.h>
#include <cln/real.h>
#include <cln/complex.h>
#include <string.h>
#include <cl_timing.h>
#include <math.h>
#include <cln/timing.h>
#include <cmath>
using namespace std;
using namespace cln;
void
sum_exp1 (uintL a, uintL b, cl_I & first, cl_I & second)
@ -69,15 +71,19 @@ sum_exp1 (uintL a, uintL b, cl_I & first, cl_I & second)
}
}
namespace cln {
extern cl_LF cl_I_to_LF(const cl_I&, uintC);
};
void
const_exp1 (cl_LF & result, uintL dec)
{
uintL c = (uintL) (dec * log (10));
uintL c = (uintL) (dec * ::log (10));
uintL n = dec;
uintC actuallen = (uintC)(3.321928094 * dec / intDsize);
n = (uintL) ((n + c) / log ((double)n));
n = (uintL) ((n + c) / log ((double)n));
n = (uintL) ((n + c) / log ((double)n));
n = (uintL) ((n + c) / ::log ((double)n));
n = (uintL) ((n + c) / ::log ((double)n));
n = (uintL) ((n + c) / ::log ((double)n));
n += 2;
actuallen += 2;
@ -87,7 +93,6 @@ const_exp1 (cl_LF & result, uintL dec)
cl_I p, q;
sum_exp1 (0, n, p, q);
cout << "sum_exp1 ends ok" << endl;
extern cl_LF cl_I_to_LF(const cl_I&, uintC);
result = The(cl_LF)(cl_I_to_LF (p, actuallen) / cl_I_to_LF (q, actuallen));
cout << "const_exp1 returns ok" << endl;
}
@ -105,7 +110,7 @@ main (int argc, char *argv[])
break;
}
if (argc < 1)
exit(1);
return(1);
cl_LF c1;
long l = digits;
@ -118,4 +123,5 @@ main (int argc, char *argv[])
cout << c1 << endl;
cout << "@" << endl;
}
return(0);
}

84
examples/fibonacci.cc

@ -1,18 +1,18 @@
// Compute and print the n-th Fibonacci number.
// We work with integers and real numbers.
#include <cl_integer.h>
#include <cl_real.h>
#include <cln/integer.h>
#include <cln/real.h>
// We do I/O.
#include <cl_io.h>
#include <cl_integer_io.h>
#include <cln/io.h>
#include <cln/integer_io.h>
// We use the timing functions.
#include <cl_timing.h>
#include <cln/timing.h>
// Declare the exit() function.
#include <stdlib.h>
using namespace std;
using namespace cln;
// F_n is defined through the recurrence relation
// F_0 = 0, F_1 = 1, F_(n+2) = F_(n+1) + F_n.
@ -79,12 +79,42 @@ const cl_I fibonacci (int n)
}
}
// The next routine is a variation of the above. It is mathematically
// equivalent but implemented in a non-recursive way.
const cl_I fibonacci_compact (int n)
{
if (n==0)
return 0;
cl_I u = 0;
cl_I v = 1;
cl_I m = n/2; // floor(n/2)
for (uintL bit=integer_length(m); bit>0; --bit) {
// Since a squaring is cheaper than a multiplication, better use
// three squarings instead of one multiplication and two squarings.
cl_I u2 = square(u);
cl_I v2 = square(v);
if (logbitp(bit-1, m)) {
v = square(u + v) - u2;
u = u2 + v2;
} else {
u = v2 - square(v - u);
v = u2 + v2;
}
}
if (n==2*m)
// Here we don't use the squaring formula because
// one multiplication is cheaper than two squarings.
return u * ((v << 1) - u);
else
return square(u) + square(v);
}
// Returns just F_n, computed as the nearest integer to
// ((1+sqrt(5))/2)^n/sqrt(5). Assume n>=0.
const cl_I fibonacci_slow (int n)
{
// Need a precision of ((1+sqrt(5))/2)^-n.
cl_float_format_t prec = cl_float_format((int)(0.208987641*n+5));
float_format_t prec = float_format((int)(0.208987641*n+5));
cl_R sqrt5 = sqrt(cl_float(5,prec));
cl_R phi = (1+sqrt5)/2;
return round1( expt(phi,n)/sqrt5 );
@ -95,49 +125,47 @@ const cl_I fibonacci_slow (int n)
int main (int argc, char* argv[])
{
if (argc != 2) {
fprint(cl_stderr, "Usage: fibonacci n\n");
exit(1);
stderr << "Usage: fibonacci n" << endl;
return(1);
}
int n = atoi(argv[1]);
fprint(cl_stdout, "fib(");
fprintdecimal(cl_stdout, n);
fprint(cl_stdout, ") = ");
fprint(cl_stdout, fibonacci(n));
fprint(cl_stdout, "\n");
stdout << "fib(" << n << ") = " << fibonacci(n) << endl;
return(0);
}
#else // TIMING
int main (int argc, char* argv[])
{
int repetitions = 1;
int repetitions = 100;
if ((argc >= 3) && !strcmp(argv[1],"-r")) {
repetitions = atoi(argv[2]);
argc -= 2; argv += 2;
}
if (argc != 2) {
fprint(cl_stderr, "Usage: fibonacci n\n");
exit(1);
stderr << "Usage: fibonacci n" << endl;
return(1);
}
int n = atoi(argv[1]);
{ CL_TIMING;
fprint(cl_stdout, "fib(");
fprintdecimal(cl_stdout, n);
fprint(cl_stdout, ") = ");
stdout << "fib(" << n << ") = ";
for (int rep = repetitions-1; rep > 0; rep--)
fibonacci(n);
fprint(cl_stdout, fibonacci(n));
fprint(cl_stdout, "\n");
stdout << fibonacci(n) << endl;
}
{ CL_TIMING;
stdout << "fib(" << n << ") = ";
for (int rep = repetitions-1; rep > 0; rep--)
fibonacci_compact(n);
stdout << fibonacci_compact(n) << endl;
}
{ CL_TIMING;
fprint(cl_stdout, "fib(");
fprintdecimal(cl_stdout, n);
fprint(cl_stdout, ") = ");
stdout << "fib(" << n << ") = ";
for (int rep = repetitions-1; rep > 0; rep--)
fibonacci_slow(n);
fprint(cl_stdout, fibonacci_slow(n));
fprint(cl_stdout, "\n");
stdout << fibonacci_slow(n) << endl;
}
return(0);
}
#endif

34
examples/legendre.cc

@ -1,21 +1,23 @@
// Compute the Legendre polynomials.
#include <cl_number.h>
#include <cl_integer.h>
#include <cl_rational.h>
#include <cl_univpoly.h>
#include <cl_modinteger.h>
#include <cl_univpoly_rational.h>
#include <cl_univpoly_modint.h>
#include <cl_io.h>
#include <cln/number.h>
#include <cln/integer.h>
#include <cln/rational.h>
#include <cln/univpoly.h>
#include <cln/modinteger.h>
#include <cln/univpoly_rational.h>
#include <cln/univpoly_modint.h>
#include <cln/io.h>
#include <stdlib.h>
using namespace cln;
// Computes the n-th Legendre polynomial in R[x], using the formula
// P_n(x) = 1/(2^n n!) * (d/dx)^n (x^2-1)^n. (Assume n >= 0.)
const cl_UP_RA legendre (const cl_rational_ring& R, int n)
{
cl_univpoly_rational_ring PR = cl_find_univpoly_ring(R);
cl_univpoly_rational_ring PR = find_univpoly_ring(R);
cl_UP_RA b = PR->create(2);
b.set_coeff(2,1);
b.set_coeff(1,0);
@ -33,7 +35,7 @@ const cl_UP_RA legendre (const cl_rational_ring& R, int n)
const cl_UP_MI legendre (const cl_modint_ring& R, int n)
{
cl_univpoly_modint_ring PR = cl_find_univpoly_ring(R);
cl_univpoly_modint_ring PR = find_univpoly_ring(R);
cl_UP_MI b = PR->create(2);
b.set_coeff(2,R->canonhom(1));
b.set_coeff(1,R->canonhom(0));
@ -52,21 +54,21 @@ const cl_UP_MI legendre (const cl_modint_ring& R, int n)
int main (int argc, char* argv[])
{
if (!(argc == 2 || argc == 3)) {
fprint(cl_stderr, "Usage: legendre n [m]\n");
fprint(stderr, "Usage: legendre n [m]\n");
exit(1);
}
int n = atoi(argv[1]);
if (!(n >= 0)) {
fprint(cl_stderr, "Usage: legendre n [m] with n >= 0\n");
fprint(stderr, "Usage: legendre n [m] with n >= 0\n");
exit(1);
}
if (argc == 2) {
cl_UP p = legendre(cl_RA_ring,n);
fprint(cl_stdout, p);
fprint(stdout, p);
} else {
cl_I m = argv[2];
cl_UP p = legendre(cl_find_modint_ring(m),n);
fprint(cl_stdout, p);
cl_UP p = legendre(find_modint_ring(m),n);
fprint(stdout, p);
}
fprint(cl_stdout, "\n");
fprint(stdout, "\n");
}

26
examples/lucaslehmer.cc

@ -4,7 +4,10 @@
// Seminumerical Algorithms, second edition. Section 4.5.4, p. 391.]
// We work with integers.
#include <cl_integer.h>
#include <cln/integer.h>
using namespace std;
using namespace cln;
// Checks whether 2^q-1 is prime, q an odd prime.
bool mersenne_prime_p (int q)
@ -33,13 +36,13 @@ bool mersenne_prime_p_opt (int q)
}
// Now we work with modular integers.
#include <cl_modinteger.h>
#include <cln/modinteger.h>
// Same thing, but using modular integers.
bool mersenne_prime_p_modint (int q)
{
cl_I m = ((cl_I)1 << q) - 1;
cl_modint_ring R = cl_find_modint_ring(m); // Z/mZ
cl_modint_ring R = find_modint_ring(m); // Z/mZ
int i;
cl_MI L_i;
for (i = 0, L_i = R->canonhom(4); i < q-2; i++)
@ -47,33 +50,30 @@ bool mersenne_prime_p_modint (int q)
return R->equal(L_i,R->zero());
}
#include <cl_io.h> // we do I/O
#include <cln/io.h> // we do I/O
#include <stdlib.h> // declares exit()
#include <cl_timing.h>
#include <cln/timing.h>
int main (int argc, char* argv[])
{
if (!(argc == 2)) {
fprint(cl_stderr, "Usage: lucaslehmer exponent\n");
cerr << "Usage: lucaslehmer exponent" << endl;
exit(1);
}
int q = atoi(argv[1]);
if (!(q >= 2 && ((q % 2)==1))) {
fprint(cl_stderr, "Usage: lucaslehmer q with q odd prime\n");
cerr << "Usage: lucaslehmer q with q odd prime" << endl;
exit(1);
}
bool isprime;
{ CL_TIMING; isprime = mersenne_prime_p(q); }
{ CL_TIMING; isprime = mersenne_prime_p_opt(q); }
{ CL_TIMING; isprime = mersenne_prime_p_modint(q); }
fprint(cl_stdout, "2^");
fprintdecimal(cl_stdout, q);
fprint(cl_stdout, "-1 is ");
cout << "2^" << q << "-1 is ";
if (isprime)
fprint(cl_stdout, "prime");
cout << "prime" << endl;
else
fprint(cl_stdout, "composite");
fprint(cl_stdout, "\n");
cout << "composite" << endl;
}
// Computing time on a i486, 33 MHz:

22
examples/nextprime.cc

@ -2,24 +2,24 @@
// command line.
// We work with real numbers and integers.
#include <cl_real.h>
#include <cl_integer.h>
#include <cln/real.h>
#include <cln/integer.h>
// We do I/O.
#include <cl_io.h>
#include <cl_integer_io.h>
#include <cln/io.h>
#include <cln/integer_io.h>
// The function nextprobprime() is part of the number theory package.
#include <cl_numtheory.h>
#include <cln/numtheory.h>
int main (int argc, char* argv[])
{
if (argc != 2) {
fprint(cl_stderr, "Usage: nextprime x\n");
exit(1);
cln::stderr << "Usage: nextprime x" << std::endl;
return(1);
}
cl_R x = (cl_R)argv[1];
cl_I p = nextprobprime(x);
fprint(cl_stdout, p);
fprint(cl_stdout, "\n");
cln::cl_R x = (cln::cl_R)argv[1];
cln::cl_I p = cln::nextprobprime(x);
cln::stdout << p << std::endl;
return(0);
}

12
examples/perfnum.cc

@ -1,11 +1,15 @@
// This program prints the largest now known perfect number.
// This program prints the largest now known even perfect number.
#include <cl_integer.h>
#include <cl_integer_io.h>
#include <cln/integer.h>
#include <cln/integer_io.h>
using namespace std;
using namespace cln;
int main ()
{
int p = 1398269; // previous one was 1257787
// previous ones were 1257787, 1398269, 2976221, 3021377
int p = 6972593;
cl_I x = (((cl_I)1 << p) - 1) << (p-1);
cout << x << endl;
}

127
include/cl_config.h.in

@ -1,127 +0,0 @@
// Defines CPU and compiler dependent macros
#ifndef _CL_CONFIG_H
#define _CL_CONFIG_H
/* These definitions are adjusted by `configure' automatically. */
/* release version */
#undef CL_VERSION
#undef CL_VERSION_MINOR
#undef CL_VERSION_PATCHLEVEL
/* CPU */
#ifndef __i386__
#undef __i386__
#endif
#ifndef __m68k__
#undef __m68k__
#endif
#ifndef __mips__
#undef __mips__
#endif
#ifndef __mips64__
#undef __mips64__
#endif
#ifndef __sparc__
#undef __sparc__
#endif
#ifndef __sparc64__
#undef __sparc64__
#endif
#ifndef __alpha__
#undef __alpha__
#endif
#ifndef __hppa__
#undef __hppa__
#endif
#ifndef __arm__
#undef __arm__
#endif
#ifndef __rs6000__
#undef __rs6000__
#endif
#ifndef __m88k__
#undef __m88k__
#endif
#ifndef __convex__
#undef __convex__
#endif
/* assembler syntax */
/* CL_AS_UNDERSCORE */
/* Define if C symbols are prefixed by an underscore in assembly language. */
#undef ASM_UNDERSCORE
/* compiler characteristics */
/* CL_BOOL */
/* Define if your compiler understands the bool type. */
#undef HAVE_BOOL
/* Define this as `int' if your compiler doesn't understand the bool type. */
#undef bool
/* CL_LONGLONG */
/* Define if your compiler supports the `long long' type. */
#undef HAVE_LONGLONG
/* CL_LONGDOUBLE */
/* Define if your compiler supports the `long double' type. */
#undef HAVE_LONGDOUBLE
/* CL_TEMPLATE_NULL */
/* Define if your compiler supports the `template <>' syntax. */
#undef HAVE_TEMPLATE_NULL
/* header files */
/* CL_UNISTD_H */
/* Define if you have <unistd.h>. */
#undef HAVE_UNISTD_H
/* functions and declarations */
/* CL_ALLOCA */
/* Define if you have <alloca.h> and it should be used (not Ultrix). */
#undef HAVE_ALLOCA_H
/* Define if you need to link with an external alloca.o when using alloca(). */
#undef NO_ALLOCA
/* compiler characteristics */
/* CL_GLOBAL_CONSTRUCTORS */
/* Define as the prefix of the name of a module's global constructor function,
cf. macro FILE_FUNCTION_FORMAT in gcc/tree.c. */
#ifndef CL_GLOBAL_CONSTRUCTOR_PREFIX
#undef CL_GLOBAL_CONSTRUCTOR_PREFIX
#endif
/* Define as the prefix of the name of a module's global destructor function,
cf. macro FILE_FUNCTION_FORMAT in gcc/tree.c. */
#ifndef CL_GLOBAL_DESTRUCTOR_PREFIX
#undef CL_GLOBAL_DESTRUCTOR_PREFIX
#endif
/* Define if a module's global constructor function and global destructor
function need to be exported in order to be accessible from other modules. */
#undef CL_NEED_GLOBALIZE_CTORDTOR
/* CL_CHAR_UNSIGNED */
#ifndef __CHAR_UNSIGNED__
#undef __CHAR_UNSIGNED__
#endif
/* CL_MACHINE */
/* see cl_intparam.h */
/* see cl_floatparam.h */
#endif /* _CL_CONFIG_H */

16
include/cl_floatformat.h

@ -1,16 +0,0 @@
// Floating point format specifiers.
#ifndef _CL_FLOATFORMAT_H
#define _CL_FLOATFORMAT_H
#include "cl_types.h"
// Float format specifier type. (Float mantissa precision in bits.)
typedef enum cl_float_format_t {
cl_float_format_sfloat = 17,
cl_float_format_ffloat = 24,
cl_float_format_dfloat = 53,
cl_float_format_lfloat_min = ((53+intDsize-1)/intDsize)*intDsize // = round_up(53,intDsize)
};
#endif /* _CL_FLOATFORMAT_H */

141
include/cln.h

@ -1,141 +0,0 @@
// CLN exported types and functions
#ifndef _CLN_H
#define _CLN_H
// Automatically generated by configure
//#include "cl_config.h" // included by "cl_types.h" below
//#include "cl_intparam.h" // included by "cl_types.h" below
//#include "cl_floatparam.h" // not needed by any public header file
// ============================== base ==============================
// Basic types and definitions.
#include "cl_types.h"
#include "cl_modules.h"
#include "cl_object.h"
// Miscellaneous.
#include "cl_random.h"
#include "cl_malloc.h"
#include "cl_abort.h"
#include "cl_floatformat.h"
#include "cl_io.h"
#include "cl_condition.h"
// Symbolic facilities.
#include "cl_string.h"
#include "cl_symbol.h"
#include "cl_proplist.h"
// Miscellaneous.
#include "cl_input.h"
#include "cl_output.h"
// Abstract number classes.
#include "cl_number.h"
#include "cl_number_io.h"
#include "cl_complex_class.h"
#include "cl_real_class.h"
#include "cl_rational_class.h"
// Rings.
#include "cl_ring.h"
// ============================== integer ==============================
// Integers.
#include "cl_integer_class.h"
#include "cl_integer.h"
#include "cl_integer_io.h"
#include "cl_integer_ring.h"
#include "cl_null_ring.h"
// ============================== rational ==============================
// Rational numbers.
#include "cl_rational.h"
#include "cl_rational_io.h"
#include "cl_rational_ring.h"
// ============================== float ==============================
// Floating-point numbers.
#include "cl_float_class.h"
#include "cl_sfloat_class.h"
#include "cl_ffloat_class.h"
#include "cl_dfloat_class.h"
#include "cl_lfloat_class.h"
#include "cl_float.h"
#include "cl_float_io.h"
#include "cl_sfloat.h"
#include "cl_sfloat_io.h"
#include "cl_ffloat.h"
#include "cl_ffloat_io.h"
#include "cl_dfloat.h"
#include "cl_dfloat_io.h"
#include "cl_lfloat.h"
#include "cl_lfloat_io.h"
// ============================== real ==============================
// Real numbers.
#include "cl_real.h"
#include "cl_real_io.h"
#include "cl_real_ring.h"
// ============================== complex ==============================
// Complex numbers.
#include "cl_complex.h"
#include "cl_complex_io.h"
#include "cl_complex_ring.h"
// ============================== modinteger ==============================
// Modular integers.
#include "cl_modinteger.h"
// ============================== numtheory ==============================
// Rings for number theory.
#include "cl_numtheory.h"
// ============================== vector ==============================
// Vectors.
#include "cl_V.h"
#include "cl_GV.h"
#include "cl_GV_number.h"
#include "cl_GV_complex.h"
#include "cl_GV_real.h"
#include "cl_GV_rational.h"
#include "cl_GV_integer.h"
#include "cl_GV_modinteger.h"
#include "cl_SV.h"
#include "cl_SV_number.h"
#include "cl_SV_complex.h"
#include "cl_SV_real.h"
#include "cl_SV_rational.h"
#include "cl_SV_integer.h"
#include "cl_SV_ringelt.h"
// ============================== polynomial ==============================
// Polynomials.
#include "cl_univpoly.h"
#include "cl_univpoly_complex.h"
#include "cl_univpoly_real.h"
#include "cl_univpoly_rational.h"
#include "cl_univpoly_integer.h"
#include "cl_univpoly_modint.h"
// ============================== modpolynomial ==============================
// ============================== timing ==============================
// Environmental facilities.
#include "cl_timing.h"
#endif /* _CLN_H */

8
include/cl_GV.h → include/cln/GV.h

@ -3,11 +3,12 @@
#ifndef _CL_GV_H
#define _CL_GV_H
#include "cl_object.h"
#include "cl_V.h"
#include "cl_abort.h"
#include "cln/object.h"
#include "cln/V.h"
#include "cln/abort.h"
#include <stdlib.h>
namespace cln {
// A vector is a structure having the following interface:
// v.length() returns the number of elements
@ -295,5 +296,6 @@ typedef cl_GV<cl_gcobject,cl_V_any> cl_GV_any;
// This inline function is for type checking purposes only.
inline const cl_GV_any& cl_identity (const cl_GV_any& x) { return x; }
} // namespace cln
#endif /* _CL_GV_H */

16
include/cl_GV_complex.h → include/cln/GV_complex.h

@ -3,10 +3,12 @@
#ifndef _CL_GV_COMPLEX_H
#define _CL_GV_COMPLEX_H
#include "cl_number.h"
#include "cl_GV_number.h"
#include "cl_complex_class.h"
#include "cl_io.h"
#include "cln/number.h"
#include "cln/GV_number.h"
#include "cln/complex_class.h"
#include "cln/io.h"
namespace cln {
// A vector of complex numbers is just a normal vector of numbers.
@ -40,10 +42,10 @@ inline const cl_GV_N copy (const cl_GV_N& vector)
// Output.
inline void fprint (cl_ostream stream, const cl_GV_N& x)
{
extern cl_print_flags cl_default_print_flags;
extern cl_print_flags default_print_flags;
extern void print_vector (cl_ostream stream, const cl_print_flags& flags, void (* fun) (cl_ostream, const cl_print_flags&, const cl_number&), const cl_GV_number& vector);
extern void print_complex (cl_ostream stream, const cl_print_flags& flags, const cl_N& z);
print_vector(stream, cl_default_print_flags,
print_vector(stream, default_print_flags,
(void (*) (cl_ostream, const cl_print_flags&, const cl_number&))
(void (*) (cl_ostream, const cl_print_flags&, const cl_N&))
&print_complex,
@ -51,4 +53,6 @@ inline void fprint (cl_ostream stream, const cl_GV_N& x)
}
CL_DEFINE_PRINT_OPERATOR(cl_GV_N)
} // namespace cln
#endif /* _CL_GV_COMPLEX_H */

16
include/cl_GV_integer.h → include/cln/GV_integer.h

@ -3,10 +3,12 @@
#ifndef _CL_GV_INTEGER_H
#define _CL_GV_INTEGER_H
#include "cl_number.h"
#include "cl_GV_rational.h"
#include "cl_integer_class.h"
#include "cl_io.h"
#include "cln/number.h"
#include "cln/GV_rational.h"
#include "cln/integer_class.h"
#include "cln/io.h"
namespace cln {
// A vector of integers is *not* just a normal vector of numbers (the vectorops
// support the maxbits() operation), but we treat can it like this nevertheless.
@ -62,10 +64,10 @@ extern const cl_GV_I copy (const cl_GV_I&);
// Output.
inline void fprint (cl_ostream stream, const cl_GV_I& x)
{
extern cl_print_flags cl_default_print_flags;
extern cl_print_flags default_print_flags;
extern void print_vector (cl_ostream stream, const cl_print_flags& flags, void (* fun) (cl_ostream, const cl_print_flags&, const cl_number&), const cl_GV_number& vector);
extern void print_integer (cl_ostream stream, const cl_print_flags& flags, const cl_I& z);
print_vector(stream, cl_default_print_flags,
print_vector(stream, default_print_flags,
(void (*) (cl_ostream, const cl_print_flags&, const cl_number&))
(void (*) (cl_ostream, const cl_print_flags&, const cl_I&))
&print_integer,
@ -81,4 +83,6 @@ static void* const cl_GV_I_debug_dummy[] = { &cl_GV_I_debug_dummy,
};
#endif
} // namespace cln
#endif /* _CL_GV_INTEGER_H */

7
include/cl_GV_modinteger.h → include/cln/GV_modinteger.h

@ -3,8 +3,10 @@
#ifndef _CL_GV_MODINTEGER_H
#define _CL_GV_MODINTEGER_H
#include "cl_modinteger.h"
#include "cl_GV_integer.h"
#include "cln/modinteger.h"
#include "cln/GV_integer.h"
namespace cln {
// A vector of modular integers (over the same modular integer ring)
// is just a normal vector of integers, with maxbits() operation.
@ -46,5 +48,6 @@ inline const cl_GV_MI copy (const cl_GV_MI& vector)
return The(cl_GV_MI) (copy((const cl_GV_I&) vector));
}
} // namespace cln
#endif /* _CL_GV_MODINTEGER_H */

8
include/cl_GV_number.h → include/cln/GV_number.h

@ -3,8 +3,10 @@
#ifndef _CL_GV_NUMBER_H
#define _CL_GV_NUMBER_H
#include "cl_number.h"
#include "cl_GV.h"
#include "cln/number.h"
#include "cln/GV.h"
namespace cln {
typedef cl_heap_GV<cl_number> cl_heap_GV_number;
@ -43,4 +45,6 @@ static void* const cl_GV_number_debug_dummy[] = { &cl_GV_number_debug_dummy,
};
#endif
} // namespace cln
#endif /* _CL_GV_NUMBER_H */

16
include/cl_GV_rational.h → include/cln/GV_rational.h

@ -3,10 +3,12 @@
#ifndef _CL_GV_RATIONAL_H
#define _CL_GV_RATIONAL_H
#include "cl_number.h"
#include "cl_GV_real.h"
#include "cl_rational_class.h"
#include "cl_io.h"
#include "cln/number.h"
#include "cln/GV_real.h"
#include "cln/rational_class.h"
#include "cln/io.h"
namespace cln {
// A vector of rational numbers is just a normal vector of real numbers.
@ -40,10 +42,10 @@ inline const cl_GV_RA copy (const cl_GV_RA& vector)
// Output.
inline void fprint (cl_ostream stream, const cl_GV_RA& x)
{
extern cl_print_flags cl_default_print_flags;
extern cl_print_flags default_print_flags;
extern void print_vector (cl_ostream stream, const cl_print_flags& flags, void (* fun) (cl_ostream, const cl_print_flags&, const cl_number&), const cl_GV_number& vector);
extern void print_rational (cl_ostream stream, const cl_print_flags& flags, const cl_RA& z);
print_vector(stream, cl_default_print_flags,
print_vector(stream, default_print_flags,
(void (*) (cl_ostream, const cl_print_flags&, const cl_number&))
(void (*) (cl_ostream, const cl_print_flags&, const cl_RA&))
&print_rational,
@ -51,4 +53,6 @@ inline void fprint (cl_ostream stream, const cl_GV_RA& x)
}
CL_DEFINE_PRINT_OPERATOR(cl_GV_RA)
} // namespace cln
#endif /* _CL_GV_RAATIONAL_H */

16
include/cl_GV_real.h → include/cln/GV_real.h

@ -3,10 +3,12 @@
#ifndef _CL_GV_REAL_H
#define _CL_GV_REAL_H
#include "cl_number.h"
#include "cl_GV_complex.h"
#include "cl_real_class.h"
#include "cl_io.h"
#include "cln/number.h"
#include "cln/GV_complex.h"
#include "cln/real_class.h"
#include "cln/io.h"
namespace cln {
// A vector of real numbers is just a normal vector of numbers.
@ -40,10 +42,10 @@ inline const cl_GV_R copy (const cl_GV_R& vector)
// Output.
inline void fprint (cl_ostream stream, const cl_GV_R& x)
{
extern cl_print_flags cl_default_print_flags;
extern cl_print_flags default_print_flags;
extern void print_vector (cl_ostream stream, const cl_print_flags& flags, void (* fun) (cl_ostream, const cl_print_flags&, const cl_number&), const cl_GV_number& vector);
extern void print_real (cl_ostream stream, const cl_print_flags& flags, const cl_R& z);
print_vector(stream, cl_default_print_flags,
print_vector(stream, default_print_flags,
(void (*) (cl_ostream, const cl_print_flags&, const cl_number&))
(void (*) (cl_ostream, const cl_print_flags&, const cl_R&))
&print_real,
@ -51,4 +53,6 @@ inline void fprint (cl_ostream stream, const cl_GV_R& x)
}
CL_DEFINE_PRINT_OPERATOR(cl_GV_R)
} // namespace cln
#endif /* _CL_GV_REAL_H */

8
include/cl_SV.h → include/cln/SV.h

@ -3,11 +3,12 @@
#ifndef _CL_SV_H
#define _CL_SV_H
#include "cl_object.h"
#include "cl_V.h"
#include "cl_abort.h"
#include "cln/object.h"
#include "cln/V.h"
#include "cln/abort.h"
#include <stdlib.h>
namespace cln {
// A simple vector has the same operations as a vector, but it can store
// _only_ cl_gcobject's.
@ -176,5 +177,6 @@ extern const cl_SV_any copy (const cl_SV_any&);
// This inline function is for type checking purposes only.
inline const cl_SV_any& cl_identity (const cl_SV_any& x) { return x; }
} // namespace cln
#endif /* _CL_SV_H */

16
include/cl_SV_complex.h → include/cln/SV_complex.h

@ -3,10 +3,12 @@
#ifndef _CL_SV_COMPLEX_H
#define _CL_SV_COMPLEX_H
#include "cl_number.h"
#include "cl_SV_number.h"
#include "cl_complex_class.h"
#include "cl_io.h"
#include "cln/number.h"
#include "cln/SV_number.h"
#include "cln/complex_class.h"
#include "cln/io.h"
namespace cln {
// A vector of complex numbers is just a normal vector of numbers.
@ -36,10 +38,10 @@ inline const cl_SV_N copy (const cl_SV_N& vector)
// Output.
inline void fprint (cl_ostream stream, const cl_SV_N& x)
{
extern cl_print_flags cl_default_print_flags;
extern cl_print_flags default_print_flags;
extern void print_vector (cl_ostream stream, const cl_print_flags& flags, void (* fun) (cl_ostream, const cl_print_flags&, const cl_number&), const cl_SV_number& vector);
extern void print_complex (cl_ostream stream, const cl_print_flags& flags, const cl_N& z);
print_vector(stream, cl_default_print_flags,
print_vector(stream, default_print_flags,
(void (*) (cl_ostream, const cl_print_flags&, const cl_number&))
(void (*) (cl_ostream, const cl_print_flags&, const cl_N&))
&print_complex,
@ -47,4 +49,6 @@ inline void fprint (cl_ostream stream, const cl_SV_N& x)
}
CL_DEFINE_PRINT_OPERATOR(cl_SV_N)
} // namespace cln
#endif /* _CL_SV_COMPLEX_H */

16
include/cl_SV_integer.h → include/cln/SV_integer.h

@ -3,10 +3,12 @@
#ifndef _CL_SV_INTEGER_H
#define _CL_SV_INTEGER_H
#include "cl_number.h"
#include "cl_SV_rational.h"
#include "cl_integer_class.h"
#include "cl_io.h"
#include "cln/number.h"
#include "cln/SV_rational.h"
#include "cln/integer_class.h"
#include "cln/io.h"
namespace cln {
// A vector of integers is just a normal vector of rational numbers.
@ -33,10 +35,10 @@ inline const cl_SV_I copy (const cl_SV_I& vector)
// Output.
inline void fprint (cl_ostream stream, const cl_SV_I& x)
{
extern cl_print_flags cl_default_print_flags;
extern cl_print_flags default_print_flags;
extern void print_vector (cl_ostream stream, const cl_print_flags& flags, void (* fun) (cl_ostream, const cl_print_flags&, const cl_number&), const cl_SV_number& vector);
extern void print_integer (cl_ostream stream, const cl_print_flags& flags, const cl_I& z);
print_vector(stream, cl_default_print_flags,
print_vector(stream, default_print_flags,
(void (*) (cl_ostream, const cl_print_flags&, const cl_number&))
(void (*) (cl_ostream, const cl_print_flags&, const cl_I&))
&print_integer,
@ -44,4 +46,6 @@ inline void fprint (cl_ostream stream, const cl_SV_I& x)
}
CL_DEFINE_PRINT_OPERATOR(cl_SV_I)
} // namespace cln
#endif /* _CL_SV_INTEGER_H */

10
include/cl_SV_number.h → include/cln/SV_number.h

@ -3,9 +3,11 @@
#ifndef _CL_SV_NUMBER_H
#define _CL_SV_NUMBER_H
#include "cl_number.h"
#include "cl_SV.h"
#include "cl_io.h"
#include "cln/number.h"
#include "cln/SV.h"
#include "cln/io.h"
namespace cln {
typedef cl_heap_SV<cl_number> cl_heap_SV_number;
@ -55,4 +57,6 @@ static void* const cl_SV_number_debug_dummy[] = { &cl_SV_number_debug_dummy,
};
#endif
} // namespace cln
#endif /* _CL_SV_NUMBER_H */

16
include/cl_SV_rational.h → include/cln/SV_rational.h

@ -3,10 +3,12 @@
#ifndef _CL_SV_RATIONAL_H
#define _CL_SV_RATIONAL_H
#include "cl_number.h"
#include "cl_SV_real.h"
#include "cl_rational_class.h"
#include "cl_io.h"
#include "cln/number.h"
#include "cln/SV_real.h"
#include "cln/rational_class.h"
#include "cln/io.h"
namespace cln {
// A vector of rational numbers is just a normal vector of real numbers.
@ -36,10 +38,10 @@ inline const cl_SV_RA copy (const cl_SV_RA& vector)
// Output.
inline void fprint (cl_ostream stream, const cl_SV_RA& x)
{
extern cl_print_flags cl_default_print_flags;
extern cl_print_flags default_print_flags;
extern void print_vector (cl_ostream stream, const cl_print_flags& flags, void (* fun) (cl_ostream, const cl_print_flags&, const cl_number&), const cl_SV_number& vector);
extern void print_rational (cl_ostream stream, const cl_print_flags& flags, const cl_RA& z);
print_vector(stream, cl_default_print_flags,
print_vector(stream, default_print_flags,
(void (*) (cl_ostream, const cl_print_flags&, const cl_number&))
(void (*) (cl_ostream, const cl_print_flags&, const cl_RA&))
&print_rational,
@ -47,4 +49,6 @@ inline void fprint (cl_ostream stream, const cl_SV_RA& x)
}
CL_DEFINE_PRINT_OPERATOR(cl_SV_RA)
} // namespace cln
#endif /* _CL_SV_RAATIONAL_H */

16
include/cl_SV_real.h → include/cln/SV_real.h

@ -3,10 +3,12 @@
#ifndef _CL_SV_REAL_H
#define _CL_SV_REAL_H
#include "cl_number.h"
#include "cl_SV_complex.h"
#include "cl_real_class.h"
#include "cl_io.h"
#include "cln/number.h"
#include "cln/SV_complex.h"
#include "cln/real_class.h"
#include "cln/io.h"
namespace cln {
// A vector of real numbers is just a normal vector of numbers.
@ -36,10 +38,10 @@ inline const cl_SV_R copy (const cl_SV_R& vector)
// Output.
inline void fprint (cl_ostream stream, const cl_SV_R& x)
{
extern cl_print_flags cl_default_print_flags;
extern cl_print_flags default_print_flags;
extern void print_vector (cl_ostream stream, const cl_print_flags& flags, void (* fun) (cl_ostream, const cl_print_flags&, const cl_number&), const cl_SV_number& vector);
extern void print_real (cl_ostream stream, const cl_print_flags& flags, const cl_R& z);
print_vector(stream, cl_default_print_flags,
print_vector(stream, default_print_flags,
(void (*) (cl_ostream, const cl_print_flags&, const cl_number&))
(void (*) (cl_ostream, const cl_print_flags&, const cl_R&))
&print_real,
@ -47,4 +49,6 @@ inline void fprint (cl_ostream stream, const cl_SV_R& x)
}
CL_DEFINE_PRINT_OPERATOR(cl_SV_R)
} // namespace cln
#endif /* _CL_SV_REAL_H */

10
include/cl_SV_ringelt.h → include/cln/SV_ringelt.h

@ -3,9 +3,11 @@
#ifndef _CL_SV_RINGELT_H
#define _CL_SV_RINGELT_H
#include "cl_ring.h"
#include "cl_SV.h"
#include "cl_io.h"
#include "cln/ring.h"
#include "cln/SV.h"
#include "cln/io.h"
namespace cln {
typedef cl_heap_SV<_cl_ring_element> cl_heap_SV_ringelt;
@ -59,4 +61,6 @@ static void* const cl_SV_ringelt_debug_dummy[] = { &cl_SV_ringelt_debug_dummy,
};
#endif
} // namespace cln
#endif /* _CL_SV_RINGELT_H */

6
include/cl_V.h → include/cln/V.h

@ -3,7 +3,9 @@
#ifndef _CL_V_H
#define _CL_V_H
#include "cl_object.h"
#include "cln/object.h"
namespace cln {
struct cl_V_any : public cl_gcpointer {
// Constructors.
@ -16,4 +18,6 @@ struct cl_V_any : public cl_gcpointer {
CL_DEFINE_COPY_CONSTRUCTOR2(cl_V_any,cl_gcpointer)
CL_DEFINE_ASSIGNMENT_OPERATOR(cl_V_any,cl_V_any)
} // namespace cln
#endif /* _CL_V_H */

4
include/cl_abort.h → include/cln/abort.h

@ -3,10 +3,14 @@
#ifndef _CL_ABORT_H
#define _CL_ABORT_H
namespace cln {
#ifdef _CL_MACROS_H
nonreturning_function(extern, cl_abort, (void));
#else
extern void cl_abort (void);
#endif
} // namespace cln
#endif /* _CL_ABORT_H */

141
include/cln/cln.h

@ -0,0 +1,141 @@
// CLN exported types and functions
#ifndef _CLN_H
#define _CLN_H
// Automatically generated by configure
//#include "cln/config.h" // included by "cln/types.h" below
//#include "cln/intparam.h" // included by "cln/types.h" below
//#include "cln/floatparam.h" // not needed by any public header file
// ============================== base ==============================
// Basic types and definitions.
#include "cln/types.h"
#include "cln/modules.h"
#include "cln/object.h"
// Miscellaneous.
#include "cln/random.h"
#include "cln/malloc.h"
#include "cln/abort.h"
#include "cln/floatformat.h"
#include "cln/io.h"
#include "cln/condition.h"
// Symbolic facilities.
#include "cln/string.h"
#include "cln/symbol.h"
#include "cln/proplist.h"
// Miscellaneous.
#include "cln/input.h"
#include "cln/output.h"
// Abstract number classes.
#include "cln/number.h"
#include "cln/number_io.h"
#include "cln/complex_class.h"
#include "cln/real_class.h"
#include "cln/rational_class.h"
// Rings.
#include "cln/ring.h"
// ============================== integer ==============================
// Integers.
#include "cln/integer_class.h"
#include "cln/integer.h"
#include "cln/integer_io.h"
#include "cln/integer_ring.h"
#include "cln/null_ring.h"
// ============================== rational ==============================
// Rational numbers.
#include "cln/rational.h"
#include "cln/rational_io.h"
#include "cln/rational_ring.h"
// ============================== float ==============================
// Floating-point numbers.
#include "cln/float_class.h"
#include "cln/sfloat_class.h"
#include "cln/ffloat_class.h"
#include "cln/dfloat_class.h"
#include "cln/lfloat_class.h"
#include "cln/float.h"
#include "cln/float_io.h"
#include "cln/sfloat.h"
#include "cln/sfloat_io.h"
#include "cln/ffloat.h"
#include "cln/ffloat_io.h"
#include "cln/dfloat.h"
#include "cln/dfloat_io.h"
#include "cln/lfloat.h"
#include "cln/lfloat_io.h"
// ============================== real ==============================
// Real numbers.
#include "cln/real.h"
#include "cln/real_io.h"
#include "cln/real_ring.h"
// ============================== complex ==============================
// Complex numbers.
#include "cln/complex.h"
#include "cln/complex_io.h"
#include "cln/complex_ring.h"
// ============================== modinteger ==============================
// Modular integers.
#include "cln/modinteger.h"
// ============================== numtheory ==============================
// Rings for number theory.
#include "cln/numtheory.h"
// ============================== vector ==============================
// Vectors.
#include "cln/V.h"
#include "cln/GV.h"
#include "cln/GV_number.h"
#include "cln/GV_complex.h"
#include "cln/GV_real.h"
#include "cln/GV_rational.h"
#include "cln/GV_integer.h"
#include "cln/GV_modinteger.h"
#include "cln/SV.h"
#include "cln/SV_number.h"
#include "cln/SV_complex.h"
#include "cln/SV_real.h"
#include "cln/SV_rational.h"
#include "cln/SV_integer.h"
#include "cln/SV_ringelt.h"
// ============================== polynomial ==============================
// Polynomials.
#include "cln/univpoly.h"
#include "cln/univpoly_complex.h"
#include "cln/univpoly_real.h"
#include "cln/univpoly_rational.h"
#include "cln/univpoly_integer.h"
#include "cln/univpoly_modint.h"
// ============================== modpolynomial ==============================
// ============================== timing ==============================
// Environmental facilities.
#include "cln/timing.h"
#endif /* _CLN_H */

22
include/cl_complex.h → include/cln/complex.h

@ -3,11 +3,12 @@
#ifndef _CL_COMPLEX_H
#define _CL_COMPLEX_H
#include "cl_number.h"
#include "cl_complex_class.h"
#include "cl_real_class.h"
#include "cl_integer_class.h"
#include "cln/number.h"
#include "cln/complex_class.h"
#include "cln/real_class.h"
#include "cln/integer_class.h"
namespace cln {
CL_DEFINE_AS_CONVERSION(cl_N)
@ -66,15 +67,15 @@ extern const cl_N signum (const cl_N& x);
// sqrt(x) = (sqrt x) zieht die Wurzel aus einer Zahl x.
extern const cl_N sqrt (const cl_N& x);
// cl_equal(x,y) vergleicht zwei Zahlen x und y auf Gleichheit.
extern cl_boolean cl_equal (const cl_N& x, const cl_N& y);
// cl_equal_hashcode(x) liefert einen cl_equal-invarianten Hashcode für x.
extern uint32 cl_equal_hashcode (const cl_N& x);
// equal(x,y) vergleicht zwei Zahlen x und y auf Gleichheit.
extern cl_boolean equal (const cl_N& x, const cl_N& y);
// equal_hashcode(x) liefert einen equal-invarianten Hashcode für x.
extern uint32 equal_hashcode (const cl_N& x);
inline bool operator== (const cl_N& x, const cl_N& y)
{ return cl_equal(x,y); }
{ return equal(x,y); }
inline bool operator!= (const cl_N& x, const cl_N& y)
{ return !cl_equal(x,y); }
{ return !equal(x,y); }
// phase(x) liefert (phase x), wo x eine Zahl ist.
// Ergebnis rational nur wenn (= x 0) oder wenn x reell und >0.
@ -153,5 +154,6 @@ inline cl_N& operator/= (cl_N& x, const cl_N& y) { return x = x / y; }
// Runtime typing support.
extern cl_class cl_class_complex;
} // namespace cln
#endif /* _CL_COMPLEX_H */

8
include/cl_complex_class.h → include/cln/complex_class.h

@ -3,8 +3,9 @@
#ifndef _CL_COMPLEX_CLASS_H
#define _CL_COMPLEX_CLASS_H
#include "cl_number.h"
#include "cln/number.h"
namespace cln {
class cl_N : public cl_number {
public:
@ -34,9 +35,9 @@ public:
cl_N (cl_private_thing);
cl_N (struct cl_heap_complex *);
public: // Ability to place an object at a given address.
void* operator new (size_t size) { return cl_malloc_hook(size); }
void* operator new (size_t size) { return malloc_hook(size); }
void* operator new (size_t size, cl_N* ptr) { (void)size; return ptr; }
void operator delete (void* ptr) { cl_free_hook(ptr); }
void operator delete (void* ptr) { free_hook(ptr); }
private:
// Friend declarations. They are for the compiler. Just ignore them.
};
@ -59,5 +60,6 @@ CL_DEFINE_LONG_ASSIGNMENT_OPERATORS(cl_N)
CL_DEFINE_FLOAT_CONSTRUCTOR(cl_N)
CL_DEFINE_DOUBLE_CONSTRUCTOR(cl_N)
} // namespace cln
#endif /* _CL_COMPLEX_CLASS_H */

10
include/cl_complex_io.h → include/cln/complex_io.h

@ -3,9 +3,10 @@
#ifndef _CL_COMPLEX_IO_H
#define _CL_COMPLEX_IO_H
#include "cl_number_io.h"
#include "cl_complex.h"
#include "cln/number_io.h"
#include "cln/complex.h"
namespace cln {
// Undocumented input functions
@ -36,11 +37,12 @@ extern void print_complex (cl_ostream stream, const cl_print_number_flags& flags
inline void fprint (cl_ostream stream, const cl_N& x)
{
extern cl_print_flags cl_default_print_flags;
print_complex(stream,cl_default_print_flags,x);
extern cl_print_flags default_print_flags;
print_complex(stream,default_print_flags,x);
}
CL_DEFINE_PRINT_OPERATOR(cl_N)
} // namespace cln
#endif /* _CL_COMPLEX_IO_H */

8
include/cl_complex_ring.h → include/cln/complex_ring.h

@ -3,12 +3,16 @@
#ifndef _CL_COMPLEX_RING_H
#define _CL_COMPLEX_RING_H
#include "cl_ring.h"
#include "cl_complex_class.h"
#include "cln/ring.h"
#include "cln/complex_class.h"
namespace cln {
typedef cl_specialized_number_ring<cl_N> cl_complex_ring;
extern const cl_complex_ring cl_C_ring; // math. C
extern cl_class cl_class_complex_ring;
//CL_REQUIRE(cl_C_ring)
} // namespace cln
#endif /* _CL_COMPLEX_RING_H */

23
include/cl_condition.h → include/cln/condition.h

@ -3,38 +3,37 @@
#ifndef _CL_CONDITION_H
#define _CL_CONDITION_H
#include "cl_malloc.h"
#include "cl_io.h"
#include "cln/malloc.h"
#include "cln/io.h"
namespace cln {
struct cl_condition {
// Allocation.
void* operator new (size_t size) { return cl_malloc_hook(size); }
void* operator new (size_t size) { return malloc_hook(size); }
// Deallocation.
void operator delete (void* ptr) { cl_free_hook(ptr); }
void operator delete (void* ptr) { free_hook(ptr); }
// Name.
virtual const char * name () const = 0;
// Print.
virtual void print (cl_ostream) const = 0;
// Virtual destructor.
virtual ~cl_condition ()
#if defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ < 8) // workaround gcc bug
{}
#else
= 0;
#endif
virtual ~cl_condition () = 0;
private:
virtual void dummy ();
};
#define SUBCLASS_cl_condition() \
public: \
/* Allocation. */ \
void* operator new (size_t size) { return cl_malloc_hook(size); } \
void* operator new (size_t size) { return malloc_hook(size); } \
/* Deallocation. */ \
void operator delete (void* ptr) { cl_free_hook(ptr); }
void operator delete (void* ptr) { free_hook(ptr); }
// Functions which want to raise a condition return a `cl_condition*'.
// The caller checks this value. NULL means no condition. The one who
// disposes the condition (handles it without resignalling it) should
// call `delete' on the condition pointer.
} // namespace cln
#endif /* _CL_CONDITION_H */

42
include/cl_dfloat.h → include/cln/dfloat.h

@ -3,11 +3,12 @@
#ifndef _CL_DFLOAT_H
#define _CL_DFLOAT_H
#include "cl_number.h"
#include "cl_dfloat_class.h"
#include "cl_integer_class.h"
#include "cl_float.h"
#include "cln/number.h"
#include "cln/dfloat_class.h"
#include "cln/integer_class.h"
#include "cln/float.h"
namespace cln {
CL_DEFINE_AS_CONVERSION(cl_DF)
@ -15,25 +16,25 @@ CL_DEFINE_AS_CONVERSION(cl_DF)
// Liefert zu einem Double-Float x : (- x), ein DF.
extern const cl_DF operator- (const cl_DF& x);
// cl_compare(x,y) vergleicht zwei Double-Floats x und y.
// compare(x,y) vergleicht zwei Double-Floats x und y.
// Ergebnis: 0 falls x=y, +1 falls x>y, -1 falls x<y.
extern cl_signean cl_compare (const cl_DF& x, const cl_DF& y);
extern cl_signean compare (const cl_DF& x, const cl_DF& y);
// cl_equal_hashcode(x) liefert einen cl_equal-invarianten Hashcode für x.
extern uint32 cl_equal_hashcode (const cl_DF& x);
// equal_hashcode(x) liefert einen equal-invarianten Hashcode für x.
extern uint32 equal_hashcode (const cl_DF& x);
inline bool operator== (const cl_DF& x, const cl_DF& y)
{ return cl_compare(x,y)==0; }
{ return compare(x,y)==0; }
inline bool operator!= (const cl_DF& x, const cl_DF& y)
{ return cl_compare(x,y)!=0; }
{ return compare(x,y)!=0; }
inline bool operator<= (const cl_DF& x, const cl_DF& y)
{ return cl_compare(x,y)<=0; }
{ return compare(x,y)<=0; }
inline bool operator< (const cl_DF& x, const cl_DF& y)
{ return cl_compare(x,y)<0; }
{ return compare(x,y)<0; }
inline bool operator>= (const cl_DF& x, const cl_DF& y)
{ return cl_compare(x,y)>=0; }
{ return compare(x,y)>=0; }
inline bool operator> (const cl_DF& x, const cl_DF& y)
{ return cl_compare(x,y)>0; }
{ return compare(x,y)>0; }
// minusp(x) == (< x 0)
extern cl_boolean minusp (const cl_DF& x);
@ -204,19 +205,19 @@ inline const cl_I round1 (const cl_DF& x, const cl_DF& y) { return round1(x/y);
// Return type for decode_float:
struct cl_decoded_dfloat {
struct decoded_dfloat {
cl_DF mantissa;
cl_I exponent;
cl_DF sign;
// Constructor.
cl_decoded_dfloat () {}
cl_decoded_dfloat (const cl_DF& m, const cl_I& e, const cl_DF& s) : mantissa(m), exponent(e), sign(s) {}
decoded_dfloat () {}
decoded_dfloat (const cl_DF& m, const cl_I& e, const cl_DF& s) : mantissa(m), exponent(e), sign(s) {}
};
// decode_float(x) liefert zu einem Float x: (decode-float x).
// x = 0.0 liefert (0.0, 0, 1.0).
// x = (-1)^s * 2^e * m liefert ((-1)^0 * 2^0 * m, e als Integer, (-1)^s).
extern const cl_decoded_dfloat decode_float (const cl_DF& x);
extern const decoded_dfloat decode_float (const cl_DF& x);
// float_exponent(x) liefert zu einem Float x:
// den Exponenten von (decode-float x).
@ -266,10 +267,10 @@ extern const cl_DF signum (const cl_DF& x);
// Konversion zu einem C "float".
extern float cl_float_approx (const cl_DF& x);
extern float float_approx (const cl_DF& x);
// Konversion zu einem C "double".
extern double cl_double_approx (const cl_DF& x);
extern double double_approx (const cl_DF& x);
#ifdef WANT_OBFUSCATING_OPERATORS
@ -301,5 +302,6 @@ static void* const cl_DF_debug_dummy[] = { &cl_DF_debug_dummy,
};
#endif
} // namespace cln
#endif /* _CL_DFLOAT_H */

10
include/cl_dfloat_class.h → include/cln/dfloat_class.h

@ -3,9 +3,10 @@
#ifndef _CL_DFLOAT_CLASS_H
#define _CL_DFLOAT_CLASS_H
#include "cl_number.h"
#include "cl_float_class.h"
#include "cln/number.h"
#include "cln/float_class.h"
namespace cln {
class cl_DF : public cl_F {
public:
@ -29,9 +30,9 @@ public:
// Private pointer manipulations.
operator struct cl_heap_dfloat * () const;
public: // Ability to place an object at a given address.
void* operator new (size_t size) { return cl_malloc_hook(size); }
void* operator new (size_t size) { return malloc_hook(size); }
void* operator new (size_t size, cl_DF* ptr) { (void)size; return ptr; }
void operator delete (void* ptr) { cl_free_hook(ptr); }
void operator delete (void* ptr) { free_hook(ptr); }
private:
// Friend declarations. They are for the compiler. Just ignore them.
};
@ -61,5 +62,6 @@ CL_DEFINE_COPY_CONSTRUCTOR2(cl_DF,cl_F)
// Constructors and assignment operators from C numeric types.
CL_DEFINE_DOUBLE_CONSTRUCTOR(cl_DF)
} // namespace cln
#endif /* _CL_DFLOAT_CLASS_H */

14
include/cl_dfloat_io.h → include/cln/dfloat_io.h

@ -3,8 +3,10 @@
#ifndef _CL_DFLOAT_IO_H
#define _CL_DFLOAT_IO_H
#include "cl_number_io.h"
#include "cl_dfloat.h"
#include "cln/number_io.h"
#include "cln/dfloat.h"
namespace cln {
inline cl_istream operator>> (cl_istream stream, cl_DF& result)
{
@ -15,13 +17,15 @@ inline cl_istream operator>> (cl_istream stream, cl_DF& result)
}
// The following does strictly the same as the general `fprint' for floats.
// It is here only so that people don't need to include <cl_float_io.h>.
// It is here only so that people don't need to include <cln/float_io.h>.
inline void fprint (cl_ostream stream, const cl_DF& x)
{
extern void print_float (cl_ostream stream, const cl_print_flags& flags, const cl_F& z);
extern cl_print_flags cl_default_print_flags;
print_float(stream,cl_default_print_flags,x);
extern cl_print_flags default_print_flags;
print_float(stream,default_print_flags,x);
}
CL_DEFINE_PRINT_OPERATOR(cl_DF)
} // namespace cln
#endif /* _CL_DFLOAT_IO_H */

42
include/cl_ffloat.h → include/cln/ffloat.h

@ -3,11 +3,12 @@
#ifndef _CL_FFLOAT_H
#define _CL_FFLOAT_H
#include "cl_number.h"
#include "cl_ffloat_class.h"
#include "cl_integer_class.h"
#include "cl_float.h"
#include "cln/number.h"
#include "cln/ffloat_class.h"
#include "cln/integer_class.h"
#include "cln/float.h"
namespace cln {
CL_DEFINE_AS_CONVERSION(cl_FF)
@ -15,25 +16,25 @@ CL_DEFINE_AS_CONVERSION(cl_FF)
// Liefert zu einem Single-Float x : (- x), ein FF.
extern const cl_FF operator- (const cl_FF& x);
// cl_compare(x,y) vergleicht zwei Single-Floats x und y.
// compare(x,y) vergleicht zwei Single-Floats x und y.
// Ergebnis: 0 falls x=y, +1 falls x>y, -1 falls x<y.
extern cl_signean cl_compare (const cl_FF& x, const cl_FF& y);
extern cl_signean compare (const cl_FF& x, const cl_FF& y);
// cl_equal_hashcode(x) liefert einen cl_equal-invarianten Hashcode für x.
extern uint32 cl_equal_hashcode (const cl_FF& x);
// equal_hashcode(x) liefert einen equal-invarianten Hashcode für x.
extern uint32 equal_hashcode (const cl_FF& x);
inline bool operator== (const cl_FF& x, const cl_FF& y)
{ return cl_compare(x,y)==0; }
{ return compare(x,y)==0; }
inline bool operator!= (const cl_FF& x, const cl_FF& y)
{ return cl_compare(x,y)!=0; }
{ return compare(x,y)!=0; }
inline bool operator<= (const cl_FF& x, const cl_FF& y)
{ return cl_compare(x,y)<=0; }
{ return compare(x,y)<=0; }
inline bool operator< (const cl_FF& x, const cl_FF& y)
{ return cl_compare(x,y)<0; }
{ return compare(x,y)<0; }
inline bool operator>= (const cl_FF& x, const cl_FF& y)
{ return cl_compare(x,y)>=0; }
{ return compare(x,y)>=0; }
inline bool operator> (const cl_FF& x, const cl_FF& y)
{ return cl_compare(x,y)>0; }
{ return compare(x,y)>0; }
// minusp(x) == (< x 0)
extern cl_boolean minusp (const cl_FF& x);
@ -204,19 +205,19 @@ inline const cl_I round1 (const cl_FF& x, const cl_FF& y) { return round1(x/y);
// Return type for decode_float:
struct cl_decoded_ffloat {
struct decoded_ffloat {
cl_FF mantissa;
cl_I exponent;
cl_FF sign;
// Constructor.
cl_decoded_ffloat () {}
cl_decoded_ffloat (const cl_FF& m, const cl_I& e, const cl_FF& s) : mantissa(m), exponent(e), sign(s) {}
decoded_ffloat () {}
decoded_ffloat (const cl_FF& m, const cl_I& e, const cl_FF& s) : mantissa(m), exponent(e), sign(s) {}
};
// decode_float(x) liefert zu einem Float x: (decode-float x).
// x = 0.0 liefert (0.0, 0, 1.0).
// x = (-1)^s * 2^e * m liefert ((-1)^0 * 2^0 * m, e als Integer, (-1)^s).
extern const cl_decoded_ffloat decode_float (const cl_FF& x);
extern const decoded_ffloat decode_float (const cl_FF& x);
// float_exponent(x) liefert zu einem Float x:
// den Exponenten von (decode-float x).
@ -266,10 +267,10 @@ extern const cl_FF signum (const cl_FF& x);
// Konversion zu einem C "float".
extern float cl_float_approx (const cl_FF& x);
extern float float_approx (const cl_FF& x);
// Konversion zu einem C "double".
extern double cl_double_approx (const cl_FF& x);
extern double double_approx (const cl_FF& x);
#ifdef WANT_OBFUSCATING_OPERATORS
@ -306,5 +307,6 @@ static void* const cl_FF_debug_dummy[] = { &cl_FF_debug_dummy,
};
#endif
} // namespace cln
#endif /* _CL_FFLOAT_H */

10
include/cl_ffloat_class.h → include/cln/ffloat_class.h

@ -3,9 +3,10 @@
#ifndef _CL_FFLOAT_CLASS_H
#define _CL_FFLOAT_CLASS_H
#include "cl_number.h"
#include "cl_float_class.h"
#include "cln/number.h"
#include "cln/float_class.h"
namespace cln {
class cl_FF : public cl_F {
public:
@ -37,9 +38,9 @@ public:
operator struct cl_heap_ffloat * () const;
#endif
public: // Ability to place an object at a given address.
void* operator new (size_t size) { return cl_malloc_hook(size); }
void* operator new (size_t size) { return malloc_hook(size); }
void* operator new (size_t size, cl_FF* ptr) { (void)size; return ptr; }
void operator delete (void* ptr) { cl_free_hook(ptr); }
void operator delete (void* ptr) { free_hook(ptr); }
};
// Private constructors.
@ -72,5 +73,6 @@ CL_DEFINE_COPY_CONSTRUCTOR2(cl_FF,cl_F)
// Constructors and assignment operators from C numeric types.
CL_DEFINE_FLOAT_CONSTRUCTOR(cl_FF)
} // namespace cln
#endif /* _CL_FFLOAT_CLASS_H */

14
include/cl_ffloat_io.h → include/cln/ffloat_io.h

@ -3,8 +3,10 @@
#ifndef _CL_FFLOAT_IO_H
#define _CL_FFLOAT_IO_H
#include "cl_number_io.h"
#include "cl_ffloat.h"
#include "cln/number_io.h"
#include "cln/ffloat.h"
namespace cln {
inline cl_istream operator>> (cl_istream stream, cl_FF& result)
{
@ -15,13 +17,15 @@ inline cl_istream operator>> (cl_istream stream, cl_FF& result)
}
// The following does strictly the same as the general `fprint' for floats.
// It is here only so that people don't need to include <cl_float_io.h>.
// It is here only so that people don't need to include <cln/float_io.h>.
inline void fprint (cl_ostream stream, const cl_FF& x)
{
extern void print_float (cl_ostream stream, const cl_print_flags& flags, const cl_F& z);
extern cl_print_flags cl_default_print_flags;
print_float(stream,cl_default_print_flags,x);
extern cl_print_flags default_print_flags;
print_float(stream,default_print_flags,x);
}
CL_DEFINE_PRINT_OPERATOR(cl_FF)
} // namespace cln
#endif /* _CL_FFLOAT_IO_H */

172
include/cl_float.h → include/cln/float.h

@ -3,16 +3,17 @@
#ifndef _CL_FLOAT_H
#define _CL_FLOAT_H
#include "cl_number.h"
#include "cl_float_class.h"
#include "cl_floatformat.h"
#include "cl_random.h"
#include "cl_integer_class.h"
#include "cl_sfloat_class.h"
#include "cl_ffloat_class.h"
#include "cl_dfloat_class.h"
#include "cl_lfloat_class.h"
#include "cln/number.h"
#include "cln/float_class.h"
#include "cln/floatformat.h"
#include "cln/random.h"
#include "cln/integer_class.h"
#include "cln/sfloat_class.h"
#include "cln/ffloat_class.h"
#include "cln/dfloat_class.h"
#include "cln/lfloat_class.h"
namespace cln {
CL_DEFINE_AS_CONVERSION(cl_F)
@ -54,11 +55,11 @@ extern const cl_LF cl_F_to_LF (const cl_F& x, uintC len);
// The default float format used when converting rational numbers to floats.
extern cl_float_format_t cl_default_float_format;
extern float_format_t default_float_format;
// Returns the smallest float format which guarantees at least n decimal digits
// in the mantissa (after the decimal point).
extern cl_float_format_t cl_float_format (uintL n);
extern float_format_t float_format (uintL n);
// cl_float(x,y) wandelt ein Float x in das Float-Format des Floats y um
// und rundet dabei nötigenfalls.
@ -71,13 +72,13 @@ extern const cl_F cl_float (const cl_F& x, const cl_F& y);
// > x: ein Float
// > f: eine Float-Format-Spezifikation
// < ergebnis: (float x f)
extern const cl_F cl_float (const cl_F& x, cl_float_format_t f);
extern const cl_F cl_float (const cl_F& x, float_format_t f);
// cl_float(x) wandelt eine reelle Zahl x in ein Float um
// und rundet dabei nötigenfalls.
// > x: eine reelle Zahl
// < ergebnis: (float x)
// Abhängig von cl_default_float_format.
// Abhängig von default_float_format.
inline const cl_F cl_float (const cl_F& x) { return x; }
// cl_float(x,y) wandelt ein Integer x in das Float-Format des Floats y um
@ -92,12 +93,12 @@ extern const cl_F cl_float (const cl_I& x, const cl_F& y);
// > x: ein Integer
// > f: eine Float-Format-Spezifikation
// < ergebnis: (float x f)
extern const cl_F cl_float (const cl_I& x, cl_float_format_t f);
extern const cl_F cl_float (const cl_I& x, float_format_t f);
// cl_float(x) wandelt ein Integer x in ein Float um und rundet dabei.
// > x: ein Integer
// < ergebnis: (float x)
// Abhängig von cl_default_float_format.
// Abhängig von default_float_format.
extern const cl_F cl_float (const cl_I& x);
// cl_float(x,y) wandelt eine rationale Zahl x in das Float-Format des
@ -112,12 +113,12 @@ extern const cl_F cl_float (const cl_RA& x, const cl_F& y);
// > x: eine rationale Zahl
// > f: eine Float-Format-Spezifikation
// < ergebnis: (float x f)
extern const cl_F cl_float (const cl_RA& x, cl_float_format_t f);
extern const cl_F cl_float (const cl_RA& x, float_format_t f);
// cl_float(x) wandelt eine rationale Zahl x in ein Float um und rundet dabei.
// > x: eine rationale Zahl
// < ergebnis: (float x)
// Abhängig von cl_default_float_format.
// Abhängig von default_float_format.
extern const cl_F cl_float (const cl_RA& x);
// The C++ compilers are not clever enough to guess this:
@ -125,9 +126,9 @@ inline const cl_F cl_float (int x, const cl_F& y)
{ return cl_float(cl_I(x),y); }
inline const cl_F cl_float (unsigned int x, const cl_F& y)
{ return cl_float(cl_I(x),y); }
inline const cl_F cl_float (int x, cl_float_format_t y)
inline const cl_F cl_float (int x, float_format_t y)
{ return cl_float(cl_I(x),y); }
inline const cl_F cl_float (unsigned int x, cl_float_format_t y)
inline const cl_F cl_float (unsigned int x, float_format_t y)
{ return cl_float(cl_I(x),y); }
inline const cl_F cl_float (int x)
{ return cl_float(cl_I(x)); }
@ -138,9 +139,9 @@ inline const cl_F cl_float (float x, const cl_F& y)
{ return cl_float(cl_FF(x),y); }
inline const cl_F cl_float (double x, const cl_F& y)
{ return cl_float(cl_DF(x),y); }
inline const cl_F cl_float (float x, cl_float_format_t y)
inline const cl_F cl_float (float x, float_format_t y)
{ return cl_float(cl_FF(x),y); }
inline const cl_F cl_float (double x, cl_float_format_t y)
inline const cl_F cl_float (double x, float_format_t y)
{ return cl_float(cl_DF(x),y); }
inline const cl_F cl_float (float x)
{ return cl_float(cl_FF(x)); }
@ -299,25 +300,25 @@ inline const cl_F minus1 (const cl_F& x) // { return x + cl_I(-1); }
return x + cl_float(-1,x);
}
// cl_compare(x,y) vergleicht zwei Floats x und y.
// compare(x,y) vergleicht zwei Floats x und y.
// Ergebnis: 0 falls x=y, +1 falls x>y, -1 falls x<y.
extern cl_signean cl_compare (const cl_F& x, const cl_F& y);
extern cl_signean compare (const cl_F& x, const cl_F& y);
// cl_equal_hashcode(x) liefert einen cl_equal-invarianten Hashcode für x.
extern uint32 cl_equal_hashcode (const cl_F& x);
// equal_hashcode(x) liefert einen equal-invarianten Hashcode für x.
extern uint32 equal_hashcode (const cl_F& x);
inline bool operator== (const cl_F& x, const cl_F& y)
{ return cl_compare(x,y)==0; }
{ return compare(x,y)==0; }
inline bool operator!= (const cl_F& x, const cl_F& y)
{ return cl_compare(x,y)!=0; }
{ return compare(x,y)!=0; }
inline bool operator<= (const cl_F& x, const cl_F& y)
{ return cl_compare(x,y)<=0; }
{ return compare(x,y)<=0; }
inline bool operator< (const cl_F& x, const cl_F& y)
{ return cl_compare(x,y)<0; }
{ return compare(x,y)<0; }
inline bool operator>= (const cl_F& x, const cl_F& y)
{ return cl_compare(x,y)>=0; }
{ return compare(x,y)>=0; }
inline bool operator> (const cl_F& x, const cl_F& y)
{ return cl_compare(x,y)>0; }
{ return compare(x,y)>0; }
// ffloor(x) liefert (ffloor x), wo x ein Float ist.
@ -400,19 +401,19 @@ inline const cl_I round1 (const cl_F& x, const cl_F& y) { return round1(x/y); }
// Return type for decode_float:
struct cl_decoded_float {
struct decoded_float {
cl_F mantissa;
cl_I exponent;
cl_F sign;
// Constructor.
cl_decoded_float () {}
cl_decoded_float (const cl_F& m, const cl_I& e, const cl_F& s) : mantissa(m), exponent(e), sign(s) {}
decoded_float () {}
decoded_float (const cl_F& m, const cl_I& e, const cl_F& s) : mantissa(m), exponent(e), sign(s) {}
};
// decode_float(x) liefert zu einem Float x: (decode-float x).
// x = 0.0 liefert (0.0, 0, 1.0).
// x = (-1)^s * 2^e * m liefert ((-1)^0 * 2^0 * m, e als Integer, (-1)^s).
extern const cl_decoded_float decode_float (const cl_F& x);
extern const decoded_float decode_float (const cl_F& x);
// float_exponent(x) liefert zu einem Float x:
// den Exponenten von (decode-float x).
@ -442,8 +443,8 @@ extern uintL float_digits (const cl_F& x);
extern uintL float_precision (const cl_F& x);
// Returns the floating point format of a float.
inline cl_float_format_t cl_float_format (const cl_F& x)
{ return (cl_float_format_t) float_digits(x); }
inline float_format_t float_format (const cl_F& x)
{ return (float_format_t) float_digits(x); }
// integer_decode_float(x) liefert zu einem Float x: (integer-decode-float x).
@ -473,52 +474,52 @@ extern const cl_F signum (const cl_F& x);
// Returns the largest (most positive) floating point number in float format f.
extern const cl_F most_positive_float (cl_float_format_t f);
extern const cl_F most_positive_float (float_format_t f);
//CL_REQUIRE(cl_F_mostpos)
// Returns the smallest (most negative) floating point number in float format f.
extern const cl_F most_negative_float (cl_float_format_t f);
extern const cl_F most_negative_float (float_format_t f);
//CL_REQUIRE(cl_F_mostneg)
// Returns the least positive floating point number (i.e. > 0 but closest to 0)
// in float format f.
extern const cl_F least_positive_float (cl_float_format_t f);
extern const cl_F least_positive_float (float_format_t f);
//CL_REQUIRE(cl_F_leastpos)
// Returns the least negative floating point number (i.e. < 0 but closest to 0)
// in float format f.
extern const cl_F least_negative_float (cl_float_format_t f);
extern const cl_F least_negative_float (float_format_t f);
//CL_REQUIRE(cl_F_leastneg)
// Returns the smallest floating point number e > 0 such that 1+e != 1.
extern const cl_F float_epsilon (cl_float_format_t f);
extern const cl_F float_epsilon (float_format_t f);
//CL_REQUIRE(cl_F_epspos)
// Returns the smallest floating point number e > 0 such that 1-e != 1.
extern const cl_F float_negative_epsilon (cl_float_format_t f);
extern const cl_F float_negative_epsilon (float_format_t f);
//CL_REQUIRE(cl_F_epsneg)
// Konversion zu einem C "float".
extern float cl_float_approx (const cl_F& x);
extern float float_approx (const cl_F& x);
// Konversion zu einem C "double".
extern double cl_double_approx (const cl_F& x);
extern double double_approx (const cl_F& x);
// Transcendental functions
// cl_pi(y) liefert die Zahl pi im selben Float-Format wie y.
// pi(y) liefert die Zahl pi im selben Float-Format wie y.
// > y: ein Float
extern const cl_F cl_pi (const cl_F& y);
extern const cl_F pi (const cl_F& y);
// cl_pi(y) liefert die Zahl pi im Float-Format f.
// pi(y) liefert die Zahl pi im Float-Format f.
// > f: eine Float-Format-Spezifikation
extern const cl_F cl_pi (cl_float_format_t f);
extern const cl_F pi (float_format_t f);
// cl_pi() liefert die Zahl pi im Default-Float-Format.
extern const cl_F cl_pi (void);
// pi() liefert die Zahl pi im Default-Float-Format.
extern const cl_F pi (void);
//CL_REQUIRE(cl_F_pi_var)
@ -529,31 +530,31 @@ extern const cl_F sin (const cl_F& x);
// cos(x) liefert den Cosinus (cos x) eines Float x.
extern const cl_F cos (const cl_F& x);
// Return type for cl_cos_sin():
struct cl_cos_sin_t {
// Return type for cos_sin():
struct cos_sin_t {
cl_R cos;
cl_R sin;
// Constructor:
cl_cos_sin_t (const cl_R& u, const cl_R& v) : cos (u), sin (v) {}
cos_sin_t (const cl_R& u, const cl_R& v) : cos (u), sin (v) {}
};
// cl_cos_sin(x) liefert ((cos x),(sin x)), beide Werte.
extern const cl_cos_sin_t cl_cos_sin (const cl_F& x);
// cos_sin(x) liefert ((cos x),(sin x)), beide Werte.
extern const cos_sin_t cos_sin (const cl_F& x);
// tan(x) liefert den Tangens (tan x) eines Float x.
extern const cl_F tan (const cl_F& x);
// cl_exp1(y) liefert die Zahl e = exp(1) im selben Float-Format wie y.
// exp1(y) liefert die Zahl e = exp(1) im selben Float-Format wie y.
// > y: ein Float
extern const cl_F cl_exp1 (const cl_F& y);
extern const cl_F exp1 (const cl_F& y);
// cl_exp1(y) liefert die Zahl e = exp(1) im Float-Format f.
// exp1(y) liefert die Zahl e = exp(1) im Float-Format f.
// > f: eine Float-Format-Spezifikation
extern const cl_F cl_exp1 (cl_float_format_t f);
extern const cl_F exp1 (float_format_t f);
// cl_exp1() liefert die Zahl e = exp(1) im Default-Float-Format.
extern const cl_F cl_exp1 (void);
// exp1() liefert die Zahl e = exp(1) im Default-Float-Format.
extern const cl_F exp1 (void);
//CL_REQUIRE(cl_F_exp1_var)
@ -572,64 +573,64 @@ extern const cl_F sinh (const cl_F& x);
// cosh(x) liefert zu einem Float x die Zahl cosh(x).
extern const cl_F cosh (const cl_F& x);
// Return type for cl_cosh_sinh():
struct cl_cosh_sinh_t {
// Return type for cosh_sinh():
struct cosh_sinh_t {
cl_R cosh;
cl_R sinh;
// Constructor:
cl_cosh_sinh_t (const cl_R& u, const cl_R& v) : cosh (u), sinh (v) {}
cosh_sinh_t (const cl_R& u, const cl_R& v) : cosh (u), sinh (v) {}
};
// cl_cosh_sinh(x) liefert ((cosh x),(sinh x)), beide Werte.
extern const cl_cosh_sinh_t cl_cosh_sinh (const cl_F& x);
// cosh_sinh(x) liefert ((cosh x),(sinh x)), beide Werte.
extern const cosh_sinh_t cosh_sinh (const cl_F& x);
// tanh(x) liefert zu einem Float x die Zahl tanh(x).
extern const cl_F tanh (const cl_F& x);
// cl_eulerconst(y) liefert die Eulersche Konstante
// eulerconst(y) liefert die Eulersche Konstante
// im selben Float-Format wie y.
// > y: ein Float
extern const cl_F cl_eulerconst (const cl_F& y);
extern const cl_F eulerconst (const cl_F& y);
// cl_eulerconst(y) liefert die Eulersche Konstante im Float-Format f.
// eulerconst(y) liefert die Eulersche Konstante im Float-Format f.
// > f: eine Float-Format-Spezifikation
extern const cl_F cl_eulerconst (cl_float_format_t f);
extern const cl_F eulerconst (float_format_t f);
// cl_eulerconst() liefert die Eulersche Konstante im Default-Float-Format.
extern const cl_F cl_eulerconst (void);
// eulerconst() liefert die Eulersche Konstante im Default-Float-Format.
extern const cl_F eulerconst (void);
//CL_REQUIRE(cl_F_eulerconst_var)
// cl_catalanconst(y) liefert die Catalansche Konstante
// catalanconst(y) liefert die Catalansche Konstante
// im selben Float-Format wie y.
// > y: ein Float
extern const cl_F cl_catalanconst (const cl_F& y);
extern const cl_F catalanconst (const cl_F& y);
// cl_catalanconst(y) liefert die Catalansche Konstante im Float-Format f.
// catalanconst(y) liefert die Catalansche Konstante im Float-Format f.
// > f: eine Float-Format-Spezifikation
extern const cl_F cl_catalanconst (cl_float_format_t f);
extern const cl_F catalanconst (float_format_t f);
// cl_catalanconst() liefert die Catalansche Konstante im Default-Float-Format.
extern const cl_F cl_catalanconst (void);
// catalanconst() liefert die Catalansche Konstante im Default-Float-Format.
extern const cl_F catalanconst (void);
//CL_REQUIRE(cl_F_catalanconst_var)
// zeta(s) returns the Riemann zeta function at s>1.
extern const cl_F cl_zeta (int s, const cl_F& y);
extern const cl_F cl_zeta (int s, cl_float_format_t f);
extern const cl_F cl_zeta (int s);
extern const cl_F zeta (int s, const cl_F& y);
extern const cl_F zeta (int s, float_format_t f);
extern const cl_F zeta (int s);
// random_F(randomstate,n) liefert zu einem Float n>0 ein zufälliges
// Float x mit 0 <= x < n.
// > randomstate: ein Random-State, wird verändert
extern const cl_F random_F (cl_random_state& randomstate, const cl_F& n);
extern const cl_F random_F (random_state& randomstate, const cl_F& n);
inline const cl_F random_F (const cl_F& n)
{ return random_F(cl_default_random_state,n); }
{ return random_F(default_random_state,n); }
#ifdef WANT_OBFUSCATING_OPERATORS
@ -651,5 +652,6 @@ CL_REQUIRE(cl_ieee)
// If this is true, floating point underflow returns zero instead of an error.
extern cl_boolean cl_inhibit_floating_point_underflow;
} // namespace cln
#endif /* _CL_FLOAT_H */

10
include/cl_float_class.h → include/cln/float_class.h

@ -3,9 +3,10 @@
#ifndef _CL_FLOAT_CLASS_H
#define _CL_FLOAT_CLASS_H
#include "cl_number.h"
#include "cl_real_class.h"
#include "cln/number.h"
#include "cln/real_class.h"
namespace cln {
class cl_F : public cl_R {
public:
@ -26,9 +27,9 @@ public:
// Private constructor.
cl_F (cl_private_thing);
public: // Ability to place an object at a given address.
void* operator new (size_t size) { return cl_malloc_hook(size); }
void* operator new (size_t size) { return malloc_hook(size); }
void* operator new (size_t size, cl_F* ptr) { (void)size; return ptr; }
void operator delete (void* ptr) { cl_free_hook(ptr); }
void operator delete (void* ptr) { free_hook(ptr); }
private:
// Friend declarations. They are for the compiler. Just ignore them.
};
@ -46,5 +47,6 @@ CL_DEFINE_COPY_CONSTRUCTOR2(cl_F,cl_R)
CL_DEFINE_FLOAT_CONSTRUCTOR(cl_F)
CL_DEFINE_DOUBLE_CONSTRUCTOR(cl_F)
} // namespace cln
#endif /* _CL_FLOAT_CLASS_H */

12
include/cl_float_io.h → include/cln/float_io.h

@ -3,9 +3,10 @@
#ifndef _CL_FLOAT_IO_H
#define _CL_FLOAT_IO_H
#include "cl_number_io.h"
#include "cl_float.h"
#include "cln/number_io.h"
#include "cln/float.h"
namespace cln {
// Undocumented input functions
@ -24,7 +25,7 @@
// index4+1 = Index des Exponenten-Vorzeichens oder der ersten
// Exponenten-Ziffer)
// < ergebnis: Float
extern const cl_F read_float (unsigned int base, cl_float_format_t prec,
extern const cl_F read_float (unsigned int base, float_format_t prec,
cl_signean sign, const char * string, uintL index1, uintL index4, uintL index2, uintL index3);
// The following does strictly the same as the general read_complex.
@ -69,11 +70,12 @@ extern void print_float_binary (cl_ostream stream, const cl_F& z);
inline void fprint (cl_ostream stream, const cl_F& x)
{
extern cl_print_flags cl_default_print_flags;
print_float(stream,cl_default_print_flags,x);
extern cl_print_flags default_print_flags;
print_float(stream,default_print_flags,x);
}
CL_DEFINE_PRINT_OPERATOR(cl_F)
} // namespace cln
#endif /* _CL_FLOAT_IO_H */

20
include/cln/floatformat.h

@ -0,0 +1,20 @@
// Floating point format specifiers.
#ifndef _CL_FLOATFORMAT_H
#define _CL_FLOATFORMAT_H
#include "cln/types.h"
namespace cln {
// Float format specifier type. (Float mantissa precision in bits.)
typedef enum float_format_t {
float_format_sfloat = 17,
float_format_ffloat = 24,
float_format_dfloat = 53,
float_format_lfloat_min = ((53+intDsize-1)/intDsize)*intDsize // = round_up(53,intDsize)
};
} // namespace cln
#endif /* _CL_FLOATFORMAT_H */

14
include/cl_input.h → include/cln/input.h

@ -3,15 +3,17 @@
#ifndef _CL_INPUT_H
#define _CL_INPUT_H
#include "cl_types.h"
#include "cl_floatformat.h"
#include "cl_io.h"
#include "cln/types.h"
#include "cln/floatformat.h"
#include "cln/io.h"
namespace cln {
struct cl_read_float_flags {
// The float format used when reading floats with exponent marker 'E'.
cl_float_format_t default_float_format;
float_format_t default_float_format;
// The float format used when reading floats with exponent marker 'L'.
cl_float_format_t default_lfloat_format;
float_format_t default_lfloat_format;
// Flag whether floats specified with more digits than corresponding
// to the exponent marker they contain, but without _nnn suffix, will
// get a precision corresponding to their number of significant digits.
@ -54,4 +56,6 @@ struct cl_read_flags {
cl_read_float_flags float_flags;
};
} // namespace cln
#endif /* _CL_INPUT_H */

44
include/cl_integer.h → include/cln/integer.h

@ -3,10 +3,11 @@
#ifndef _CL_INTEGER_H
#define _CL_INTEGER_H
#include "cl_number.h"
#include "cl_integer_class.h"
#include "cl_random.h"
#include "cln/number.h"
#include "cln/integer_class.h"
#include "cln/random.h"
namespace cln {
CL_DEFINE_AS_CONVERSION(cl_I)
@ -238,27 +239,27 @@ inline const cl_I operator>> (const cl_I& x, const cl_I& y) // assume y >= 0
// Vergleich von Integers
// cl_equal(x,y) vergleicht zwei Integers x und y auf Gleichheit.
extern cl_boolean cl_equal (const cl_I& x, const cl_I& y);
// cl_equal_hashcode(x) liefert einen cl_equal-invarianten Hashcode für x.
extern uint32 cl_equal_hashcode (const cl_I& x);
// equal(x,y) vergleicht zwei Integers x und y auf Gleichheit.
extern cl_boolean equal (const cl_I& x, const cl_I& y);
// equal_hashcode(x) liefert einen equal-invarianten Hashcode für x.
extern uint32 equal_hashcode (const cl_I& x);
// cl_compare(x,y) vergleicht zwei Integers x und y.
// compare(x,y) vergleicht zwei Integers x und y.
// Ergebnis: 0 falls x=y, +1 falls x>y, -1 falls x<y.
extern cl_signean cl_compare (const cl_I& x, const cl_I& y);
extern cl_signean compare (const cl_I& x, const cl_I& y);
inline bool operator== (const cl_I& x, const cl_I& y)
{ return cl_equal(x,y); }
{ return equal(x,y); }
inline bool operator!= (const cl_I& x, const cl_I& y)
{ return !cl_equal(x,y); }
{ return !equal(x,y); }
inline bool operator<= (const cl_I& x, const cl_I& y)
{ return cl_compare(x,y)<=0; }
{ return compare(x,y)<=0; }
inline bool operator< (const cl_I& x, const cl_I& y)
{ return cl_compare(x,y)<0; }
{ return compare(x,y)<0; }
inline bool operator>= (const cl_I& x, const cl_I& y)
{ return cl_compare(x,y)>=0; }
{ return compare(x,y)>=0; }
inline bool operator> (const cl_I& x, const cl_I& y)
{ return cl_compare(x,y)>0; }
{ return compare(x,y)>0; }
// minusp(x) == (< x 0)
extern cl_boolean minusp (const cl_I& x);
@ -522,26 +523,26 @@ inline const cl_I denominator (const cl_I& r)
// Konversion zu einem C "float".
extern float cl_float_approx (const cl_I& x);
extern float float_approx (const cl_I& x);
// Konversion zu einem C "double".
extern double cl_double_approx (const cl_I& x);
extern double double_approx (const cl_I& x);
// random_I(randomstate,n) liefert zu einem Integer n>0 ein zufälliges
// Integer x mit 0 <= x < n.
// > randomstate: ein Random-State, wird verändert
extern const cl_I random_I (cl_random_state& randomstate, const cl_I& n);
extern const cl_I random_I (random_state& randomstate, const cl_I& n);
inline const cl_I random_I (const cl_I& n)
{ return random_I(cl_default_random_state,n); }
{ return random_I(default_random_state,n); }
// testrandom_I(randomstate) liefert ein zufälliges Integer zum Testen.
// > randomstate: ein Random-State, wird verändert
extern const cl_I testrandom_I (cl_random_state& randomstate);
extern const cl_I testrandom_I (random_state& randomstate);
inline const cl_I testrandom_I ()
{ return testrandom_I(cl_default_random_state); }
{ return testrandom_I(default_random_state); }
#ifdef WANT_OBFUSCATING_OPERATORS
@ -598,5 +599,6 @@ static void* const cl_I_debug_dummy[] = { &cl_I_debug_dummy,
};
#endif
} // namespace cln
#endif /* _CL_INTEGER_H */

10
include/cl_integer_class.h → include/cln/integer_class.h

@ -3,9 +3,10 @@
#ifndef _CL_INTEGER_CLASS_H
#define _CL_INTEGER_CLASS_H
#include "cl_number.h"
#include "cl_rational_class.h"
#include "cln/number.h"
#include "cln/rational_class.h"
namespace cln {
class cl_I : public cl_RA {
public:
@ -31,9 +32,9 @@ public:
cl_I (struct cl_fixnum * /* NULL! */, cl_uint);
cl_I (struct cl_heap_bignum *);
public: // Ability to place an object at a given address.
void* operator new (size_t size) { return cl_malloc_hook(size); }
void* operator new (size_t size) { return malloc_hook(size); }
void* operator new (size_t size, cl_I* ptr) { (void)size; return ptr; }
void operator delete (void* ptr) { cl_free_hook(ptr); }
void operator delete (void* ptr) { free_hook(ptr); }
};
// Private constructors.
@ -51,5 +52,6 @@ CL_DEFINE_INT_ASSIGNMENT_OPERATORS(cl_I)
CL_DEFINE_LONG_CONSTRUCTORS(cl_I)
CL_DEFINE_LONG_ASSIGNMENT_OPERATORS(cl_I)
} // namespace cln
#endif /* _CL_INTEGER_CLASS_H */

14
include/cl_integer_io.h → include/cln/integer_io.h

@ -3,9 +3,10 @@
#ifndef _CL_INTEGER_IO_H
#define _CL_INTEGER_IO_H
#include "cl_number_io.h"
#include "cl_integer_class.h"
#include "cln/number_io.h"
#include "cln/integer_class.h"
namespace cln {
// Undocumented input functions
@ -42,7 +43,7 @@ inline cl_istream operator>> (cl_istream stream, cl_I& result)
// Liefert zu einem Integer >=0 (write-to-string integer :base 10 :radix nil),
// also die Ziffernfolge als String.
// Mit cl_malloc_hook() alloziert, mit cl_free_hook() freizugeben.
// Mit malloc_hook() alloziert, mit free_hook() freizugeben.
extern char * cl_decimal_string (const cl_I& x);
// Gibt ein Integer aus.
@ -51,7 +52,7 @@ extern char * cl_decimal_string (const cl_I& x);
// > base: Basis (>=2, <=36)
// > stream: Stream
extern void print_integer (cl_ostream stream, unsigned int base, const cl_I& z);
// Dasselbe als String. Mit cl_malloc_hook() alloziert, mit cl_free_hook() freizugeben.
// Dasselbe als String. Mit malloc_hook() alloziert, mit free_hook() freizugeben.
extern char * print_integer_to_string (unsigned int base, const cl_I& z);
@ -93,11 +94,12 @@ extern void print_integer (cl_ostream stream, const cl_print_rational_flags& fla
inline void fprint (cl_ostream stream, const cl_I& x)
{
extern cl_print_flags cl_default_print_flags;
print_integer(stream,cl_default_print_flags,x);
extern cl_print_flags default_print_flags;
print_integer(stream,default_print_flags,x);
}
CL_DEFINE_PRINT_OPERATOR(cl_I)
} // namespace cln
#endif /* _CL_INTEGER_IO_H */

8
include/cl_integer_ring.h → include/cln/integer_ring.h

@ -3,12 +3,16 @@
#ifndef _CL_INTEGER_RING_H
#define _CL_INTEGER_RING_H
#include "cl_ring.h"
#include "cl_integer_class.h"
#include "cln/ring.h"
#include "cln/integer_class.h"
namespace cln {
typedef cl_specialized_number_ring<cl_I> cl_integer_ring;
extern const cl_integer_ring cl_I_ring; // math. Z
extern cl_class cl_class_integer_ring;
//CL_REQUIRE(cl_I_ring)
} // namespace cln
#endif /* _CL_INTEGER_RING_H */

84
include/cl_io.h → include/cln/io.h

@ -1,80 +1,29 @@
// I/O through <stdio.h> or <iostream.h>
// I/O through <stdio.h> or <iostream>
#ifndef _CL_IO_H
#define _CL_IO_H
#include "cl_types.h"
#include "cl_modules.h"
#include "cln/types.h"
#include "cln/modules.h"
#if !defined(CL_IO_STDIO) && !defined(CL_IO_IOSTREAM)
// Prefer iostream based I/O - this is what people expect.
#define CL_IO_IOSTREAM
#endif
#if defined(CL_IO_STDIO)
// I/O through <stdio.h>
#include <stdio.h>
#define cl_istream FILE *
#define cl_ostream FILE *
#define cl_stdin stdin
#define cl_stdout stdout
#define cl_stderr stderr
extern FILE* cl_debugout;
// Elementary operations on cl_istream
#define cl_EOF EOF
inline int freadchar (cl_istream stream)
{
// return fgetc(stream);
return getc(stream);
}
inline int funreadchar (cl_istream stream, int c)
{
return ungetc(c,stream);
}
// Elementary operations on cl_ostream
inline void fprintchar (cl_ostream stream, char c)
{
// fputc(c,stream);
putc(c,stream);
}
inline void fprint (cl_ostream stream, const char * string)
{
// fprintf(stream,"%s",string);
fputs(string,stream);
}
#endif
#if defined(CL_IO_IOSTREAM)
// I/O through <iostream.h>
// I/O through <iostream>
#ifdef floor
#undef floor
#include <iostream.h>
#include <iostream>
#define floor cln_floor
#else
#include <iostream.h>
#include <iostream>
#endif
#define cl_istream istream&
#define cl_ostream ostream&
#define cl_stdin cin
#define cl_stdout cout
#define cl_stderr cerr
extern ostream* cl_debugout_stream;
namespace cln {
typedef std::istream& cl_istream;
typedef std::ostream& cl_ostream;
extern cl_istream stdin;
extern cl_ostream stdout;
extern cl_ostream stderr;
extern std::ostream* cl_debugout_stream;
#define cl_debugout (*cl_debugout_stream)
// Elementary operations on cl_istream
@ -110,8 +59,6 @@ inline void fprint (cl_ostream stream, const char * string)
stream << string;
}
#endif
extern void fprintdecimal (cl_ostream stream, unsigned long x);
extern void fprintdecimal (cl_ostream stream, long x);
@ -154,6 +101,7 @@ inline cl_ostream operator<< (cl_ostream stream, const _class_& x) \
fprint(stream,x); \
return stream; \
}
} // namespace cln
#endif /* _CL_IO_H */

42
include/cl_lfloat.h → include/cln/lfloat.h

@ -3,11 +3,12 @@
#ifndef _CL_LFLOAT_H
#define _CL_LFLOAT_H
#include "cl_number.h"
#include "cl_lfloat_class.h"
#include "cl_integer_class.h"
#include "cl_float.h"
#include "cln/number.h"
#include "cln/lfloat_class.h"
#include "cln/integer_class.h"
#include "cln/float.h"
namespace cln {
CL_DEFINE_AS_CONVERSION(cl_LF)
@ -15,25 +16,25 @@ CL_DEFINE_AS_CONVERSION(cl_LF)
// Liefert zu einem Long-Float x : (- x), ein LF.
extern const cl_LF operator- (const cl_LF& x);
// cl_compare(x,y) vergleicht zwei Long-Floats x und y.
// compare(x,y) vergleicht zwei Long-Floats x und y.
// Ergebnis: 0 falls x=y, +1 falls x>y, -1 falls x<y.
extern cl_signean cl_compare (const cl_LF& x, const cl_LF& y);
extern cl_signean compare (const cl_LF& x, const cl_LF& y);
// cl_equal_hashcode(x) liefert einen cl_equal-invarianten Hashcode für x.
extern uint32 cl_equal_hashcode (const cl_LF& x);
// equal_hashcode(x) liefert einen equal-invarianten Hashcode für x.
extern uint32 equal_hashcode (const cl_LF& x);
inline bool operator== (const cl_LF& x, const cl_LF& y)
{ return cl_compare(x,y)==0; }
{ return compare(x,y)==0; }
inline bool operator!= (const cl_LF& x, const cl_LF& y)
{ return cl_compare(x,y)!=0; }
{ return compare(x,y)!=0; }
inline bool operator<= (const cl_LF& x, const cl_LF& y)
{ return cl_compare(x,y)<=0; }
{ return compare(x,y)<=0; }
inline bool operator< (const cl_LF& x, const cl_LF& y)
{ return cl_compare(x,y)<0; }
{ return compare(x,y)<0; }
inline bool operator>= (const cl_LF& x, const cl_LF& y)
{ return cl_compare(x,y)>=0; }
{ return compare(x,y)>=0; }
inline bool operator> (const cl_LF& x, const cl_LF& y)
{ return cl_compare(x,y)>0; }
{ return compare(x,y)>0; }
// minusp(x) == (< x 0)
extern cl_boolean minusp (const cl_LF& x);
@ -314,19 +315,19 @@ inline const cl_LF cl_float (unsigned int x, const cl_LF& y)
// Return type for decode_float:
struct cl_decoded_lfloat {
struct decoded_lfloat {
cl_LF mantissa;
cl_I exponent;
cl_LF sign;
// Constructor.
cl_decoded_lfloat () {}
cl_decoded_lfloat (const cl_LF& m, const cl_I& e, const cl_LF& s) : mantissa(m), exponent(e), sign(s) {}
decoded_lfloat () {}
decoded_lfloat (const cl_LF& m, const cl_I& e, const cl_LF& s) : mantissa(m), exponent(e), sign(s) {}
};
// decode_float(x) liefert zu einem Float x: (decode-float x).
// x = 0.0 liefert (0.0, 0, 1.0).
// x = (-1)^s * 2^e * m liefert ((-1)^0 * 2^0 * m, e als Integer, (-1)^s).
extern const cl_decoded_lfloat decode_float (const cl_LF& x);
extern const decoded_lfloat decode_float (const cl_LF& x);
// float_exponent(x) liefert zu einem Float x:
// den Exponenten von (decode-float x).
@ -376,10 +377,10 @@ extern const cl_LF signum (const cl_LF& x);
// Konversion zu einem C "float".
extern float cl_float_approx (const cl_LF& x);
extern float float_approx (const cl_LF& x);
// Konversion zu einem C "double".
extern double cl_double_approx (const cl_LF& x);
extern double double_approx (const cl_LF& x);
#ifdef WANT_OBFUSCATING_OPERATORS
@ -407,5 +408,6 @@ static void* const cl_LF_debug_dummy[] = { &cl_LF_debug_dummy,
};
#endif
} // namespace cln
#endif /* _CL_LFLOAT_H */

10
include/cl_lfloat_class.h → include/cln/lfloat_class.h

@ -3,9 +3,10 @@
#ifndef _CL_LFLOAT_CLASS_H
#define _CL_LFLOAT_CLASS_H
#include "cl_number.h"
#include "cl_float_class.h"
#include "cln/number.h"
#include "cln/float_class.h"
namespace cln {
class cl_LF : public cl_F {
public:
@ -26,9 +27,9 @@ public:
// Private pointer manipulations.
operator struct cl_heap_lfloat * () const;
public: // Ability to place an object at a given address.
void* operator new (size_t size) { return cl_malloc_hook(size); }
void* operator new (size_t size) { return malloc_hook(size); }
void* operator new (size_t size, cl_LF* ptr) { (void)size; return ptr; }
void operator delete (void* ptr) { cl_free_hook(ptr); }
void operator delete (void* ptr) { free_hook(ptr); }
};
// Define this if you want the elementary cl_LF operations (+, -, *, /,
// sqrt, cl_LF_I_mul) to return results which are always the correctly
@ -60,5 +61,6 @@ inline cl_LF::cl_LF (struct cl_heap_lfloat * ptr)
// The copy constructors.
CL_DEFINE_COPY_CONSTRUCTOR2(cl_LF,cl_F)
} // namespace cln
#endif /* _CL_LFLOAT_CLASS_H */

14
include/cl_lfloat_io.h → include/cln/lfloat_io.h

@ -3,8 +3,10 @@
#ifndef _CL_LFLOAT_IO_H
#define _CL_LFLOAT_IO_H
#include "cl_number_io.h"
#include "cl_lfloat.h"
#include "cln/number_io.h"
#include "cln/lfloat.h"
namespace cln {
inline cl_istream operator>> (cl_istream stream, cl_LF& result)
{
@ -15,13 +17,15 @@ inline cl_istream operator>> (cl_istream stream, cl_LF& result)
}
// The following does strictly the same as the general `fprint' for floats.
// It is here only so that people don't need to include <cl_float_io.h>.
// It is here only so that people don't need to include <cln/float_io.h>.
inline void fprint (cl_ostream stream, const cl_LF& x)
{
extern void print_float (cl_ostream stream, const cl_print_flags& flags, const cl_F& z);
extern cl_print_flags cl_default_print_flags;
print_float(stream,cl_default_print_flags,x);
extern cl_print_flags default_print_flags;
print_float(stream,default_print_flags,x);
}
CL_DEFINE_PRINT_OPERATOR(cl_LF)
} // namespace cln
#endif /* _CL_LFLOAT_IO_H */

8
include/cl_malloc.h → include/cln/malloc.h

@ -5,9 +5,13 @@
#include <stdlib.h>
namespace cln {
// Function like malloc() which returns aligned memory of size (> 0) bytes.
extern void* (*cl_malloc_hook) (size_t size);
extern void* (*malloc_hook) (size_t size);
// Function like free() which makes available for reuse such memory.
extern void (*cl_free_hook) (void* ptr);
extern void (*free_hook) (void* ptr);
} // namespace cln
#endif /* _CL_MALLOC_H */

46
include/cl_modinteger.h → include/cln/modinteger.h

@ -3,17 +3,18 @@
#ifndef _CL_MODINTEGER_H
#define _CL_MODINTEGER_H
#include "cl_object.h"
#include "cl_ring.h"
#include "cl_integer.h"
#include "cl_random.h"
#include "cl_malloc.h"
#include "cl_io.h"
#include "cl_proplist.h"
#include "cl_condition.h"
#include "cl_abort.h"
#include "cln/object.h"
#include "cln/ring.h"
#include "cln/integer.h"
#include "cln/random.h"
#include "cln/malloc.h"
#include "cln/io.h"
#include "cln/proplist.h"
#include "cln/condition.h"
#include "cln/abort.h"
#undef random // Linux defines random() as a macro!
namespace cln {
// Representation of an element of a ring Z/mZ.
@ -74,10 +75,10 @@ struct cl_composite_condition : public cl_condition {
// Constructors.
cl_composite_condition (const cl_I& _p)
: p (_p), factor (0)
{ print(cl_stderr); }
{ print(stderr); }
cl_composite_condition (const cl_I& _p, const cl_I& _f)
: p (_p), factor (_f)
{ print(cl_stderr); }
{ print(stderr); }
// Implement general condition methods.
const char * name () const;
void print (cl_ostream) const;
@ -101,9 +102,9 @@ public:
// Conversion.
CL_DEFINE_CONVERTER(_cl_ring_element)
public: // Ability to place an object at a given address.
void* operator new (size_t size) { return cl_malloc_hook(size); }
void* operator new (size_t size) { return malloc_hook(size); }
void* operator new (size_t size, _cl_MI* ptr) { (void)size; return ptr; }
void operator delete (void* ptr) { cl_free_hook(ptr); }
void operator delete (void* ptr) { free_hook(ptr); }
};
class cl_MI /* cf. cl_ring_element */ : public _cl_MI {
@ -123,9 +124,9 @@ public:
// Debugging output.
void debug_print () const;
public: // Ability to place an object at a given address.
void* operator new (size_t size) { return cl_malloc_hook(size); }
void* operator new (size_t size) { return malloc_hook(size); }
void* operator new (size_t size, cl_MI* ptr) { (void)size; return ptr; }
void operator delete (void* ptr) { cl_free_hook(ptr); }
void operator delete (void* ptr) { free_hook(ptr); }
};
@ -154,7 +155,7 @@ struct _cl_modint_setops /* cf. _cl_ring_setops */ {
// equality
cl_boolean (* equal) (cl_heap_modint_ring* R, const _cl_MI& x, const _cl_MI& y);
// random number
const _cl_MI (* random) (cl_heap_modint_ring* R, cl_random_state& randomstate);
const _cl_MI (* random) (cl_heap_modint_ring* R, random_state& randomstate);
};
struct _cl_modint_addops /* cf. _cl_ring_addops */ {
// 0
@ -189,15 +190,9 @@ struct _cl_modint_mulops /* cf. _cl_ring_mulops */ {
// some inverse of canonical homomorphism
const cl_I (* retract) (cl_heap_modint_ring* R, const _cl_MI& x);
};
#if defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ < 8) // workaround two g++-2.7.0 bugs
#define cl_modint_setops _cl_modint_setops
#define cl_modint_addops _cl_modint_addops
#define cl_modint_mulops _cl_modint_mulops
#else
typedef const _cl_modint_setops cl_modint_setops;
typedef const _cl_modint_addops cl_modint_addops;
typedef const _cl_modint_mulops cl_modint_mulops;
#endif
// Representation of the ring Z/mZ.
@ -223,7 +218,7 @@ public:
{ setops->fprint(this,stream,x); }
cl_boolean _equal (const _cl_MI& x, const _cl_MI& y)
{ return setops->equal(this,x,y); }
const _cl_MI _random (cl_random_state& randomstate)
const _cl_MI _random (random_state& randomstate)
{ return setops->random(this,randomstate); }
const _cl_MI _zero ()
{ return addops->zero(this); }
@ -267,7 +262,7 @@ public:
if (!(y.ring() == this)) cl_abort();
return _equal(x,y);
}
const cl_MI random (cl_random_state& randomstate = cl_default_random_state)
const cl_MI random (random_state& randomstate = default_random_state)
{
return cl_MI(this,_random(randomstate));
}
@ -365,7 +360,7 @@ private:
SUBCLASS_cl_heap_ring()
// Lookup or create a modular integer ring Z/mZ
extern const cl_modint_ring cl_find_modint_ring (const cl_I& m);
extern const cl_modint_ring find_modint_ring (const cl_I& m);
CL_REQUIRE(cl_MI)
// Runtime typing support.
@ -466,5 +461,6 @@ static void* const cl_MI_debug_dummy[] = { &cl_MI_debug_dummy,
};
#endif
} // namespace cln
#endif /* _CL_MODINTEGER_H */

0
include/cl_modules.h → include/cln/modules.h

6
include/cl_null_ring.h → include/cln/null_ring.h

@ -3,10 +3,14 @@
#ifndef _CL_NULL_RING_H
#define _CL_NULL_RING_H
#include "cl_ring.h"
#include "cln/ring.h"
namespace cln {
class cl_null_ring : public cl_ring { public: cl_null_ring (); };
extern const cl_null_ring cl_0_ring; // math. {0}
//CL_REQUIRE(cl_0_ring)
} // namespace cln
#endif /* _CL_NULL_RING_H */

8
include/cl_number.h → include/cln/number.h

@ -3,8 +3,10 @@
#ifndef _CL_NUMBER_H
#define _CL_NUMBER_H
#include "cl_object.h"
#include "cl_malloc.h"
#include "cln/object.h"
#include "cln/malloc.h"
namespace cln {
// Type hierachy:
// Number (N) =
@ -21,7 +23,6 @@
// Ratio (RT)
// Complex (C)
// Constructors and assignment operators from C numeric types.
#define CL_DEFINE_INT_CONSTRUCTOR(_class_,_type_) \
@ -241,5 +242,6 @@ CL_DEFINE_DOUBLE_CONSTRUCTOR(cl_number)
const type& __tmp_##x = *(const type*) &x; \
const type& x = __tmp_##x;
} // namespace cln
#endif /* _CL_NUMBER_H */

8
include/cl_number_io.h → include/cln/number_io.h

@ -3,8 +3,10 @@
#ifndef _CL_NUMBER_IO_H
#define _CL_NUMBER_IO_H
#include "cl_io.h"
#include "cl_number.h"
#include "cln/io.h"
#include "cln/number.h"
namespace cln {
// Input.
@ -31,4 +33,6 @@ extern void read_number_eof (void);
struct cl_read_flags;
} // namespace cln
#endif /* _CL_NUMBER_IO_H */

12
include/cl_numtheory.h → include/cln/numtheory.h

@ -3,10 +3,12 @@
#ifndef _CL_NUMTHEORY_H
#define _CL_NUMTHEORY_H
#include "cl_number.h"
#include "cl_integer.h"
#include "cl_modinteger.h"
#include "cl_condition.h"
#include "cln/number.h"
#include "cln/integer.h"
#include "cln/modinteger.h"
#include "cln/condition.h"
namespace cln {
// jacobi(a,b) returns the Jacobi symbol
// ( a )
@ -83,4 +85,6 @@ struct cornacchia_t {
extern const cornacchia_t cornacchia1 (const cl_I& d, const cl_I& p);
extern const cornacchia_t cornacchia4 (const cl_I& d, const cl_I& p);
} // namespace cln
#endif /* _CL_NUMTHEORY_H */

19
include/cl_object.h → include/cln/object.h

@ -3,10 +3,12 @@
#ifndef _CL_OBJECT_H
#define _CL_OBJECT_H
#include "cl_types.h"
#include "cl_modules.h"
#include "cln/types.h"
#include "cln/modules.h"
#include <stdlib.h>
namespace cln {
// We don't have to deal with circular structures, so normal reference counting
// is sufficient. Is also has the advantage of being mostly non-interrupting.
@ -167,7 +169,7 @@ typedef void (*cl_heap_destructor_function) (cl_heap* pointer);
#define cl_class_flags_subclass_rational 8 // all instances belong to cl_RA
#define cl_class_flags_number_ring 16 // all instances are rings whose
// elements belong to cl_number
// Function to print an object for debugging, to cl_stderr.
// Function to print an object for debugging, to stderr.
typedef void (*cl_heap_dprint_function) (cl_heap* pointer);
struct cl_class {
@ -543,20 +545,13 @@ inline cl_private_thing as_cl_private_thing (const cl_rcpointer& x)
// Define a conversion operator from one object to another object of the
// same size.
#if (defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ <= 7)) // workaround g++ bug
#define CL_DEFINE_CONVERTER(target_class) \
operator target_class () const \
{ \
if (sizeof(*this) != sizeof(target_class)) cl_abort(); \
return * (const target_class *) (void*) this; \
}
#else
#define CL_DEFINE_CONVERTER(target_class) \
operator const target_class & () const \
{ \
if (sizeof(*this) != sizeof(target_class)) cl_abort(); \
return * (const target_class *) (void*) this; \
}
#endif
} // namespace cln
#endif /* _CL_OBJECT_H */

18
include/cl_output.h → include/cln/output.h

@ -3,10 +3,12 @@
#ifndef _CL_OUTPUT_H
#define _CL_OUTPUT_H
#include "cl_types.h"
#include "cl_floatformat.h"
#include "cl_io.h"
#include "cl_string.h"
#include "cln/types.h"
#include "cln/floatformat.h"
#include "cln/io.h"
#include "cln/string.h"
namespace cln {
struct cl_print_rational_flags {
// Base in which rational numbers are to be printed.
@ -24,11 +26,11 @@ struct cl_print_float_flags {
// Flag whether to prefer type specific exponent markers over 'E'.
cl_boolean float_readably;
// If !float_readably, the format which earns the 'E' exponent marker.
cl_float_format_t default_float_format;
float_format_t default_float_format;
// Constructor.
cl_print_float_flags () :
float_readably (cl_false),
default_float_format (cl_float_format_ffloat) {}
default_float_format (float_format_ffloat) {}
};
struct cl_print_real_flags : cl_print_rational_flags, cl_print_float_flags {};
@ -65,6 +67,8 @@ struct cl_print_univpoly_flags {
struct cl_print_flags : cl_print_number_flags, cl_print_vector_flags, cl_print_univpoly_flags {};
extern cl_print_flags cl_default_print_flags;
extern cl_print_flags default_print_flags;
} // namespace cln
#endif /* _CL_OUTPUT_H */

16
include/cl_proplist.h → include/cln/proplist.h

@ -3,8 +3,10 @@
#ifndef _CL_PROPLIST_H
#define _CL_PROPLIST_H
#include "cl_symbol.h"
#include "cl_malloc.h"
#include "cln/symbol.h"
#include "cln/malloc.h"
namespace cln {
// The only extensible way to extend objects at runtime in an extensible
// and decentralized way (without having to modify the object's class)
@ -25,16 +27,16 @@ public:
// Destructor.
virtual ~cl_property () {}
// Allocation and deallocation.
void* operator new (size_t size) { return cl_malloc_hook(size); }
void operator delete (void* ptr) { cl_free_hook(ptr); }
void* operator new (size_t size) { return malloc_hook(size); }
void operator delete (void* ptr) { free_hook(ptr); }
private:
virtual void dummy ();
// Friend declarations. They are for the compiler. Just ignore them.
friend class cl_property_list;
};
#define SUBCLASS_cl_property() \
void* operator new (size_t size) { return cl_malloc_hook(size); } \
void operator delete (void* ptr) { cl_free_hook(ptr); }
void* operator new (size_t size) { return malloc_hook(size); } \
void operator delete (void* ptr) { free_hook(ptr); }
struct cl_property_list {
private:
@ -48,4 +50,6 @@ public:
~cl_property_list ();
};
} // namespace cln
#endif /* _CL_PROPLIST_H */

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save