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

3740 lines
128 KiB

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