From c84c6db5d56829d69083c819688a973867694a2a Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Mon, 24 Apr 2006 22:55:26 +0000 Subject: [PATCH] 2006-04-25 Bruno Haible Richard B. Kreckel 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. --- ChangeLog | 225 ++++++++++++++++++ doc/cln.tex | 16 +- examples/atan_recip.cc | 34 +-- examples/atanh_recip.cc | 34 +-- include/cln/GV.h | 26 +- include/cln/GV_complex.h | 4 +- include/cln/GV_integer.h | 16 +- include/cln/GV_modinteger.h | 6 +- include/cln/GV_number.h | 6 +- include/cln/GV_rational.h | 4 +- include/cln/GV_real.h | 4 +- include/cln/SV.h | 10 +- include/cln/SV_complex.h | 2 +- include/cln/SV_integer.h | 2 +- include/cln/SV_number.h | 8 +- include/cln/SV_rational.h | 2 +- include/cln/SV_real.h | 2 +- include/cln/SV_ringelt.h | 8 +- include/cln/dfloat.h | 10 +- include/cln/ffloat.h | 10 +- include/cln/float.h | 10 +- include/cln/integer.h | 26 +- include/cln/lfloat.h | 10 +- include/cln/modinteger.h | 6 +- include/cln/sfloat.h | 10 +- include/cln/types.h | 1 + src/base/cl_low.h | 12 + src/base/digitseq/cl_2DS_div.cc | 12 +- src/base/digitseq/cl_2DS_recip.cc | 6 +- src/base/digitseq/cl_DS.h | 20 +- src/base/digitseq/cl_DS_mul.cc | 11 +- src/base/digitseq/cl_DS_mul_fftc.h | 130 +++++----- src/base/digitseq/cl_DS_mul_fftcs.h | 140 +++++------ src/base/digitseq/cl_DS_mul_fftm.h | 148 ++++++------ src/base/digitseq/cl_DS_mul_fftp.h | 102 ++++---- src/base/digitseq/cl_DS_mul_fftp3.h | 102 ++++---- src/base/digitseq/cl_DS_mul_fftp3m.h | 102 ++++---- src/base/digitseq/cl_DS_mul_fftr.h | 152 ++++++------ src/base/digitseq/cl_DS_mul_kara.h | 4 +- src/base/digitseq/cl_DS_mul_nuss.h | 108 ++++----- src/base/digitseq/cl_DS_recip.cc | 2 +- src/base/digitseq/cl_DS_recipsqrt.cc | 2 +- src/base/digitseq/cl_DS_sqrt.cc | 6 +- src/base/digitseq/cl_DS_trandom.cc | 8 +- src/complex/input/cl_N_read.cc | 12 +- src/complex/transcendental/cl_C_asinh_aux.cc | 2 +- src/complex/transcendental/cl_C_expt_C.cc | 2 +- src/float/cl_F.h | 2 +- src/float/conv/cl_F_from_F_f.cc | 2 +- src/float/conv/cl_F_from_I_f.cc | 2 +- src/float/conv/cl_F_from_RA_f.cc | 2 +- src/float/dfloat/conv/cl_I_to_double.cc | 2 +- src/float/dfloat/conv/cl_RA_to_double.cc | 4 +- src/float/dfloat/elem/cl_DF_from_I.cc | 2 +- src/float/dfloat/elem/cl_DF_from_RA.cc | 4 +- src/float/dfloat/elem/cl_DF_scale.cc | 6 +- src/float/dfloat/misc/cl_DF_digits.cc | 2 +- src/float/dfloat/misc/cl_DF_precision.cc | 2 +- src/float/elem/cl_F_scale.cc | 2 +- src/float/ffloat/conv/cl_I_to_float.cc | 2 +- src/float/ffloat/conv/cl_RA_to_float.cc | 4 +- src/float/ffloat/elem/cl_FF_from_I.cc | 2 +- src/float/ffloat/elem/cl_FF_from_RA.cc | 4 +- src/float/ffloat/elem/cl_FF_scale.cc | 6 +- src/float/ffloat/misc/cl_FF_digits.cc | 2 +- src/float/ffloat/misc/cl_FF_precision.cc | 2 +- src/float/input/cl_F_read.cc | 12 +- src/float/lfloat/algebraic/cl_LF_sqrt.cc | 2 +- src/float/lfloat/elem/cl_LF_1plus.cc | 4 +- src/float/lfloat/elem/cl_LF_I_div.cc | 6 +- src/float/lfloat/elem/cl_LF_I_mul.cc | 2 +- src/float/lfloat/elem/cl_LF_div.cc | 4 +- src/float/lfloat/elem/cl_LF_from_I.cc | 2 +- src/float/lfloat/elem/cl_LF_from_RA.cc | 12 +- src/float/lfloat/elem/cl_LF_fround.cc | 4 +- src/float/lfloat/elem/cl_LF_ftrunc.cc | 4 +- src/float/lfloat/elem/cl_LF_futrunc.cc | 4 +- src/float/lfloat/elem/cl_LF_scale.cc | 8 +- src/float/lfloat/elem/cl_LF_to_I.cc | 2 +- src/float/lfloat/misc/cl_LF_digits.cc | 4 +- src/float/lfloat/misc/cl_LF_idecode.cc | 2 +- src/float/lfloat/misc/cl_LF_leninc.cc | 4 +- src/float/lfloat/misc/cl_LF_lenincx.cc | 4 +- src/float/lfloat/misc/cl_LF_precision.cc | 4 +- src/float/lfloat/misc/cl_LF_shortenrel.cc | 10 +- src/float/lfloat/misc/cl_LF_shortenwith.cc | 2 +- src/float/misc/cl_F_digits.cc | 2 +- src/float/misc/cl_F_epsneg.cc | 4 +- src/float/misc/cl_F_epspos.cc | 4 +- src/float/misc/cl_F_leastneg.cc | 2 +- src/float/misc/cl_F_leastpos.cc | 2 +- src/float/misc/cl_F_mostneg.cc | 2 +- src/float/misc/cl_F_mostpos.cc | 2 +- src/float/misc/cl_F_precision.cc | 2 +- src/float/misc/cl_F_rational.cc | 6 +- src/float/misc/cl_F_shortenrel.cc | 8 +- src/float/output/cl_F_dprint.cc | 4 +- src/float/random/cl_F_random.cc | 6 +- src/float/sfloat/elem/cl_SF_from_I.cc | 2 +- src/float/sfloat/elem/cl_SF_from_RA.cc | 4 +- src/float/sfloat/elem/cl_SF_scale.cc | 6 +- src/float/sfloat/misc/cl_SF_digits.cc | 2 +- src/float/sfloat/misc/cl_SF_precision.cc | 2 +- src/float/transcendental/cl_F_atanhx.cc | 12 +- src/float/transcendental/cl_F_atanx.cc | 24 +- .../transcendental/cl_F_catalanconst_f.cc | 2 +- src/float/transcendental/cl_F_cos.cc | 4 +- src/float/transcendental/cl_F_cosh.cc | 4 +- src/float/transcendental/cl_F_coshsinh.cc | 2 +- src/float/transcendental/cl_F_cossin.cc | 4 +- src/float/transcendental/cl_F_eulerconst_f.cc | 2 +- src/float/transcendental/cl_F_exp1_f.cc | 2 +- src/float/transcendental/cl_F_expx.cc | 10 +- src/float/transcendental/cl_F_ln10_f.cc | 2 +- src/float/transcendental/cl_F_ln2_f.cc | 2 +- src/float/transcendental/cl_F_lnx.cc | 18 +- src/float/transcendental/cl_F_pi_f.cc | 2 +- src/float/transcendental/cl_F_sin.cc | 4 +- src/float/transcendental/cl_F_sinh.cc | 2 +- src/float/transcendental/cl_F_sinhx.cc | 12 +- src/float/transcendental/cl_F_sinx.cc | 12 +- src/float/transcendental/cl_F_tran.h | 6 +- src/float/transcendental/cl_F_zeta_int_f.cc | 2 +- src/float/transcendental/cl_LF_atan_recip.cc | 4 +- src/float/transcendental/cl_LF_atanh_recip.cc | 4 +- .../transcendental/cl_LF_catalanconst.cc | 32 +-- .../transcendental/cl_LF_coshsinh_aux.cc | 18 +- src/float/transcendental/cl_LF_cossin_aux.cc | 18 +- src/float/transcendental/cl_LF_eulerconst.cc | 44 ++-- src/float/transcendental/cl_LF_exp1.cc | 12 +- src/float/transcendental/cl_LF_exp_aux.cc | 18 +- src/float/transcendental/cl_LF_pi.cc | 18 +- src/float/transcendental/cl_LF_ratseries.cc | 2 +- src/float/transcendental/cl_LF_ratseries_.cc | 4 +- src/float/transcendental/cl_LF_ratseries_a.cc | 6 +- .../transcendental/cl_LF_ratseries_ab.cc | 6 +- src/float/transcendental/cl_LF_ratseries_b.cc | 6 +- src/float/transcendental/cl_LF_ratseries_p.cc | 6 +- .../transcendental/cl_LF_ratseries_pa.cc | 6 +- .../transcendental/cl_LF_ratseries_pab.cc | 6 +- .../transcendental/cl_LF_ratseries_pb.cc | 6 +- .../transcendental/cl_LF_ratseries_pq.cc | 24 +- .../transcendental/cl_LF_ratseries_pqa.cc | 24 +- .../transcendental/cl_LF_ratseries_pqab.cc | 24 +- .../transcendental/cl_LF_ratseries_pqb.cc | 24 +- src/float/transcendental/cl_LF_ratseries_q.cc | 6 +- .../transcendental/cl_LF_ratseries_qa.cc | 6 +- .../transcendental/cl_LF_ratseries_qab.cc | 6 +- .../transcendental/cl_LF_ratseries_qb.cc | 6 +- .../cl_LF_ratseries_stream_pq.cc | 6 +- .../cl_LF_ratseries_stream_pqa.cc | 6 +- .../cl_LF_ratseries_stream_pqab.cc | 6 +- .../cl_LF_ratseries_stream_pqb.cc | 6 +- .../transcendental/cl_LF_ratsumseries_pqcd.cc | 2 +- .../cl_LF_ratsumseries_pqcd_aux.cc | 4 +- .../transcendental/cl_LF_ratsumseries_pqd.cc | 2 +- .../cl_LF_ratsumseries_pqd_aux.cc | 4 +- src/float/transcendental/cl_LF_tran.h | 68 +++--- src/float/transcendental/cl_LF_zeta3.cc | 4 +- src/float/transcendental/cl_LF_zeta_int.cc | 14 +- src/integer/algebraic/cl_I_rootp_I.cc | 6 +- src/integer/algebraic/cl_I_rootp_aux.cc | 14 +- src/integer/bitwise/cl_I_ash.cc | 12 +- src/integer/bitwise/cl_I_ash_I.cc | 6 +- src/integer/bitwise/cl_I_byte.h | 8 +- src/integer/bitwise/cl_I_fullbyte.cc | 4 +- src/integer/bitwise/cl_I_ilength.cc | 4 +- src/integer/bitwise/cl_I_ldb.cc | 8 +- src/integer/bitwise/cl_I_ldbtest.cc | 8 +- src/integer/bitwise/cl_I_ldbx.cc | 12 +- src/integer/bitwise/cl_I_ldbxtest.cc | 8 +- src/integer/bitwise/cl_I_logbitp.cc | 4 +- src/integer/bitwise/cl_I_logbitp_I.cc | 2 +- src/integer/bitwise/cl_I_logcount.cc | 6 +- src/integer/bitwise/cl_I_mkf.cc | 8 +- src/integer/bitwise/cl_I_mkfx.cc | 14 +- src/integer/cl_I.h | 10 +- src/integer/conv/cl_I_cached_power.h | 2 +- src/integer/conv/cl_I_digits_need.cc | 4 +- src/integer/conv/cl_I_from_digits.cc | 8 +- src/integer/conv/cl_I_to_digits.cc | 8 +- src/integer/gcd/cl_I_gcd.cc | 2 +- src/integer/gcd/cl_I_xgcd.cc | 2 +- src/integer/misc/cl_I_eqhashcode.cc | 4 +- src/integer/misc/cl_I_ord2.cc | 4 +- src/integer/misc/cl_I_power2p.cc | 4 +- src/integer/output/cl_I_decstring.cc | 2 +- src/integer/output/cl_I_print.cc | 4 +- src/integer/output/cl_I_print_string.cc | 2 +- src/modinteger/cl_MI.cc | 12 +- src/modinteger/cl_MI_lshift.cc | 2 +- src/modinteger/cl_MI_montgom.h | 12 +- src/modinteger/cl_MI_pow2.h | 6 +- src/modinteger/cl_MI_pow2m1.h | 16 +- src/modinteger/cl_MI_pow2p1.h | 16 +- src/modinteger/cl_MI_rshift.cc | 2 +- src/modinteger/cl_MI_std.h | 12 +- src/numtheory/cl_IF_millerrabin.cc | 4 +- src/numtheory/cl_nt_isprobprime.cc | 2 +- src/numtheory/cl_nt_sqrtmodp.cc | 12 +- src/polynomial/elem/cl_UP_GF2.h | 2 +- src/real/conv/cl_F_from_R_f.cc | 2 +- src/real/format-output/cl_fmt_floatstring.cc | 2 +- src/real/input/cl_R_read.cc | 12 +- src/vector/cl_GV_I.cc | 74 +++--- src/vector/cl_GV_I_copy.cc | 2 +- src/vector/cl_GV_number.cc | 20 +- src/vector/cl_GV_number_copy.cc | 2 +- src/vector/cl_SV_copy.cc | 4 +- src/vector/cl_SV_number.cc | 8 +- src/vector/cl_SV_ringelt.cc | 8 +- tests/main.cc | 2 +- tests/test_I_ilength.cc | 2 +- tests/test_I_ord2.cc | 6 +- 214 files changed, 1518 insertions(+), 1275 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7b06fab..de6c0e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,228 @@ +2006-04-25 Bruno Haible + Richard B. Kreckel + + 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. + 2006-04-19 Bruno Haible Prepare for autoconf-2.60. diff --git a/doc/cln.tex b/doc/cln.tex index fd71f60..5e47dd0 100644 --- a/doc/cln.tex +++ b/doc/cln.tex @@ -1804,7 +1804,7 @@ Returns true if some bit is set in both @code{x} and @code{y}, i.e. if Returns true if the @code{n}th bit (from the right) of @code{x} is set. Bit 0 is the least significant bit. -@item uintL logcount (const cl_I& x) +@item uintC logcount (const cl_I& x) @cindex @code{logcount ()} Returns the number of one bits in @code{x}, if @code{x} >= 0, or the number of zero bits in @code{x}, if @code{x} < 0. @@ -1813,7 +1813,7 @@ the number of zero bits in @code{x}, if @code{x} < 0. The following functions operate on intervals of bits in integers. The type @example -struct cl_byte @{ uintL size; uintL position; @}; +struct cl_byte @{ uintC size; uintC position; @}; @end example @cindex @code{cl_byte} represents the bit interval containing the bits @@ -1895,20 +1895,20 @@ Shifts @code{x} by @code{y} bits to the left (if @code{y}>=0) or by @code{-y} bits to the right (if @code{y}<=0). In other words, this returns @code{floor(x * expt(2,y))}. -@item uintL integer_length (const cl_I& x) +@item uintC integer_length (const cl_I& x) @cindex @code{integer_length ()} Returns the number of bits (excluding the sign bit) needed to represent @code{x} in two's complement notation. This is the smallest n >= 0 such that -2^n <= x < 2^n. If x > 0, this is the unique n > 0 such that 2^(n-1) <= x < 2^n. -@item uintL ord2 (const cl_I& x) +@item uintC ord2 (const cl_I& x) @cindex @code{ord2 ()} @code{x} must be non-zero. This function returns the number of 0 bits at the right of @code{x} in two's complement notation. This is the largest n >= 0 such that 2^n divides @code{x}. -@item uintL power2p (const cl_I& x) +@item uintC power2p (const cl_I& x) @cindex @code{power2p ()} @code{x} must be > 0. This function checks whether @code{x} is a power of 2. If @code{x} = 2^(n-1), it returns n. Else it returns 0. @@ -2012,7 +2012,7 @@ Each of the classes defines the following operations. @table @code -@item @var{type} scale_float (const @var{type}& x, sintL delta) +@item @var{type} scale_float (const @var{type}& x, sintC delta) @cindex @code{scale_float ()} @itemx @var{type} scale_float (const @var{type}& x, const cl_I& delta) Returns @code{x*2^delta}. This is more efficient than an explicit multiplication @@ -2038,13 +2038,13 @@ Returns the base of the floating-point representation. This is always @code{2}. Returns the sign @code{s} of @code{x} as a float. The value is 1 for @code{x} >= 0, -1 for @code{x} < 0. -@item uintL float_digits (const @var{type}& x) +@item uintC float_digits (const @var{type}& x) @cindex @code{float_digits ()} Returns the number of mantissa bits in the floating-point representation of @code{x}, including the hidden bit. The value only depends on the type of @code{x}, not on its value. -@item uintL float_precision (const @var{type}& x) +@item uintC float_precision (const @var{type}& x) @cindex @code{float_precision ()} Returns the number of significant mantissa bits in the floating-point representation of @code{x}. Since denormalized numbers are not supported, diff --git a/examples/atan_recip.cc b/examples/atan_recip.cc index 1540bd5..824814c 100644 --- a/examples/atan_recip.cc +++ b/examples/atan_recip.cc @@ -31,11 +31,11 @@ using namespace cln; const cl_LF atan_recip_1a (cl_I m, uintC len) { var uintC actuallen = len + 1; - var cl_LF eps = scale_float(cl_I_to_LF(1,actuallen),-intDsize*(sintL)actuallen); + var cl_LF eps = scale_float(cl_I_to_LF(1,actuallen),-intDsize*(sintC)actuallen); var cl_I m2 = m*m; var cl_LF fterm = cl_I_to_LF(1,actuallen)/m; var cl_LF fsum = fterm; - for (var uintL n = 1; fterm >= eps; n++) { + for (var uintC n = 1; fterm >= eps; n++) { fterm = fterm/m2; fterm = cl_LF_shortenwith(fterm,eps); if ((n % 2) == 0) @@ -52,23 +52,23 @@ const cl_LF atan_recip_1b (cl_I m, uintC len) var cl_I m2 = m*m; var cl_I fterm = floor1((cl_I)1 << (intDsize*actuallen), m); var cl_I fsum = fterm; - for (var uintL n = 1; fterm > 0; n++) { + for (var uintC n = 1; fterm > 0; n++) { fterm = floor1(fterm,m2); if ((n % 2) == 0) fsum = fsum + floor1(fterm,2*n+1); else fsum = fsum - floor1(fterm,2*n+1); } - return scale_float(cl_I_to_LF(fsum,len),-intDsize*(sintL)actuallen); + return scale_float(cl_I_to_LF(fsum,len),-intDsize*(sintC)actuallen); } const cl_LF atan_recip_1c (cl_I m, uintC len) { var uintC actuallen = len + 1; var cl_I m2 = m*m; - var sintL N = (sintL)(0.69314718*intDsize/2*actuallen/log(double_approx(m))) + 1; + var sintC N = (sintC)(0.69314718*intDsize/2*actuallen/log(double_approx(m))) + 1; var cl_I num = 0, den = 1; // "lazy rational number" - for (sintL n = N-1; n>=0; n--) { + for (sintC n = N-1; n>=0; n--) { // Multiply sum with 1/m^2: den = den * m2; // Add (-1)^n/(2n+1): @@ -87,11 +87,11 @@ const cl_LF atan_recip_1d (cl_I m, uintC len) { var uintC actuallen = len + 1; var cl_I m2 = m*m; - var uintL N = (uintL)(0.69314718*intDsize/2*actuallen/log(double_approx(m))) + 1; + var uintC N = (uintC)(0.69314718*intDsize/2*actuallen/log(double_approx(m))) + 1; CL_ALLOCA_STACK; var cl_I* bv = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I)); - var uintL n; + var uintC n; for (n = 0; n < N; n++) { new (&bv[n]) cl_I ((n % 2) == 0 ? (cl_I)(2*n+1) : -(cl_I)(2*n+1)); new (&qv[n]) cl_I (n==0 ? m : m2); @@ -113,11 +113,11 @@ const cl_LF atan_recip_1d (cl_I m, uintC len) const cl_LF atan_recip_2a (cl_I m, uintC len) { var uintC actuallen = len + 1; - var cl_LF eps = scale_float(cl_I_to_LF(1,actuallen),-intDsize*(sintL)actuallen); + var cl_LF eps = scale_float(cl_I_to_LF(1,actuallen),-intDsize*(sintC)actuallen); var cl_I m2 = m*m+1; var cl_LF fterm = cl_I_to_LF(m,actuallen)/m2; var cl_LF fsum = fterm; - for (var uintL n = 1; fterm >= eps; n++) { + for (var uintC n = 1; fterm >= eps; n++) { fterm = The(cl_LF)((2*n)*fterm)/((2*n+1)*m2); fterm = cl_LF_shortenwith(fterm,eps); fsum = fsum + LF_to_LF(fterm,actuallen); @@ -131,20 +131,20 @@ const cl_LF atan_recip_2b (cl_I m, uintC len) var cl_I m2 = m*m+1; var cl_I fterm = floor1((cl_I)m << (intDsize*actuallen), m2); var cl_I fsum = fterm; - for (var uintL n = 1; fterm > 0; n++) { + for (var uintC n = 1; fterm > 0; n++) { fterm = floor1((2*n)*fterm,(2*n+1)*m2); fsum = fsum + fterm; } - return scale_float(cl_I_to_LF(fsum,len),-intDsize*(sintL)actuallen); + return scale_float(cl_I_to_LF(fsum,len),-intDsize*(sintC)actuallen); } const cl_LF atan_recip_2c (cl_I m, uintC len) { var uintC actuallen = len + 1; var cl_I m2 = m*m+1; - var uintL N = (uintL)(0.69314718*intDsize*actuallen/log(double_approx(m2))) + 1; + var uintC N = (uintC)(0.69314718*intDsize*actuallen/log(double_approx(m2))) + 1; var cl_I num = 0, den = 1; // "lazy rational number" - for (uintL n = N; n>0; n--) { + for (uintC n = N; n>0; n--) { // Multiply sum with (2n)/(2n+1)(m^2+1): num = num * (2*n); den = den * ((2*n+1)*m2); @@ -161,11 +161,11 @@ const cl_LF atan_recip_2d (cl_I m, uintC len) { var uintC actuallen = len + 1; var cl_I m2 = m*m+1; - var uintL N = (uintL)(0.69314718*intDsize*actuallen/log(double_approx(m2))) + 1; + var uintC N = (uintC)(0.69314718*intDsize*actuallen/log(double_approx(m2))) + 1; CL_ALLOCA_STACK; var cl_I* pv = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I)); - var uintL n; + var uintC n; new (&pv[0]) cl_I (m); new (&qv[0]) cl_I (m2); for (n = 1; n < N; n++) { @@ -196,7 +196,7 @@ int main (int argc, char * argv[]) if (argc < 2) exit(1); cl_I m = (cl_I)argv[1]; - uintL len = atoi(argv[2]); + uintC len = atol(argv[2]); cl_LF p; ln(cl_I_to_LF(1000,len+10)); // fill cache // Method 1. diff --git a/examples/atanh_recip.cc b/examples/atanh_recip.cc index 991cc30..51455bd 100644 --- a/examples/atanh_recip.cc +++ b/examples/atanh_recip.cc @@ -33,11 +33,11 @@ const cl_LF atanh_recip_1a (cl_I m, uintC len) { var uintC actuallen = len + 1; - var cl_LF eps = scale_float(cl_I_to_LF(1,actuallen),-intDsize*(sintL)actuallen); + var cl_LF eps = scale_float(cl_I_to_LF(1,actuallen),-intDsize*(sintC)actuallen); var cl_I m2 = m*m; var cl_LF fterm = cl_I_to_LF(1,actuallen)/m; var cl_LF fsum = fterm; - for (var uintL n = 1; fterm >= eps; n++) { + for (var uintC n = 1; fterm >= eps; n++) { fterm = fterm/m2; fterm = cl_LF_shortenwith(fterm,eps); fsum = fsum + LF_to_LF(fterm/(2*n+1),actuallen); @@ -51,20 +51,20 @@ const cl_LF atanh_recip_1b (cl_I m, uintC len) var cl_I m2 = m*m; var cl_I fterm = floor1((cl_I)1 << (intDsize*actuallen), m); var cl_I fsum = fterm; - for (var uintL n = 1; fterm > 0; n++) { + for (var uintC n = 1; fterm > 0; n++) { fterm = floor1(fterm,m2); fsum = fsum + floor1(fterm,2*n+1); } - return scale_float(cl_I_to_LF(fsum,len),-intDsize*(sintL)actuallen); + return scale_float(cl_I_to_LF(fsum,len),-intDsize*(sintC)actuallen); } const cl_LF atanh_recip_1c (cl_I m, uintC len) { var uintC actuallen = len + 1; var cl_I m2 = m*m; - var sintL N = (sintL)(0.69314718*intDsize/2*actuallen/log(double_approx(m))) + 1; + var sintC N = (sintC)(0.69314718*intDsize/2*actuallen/log(double_approx(m))) + 1; var cl_I num = 0, den = 1; // "lazy rational number" - for (sintL n = N-1; n>=0; n--) { + for (sintC n = N-1; n>=0; n--) { // Multiply sum with 1/m^2: den = den * m2; // Add 1/(2n+1): @@ -80,11 +80,11 @@ const cl_LF atanh_recip_1d (cl_I m, uintC len) { var uintC actuallen = len + 1; var cl_I m2 = m*m; - var uintL N = (uintL)(0.69314718*intDsize/2*actuallen/log(double_approx(m))) + 1; + var uintC N = (uintC)(0.69314718*intDsize/2*actuallen/log(double_approx(m))) + 1; CL_ALLOCA_STACK; var cl_I* bv = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I)); - var uintL n; + var uintC n; for (n = 0; n < N; n++) { new (&bv[n]) cl_I ((cl_I)(2*n+1)); new (&qv[n]) cl_I (n==0 ? m : m2); @@ -106,11 +106,11 @@ const cl_LF atanh_recip_1d (cl_I m, uintC len) const cl_LF atanh_recip_2a (cl_I m, uintC len) { var uintC actuallen = len + 1; - var cl_LF eps = scale_float(cl_I_to_LF(1,actuallen),-intDsize*(sintL)actuallen); + var cl_LF eps = scale_float(cl_I_to_LF(1,actuallen),-intDsize*(sintC)actuallen); var cl_I m2 = m*m-1; var cl_LF fterm = cl_I_to_LF(m,actuallen)/m2; var cl_LF fsum = fterm; - for (var uintL n = 1; fterm >= eps; n++) { + for (var uintC n = 1; fterm >= eps; n++) { fterm = The(cl_LF)((2*n)*fterm)/((2*n+1)*m2); fterm = cl_LF_shortenwith(fterm,eps); if ((n % 2) == 0) @@ -127,23 +127,23 @@ const cl_LF atanh_recip_2b (cl_I m, uintC len) var cl_I m2 = m*m-1; var cl_I fterm = floor1((cl_I)m << (intDsize*actuallen), m2); var cl_I fsum = fterm; - for (var uintL n = 1; fterm > 0; n++) { + for (var uintC n = 1; fterm > 0; n++) { fterm = floor1((2*n)*fterm,(2*n+1)*m2); if ((n % 2) == 0) fsum = fsum + fterm; else fsum = fsum - fterm; } - return scale_float(cl_I_to_LF(fsum,len),-intDsize*(sintL)actuallen); + return scale_float(cl_I_to_LF(fsum,len),-intDsize*(sintC)actuallen); } const cl_LF atanh_recip_2c (cl_I m, uintC len) { var uintC actuallen = len + 1; var cl_I m2 = m*m-1; - var uintL N = (uintL)(0.69314718*intDsize*actuallen/log(double_approx(m2))) + 1; + var uintC N = (uintC)(0.69314718*intDsize*actuallen/log(double_approx(m2))) + 1; var cl_I num = 0, den = 1; // "lazy rational number" - for (uintL n = N; n>0; n--) { + for (uintC n = N; n>0; n--) { // Multiply sum with -(2n)/(2n+1)(m^2+1): num = num * (2*n); den = - den * ((2*n+1)*m2); @@ -160,11 +160,11 @@ const cl_LF atanh_recip_2d (cl_I m, uintC len) { var uintC actuallen = len + 1; var cl_I m2 = m*m-1; - var uintL N = (uintL)(0.69314718*intDsize*actuallen/log(double_approx(m2))) + 1; + var uintC N = (uintC)(0.69314718*intDsize*actuallen/log(double_approx(m2))) + 1; CL_ALLOCA_STACK; var cl_I* pv = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I)); - var uintL n; + var uintC n; new (&pv[0]) cl_I (m); new (&qv[0]) cl_I (m2); for (n = 1; n < N; n++) { @@ -195,7 +195,7 @@ int main (int argc, char * argv[]) if (argc < 2) exit(1); cl_I m = (cl_I)argv[1]; - uintL len = atoi(argv[2]); + uintC len = atol(argv[2]); cl_LF p; ln(cl_I_to_LF(1000,len+10)); // fill cache // Method 1. diff --git a/include/cln/GV.h b/include/cln/GV.h index ed83e27..e0d6d98 100644 --- a/include/cln/GV.h +++ b/include/cln/GV.h @@ -25,9 +25,9 @@ template struct cl_GV_vectorops; template class cl_GV_inner { protected: - uintL len; // number of elements + uintC len; // number of elements public: - uintL length () const; // number of elements + uintC length () const; // number of elements cl_GV_vectorops* vectorops; // get/set element const cl_GV_index operator[] (unsigned long index); const cl_GV_constindex operator[] (unsigned long index) const; @@ -39,7 +39,7 @@ public: const cl_GV_constindex operator[] (int index) const; public: /* ugh */ // Constructor. - cl_GV_inner (uintL l, cl_GV_vectorops* ops) : len (l), vectorops (ops) {} + cl_GV_inner (uintC l, cl_GV_vectorops* ops) : len (l), vectorops (ops) {} public: // Destructor. ~cl_GV_inner (); @@ -63,10 +63,10 @@ class cl_GV_index { // through []. public: cl_GV_inner* vec; - uintL index; + uintC index; operator T () const; // Constructor: - cl_GV_index (cl_GV_inner* v, uintL i) : vec (v), index (i) {} + cl_GV_index (cl_GV_inner* v, uintC i) : vec (v), index (i) {} // Assignment operator. void operator= (const T& x) const; #if (defined(__sparc__) || defined(__sparc64__) || defined(__mips__) || defined(__mips64__)) && !defined(__GNUC__) // maybe an SGI CC and Sun CC bug? @@ -88,10 +88,10 @@ class cl_GV_constindex { // through []. It lacks the assignment operator. public: const cl_GV_inner* vec; - uintL index; + uintC index; operator T () const; // Constructor: - cl_GV_constindex (const cl_GV_inner* v, uintL i) : vec (v), index (i) {} + cl_GV_constindex (const cl_GV_inner* v, uintC i) : vec (v), index (i) {} private: // No default constructor, assignment operator. cl_GV_constindex (); @@ -100,16 +100,16 @@ private: template struct cl_GV_vectorops { - const T (*element) (const cl_GV_inner* vec, uintL index); - void (*set_element) (cl_GV_inner* vec, uintL index, const T& x); + const T (*element) (const cl_GV_inner* vec, uintC index); + void (*set_element) (cl_GV_inner* vec, uintC index, const T& x); void (*do_delete) (cl_GV_inner* vec); - void (*copy_elements) (const cl_GV_inner* srcvec, uintL srcindex, cl_GV_inner* destvec, uintL destindex, uintL count); + void (*copy_elements) (const cl_GV_inner* srcvec, uintC srcindex, cl_GV_inner* destvec, uintC destindex, uintC count); }; // All member functions are inline. template -inline uintL cl_GV_inner::length () const +inline uintC cl_GV_inner::length () const { return len; } @@ -219,7 +219,7 @@ template struct cl_GV : public BASE { public: // Length. - uintL length () const + uintC length () const { return ((const cl_heap_GV *) this->pointer)->v.length(); } @@ -250,7 +250,7 @@ public: cl_GV& operator= (const cl_GV&); // Copy a piece of a vector into another vector. // (Both vectors must be of the same type. Overlapping not allowed.) - static void copy_elements (const cl_GV& src, uintL srcindex, cl_GV& dest, uintL destindex, uintL count) + static void copy_elements (const cl_GV& src, uintC srcindex, cl_GV& dest, uintC destindex, uintC count) { const cl_heap_GV * hsrc = (const cl_heap_GV *) src.pointer; cl_heap_GV * hdest = (cl_heap_GV *) dest.pointer; diff --git a/include/cln/GV_complex.h b/include/cln/GV_complex.h index 60cd180..d04205e 100644 --- a/include/cln/GV_complex.h +++ b/include/cln/GV_complex.h @@ -19,7 +19,7 @@ public: // Constructors. cl_GV_N (); cl_GV_N (const cl_GV_N&); - explicit cl_GV_N (uintL len); + explicit cl_GV_N (uintC len); // Assignment operators. cl_GV_N& operator= (const cl_GV_N&); // Private pointer manipulations. @@ -28,7 +28,7 @@ public: }; inline cl_GV_N::cl_GV_N (const cl_GV_N& x) : cl_GV (as_cl_private_thing(x)) {} CL_DEFINE_ASSIGNMENT_OPERATOR(cl_GV_N,cl_GV_N) -inline cl_GV_N::cl_GV_N (uintL len) +inline cl_GV_N::cl_GV_N (uintC len) : cl_GV ((cl_heap_GV_N*) cl_make_heap_GV_number(len)) {} inline cl_GV_N::cl_GV_N () : cl_GV ((cl_heap_GV_N*) (cl_heap_GV_number*) cl_null_GV_number) {} diff --git a/include/cln/GV_integer.h b/include/cln/GV_integer.h index 712c0bd..5dd2b79 100644 --- a/include/cln/GV_integer.h +++ b/include/cln/GV_integer.h @@ -17,7 +17,7 @@ template <> struct cl_heap_GV : cl_heap { cl_GV_inner v; // here room for the elements - sintL maxbits () const; + sintC maxbits () const; }; typedef cl_heap_GV cl_heap_GV_I; @@ -27,13 +27,13 @@ public: cl_GV_I (); cl_GV_I (const cl_GV_I&); // Create a vector of unconstrained integers. - explicit cl_GV_I (uintL len); + explicit cl_GV_I (uintC len); // Create a vector of m-bit integers (>=0, <2^m). - cl_GV_I (uintL len, sintL m); + cl_GV_I (uintC len, sintC m); // Assignment operators. cl_GV_I& operator= (const cl_GV_I&); // Number m of bits allowed per element (-1 if unconstrained). - sintL maxbits () const + sintC maxbits () const { return ((const cl_heap_GV_I *) pointer)->maxbits(); } @@ -43,11 +43,11 @@ public: }; inline cl_GV_I::cl_GV_I (const cl_GV_I& x) : cl_GV (as_cl_private_thing(x)) {} CL_DEFINE_ASSIGNMENT_OPERATOR(cl_GV_I,cl_GV_I) -extern cl_heap_GV_I* cl_make_heap_GV_I (uintL len); -inline cl_GV_I::cl_GV_I (uintL len) +extern cl_heap_GV_I* cl_make_heap_GV_I (uintC len); +inline cl_GV_I::cl_GV_I (uintC len) : cl_GV (cl_make_heap_GV_I(len)) {} -extern cl_heap_GV_I* cl_make_heap_GV_I (uintL len, sintL m); -inline cl_GV_I::cl_GV_I (uintL len, sintL m) +extern cl_heap_GV_I* cl_make_heap_GV_I (uintC len, sintC m); +inline cl_GV_I::cl_GV_I (uintC len, sintC m) : cl_GV (cl_make_heap_GV_I(len,m)) {} // Private pointer manipulations. Never throw away a `struct cl_heap_GV_I *'! diff --git a/include/cln/GV_modinteger.h b/include/cln/GV_modinteger.h index 4dc7ccb..8929ef4 100644 --- a/include/cln/GV_modinteger.h +++ b/include/cln/GV_modinteger.h @@ -24,11 +24,11 @@ public: cl_GV_MI (); cl_GV_MI (const cl_GV_MI&); // Create a vector of modular integers. - cl_GV_MI (uintL len, cl_heap_modint_ring* R); + cl_GV_MI (uintC len, cl_heap_modint_ring* R); // Assignment operators. cl_GV_MI& operator= (const cl_GV_MI&); // Number m of bits allowed per element (-1 if unconstrained). - sintL maxbits () const + sintC maxbits () const { return ((const cl_heap_GV_I *) pointer)->maxbits(); } @@ -37,7 +37,7 @@ inline cl_GV_MI::cl_GV_MI (const cl_GV_MI& x) : cl_GV<_cl_MI,cl_GV_any> (as_cl_p CL_DEFINE_ASSIGNMENT_OPERATOR(cl_GV_MI,cl_GV_MI) inline cl_GV_MI::cl_GV_MI () : cl_GV<_cl_MI,cl_GV_any> ((cl_heap_GV_MI*) (cl_heap_GV_I*) cl_null_GV_I) {} -inline cl_GV_MI::cl_GV_MI (uintL len, cl_heap_modint_ring* R) +inline cl_GV_MI::cl_GV_MI (uintC len, cl_heap_modint_ring* R) : cl_GV<_cl_MI,cl_GV_any> ((cl_heap_GV_MI*) cl_make_heap_GV_I(len,R->bits)) {} // Copy a vector. diff --git a/include/cln/GV_number.h b/include/cln/GV_number.h index 14d899d..29886ca 100644 --- a/include/cln/GV_number.h +++ b/include/cln/GV_number.h @@ -15,7 +15,7 @@ public: // Constructors. cl_GV_number (); cl_GV_number (const cl_GV_number&); - explicit cl_GV_number (uintL len); + explicit cl_GV_number (uintC len); // Assignment operators. cl_GV_number& operator= (const cl_GV_number&); // Private pointer manipulations. @@ -24,8 +24,8 @@ public: }; inline cl_GV_number::cl_GV_number (const cl_GV_number& x) : cl_GV (as_cl_private_thing(x)) {} CL_DEFINE_ASSIGNMENT_OPERATOR(cl_GV_number,cl_GV_number) -extern cl_heap_GV_number* cl_make_heap_GV_number (uintL len); -inline cl_GV_number::cl_GV_number (uintL len) +extern cl_heap_GV_number* cl_make_heap_GV_number (uintC len); +inline cl_GV_number::cl_GV_number (uintC len) : cl_GV (cl_make_heap_GV_number(len)) {} // Private pointer manipulations. Never throw away a `struct cl_heap_GV_number *'! diff --git a/include/cln/GV_rational.h b/include/cln/GV_rational.h index d585206..5aaa240 100644 --- a/include/cln/GV_rational.h +++ b/include/cln/GV_rational.h @@ -19,7 +19,7 @@ public: // Constructors. cl_GV_RA (); cl_GV_RA (const cl_GV_RA&); - explicit cl_GV_RA (uintL len); + explicit cl_GV_RA (uintC len); // Assignment operators. cl_GV_RA& operator= (const cl_GV_RA&); // Private pointer manipulations. @@ -28,7 +28,7 @@ public: }; inline cl_GV_RA::cl_GV_RA (const cl_GV_RA& x) : cl_GV (as_cl_private_thing(x)) {} CL_DEFINE_ASSIGNMENT_OPERATOR(cl_GV_RA,cl_GV_RA) -inline cl_GV_RA::cl_GV_RA (uintL len) +inline cl_GV_RA::cl_GV_RA (uintC len) : cl_GV ((cl_heap_GV_RA*) cl_make_heap_GV_number(len)) {} inline cl_GV_RA::cl_GV_RA () : cl_GV ((cl_heap_GV_RA*) (cl_heap_GV_number*) cl_null_GV_number) {} diff --git a/include/cln/GV_real.h b/include/cln/GV_real.h index 510b739..a57c56f 100644 --- a/include/cln/GV_real.h +++ b/include/cln/GV_real.h @@ -19,7 +19,7 @@ public: // Constructors. cl_GV_R (); cl_GV_R (const cl_GV_R&); - explicit cl_GV_R (uintL len); + explicit cl_GV_R (uintC len); // Assignment operators. cl_GV_R& operator= (const cl_GV_R&); // Private pointer manipulations. @@ -28,7 +28,7 @@ public: }; inline cl_GV_R::cl_GV_R (const cl_GV_R& x) : cl_GV (as_cl_private_thing(x)) {} CL_DEFINE_ASSIGNMENT_OPERATOR(cl_GV_R,cl_GV_R) -inline cl_GV_R::cl_GV_R (uintL len) +inline cl_GV_R::cl_GV_R (uintC len) : cl_GV ((cl_heap_GV_R*) cl_make_heap_GV_number(len)) {} inline cl_GV_R::cl_GV_R () : cl_GV ((cl_heap_GV_R*) (cl_heap_GV_number*) cl_null_GV_number) {} diff --git a/include/cln/SV.h b/include/cln/SV.h index 7c05e80..011bb13 100644 --- a/include/cln/SV.h +++ b/include/cln/SV.h @@ -40,13 +40,13 @@ template class cl_SV_inner; template class cl_SV_inner { protected: - uintL len; // number of elements + uintC len; // number of elements private: // T data[]; // the elements T * data() { return (T *) (this+1); } const T * data() const { return (const T *) (this+1); } public: - uintL length () const { return len; } // number of elements + uintC length () const { return len; } // number of elements const T & operator[] (unsigned long index) const { #ifndef CL_SV_NO_RANGECHECKS @@ -76,7 +76,7 @@ public: { return operator[]((unsigned long)index); } public: /* ugh */ // Constructor. - cl_SV_inner (uintL l) : len (l) {} + cl_SV_inner (uintC l) : len (l) {} public: // Destructor. ~cl_SV_inner (); @@ -95,7 +95,7 @@ private: template inline cl_SV_inner::~cl_SV_inner () { - uintL i = len; + uintC i = len; while (i > 0) { i--; data()[i].~T(); @@ -115,7 +115,7 @@ template struct cl_SV : public BASE { public: // Length. - uintL length () const + uintC length () const { return ((const cl_heap_SV *) this->pointer)->v.length(); } diff --git a/include/cln/SV_complex.h b/include/cln/SV_complex.h index a7272ee..6e02727 100644 --- a/include/cln/SV_complex.h +++ b/include/cln/SV_complex.h @@ -19,7 +19,7 @@ public: // Constructors. cl_SV_N () : cl_SV ((cl_heap_SV_N*) (cl_heap_SV_number*) cl_null_SV_number) {}; cl_SV_N (const cl_SV_N&); - explicit cl_SV_N (uintL len) : cl_SV ((cl_heap_SV_N*) cl_make_heap_SV_number(len)) {}; + explicit cl_SV_N (uintC len) : cl_SV ((cl_heap_SV_N*) cl_make_heap_SV_number(len)) {}; // Assignment operators. cl_SV_N& operator= (const cl_SV_N&); // Private pointer manipulations. diff --git a/include/cln/SV_integer.h b/include/cln/SV_integer.h index 4bf03d8..aca62cc 100644 --- a/include/cln/SV_integer.h +++ b/include/cln/SV_integer.h @@ -19,7 +19,7 @@ public: // Constructors. cl_SV_I () : cl_SV ((cl_heap_SV_I*) (cl_heap_SV_number*) cl_null_SV_number) {}; cl_SV_I (const cl_SV_I&); - explicit cl_SV_I (uintL len) : cl_SV ((cl_heap_SV_I*) cl_make_heap_SV_number(len)) {}; + explicit cl_SV_I (uintC len) : cl_SV ((cl_heap_SV_I*) cl_make_heap_SV_number(len)) {}; // Assignment operators. cl_SV_I& operator= (const cl_SV_I&); }; diff --git a/include/cln/SV_number.h b/include/cln/SV_number.h index 810f26c..845142d 100644 --- a/include/cln/SV_number.h +++ b/include/cln/SV_number.h @@ -16,7 +16,7 @@ public: // Constructors. cl_SV_number (); cl_SV_number (const cl_SV_number&); - explicit cl_SV_number (uintL len); + explicit cl_SV_number (uintC len); // Assignment operators. cl_SV_number& operator= (const cl_SV_number&); // Private pointer manipulations. @@ -27,10 +27,10 @@ public: inline cl_SV_number::cl_SV_number (const cl_SV_number& x) : cl_SV (as_cl_private_thing(x)) {} CL_DEFINE_ASSIGNMENT_OPERATOR(cl_SV_number,cl_SV_number) // Returns a new simple vector with uninitialized contents. -extern cl_heap_SV_number* cl_make_heap_SV_number_uninit (uintL len); +extern cl_heap_SV_number* cl_make_heap_SV_number_uninit (uintC len); // Returns a new simple vector with all elements initialized to 0. -extern cl_heap_SV_number* cl_make_heap_SV_number (uintL len); -inline cl_SV_number::cl_SV_number (uintL len) +extern cl_heap_SV_number* cl_make_heap_SV_number (uintC len); +inline cl_SV_number::cl_SV_number (uintC len) : cl_SV (cl_make_heap_SV_number(len)) {} // Private pointer manipulations. Never throw away a `struct cl_heap_SV_number *'! diff --git a/include/cln/SV_rational.h b/include/cln/SV_rational.h index 8774dee..b7003f8 100644 --- a/include/cln/SV_rational.h +++ b/include/cln/SV_rational.h @@ -19,7 +19,7 @@ public: // Constructors. cl_SV_RA () : cl_SV ((cl_heap_SV_RA*) (cl_heap_SV_number*) cl_null_SV_number) {}; cl_SV_RA (const cl_SV_RA&); - explicit cl_SV_RA (uintL len) : cl_SV ((cl_heap_SV_RA*) cl_make_heap_SV_number(len)) {}; + explicit cl_SV_RA (uintC len) : cl_SV ((cl_heap_SV_RA*) cl_make_heap_SV_number(len)) {}; // Assignment operators. cl_SV_RA& operator= (const cl_SV_RA&); // Private pointer manipulations. diff --git a/include/cln/SV_real.h b/include/cln/SV_real.h index 7a01f5f..d297022 100644 --- a/include/cln/SV_real.h +++ b/include/cln/SV_real.h @@ -19,7 +19,7 @@ public: // Constructors. cl_SV_R () : cl_SV ((cl_heap_SV_R*) (cl_heap_SV_number*) cl_null_SV_number) {}; cl_SV_R (const cl_SV_R&); - explicit cl_SV_R (uintL len) : cl_SV ((cl_heap_SV_R*) cl_make_heap_SV_number(len)) {}; + explicit cl_SV_R (uintC len) : cl_SV ((cl_heap_SV_R*) cl_make_heap_SV_number(len)) {}; // Assignment operators. cl_SV_R& operator= (const cl_SV_R&); // Private pointer manipulations. diff --git a/include/cln/SV_ringelt.h b/include/cln/SV_ringelt.h index d5ac3bb..d370afd 100644 --- a/include/cln/SV_ringelt.h +++ b/include/cln/SV_ringelt.h @@ -16,7 +16,7 @@ public: // Constructors. cl_SV_ringelt (); cl_SV_ringelt (const cl_SV_ringelt&); - explicit cl_SV_ringelt (uintL len); + explicit cl_SV_ringelt (uintC len); // Assignment operators. cl_SV_ringelt& operator= (const cl_SV_ringelt&); // Private pointer manipulations. @@ -27,10 +27,10 @@ public: inline cl_SV_ringelt::cl_SV_ringelt (const cl_SV_ringelt& x) : cl_SV<_cl_ring_element,cl_SV_any> (as_cl_private_thing(x)) {} CL_DEFINE_ASSIGNMENT_OPERATOR(cl_SV_ringelt,cl_SV_ringelt) // Returns a new simple vector with uninitialized contents. -extern cl_heap_SV_ringelt* cl_make_heap_SV_ringelt_uninit (uintL len); +extern cl_heap_SV_ringelt* cl_make_heap_SV_ringelt_uninit (uintC len); // Returns a new simple vector with all elements initialized to some value. -extern cl_heap_SV_ringelt* cl_make_heap_SV_ringelt (uintL len); -inline cl_SV_ringelt::cl_SV_ringelt (uintL len) +extern cl_heap_SV_ringelt* cl_make_heap_SV_ringelt (uintC len); +inline cl_SV_ringelt::cl_SV_ringelt (uintC len) : cl_SV<_cl_ring_element,cl_SV_any> (cl_make_heap_SV_ringelt(len)) {} // Private pointer manipulations. diff --git a/include/cln/dfloat.h b/include/cln/dfloat.h index fde8a80..2b9d0c7 100644 --- a/include/cln/dfloat.h +++ b/include/cln/dfloat.h @@ -256,12 +256,12 @@ inline sintL float_radix (const cl_DF& x) extern const cl_DF float_sign (const cl_DF& x); // float_digits(x) liefert (float-digits x), wo x ein Float ist. -// < ergebnis: ein uintL >0 -extern uintL float_digits (const cl_DF& x); +// < ergebnis: ein uintC >0 +extern uintC float_digits (const cl_DF& x); // float_precision(x) liefert (float-precision x), wo x ein Float ist. -// < ergebnis: ein uintL >=0 -extern uintL float_precision (const cl_DF& x); +// < ergebnis: ein uintC >=0 +extern uintC float_precision (const cl_DF& x); // integer_decode_float(x) liefert zu einem Float x: (integer-decode-float x). @@ -272,7 +272,7 @@ extern const cl_idecoded_float integer_decode_float (const cl_DF& x); // scale_float(x,delta) liefert x*2^delta, wo x ein DF ist. -extern const cl_DF scale_float (const cl_DF& x, sintL delta); +extern const cl_DF scale_float (const cl_DF& x, sintC delta); extern const cl_DF scale_float (const cl_DF& x, const cl_I& delta); diff --git a/include/cln/ffloat.h b/include/cln/ffloat.h index 0644108..d690327 100644 --- a/include/cln/ffloat.h +++ b/include/cln/ffloat.h @@ -256,12 +256,12 @@ inline sintL float_radix (const cl_FF& x) extern const cl_FF float_sign (const cl_FF& x); // float_digits(x) liefert (float-digits x), wo x ein Float ist. -// < ergebnis: ein uintL >0 -extern uintL float_digits (const cl_FF& x); +// < ergebnis: ein uintC >0 +extern uintC float_digits (const cl_FF& x); // float_precision(x) liefert (float-precision x), wo x ein Float ist. -// < ergebnis: ein uintL >=0 -extern uintL float_precision (const cl_FF& x); +// < ergebnis: ein uintC >=0 +extern uintC float_precision (const cl_FF& x); // integer_decode_float(x) liefert zu einem Float x: (integer-decode-float x). @@ -272,7 +272,7 @@ extern const cl_idecoded_float integer_decode_float (const cl_FF& x); // scale_float(x,delta) liefert x*2^delta, wo x ein FF ist. -extern const cl_FF scale_float (const cl_FF& x, sintL delta); +extern const cl_FF scale_float (const cl_FF& x, sintC delta); extern const cl_FF scale_float (const cl_FF& x, const cl_I& delta); diff --git a/include/cln/float.h b/include/cln/float.h index 471cb36..4f9945c 100644 --- a/include/cln/float.h +++ b/include/cln/float.h @@ -467,12 +467,12 @@ extern const cl_F float_sign (const cl_F& x); extern const cl_F float_sign (const cl_F& x, const cl_F& y); // float_digits(x) liefert (float-digits x), wo x ein Float ist. -// < ergebnis: ein uintL >0 -extern uintL float_digits (const cl_F& x); +// < ergebnis: ein uintC >0 +extern uintC float_digits (const cl_F& x); // float_precision(x) liefert (float-precision x), wo x ein Float ist. -// < ergebnis: ein uintL >=0 -extern uintL float_precision (const cl_F& x); +// < ergebnis: ein uintC >=0 +extern uintC float_precision (const cl_F& x); // Returns the floating point format of a float. inline float_format_t float_format (const cl_F& x) @@ -491,7 +491,7 @@ extern const cl_RA rational (const cl_F& x); // scale_float(x,delta) liefert x*2^delta, wo x ein Float ist. -extern const cl_F scale_float (const cl_F& x, sintL delta); +extern const cl_F scale_float (const cl_F& x, sintC delta); extern const cl_F scale_float (const cl_F& x, const cl_I& delta); diff --git a/include/cln/integer.h b/include/cln/integer.h index d5a8eb3..72b848f 100644 --- a/include/cln/integer.h +++ b/include/cln/integer.h @@ -127,7 +127,7 @@ extern cl_boolean logtest (const cl_I& x, const cl_I& y); // Prüft, ob (LOGBITP x y), wo x und y Integers sind. // Ergebnis: /=0, wenn ja; =0, wenn nein. -extern cl_boolean logbitp (uintL x, const cl_I& y); +extern cl_boolean logbitp (uintC x, const cl_I& y); extern cl_boolean logbitp (const cl_I& x, const cl_I& y); // Prüft, ob (ODDP x), wo x ein Integer ist. @@ -140,21 +140,21 @@ inline cl_boolean evenp (const cl_I& x) { return (cl_boolean) (!oddp(x)); } // (ASH x y), wo x und y Integers sind. Ergebnis Integer. -extern const cl_I ash (const cl_I& x, sintL y); +extern const cl_I ash (const cl_I& x, sintC y); extern const cl_I ash (const cl_I& x, const cl_I& y); // (LOGCOUNT x), wo x ein Integer ist. Ergebnis uintL. -extern uintL logcount (const cl_I& x); +extern uintC logcount (const cl_I& x); // (INTEGER-LENGTH x), wo x ein Integer ist. Ergebnis uintL. -extern uintL integer_length (const cl_I& x); +extern uintC integer_length (const cl_I& x); // (ORD2 x) = max{n>=0: 2^n | x }, wo x ein Integer /=0 ist. Ergebnis uintL. -extern uintL ord2 (const cl_I& x); +extern uintC ord2 (const cl_I& x); // power2p(x) stellt fest, ob ein Integer x>0 eine Zweierpotenz ist. // Ergebnis: n>0, wenn x=2^(n-1), 0 sonst. -extern uintL power2p (const cl_I& x); +extern uintC power2p (const cl_I& x); inline const cl_I operator| (const cl_I& x, const cl_I& y) { return logior(x,y); } @@ -227,11 +227,11 @@ inline const cl_I operator- (const cl_I& x, const unsigned long y) extern const cl_I abs (const cl_I& x); // Shifts. -inline const cl_I operator<< (const cl_I& x, sintL y) // assume 0 <= y < 2^31 +inline const cl_I operator<< (const cl_I& x, sintC y) // assume 0 <= y < 2^(intCsize-1) { return ash(x,y); } inline const cl_I operator<< (const cl_I& x, const cl_I& y) // assume y >= 0 { return ash(x,y); } -inline const cl_I operator>> (const cl_I& x, sintL y) // assume 0 <= y < 2^31 +inline const cl_I operator>> (const cl_I& x, sintC y) // assume 0 <= y < 2^(intCsize-1) { return ash(x,-y); } inline const cl_I operator>> (const cl_I& x, const cl_I& y) // assume y >= 0 { return ash(x,-y); } @@ -274,10 +274,10 @@ extern cl_boolean zerop (const cl_I& x); // BYTE-Operationen auf Integers struct cl_byte { - uintL size; - uintL position; + uintC size; + uintC position; // Konstruktor: - cl_byte (unsigned int s, unsigned int p) : size (s), position (p) {} + cl_byte (uintC s, uintC p) : size (s), position (p) {} }; // (LDB byte n), wo n ein Integer ist. @@ -562,11 +562,11 @@ inline cl_I& operator-= (cl_I& x, const unsigned long y) { return x = x - y; } inline cl_I& operator-- /* prefix */ (cl_I& x) { return x = minus1(x); } inline void operator-- /* postfix */ (cl_I& x, int dummy) { (void)dummy; x = minus1(x); } inline cl_I& operator*= (cl_I& x, const cl_I& y) { return x = x * y; } -inline cl_I& operator<<= (cl_I& x, sintL y) // assume 0 <= y < 2^31 +inline cl_I& operator<<= (cl_I& x, sintC y) // assume 0 <= y < 2^(intCsize-1) { return x = x << y; } inline cl_I& operator<<= (cl_I& x, const cl_I& y) // assume y >= 0 { return x = x << y; } -inline cl_I& operator>>= (cl_I& x, sintL y) // assume 0 <= y < 2^31 +inline cl_I& operator>>= (cl_I& x, sintC y) // assume 0 <= y < 2^(intCsize-1) { return x = x >> y; } inline cl_I& operator>>= (cl_I& x, const cl_I& y) // assume y >= 0 { return x = x >> y; } diff --git a/include/cln/lfloat.h b/include/cln/lfloat.h index 440151b..24041d8 100644 --- a/include/cln/lfloat.h +++ b/include/cln/lfloat.h @@ -346,12 +346,12 @@ inline sintL float_radix (const cl_LF& x) extern const cl_LF float_sign (const cl_LF& x); // float_digits(x) liefert (float-digits x), wo x ein Float ist. -// < ergebnis: ein uintL >0 -extern uintL float_digits (const cl_LF& x); +// < ergebnis: ein uintC >0 +extern uintC float_digits (const cl_LF& x); // float_precision(x) liefert (float-precision x), wo x ein Float ist. -// < ergebnis: ein uintL >=0 -extern uintL float_precision (const cl_LF& x); +// < ergebnis: ein uintC >=0 +extern uintC float_precision (const cl_LF& x); // integer_decode_float(x) liefert zu einem Float x: (integer-decode-float x). @@ -362,7 +362,7 @@ extern const cl_idecoded_float integer_decode_float (const cl_LF& x); // scale_float(x,delta) liefert x*2^delta, wo x ein LF ist. -extern const cl_LF scale_float (const cl_LF& x, sintL delta); +extern const cl_LF scale_float (const cl_LF& x, sintC delta); extern const cl_LF scale_float (const cl_LF& x, const cl_I& delta); diff --git a/include/cln/modinteger.h b/include/cln/modinteger.h index 59ae42f..90647ca 100644 --- a/include/cln/modinteger.h +++ b/include/cln/modinteger.h @@ -342,7 +342,7 @@ public: return _retract(x); } // Miscellaneous. - sintL bits; // number of bits needed to represent a representative, or -1 + sintC bits; // number of bits needed to represent a representative, or -1 int log2_bits; // log_2(bits), or -1 // Property operations. cl_property* get_property (const cl_symbol& key) @@ -389,8 +389,8 @@ inline const cl_MI operator- (const cl_I& x, const cl_MI& y) { return y.ring()->minus(y.ring()->canonhom(x),y); } // Shifts. -extern const cl_MI operator<< (const cl_MI& x, sintL y); // assume 0 <= y < 2^31 -extern const cl_MI operator>> (const cl_MI& x, sintL y); // assume m odd, 0 <= y < 2^31 +extern const cl_MI operator<< (const cl_MI& x, sintC y); // assume 0 <= y < 2^(intCsize-1) +extern const cl_MI operator>> (const cl_MI& x, sintC y); // assume m odd, 0 <= y < 2^(intCsize-1) // Equality. inline bool operator== (const cl_MI& x, const cl_MI& y) diff --git a/include/cln/sfloat.h b/include/cln/sfloat.h index cb3aa96..a95d65f 100644 --- a/include/cln/sfloat.h +++ b/include/cln/sfloat.h @@ -236,12 +236,12 @@ inline sintL float_radix (const cl_SF& x) extern const cl_SF float_sign (const cl_SF& x); // float_digits(x) liefert (float-digits x), wo x ein Float ist. -// < ergebnis: ein uintL >0 -extern uintL float_digits (const cl_SF& x); +// < ergebnis: ein uintC >0 +extern uintC float_digits (const cl_SF& x); // float_precision(x) liefert (float-precision x), wo x ein Float ist. -// < ergebnis: ein uintL >=0 -extern uintL float_precision (const cl_SF& x); +// < ergebnis: ein uintC >=0 +extern uintC float_precision (const cl_SF& x); // integer_decode_float(x) liefert zu einem Float x: (integer-decode-float x). @@ -252,7 +252,7 @@ extern const cl_idecoded_float integer_decode_float (const cl_SF& x); // scale_float(x,delta) liefert x*2^delta, wo x ein SF ist. -extern const cl_SF scale_float (const cl_SF& x, sintL delta); +extern const cl_SF scale_float (const cl_SF& x, sintC delta); extern const cl_SF scale_float (const cl_SF& x, const cl_I& delta); diff --git a/include/cln/types.h b/include/cln/types.h index 1f956a4..d23fcc7 100644 --- a/include/cln/types.h +++ b/include/cln/types.h @@ -85,6 +85,7 @@ #define signean_minus -1 // Integer type used for counters. +// Constraint: sizeof(uintC) >= sizeof(uintL) #if (defined(HAVE_FAST_LONGLONG) && (defined(__alpha__) || defined(__ia64__) || defined(__powerpc64__) || defined(__x86_64__))) #define intCsize long_bitsize typedef long sintC; diff --git a/src/base/cl_low.h b/src/base/cl_low.h index 03dbfed..98b371e 100644 --- a/src/base/cl_low.h +++ b/src/base/cl_low.h @@ -1430,6 +1430,18 @@ inline uint32 mulu32_unchecked (uint32 arg1, uint32 arg2) } #endif +// Bits einer uintC-Zahl zählen: +// integerlengthC(digit,size=); +// setzt size auf die höchste in digit vorkommende Bitnummer. +// > digit: ein uintC >0 +// < size: >0, <=intCsize, mit 2^(size-1) <= digit < 2^size + #if (intCsize==32) + #define integerlengthC integerlength32 + #endif + #if (intCsize==64) + #define integerlengthC integerlength64 + #endif + // Hintere Nullbits eines 32-Bit-Wortes zählen: // ord2_32(digit,count=); // setzt size auf die kleinste in digit vorkommende Bitnummer. diff --git a/src/base/digitseq/cl_2DS_div.cc b/src/base/digitseq/cl_2DS_div.cc index 8730623..5d0738e 100644 --- a/src/base/digitseq/cl_2DS_div.cc +++ b/src/base/digitseq/cl_2DS_div.cc @@ -55,12 +55,12 @@ namespace cln { // // Break-even-point. When in doubt, prefer to choose the standard algorithm. #if CL_USE_GMP - static inline cl_boolean cl_recip_suitable (uintL m, uintL n) // n <= m + static inline cl_boolean cl_recip_suitable (uintC m, uintC n) // n <= m { if (n < 2000) return cl_false; else // when n >= 4400/(m/n)^2, i.e. (m/66)^2 > n - { var uintL mq = floor(m,66); - if ((mq >= bit(16)) || ((uintL)(mq*mq) > n)) + { var uintC mq = floor(m,66); + if ((mq >= bit(intCsize/2)) || (mq*mq > n)) return cl_true; else return cl_false; @@ -93,12 +93,12 @@ namespace cln { // 1.8*N / N : Newton for N >= 500 // 1.9*N / N : Newton for N >= 500 // 2.0*N / N : Newton for N >= 500 - static inline cl_boolean cl_recip_suitable (uintL m, uintL n) // n <= m + static inline cl_boolean cl_recip_suitable (uintC m, uintC n) // n <= m { if (n < 500) return cl_false; else // when n >= 2100/(m/n)^2, i.e. (m/46)^2 > n - { var uintL mq = floor(m,46); - if ((mq >= bit(16)) || ((uintL)(mq*mq) > n)) + { var uintC mq = floor(m,46); + if ((mq >= bit(intCsize/2)) || (mq*mq > n)) return cl_true; else return cl_false; diff --git a/src/base/digitseq/cl_2DS_recip.cc b/src/base/digitseq/cl_2DS_recip.cc index 8ae8621..a6b96c8 100644 --- a/src/base/digitseq/cl_2DS_recip.cc +++ b/src/base/digitseq/cl_2DS_recip.cc @@ -31,7 +31,7 @@ void recip2adic (uintC len, const uintD* a_LSDptr, uintD* dest_LSDptr) // return 2*b-a*b^2 mod 2^(intDsize*2*n). CL_ALLOCA_STACK; var uintL k = 0; // number of Newton steps - var uintL n = len; + var uintC n = len; while (n >= recip2adic_threshold) { n = ceiling(n,2); k++; @@ -47,13 +47,13 @@ void recip2adic (uintC len, const uintD* a_LSDptr, uintD* dest_LSDptr) var uintD* b2_LSDptr; var uintD* prod_LSDptr; num_stack_alloc(len+1,,b2_LSDptr=); - num_stack_alloc(2*(uintL)len,,prod_LSDptr=); + num_stack_alloc(2*len,,prod_LSDptr=); do { // n = ceiling(len/2^k) // Compute n2 = ceiling(len/2^(k-1)), // then n = ceiling(n2/2). k--; - var uintL n2 = ((len-1)>>k)+1; // = 2*n or = 2*n-1 + var uintC n2 = ((len-1)>>k)+1; // = 2*n or = 2*n-1 // Set b := 2*b-a*b^2 mod 2^(intDsize*n2) cl_UDS_mul_square(dest_LSDptr,n,b2_LSDptr); // b^2 cl_UDS_mul(b2_LSDptr,n2,a_LSDptr,n2,prod_LSDptr); // a*b^2 diff --git a/src/base/digitseq/cl_DS.h b/src/base/digitseq/cl_DS.h index 246ccd8..a9a5b84 100644 --- a/src/base/digitseq/cl_DS.h +++ b/src/base/digitseq/cl_DS.h @@ -2489,12 +2489,12 @@ inline uintD divucopy_loop_down (uintD digit, const uintD* sourceptr, uintD* des // zusätzlich belegt wird. #define num_stack_array(need,low_zuweisung,high_zuweisung) \ - {var uintL __need = (uintL)(need); \ + {var uintC __need = (uintC)(need); \ var uintD* __array = cl_alloc_array(uintD,__need); \ unused (low_zuweisung &__array[0]); unused (high_zuweisung &__array[__need]); \ } #define num_stack_small_array(need,low_zuweisung,high_zuweisung) \ - {var uintL __need = (uintL)(need); \ + {var uintC __need = (uintC)(need); \ var uintD* __array = cl_small_alloc_array(uintD,__need); \ unused (low_zuweisung &__array[0]); unused (high_zuweisung &__array[__need]); \ } @@ -2504,18 +2504,18 @@ inline uintD divucopy_loop_down (uintD digit, const uintD* sourceptr, uintD* des #define num_stack_small_alloc(need,MSDptr_zuweisung,LSDptr_zuweisung) \ num_stack_small_array(need,MSDptr_zuweisung,LSDptr_zuweisung) #define num_stack_alloc_1(need,MSDptr_zuweisung,LSDptr_zuweisung) \ - num_stack_array((uintL)(need)+1,MSDptr_zuweisung 1 + ,LSDptr_zuweisung) + num_stack_array((uintC)(need)+1,MSDptr_zuweisung 1 + ,LSDptr_zuweisung) #define num_stack_small_alloc_1(need,MSDptr_zuweisung,LSDptr_zuweisung) \ - num_stack_small_array((uintL)(need)+1,MSDptr_zuweisung 1 + ,LSDptr_zuweisung) + num_stack_small_array((uintC)(need)+1,MSDptr_zuweisung 1 + ,LSDptr_zuweisung) #else #define num_stack_alloc(need,MSDptr_zuweisung,LSDptr_zuweisung) \ num_stack_array(need,LSDptr_zuweisung,MSDptr_zuweisung) #define num_stack_small_alloc(need,MSDptr_zuweisung,LSDptr_zuweisung) \ num_stack_small_array(need,LSDptr_zuweisung,MSDptr_zuweisung) #define num_stack_alloc_1(need,MSDptr_zuweisung,LSDptr_zuweisung) \ - num_stack_array((uintL)(need)+1,LSDptr_zuweisung,MSDptr_zuweisung -1 + ) + num_stack_array((uintC)(need)+1,LSDptr_zuweisung,MSDptr_zuweisung -1 + ) #define num_stack_small_alloc_1(need,MSDptr_zuweisung,LSDptr_zuweisung) \ - num_stack_small_array((uintL)(need)+1,LSDptr_zuweisung,MSDptr_zuweisung -1 + ) + num_stack_small_array((uintC)(need)+1,LSDptr_zuweisung,MSDptr_zuweisung -1 + ) #endif @@ -2585,7 +2585,7 @@ extern void cl_UDS_mul_square (const uintD* sourceptr, uintC len, // Ergebnis ist die UDS MSDptr/len/LSDptr, mit len=len1+len2, im Stack. // Dabei wird num_stack erniedrigt. #define UDS_UDS_mul_UDS(len1,LSDptr1,len2,LSDptr2, MSDptr_zuweisung,len_zuweisung,LSDptr_zuweisung) \ - var uintL CONCAT(len_from_UDSmul_,__LINE__) = (uintL)(len1) + (uintL)(len2); \ + var uintC CONCAT(len_from_UDSmul_,__LINE__) = (uintC)(len1) + (uintC)(len2); \ var uintD* CONCAT(LSDptr_from_UDSmul_,__LINE__); \ unused (len_zuweisung CONCAT(len_from_UDSmul_,__LINE__)); \ num_stack_alloc(CONCAT(len_from_UDSmul_,__LINE__),MSDptr_zuweisung,LSDptr_zuweisung CONCAT(LSDptr_from_UDSmul_,__LINE__) =); \ @@ -2611,13 +2611,13 @@ extern void cl_UDS_mul_square (const uintD* sourceptr, uintC len, #define DS_DS_mul_DS(MSDptr1,len1,LSDptr1,MSDptr2,len2,LSDptr2, MSDptr_zuweisung,len_zuweisung,LSDptr_zuweisung) \ var uintD* MSDptr0; \ var uintD* LSDptr0; \ - var uintL len_from_DSmal = (uintL)(len1) + (uintL)(len2); \ + var uintC len_from_DSmal = (uintC)(len1) + (uintC)(len2); \ unused (len_zuweisung len_from_DSmal); \ num_stack_alloc(len_from_DSmal,MSDptr_zuweisung MSDptr0 =,LSDptr_zuweisung LSDptr0 =); \ var uintD MSD1_from_DSmal = mspref(MSDptr1,0); \ var uintD MSD2_from_DSmal = mspref(MSDptr2,0); \ - var uintL len1_from_DSmal = (len1); \ - var uintL len2_from_DSmal = (len2); \ + var uintC len1_from_DSmal = (len1); \ + var uintC len2_from_DSmal = (len2); \ if (MSD1_from_DSmal==0) { msprefnext(MSDptr0) = 0; len1_from_DSmal--; } \ if (MSD2_from_DSmal==0) { msprefnext(MSDptr0) = 0; len2_from_DSmal--; } \ cl_UDS_mul((LSDptr1),len1_from_DSmal,(LSDptr2),len2_from_DSmal,LSDptr0); \ diff --git a/src/base/digitseq/cl_DS_mul.cc b/src/base/digitseq/cl_DS_mul.cc index e1f94a4..5400e7f 100644 --- a/src/base/digitseq/cl_DS_mul.cc +++ b/src/base/digitseq/cl_DS_mul.cc @@ -354,15 +354,20 @@ namespace cln { const unsigned int cl_fftm_threshold2 = 2*cl_fftm_threshold; // len1 > cl_fftm_threshold1 && len2 > cl_fftm_threshold2 // && len1 >= cl_fftm_threshold1 + cl_fftm_threshold/(len2-cl_fftm_threshold1)*(cl_fftm_threshold-cl_fftm_threshold1). - static inline cl_boolean cl_fftm_suitable (uintL len1, uintL len2) + static inline cl_boolean cl_fftm_suitable (uintC len1, uintC len2) { if (len1 >= cl_fftm_threshold) return cl_true; if (len1 > cl_fftm_threshold1) if (len2 > cl_fftm_threshold2) - { var uint32 hi; + { const unsigned int prod_threshold = cl_fftm_threshold*(cl_fftm_threshold-cl_fftm_threshold1); + if (len1-cl_fftm_threshold1 >= prod_threshold) + return cl_true; + if (len2-cl_fftm_threshold1 >= prod_threshold) + return cl_true; + var uint32 hi; var uint32 lo; mulu32(len1-cl_fftm_threshold1,len2-cl_fftm_threshold1, hi=,lo=); - if (hi > 0 || lo >= cl_fftm_threshold*(cl_fftm_threshold-cl_fftm_threshold1)) + if (hi > 0 || lo >= prod_threshold) return cl_true; } return cl_false; diff --git a/src/base/digitseq/cl_DS_mul_fftc.h b/src/base/digitseq/cl_DS_mul_fftc.h index 0c1e7ca..5d6eeae 100644 --- a/src/base/digitseq/cl_DS_mul_fftc.h +++ b/src/base/digitseq/cl_DS_mul_fftc.h @@ -384,9 +384,9 @@ static inline void mul (const fftc_complex& a, const fftc_complex& b, fftc_compl #ifndef _BIT_REVERSE #define _BIT_REVERSE // Reverse an n-bit number x. n>0. -static uintL bit_reverse (uintL n, uintL x) +static uintC bit_reverse (uintL n, uintC x) { - var uintL y = 0; + var uintC y = 0; do { y <<= 1; y |= (x & 1); @@ -397,7 +397,7 @@ static uintL bit_reverse (uintL n, uintL x) #endif // Compute a complex convolution using FFT: z[0..N-1] := x[0..N-1] * y[0..N-1]. -static void fftc_convolution (const uintL n, const uintL N, // N = 2^n +static void fftc_convolution (const uintL n, const uintC N, // N = 2^n fftc_complex * x, // N numbers fftc_complex * y, // N numbers fftc_complex * z // N numbers result @@ -409,7 +409,7 @@ static void fftc_convolution (const uintL n, const uintL N, // N = 2^n #else var fftc_complex* const w = cl_alloc_array(fftc_complex,(N>>1)+1); #endif - var uintL i; + var uintC i; // Initialize w[i] to w^i, w a primitive N-th root of unity. w[0] = fftc_roots_of_1[0]; #if (FFTC_BACKWARD == RECIPROOT) || defined(DEBUG_FFTC) @@ -478,10 +478,10 @@ static void fftc_convolution (const uintL n, const uintL N, // N = 2^n { var sintL l; /* l = n-1 */ { - var const uintL tmax = N>>1; // tmax = 2^(n-1) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var const uintC tmax = N>>1; // tmax = 2^(n-1) + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Butterfly: replace (x(i1),x(i2)) by // (x(i1) + x(i2), x(i1) - x(i2)). var fftc_complex tmp; @@ -491,13 +491,13 @@ static void fftc_convolution (const uintL n, const uintL N, // N = 2^n } } for (l = n-2; l>=0; l--) { - var const uintL smax = (uintL)1 << (n-1-l); - var const uintL tmax = (uintL)1 << l; - for (var uintL s = 0; s < smax; s++) { - var uintL exp = bit_reverse(n-1-l,s) << l; - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + var const uintC smax = (uintC)1 << (n-1-l); + var const uintC tmax = (uintC)1 << l; + for (var uintC s = 0; s < smax; s++) { + var uintC exp = bit_reverse(n-1-l,s) << l; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Butterfly: replace (x(i1),x(i2)) by // (x(i1) + w^exp*x(i2), x(i1) - w^exp*x(i2)). var fftc_complex tmp; @@ -512,10 +512,10 @@ static void fftc_convolution (const uintL n, const uintL N, // N = 2^n if (!squaring) { var sintL l; /* l = n-1 */ { - var uintL const tmax = N>>1; // tmax = 2^(n-1) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var uintC const tmax = N>>1; // tmax = 2^(n-1) + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Butterfly: replace (y(i1),y(i2)) by // (y(i1) + y(i2), y(i1) - y(i2)). var fftc_complex tmp; @@ -525,13 +525,13 @@ static void fftc_convolution (const uintL n, const uintL N, // N = 2^n } } for (l = n-2; l>=0; l--) { - var const uintL smax = (uintL)1 << (n-1-l); - var const uintL tmax = (uintL)1 << l; - for (var uintL s = 0; s < smax; s++) { - var uintL exp = bit_reverse(n-1-l,s) << l; - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + var const uintC smax = (uintC)1 << (n-1-l); + var const uintC tmax = (uintC)1 << l; + for (var uintC s = 0; s < smax; s++) { + var uintC exp = bit_reverse(n-1-l,s) << l; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Butterfly: replace (y(i1),y(i2)) by // (y(i1) + w^exp*y(i2), y(i1) - w^exp*y(i2)). var fftc_complex tmp; @@ -549,18 +549,18 @@ static void fftc_convolution (const uintL n, const uintL N, // N = 2^n { var uintL l; for (l = 0; l < n-1; l++) { - var const uintL smax = (uintL)1 << (n-1-l); - var const uintL tmax = (uintL)1 << l; + var const uintC smax = (uintC)1 << (n-1-l); + var const uintC tmax = (uintC)1 << l; #if FFTC_BACKWARD != CLEVER - for (var uintL s = 0; s < smax; s++) { - var uintL exp = bit_reverse(n-1-l,s) << l; + for (var uintC s = 0; s < smax; s++) { + var uintC exp = bit_reverse(n-1-l,s) << l; #if FFTC_BACKWARD == RECIPROOT if (exp > 0) exp = N - exp; // negate exp (use w^-1 instead of w) #endif - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (z(i1),z(i2)) by // ((z(i1)+z(i2))/2, (z(i1)-z(i2))/(2*w^exp)). // Do the division by 2 later. @@ -574,9 +574,9 @@ static void fftc_convolution (const uintL n, const uintL N, // N = 2^n } #else // FFTC_BACKWARD == CLEVER: clever handling of negative exponents /* s = 0, exp = 0 */ { - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (z(i1),z(i2)) by // ((z(i1)+z(i2))/2, (z(i1)-z(i2))/(2*w^exp)), // with exp <-- 0. @@ -589,12 +589,12 @@ static void fftc_convolution (const uintL n, const uintL N, // N = 2^n z[i2] = diff; } } - for (var uintL s = 1; s < smax; s++) { - var uintL exp = bit_reverse(n-1-l,s) << l; + for (var uintC s = 1; s < smax; s++) { + var uintC exp = bit_reverse(n-1-l,s) << l; exp = (N>>1) - exp; // negate exp (use w^-1 instead of w) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (z(i1),z(i2)) by // ((z(i1)+z(i2))/2, (z(i1)-z(i2))/(2*w^exp)), // with exp <-- (N/2 - exp). @@ -611,10 +611,10 @@ static void fftc_convolution (const uintL n, const uintL N, // N = 2^n } /* l = n-1 */ { var const fftc_real pow2 = (fftc_real)1 / (fftc_real)N; - var const uintL tmax = N>>1; // tmax = 2^(n-1) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var const uintC tmax = N>>1; // tmax = 2^(n-1) + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (z(i1),z(i2)) by // ((z(i1)+z(i2))/2, (z(i1)-z(i2))/2). // Do all the divisions by 2 now. @@ -656,10 +656,10 @@ static int max_l_table[32+1] = // Split len uintD's below sourceptr into chunks of l bits, thus filling // N complex numbers at x. -static void fill_factor (uintL N, fftc_complex* x, uintL l, - const uintD* sourceptr, uintL len) +static void fill_factor (uintC N, fftc_complex* x, uintL l, + const uintD* sourceptr, uintC len) { - var uintL i; + var uintC i; if (max_l(2) > intDsize && l > intDsize) { // l > intDsize if (max_l(2) > 64 && l > 64) { @@ -784,11 +784,11 @@ static inline fftc_real fftc_ffloor (fftc_real x) // The z[i] are known to be approximately integers >= 0, < N*2^(2*l). // Assumes room for floor(N*l/intDsize)+(1+ceiling((n+2*l)/intDsize)) uintD's // below destptr. Fills len digits and returns (destptr lspop len). -static uintD* unfill_product (uintL n, uintL N, // N = 2^n +static uintD* unfill_product (uintL n, uintC N, // N = 2^n const fftc_complex * z, uintL l, uintD* destptr) { - var uintL i; + var uintC i; if (n + 2*l <= intDsize) { // 2-digit carry is sufficient, l < intDsize var uintD carry0 = 0; @@ -934,11 +934,11 @@ static inline void mulu_fftcomplex_nocheck (const uintD* sourceptr1, uintC len1, // is 2*len1*intDsize/l_max - 1 <= 2^k. { var const int l = max_l(2); - var uintL lhs = 2*ceiling((uintL)len1*intDsize,l) - 1; // >=1 + var uintC lhs = 2*ceiling(len1*intDsize,l) - 1; // >=1 if (lhs < 3) k = 2; else - integerlength32(lhs-1, k=); // k>=2 + integerlengthC(lhs-1, k=); // k>=2 } // Try whether this k is ok or whether we have to increase k. for ( ; ; k++) { @@ -947,22 +947,22 @@ static inline void mulu_fftcomplex_nocheck (const uintD* sourceptr1, uintC len1, fprint(std::cerr, "FFT problem: numbers too big, floating point precision not sufficient\n"); cl_abort(); } - if (2*ceiling((uintL)len1*intDsize,max_l_table[k])-1 <= ((uintL)1 << k)) + if (2*ceiling(len1*intDsize,max_l_table[k])-1 <= ((uintC)1 << k)) break; } // We could try to reduce l, keeping the same k. But why should we? // Calculate the number of pieces in which source2 will have to be // split. Each of the pieces must satisfy // ceiling(len1*intDsize/l) + ceiling(len2*intDsize/l) - 1 <= 2^k, - var uintL len2p; + var uintC len2p; // Try once with k, once with k+1. Compare them. { - var uintL remaining_k = ((uintL)1 << k) + 1 - ceiling((uintL)len1*intDsize,max_l_table[k]); - var uintL max_piecelen_k = floor(remaining_k*max_l_table[k],intDsize); - var uintL numpieces_k = ceiling(len2,max_piecelen_k); - var uintL remaining_k1 = ((uintL)1 << (k+1)) + 1 - ceiling((uintL)len1*intDsize,max_l_table[k+1]); - var uintL max_piecelen_k1 = floor(remaining_k1*max_l_table[k+1],intDsize); - var uintL numpieces_k1 = ceiling(len2,max_piecelen_k1); + var uintC remaining_k = ((uintC)1 << k) + 1 - ceiling(len1*intDsize,max_l_table[k]); + var uintC max_piecelen_k = floor(remaining_k*max_l_table[k],intDsize); + var uintC numpieces_k = ceiling(len2,max_piecelen_k); + var uintC remaining_k1 = ((uintC)1 << (k+1)) + 1 - ceiling(len1*intDsize,max_l_table[k+1]); + var uintC max_piecelen_k1 = floor(remaining_k1*max_l_table[k+1],intDsize); + var uintC numpieces_k1 = ceiling(len2,max_piecelen_k1); if (numpieces_k <= 2*numpieces_k1) { // keep k len2p = max_piecelen_k; @@ -974,7 +974,7 @@ static inline void mulu_fftcomplex_nocheck (const uintD* sourceptr1, uintC len1, } var const uintL l = max_l_table[k]; var const uintL n = k; - var const uintL N = (uintL)1 << n; + var const uintC N = (uintC)1 << n; CL_ALLOCA_STACK; var fftc_complex* const x = cl_alloc_array(fftc_complex,N); var fftc_complex* const y = cl_alloc_array(fftc_complex,N); @@ -984,9 +984,9 @@ static inline void mulu_fftcomplex_nocheck (const uintD* sourceptr1, uintC len1, var fftc_complex* const z = x; // put z in place of x - saves memory #endif var uintD* const tmpprod1 = cl_alloc_array(uintD,len1+1); - var uintL tmpprod_len = floor(l< len2) @@ -1017,7 +1017,7 @@ static inline void mulu_fftcomplex_nocheck (const uintD* sourceptr1, uintC len1, var fftc_real re_hi_limit = (fftc_real)N * fftc_pow2_table[l] * fftc_pow2_table[l] + (fftc_real)0.5; var fftc_real im_lo_limit = (fftc_real)(-0.5); var fftc_real im_hi_limit = (fftc_real)0.5; - for (var uintL i = 0; i < N; i++) { + for (var uintC i = 0; i < N; i++) { if (!(z[i].im > im_lo_limit && z[i].im < im_hi_limit)) cl_abort(); @@ -1029,7 +1029,7 @@ static inline void mulu_fftcomplex_nocheck (const uintD* sourceptr1, uintC len1, #endif var uintD* tmpLSDptr = arrayLSDptr(tmpprod,tmpprod_len); var uintD* tmpMSDptr = unfill_product(n,N,z,l,tmpLSDptr); - var uintL tmplen = + var uintC tmplen = #if CL_DS_BIG_ENDIAN_P tmpLSDptr - tmpMSDptr; #else diff --git a/src/base/digitseq/cl_DS_mul_fftcs.h b/src/base/digitseq/cl_DS_mul_fftcs.h index f63ea29..ed3019d 100644 --- a/src/base/digitseq/cl_DS_mul_fftcs.h +++ b/src/base/digitseq/cl_DS_mul_fftcs.h @@ -460,10 +460,10 @@ static inline void mul (const fftcs_complex& a, const fftcs_complex& b, fftcs_co r.im = r_im; } -static uintL shuffle (uintL n, uintL x) +static uintC shuffle (uintL n, uintC x) { - var uintL y = 0; - var sintL v = 1; + var uintC y = 0; + var sintC v = 1; // Invariant: y + v*shuffle(n,x). do { if (x & 1) @@ -479,16 +479,16 @@ static uintL shuffle (uintL n, uintL x) } #if 0 // unused -static uintL invshuffle (uintL n, uintL x) +static uintC invshuffle (uintL n, uintC x) { - var uintL y = 0; - var uintL v = 1; + var uintC y = 0; + var uintC v = 1; // Invariant: y + v*invshuffle(n,x). do { - if (x == ((uintL)1 << (n-1))) + if (x == ((uintC)1 << (n-1))) return y + v; - else if (x > ((uintL)1 << (n-1))) { - x = ((uintL)1 << n) - x; + else if (x > ((uintC)1 << (n-1))) { + x = ((uintC)1 << n) - x; y = y+v; } v <<= 1; @@ -498,7 +498,7 @@ static uintL invshuffle (uintL n, uintL x) #endif // Compute a real convolution using FFT: z[0..N-1] := x[0..N-1] * y[0..N-1]. -static void fftcs_convolution (const uintL n, const uintL N, // N = 2^n +static void fftcs_convolution (const uintL n, const uintC N, // N = 2^n fftcs_real * x, // N numbers fftcs_real * y, // N numbers fftcs_real * z // N numbers result @@ -506,7 +506,7 @@ static void fftcs_convolution (const uintL n, const uintL N, // N = 2^n { CL_ALLOCA_STACK; var fftcs_complex* const w = cl_alloc_array(fftcs_complex,N>>2); - var uintL i; + var uintC i; // Initialize w[i] to w^i, w a primitive N-th root of unity. w[0] = fftcs_roots_of_1[0]; { @@ -524,10 +524,10 @@ static void fftcs_convolution (const uintL n, const uintL N, // N = 2^n var uintL l; for (l = n-1; l > 0; l--) { /* s = 0 */ { - var const uintL tmax = (uintL)1 << l; - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var const uintC tmax = (uintC)1 << l; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // replace (x[i1],x[i2]) by // (x[i1] + x[i2], x[i1] - x[i2]) var fftcs_real tmp; @@ -536,15 +536,15 @@ static void fftcs_convolution (const uintL n, const uintL N, // N = 2^n x[i1] = x[i1] + tmp; } } - var const uintL smax = (uintL)1 << (n-1-l); - var const uintL tmax = (uintL)1 << (l-1); - for (var uintL s = 1; s < smax; s++) { - var uintL exp = shuffle(n-1-l,s) << (l-1); - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; - var uintL i3 = i2 + tmax; - var uintL i4 = i3 + tmax; + var const uintC smax = (uintC)1 << (n-1-l); + var const uintC tmax = (uintC)1 << (l-1); + for (var uintC s = 1; s < smax; s++) { + var uintC exp = shuffle(n-1-l,s) << (l-1); + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; + var uintC i3 = i2 + tmax; + var uintC i4 = i3 + tmax; // replace (x[i1],x[i2],x[i3],x[i4]) by // (x[i1] + x[i2]*Re(w^exp) - x[i4]*Im(w^exp), // x[i3] + x[i4]*Re(w^exp) + x[i2]*Im(w^exp), @@ -578,10 +578,10 @@ static void fftcs_convolution (const uintL n, const uintL N, // N = 2^n var uintL l; for (l = n-1; l > 0; l--) { /* s = 0 */ { - var const uintL tmax = (uintL)1 << l; - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var const uintC tmax = (uintC)1 << l; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // replace (y[i1],y[i2]) by // (y[i1] + y[i2], y[i1] - y[i2]) var fftcs_real tmp; @@ -590,15 +590,15 @@ static void fftcs_convolution (const uintL n, const uintL N, // N = 2^n y[i1] = y[i1] + tmp; } } - var const uintL smax = (uintL)1 << (n-1-l); - var const uintL tmax = (uintL)1 << (l-1); - for (var uintL s = 1; s < smax; s++) { - var uintL exp = shuffle(n-1-l,s) << (l-1); - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; - var uintL i3 = i2 + tmax; - var uintL i4 = i3 + tmax; + var const uintC smax = (uintC)1 << (n-1-l); + var const uintC tmax = (uintC)1 << (l-1); + for (var uintC s = 1; s < smax; s++) { + var uintC exp = shuffle(n-1-l,s) << (l-1); + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; + var uintC i3 = i2 + tmax; + var uintC i4 = i3 + tmax; // replace (y[i1],y[i2],y[i3],y[i4]) by // (y[i1] + y[i2]*Re(w^exp) - y[i4]*Im(w^exp), // y[i3] + y[i4]*Re(w^exp) + y[i2]*Im(w^exp), @@ -649,10 +649,10 @@ static void fftcs_convolution (const uintL n, const uintL N, // N = 2^n } for (l = 1; l < n; l++) { /* s = 0 */ { - var const uintL tmax = (uintL)1 << l; - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var const uintC tmax = (uintC)1 << l; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // replace (z[i1],z[i2]) by // ((z[i1]+z[i2])/2, (z[i1]-z[i2])/2) // Do the division by 2 later. @@ -662,15 +662,15 @@ static void fftcs_convolution (const uintL n, const uintL N, // N = 2^n z[i1] = z[i1] + tmp; } } - var const uintL smax = (uintL)1 << (n-1-l); - var const uintL tmax = (uintL)1 << (l-1); - for (var uintL s = 1; s < smax; s++) { - var uintL exp = shuffle(n-1-l,s) << (l-1); - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; - var uintL i3 = i2 + tmax; - var uintL i4 = i3 + tmax; + var const uintC smax = (uintC)1 << (n-1-l); + var const uintC tmax = (uintC)1 << (l-1); + for (var uintC s = 1; s < smax; s++) { + var uintC exp = shuffle(n-1-l,s) << (l-1); + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; + var uintC i3 = i2 + tmax; + var uintC i4 = i3 + tmax; // replace (z[i1],z[i2],z[i3],z[i4]) by // ((z[i1]+z[i3])/2, // (z[i1]-z[i3])/2*Re(w^exp)+(z[i2]+z[i4])/2*Im(w^exp), @@ -720,10 +720,10 @@ static int max_l_table[32+1] = // Split len uintD's below sourceptr into chunks of l bits, thus filling // N real numbers at x. -static void fill_factor (uintL N, fftcs_real* x, uintL l, - const uintD* sourceptr, uintL len) +static void fill_factor (uintC N, fftcs_real* x, uintL l, + const uintD* sourceptr, uintC len) { - var uintL i; + var uintC i; if (max_l(2) > intDsize && l > intDsize) { // l > intDsize if (max_l(2) > 64 && l > 64) { @@ -840,11 +840,11 @@ static inline fftcs_real fftcs_ffloor (fftcs_real x) // The z[i] are known to be approximately integers >= 0, < N*2^(2*l). // Assumes room for floor(N*l/intDsize)+(1+ceiling((n+2*l)/intDsize)) uintD's // below destptr. Fills len digits and returns (destptr lspop len). -static uintD* unfill_product (uintL n, uintL N, // N = 2^n +static uintD* unfill_product (uintL n, uintC N, // N = 2^n const fftcs_real * z, uintL l, uintD* destptr) { - var uintL i; + var uintC i; if (n + 2*l <= intDsize) { // 2-digit carry is sufficient, l < intDsize var uintD carry0 = 0; @@ -990,11 +990,11 @@ static inline void mulu_fftcs_nocheck (const uintD* sourceptr1, uintC len1, // is 2*len1*intDsize/l_max - 1 <= 2^k. { var const int l = max_l(2); - var uintL lhs = 2*ceiling((uintL)len1*intDsize,l) - 1; // >=1 + var uintC lhs = 2*ceiling(len1*intDsize,l) - 1; // >=1 if (lhs < 3) k = 2; else - integerlength32(lhs-1, k=); // k>=2 + integerlengthC(lhs-1, k=); // k>=2 } // Try whether this k is ok or whether we have to increase k. for ( ; ; k++) { @@ -1003,22 +1003,22 @@ static inline void mulu_fftcs_nocheck (const uintD* sourceptr1, uintC len1, fprint(std::cerr, "FFT problem: numbers too big, floating point precision not sufficient\n"); cl_abort(); } - if (2*ceiling((uintL)len1*intDsize,max_l_table[k])-1 <= ((uintL)1 << k)) + if (2*ceiling(len1*intDsize,max_l_table[k])-1 <= ((uintC)1 << k)) break; } // We could try to reduce l, keeping the same k. But why should we? // Calculate the number of pieces in which source2 will have to be // split. Each of the pieces must satisfy // ceiling(len1*intDsize/l) + ceiling(len2*intDsize/l) - 1 <= 2^k, - var uintL len2p; + var uintC len2p; // Try once with k, once with k+1. Compare them. { - var uintL remaining_k = ((uintL)1 << k) + 1 - ceiling((uintL)len1*intDsize,max_l_table[k]); - var uintL max_piecelen_k = floor(remaining_k*max_l_table[k],intDsize); - var uintL numpieces_k = ceiling(len2,max_piecelen_k); - var uintL remaining_k1 = ((uintL)1 << (k+1)) + 1 - ceiling((uintL)len1*intDsize,max_l_table[k+1]); - var uintL max_piecelen_k1 = floor(remaining_k1*max_l_table[k+1],intDsize); - var uintL numpieces_k1 = ceiling(len2,max_piecelen_k1); + var uintC remaining_k = ((uintC)1 << k) + 1 - ceiling(len1*intDsize,max_l_table[k]); + var uintC max_piecelen_k = floor(remaining_k*max_l_table[k],intDsize); + var uintC numpieces_k = ceiling(len2,max_piecelen_k); + var uintC remaining_k1 = ((uintC)1 << (k+1)) + 1 - ceiling(len1*intDsize,max_l_table[k+1]); + var uintC max_piecelen_k1 = floor(remaining_k1*max_l_table[k+1],intDsize); + var uintC numpieces_k1 = ceiling(len2,max_piecelen_k1); if (numpieces_k <= 2*numpieces_k1) { // keep k len2p = max_piecelen_k; @@ -1030,7 +1030,7 @@ static inline void mulu_fftcs_nocheck (const uintD* sourceptr1, uintC len1, } var const uintL l = max_l_table[k]; var const uintL n = k; - var const uintL N = (uintL)1 << n; + var const uintC N = (uintC)1 << n; CL_ALLOCA_STACK; var fftcs_real* const x = cl_alloc_array(fftcs_real,N); var fftcs_real* const y = cl_alloc_array(fftcs_real,N); @@ -1040,9 +1040,9 @@ static inline void mulu_fftcs_nocheck (const uintD* sourceptr1, uintC len1, var fftcs_real* const z = x; // put z in place of x - saves memory #endif var uintD* const tmpprod1 = cl_alloc_array(uintD,len1+1); - var uintL tmpprod_len = floor(l< len2) @@ -1071,7 +1071,7 @@ static inline void mulu_fftcs_nocheck (const uintD* sourceptr1, uintC len1, { var fftcs_real re_lo_limit = (fftcs_real)(-0.5); var fftcs_real re_hi_limit = (fftcs_real)N * fftcs_pow2_table[l] * fftcs_pow2_table[l] + (fftcs_real)0.5; - for (var uintL i = 0; i < N; i++) + for (var uintC i = 0; i < N; i++) if (!(z[i] > re_lo_limit && z[i] < re_hi_limit)) cl_abort(); @@ -1079,7 +1079,7 @@ static inline void mulu_fftcs_nocheck (const uintD* sourceptr1, uintC len1, #endif var uintD* tmpLSDptr = arrayLSDptr(tmpprod,tmpprod_len); var uintD* tmpMSDptr = unfill_product(n,N,z,l,tmpLSDptr); - var uintL tmplen = + var uintC tmplen = #if CL_DS_BIG_ENDIAN_P tmpLSDptr - tmpMSDptr; #else diff --git a/src/base/digitseq/cl_DS_mul_fftm.h b/src/base/digitseq/cl_DS_mul_fftm.h index 04714f1..9b97364 100644 --- a/src/base/digitseq/cl_DS_mul_fftm.h +++ b/src/base/digitseq/cl_DS_mul_fftm.h @@ -57,7 +57,7 @@ // Operations modulo p = 2^R+1, each chunk represented as chlen words // (chlen = floor(R/intDsize)+1). -static inline void assign (const uintL R, const uintL chlen, +static inline void assign (const uintC R, const uintC chlen, const uintD* a, uintD* r) { unused R; @@ -65,7 +65,7 @@ static inline void assign (const uintL R, const uintL chlen, } // r := (a + b) mod p -static void addm (const uintL R, const uintL chlen, +static void addm (const uintC R, const uintC chlen, const uintD* a, const uintD* b, uintD* r) { unused R; @@ -93,7 +93,7 @@ static void addm (const uintL R, const uintL chlen, } // r := (a - b) mod p -static void subm (const uintL R, const uintL chlen, +static void subm (const uintC R, const uintC chlen, const uintD* a, const uintD* b, uintD* r) { unused R; @@ -116,7 +116,7 @@ static void subm (const uintL R, const uintL chlen, // r := (a << s) mod p (0 <= s < R). // Assume that a and r don't overlap. -static void shiftleftm (const uintL R, const uintL chlen, +static void shiftleftm (const uintC R, const uintC chlen, const uintD* a, uintL s, uintD* r) { // Write a = 2^(R-s)*b + c, then @@ -175,7 +175,7 @@ static void shiftleftm (const uintL R, const uintL chlen, } // r := (a * b) mod p -static void mulm (const uintL R, const uintL chlen, +static void mulm (const uintC R, const uintC chlen, const uintD* a, const uintD* b, uintD* r) { unused R; @@ -230,7 +230,7 @@ static void mulm (const uintL R, const uintL chlen, } // b := (a / 2) mod p -static void shiftm (const uintL R, const uintL chlen, +static void shiftm (const uintC R, const uintC chlen, const uintD* a, uintD* b) { unused R; @@ -253,9 +253,9 @@ static void shiftm (const uintL R, const uintL chlen, #ifndef _BIT_REVERSE #define _BIT_REVERSE // Reverse an n-bit number x. n>0. -static uintL bit_reverse (uintL n, uintL x) +static uintC bit_reverse (uintL n, uintC x) { - var uintL y = 0; + var uintC y = 0; do { y <<= 1; y |= (x & 1); @@ -265,9 +265,9 @@ static uintL bit_reverse (uintL n, uintL x) } #endif -static void mulu_fftm (const uintL r, const uintL R, // R = 2^r - const uintL m, const uintL M, // M = 2^m - const uintL k, // K = intDsize*k +static void mulu_fftm (const uintL r, const uintC R, // R = 2^r + const uintL m, const uintC M, // M = 2^m + const uintC k, // K = intDsize*k const uintD* sourceptr1, uintC len1, const uintD* sourceptr2, uintC len2, uintD* destptr) @@ -277,7 +277,7 @@ static void mulu_fftm (const uintL r, const uintL R, // R = 2^r // R = 2^r, M = 2^m, M | 2R. // m > 0. { - var const uintL chlen = floor(R,intDsize)+1; // chunk length (in words) + var const uintC chlen = floor(R,intDsize)+1; // chunk length (in words) CL_ALLOCA_STACK; var uintD* const arrX = cl_alloc_array(uintD,chlen<= k) { @@ -320,7 +320,7 @@ static void mulu_fftm (const uintL r, const uintL R, // R = 2^r } if (!squaring) { var const uintD* sptr = sourceptr2; - var uintL slen = len2; + var uintC slen = len2; for (i = 0; i < M; i++) { var uintD* ptr = Y(i); if (slen >= k) { @@ -342,10 +342,10 @@ static void mulu_fftm (const uintL r, const uintL R, // R = 2^r { var sintL l; /* l = m-1 */ { - var const uintL tmax = M>>1; // tmax = 2^(m-1) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var const uintC tmax = M>>1; // tmax = 2^(m-1) + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Butterfly: replace (X(i1),X(i2)) by // (X(i1) + X(i2), X(i1) - X(i2)). assign(R,chlen, X(i2), tmp); @@ -354,14 +354,14 @@ static void mulu_fftm (const uintL r, const uintL R, // R = 2^r } } for (l = m-2; l>=0; l--) { - var const uintL smax = (uintL)1 << (m-1-l); - var const uintL tmax = (uintL)1 << l; - for (var uintL s = 0; s < smax; s++) { + var const uintC smax = (uintC)1 << (m-1-l); + var const uintC tmax = (uintC)1 << l; + for (var uintC s = 0; s < smax; s++) { // w^exp = 2^(exp << (r+1-m)). - var uintL exp = bit_reverse(m-1-l,s) << (r-(m-1-l)); - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + var uintC exp = bit_reverse(m-1-l,s) << (r-(m-1-l)); + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Butterfly: replace (X(i1),X(i2)) by // (X(i1) + w^exp*X(i2), X(i1) - w^exp*X(i2)). shiftleftm(R,chlen, X(i2),exp, tmp); @@ -375,10 +375,10 @@ static void mulu_fftm (const uintL r, const uintL R, // R = 2^r if (!squaring) { var sintL l; /* l = m-1 */ { - var const uintL tmax = M>>1; // tmax = 2^(m-1) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var const uintC tmax = M>>1; // tmax = 2^(m-1) + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Butterfly: replace (Y(i1),Y(i2)) by // (Y(i1) + Y(i2), Y(i1) - Y(i2)). assign(R,chlen, Y(i2), tmp); @@ -387,14 +387,14 @@ static void mulu_fftm (const uintL r, const uintL R, // R = 2^r } } for (l = m-2; l>=0; l--) { - var const uintL smax = (uintL)1 << (m-1-l); - var const uintL tmax = (uintL)1 << l; - for (var uintL s = 0; s < smax; s++) { + var const uintC smax = (uintC)1 << (m-1-l); + var const uintC tmax = (uintC)1 << l; + for (var uintC s = 0; s < smax; s++) { // w^exp = 2^(exp << (r+1-m)). - var uintL exp = bit_reverse(m-1-l,s) << (r-(m-1-l)); - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + var uintC exp = bit_reverse(m-1-l,s) << (r-(m-1-l)); + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Butterfly: replace (Y(i1),Y(i2)) by // (Y(i1) + w^exp*Y(i2), Y(i1) - w^exp*Y(i2)). shiftleftm(R,chlen, Y(i2),exp, tmp); @@ -416,12 +416,12 @@ static void mulu_fftm (const uintL r, const uintL R, // R = 2^r { var uintL l; for (l = 0; l < m-1; l++) { - var const uintL smax = (uintL)1 << (m-1-l); - var const uintL tmax = (uintL)1 << l; + var const uintC smax = (uintC)1 << (m-1-l); + var const uintC tmax = (uintC)1 << l; /* s = 0, exp = 0 */ { - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (Z(i1),Z(i2)) by // ((Z(i1)+Z(i2))/2, (Z(i1)-Z(i2))/(2*w^exp)), // with exp <-- 0. @@ -431,13 +431,13 @@ static void mulu_fftm (const uintL r, const uintL R, // R = 2^r shiftm(R,chlen, diff, Z(i2)); } } - for (var uintL s = 1; s < smax; s++) { + for (var uintC s = 1; s < smax; s++) { // w^exp = 2^(exp << (r+1-m)). - var uintL exp = bit_reverse(m-1-l,s) << (r-(m-1-l)); + var uintC exp = bit_reverse(m-1-l,s) << (r-(m-1-l)); exp = R - exp; // negate exp (use w^-1 instead of w) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (Z(i1),Z(i2)) by // ((Z(i1)+Z(i2))/2, (Z(i1)-Z(i2))/(2*w^exp)), // with exp <-- (M/2 - exp). @@ -449,10 +449,10 @@ static void mulu_fftm (const uintL r, const uintL R, // R = 2^r } } /* l = m-1 */ { - var const uintL tmax = M>>1; // tmax = 2^(m-1) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var const uintC tmax = M>>1; // tmax = 2^(m-1) + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (Z(i1),Z(i2)) by // ((Z(i1)+Z(i2))/2, (Z(i1)-Z(i2))/2). addm(R,chlen, Z(i1),Z(i2), sum); @@ -548,20 +548,20 @@ static void mulu_fftm (const uintL r, const uintL R, // R = 2^r static bool okfor (uintL r, uintL m, uintC len1, uintC len2) { - var uintL R = (uintL)1 << r; - var uintL M = (uintL)1 << m; - var uintL k = floor(R-m,2*intDsize); + var uintC R = (uintC)1 << r; + var uintC M = (uintC)1 << m; + var uintC k = floor(R-m,2*intDsize); return (ceiling(len1,k)+ceiling(len2,k) <= M+1); } -static uintL numpieces (uintL r, uintL m, uintC len1, uintC len2) +static uintC numpieces (uintL r, uintL m, uintC len1, uintC len2) { - var uintL R = (uintL)1 << r; - var uintL M = (uintL)1 << m; - var uintL k = floor(R-m,2*intDsize); - var uintL piecelen2 = (M+1-ceiling(len1,k))*k; + var uintC R = (uintC)1 << r; + var uintC M = (uintC)1 << m; + var uintC k = floor(R-m,2*intDsize); + var uintC piecelen2 = (M+1-ceiling(len1,k))*k; #ifdef DEBUG_FFTM - if ((sintL)piecelen2 <= 0) + if ((sintC)piecelen2 <= 0) cl_abort(); #endif return ceiling(len2,piecelen2); @@ -573,16 +573,16 @@ static void mulu_fft_modm (const uintD* sourceptr1, uintC len1, // Called only with 6 <= len1 <= len2. { var uint32 n; - integerlength32(len1-1, n=); // 2^(n-1) < len1 <= 2^n + integerlengthC(len1-1, n=); // 2^(n-1) < len1 <= 2^n var uintL r; var uintL m; r = ceiling(log2_intDsize+1+n,2); if (r < log2_intDsize+2) r = log2_intDsize+2; retry: { - var uintL k = floor(((uintL)1 << r) - (r+1), 2*intDsize); - var uintL M = 2*ceiling(len1,k)-1; - integerlength32(M, m=); + var uintC k = floor(((uintC)1 << r) - (r+1), 2*intDsize); + var uintC M = 2*ceiling(len1,k)-1; + integerlengthC(M, m=); if (m == 0) m = 1; if (m > r+1) { @@ -599,21 +599,21 @@ static void mulu_fft_modm (const uintD* sourceptr1, uintC len1, if (!(sourceptr1 == sourceptr2 && len1 == len2)) // when squaring, keep one piece r--; } else { - var uintL q1 = numpieces(r,m,len1,len2); + var uintC q1 = numpieces(r,m,len1,len2); if (m <= r) { - var uintL q2 = numpieces(r,m+1,len1,len2); + var uintC q2 = numpieces(r,m+1,len1,len2); if (2*q2 <= q1) m++; } else { - var uintL q2 = numpieces(r+1,m,len1,len2); + var uintC q2 = numpieces(r+1,m,len1,len2); if (3*q2 <= q1) r++; } } - var uintL R = (uintL)1 << r; - var uintL M = (uintL)1 << m; - var uintL k = floor(R-m,2*intDsize); - var uintL piecelen2 = (M+1-ceiling(len1,k))*k; + var uintC R = (uintC)1 << r; + var uintC M = (uintC)1 << m; + var uintC k = floor(R-m,2*intDsize); + var uintC piecelen2 = (M+1-ceiling(len1,k))*k; if (piecelen2 >= len2) { // One piece only. mulu_fftm(r,R, m,M, k, sourceptr1,len1, sourceptr2,len2, destptr); @@ -622,15 +622,15 @@ static void mulu_fft_modm (const uintD* sourceptr1, uintC len1, CL_ALLOCA_STACK; var uintD* tmpptr; num_stack_alloc(len1+piecelen2,,tmpptr=); - var uintL destlen = len1+len2; + var uintC destlen = len1+len2; clear_loop_lsp(destptr,destlen); do { - var uintL len2p; // length of a piece of source2 + var uintC len2p; // length of a piece of source2 len2p = piecelen2; if (len2p > len2) len2p = len2; // len2p = min(piecelen2,len2). - var uintL destlenp = len1 + len2p; + var uintC destlenp = len1 + len2p; // destlenp = min(len1+piecelen2,destlen). // Use tmpptr[-destlenp..-1]. if (len2p == 1) { diff --git a/src/base/digitseq/cl_DS_mul_fftp.h b/src/base/digitseq/cl_DS_mul_fftp.h index 5cf41b6..4743f2f 100644 --- a/src/base/digitseq/cl_DS_mul_fftp.h +++ b/src/base/digitseq/cl_DS_mul_fftp.h @@ -441,9 +441,9 @@ static inline void shiftp (const fftp_word& a, fftp_word& b) #ifndef _BIT_REVERSE #define _BIT_REVERSE // Reverse an n-bit number x. n>0. -static uintL bit_reverse (uintL n, uintL x) +static uintC bit_reverse (uintL n, uintC x) { - var uintL y = 0; + var uintC y = 0; do { y <<= 1; y |= (x & 1); @@ -454,7 +454,7 @@ static uintL bit_reverse (uintL n, uintL x) #endif // Compute an convolution mod p using FFT: z[0..N-1] := x[0..N-1] * y[0..N-1]. -static void fftp_convolution (const uintL n, const uintL N, // N = 2^n +static void fftp_convolution (const uintL n, const uintC N, // N = 2^n fftp_word * x, // N words fftp_word * y, // N words fftp_word * z // N words result @@ -466,7 +466,7 @@ static void fftp_convolution (const uintL n, const uintL N, // N = 2^n #else var fftp_word* const w = cl_alloc_array(fftp_word,(N>>1)+1); #endif - var uintL i; + var uintC i; // Initialize w[i] to w^i, w a primitive N-th root of unity. w[0] = fftp_roots_of_1[0]; w[1] = fftp_roots_of_1[n]; @@ -494,10 +494,10 @@ static void fftp_convolution (const uintL n, const uintL N, // N = 2^n { var sintL l; /* l = n-1 */ { - var const uintL tmax = N>>1; // tmax = 2^(n-1) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var const uintC tmax = N>>1; // tmax = 2^(n-1) + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Butterfly: replace (x(i1),x(i2)) by // (x(i1) + x(i2), x(i1) - x(i2)). var fftp_word tmp; @@ -507,13 +507,13 @@ static void fftp_convolution (const uintL n, const uintL N, // N = 2^n } } for (l = n-2; l>=0; l--) { - var const uintL smax = (uintL)1 << (n-1-l); - var const uintL tmax = (uintL)1 << l; - for (var uintL s = 0; s < smax; s++) { - var uintL exp = bit_reverse(n-1-l,s) << l; - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + var const uintC smax = (uintC)1 << (n-1-l); + var const uintC tmax = (uintC)1 << l; + for (var uintC s = 0; s < smax; s++) { + var uintC exp = bit_reverse(n-1-l,s) << l; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Butterfly: replace (x(i1),x(i2)) by // (x(i1) + w^exp*x(i2), x(i1) - w^exp*x(i2)). var fftp_word tmp; @@ -528,10 +528,10 @@ static void fftp_convolution (const uintL n, const uintL N, // N = 2^n if (!squaring) { var sintL l; /* l = n-1 */ { - var uintL const tmax = N>>1; // tmax = 2^(n-1) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var uintC const tmax = N>>1; // tmax = 2^(n-1) + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Butterfly: replace (y(i1),y(i2)) by // (y(i1) + y(i2), y(i1) - y(i2)). var fftp_word tmp; @@ -541,13 +541,13 @@ static void fftp_convolution (const uintL n, const uintL N, // N = 2^n } } for (l = n-2; l>=0; l--) { - var const uintL smax = (uintL)1 << (n-1-l); - var const uintL tmax = (uintL)1 << l; - for (var uintL s = 0; s < smax; s++) { - var uintL exp = bit_reverse(n-1-l,s) << l; - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + var const uintC smax = (uintC)1 << (n-1-l); + var const uintC tmax = (uintC)1 << l; + for (var uintC s = 0; s < smax; s++) { + var uintC exp = bit_reverse(n-1-l,s) << l; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Butterfly: replace (y(i1),y(i2)) by // (y(i1) + w^exp*y(i2), y(i1) - w^exp*y(i2)). var fftp_word tmp; @@ -565,18 +565,18 @@ static void fftp_convolution (const uintL n, const uintL N, // N = 2^n { var uintL l; for (l = 0; l < n-1; l++) { - var const uintL smax = (uintL)1 << (n-1-l); - var const uintL tmax = (uintL)1 << l; + var const uintC smax = (uintC)1 << (n-1-l); + var const uintC tmax = (uintC)1 << l; #if FFTP_BACKWARD != CLEVER - for (var uintL s = 0; s < smax; s++) { - var uintL exp = bit_reverse(n-1-l,s) << l; + for (var uintC s = 0; s < smax; s++) { + var uintC exp = bit_reverse(n-1-l,s) << l; #if FFTP_BACKWARD == RECIPROOT if (exp > 0) exp = N - exp; // negate exp (use w^-1 instead of w) #endif - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (z(i1),z(i2)) by // ((z(i1)+z(i2))/2, (z(i1)-z(i2))/(2*w^exp)). var fftp_word sum; @@ -589,9 +589,9 @@ static void fftp_convolution (const uintL n, const uintL N, // N = 2^n } #else // FFTP_BACKWARD == CLEVER: clever handling of negative exponents /* s = 0, exp = 0 */ { - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (z(i1),z(i2)) by // ((z(i1)+z(i2))/2, (z(i1)-z(i2))/(2*w^exp)), // with exp <-- 0. @@ -603,12 +603,12 @@ static void fftp_convolution (const uintL n, const uintL N, // N = 2^n shiftp(diff, z[i2]); } } - for (var uintL s = 1; s < smax; s++) { - var uintL exp = bit_reverse(n-1-l,s) << l; + for (var uintC s = 1; s < smax; s++) { + var uintC exp = bit_reverse(n-1-l,s) << l; exp = (N>>1) - exp; // negate exp (use w^-1 instead of w) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (z(i1),z(i2)) by // ((z(i1)+z(i2))/2, (z(i1)-z(i2))/(2*w^exp)), // with exp <-- (N/2 - exp). @@ -623,10 +623,10 @@ static void fftp_convolution (const uintL n, const uintL N, // N = 2^n #endif } /* l = n-1 */ { - var const uintL tmax = N>>1; // tmax = 2^(n-1) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var const uintC tmax = N>>1; // tmax = 2^(n-1) + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (z(i1),z(i2)) by // ((z(i1)+z(i2))/2, (z(i1)-z(i2))/2). var fftp_word sum; @@ -661,8 +661,8 @@ static void mulu_fft_modp (const uintD* sourceptr1, uintC len1, // sum(i=0..N-1, x_i T^i), sum(i=0..N-1, y_i T^i) // multipliziert, und zwar durch Fourier-Transformation (s.o.). var uint32 n; - integerlength32(len1-1, n=); // 2^(n-1) < len1 <= 2^n - var uintL len = (uintL)1 << n; // kleinste Zweierpotenz >= len1 + integerlengthC(len1-1, n=); // 2^(n-1) < len1 <= 2^n + var uintC len = (uintC)1 << n; // kleinste Zweierpotenz >= len1 // Wählt man N = len, so hat man ceiling(len2/(len-len1+1)) * FFT(len). // Wählt man N = 2*len, so hat man ceiling(len2/(2*len-len1+1)) * FFT(2*len). // Wir wählen das billigere von beiden: @@ -673,7 +673,7 @@ static void mulu_fft_modp (const uintD* sourceptr1, uintC len1, n = n+1; len = len << 1; } - var const uintL N = len; // N = 2^n + var const uintC N = len; // N = 2^n CL_ALLOCA_STACK; var fftp_word* const x = cl_alloc_array(fftp_word,N); var fftp_word* const y = cl_alloc_array(fftp_word,N); @@ -684,10 +684,10 @@ static void mulu_fft_modp (const uintD* sourceptr1, uintC len1, #endif var uintD* const tmpprod = cl_alloc_array(uintD,len1+1); var uintP i; - var uintL destlen = len1+len2; + var uintC destlen = len1+len2; clear_loop_lsp(destptr,destlen); do { - var uintL len2p; // length of a piece of source2 + var uintC len2p; // length of a piece of source2 len2p = N - len1 + 1; if (len2p > len2) len2p = len2; @@ -700,7 +700,7 @@ static void mulu_fft_modp (const uintD* sourceptr1, uintC len1, if (inc_loop_lsp(destptr lspop (len1+1),destlen-(len1+1))) cl_abort(); } else { - var uintL destlenp = len1 + len2p - 1; + var uintC destlenp = len1 + len2p - 1; // destlenp = min(N,destlen-1). var bool squaring = ((sourceptr1 == sourceptr2) && (len1 == len2p)); // Fill factor x. diff --git a/src/base/digitseq/cl_DS_mul_fftp3.h b/src/base/digitseq/cl_DS_mul_fftp3.h index 619cc3d..0af1353 100644 --- a/src/base/digitseq/cl_DS_mul_fftp3.h +++ b/src/base/digitseq/cl_DS_mul_fftp3.h @@ -308,9 +308,9 @@ static inline void shiftp3 (const fftp3_word& a, fftp3_word& b) #ifndef _BIT_REVERSE #define _BIT_REVERSE // Reverse an n-bit number x. n>0. -static uintL bit_reverse (uintL n, uintL x) +static uintC bit_reverse (uintL n, uintC x) { - var uintL y = 0; + var uintC y = 0; do { y <<= 1; y |= (x & 1); @@ -321,7 +321,7 @@ static uintL bit_reverse (uintL n, uintL x) #endif // Compute an convolution mod p using FFT: z[0..N-1] := x[0..N-1] * y[0..N-1]. -static void fftp3_convolution (const uintL n, const uintL N, // N = 2^n +static void fftp3_convolution (const uintL n, const uintC N, // N = 2^n fftp3_word * x, // N words fftp3_word * y, // N words fftp3_word * z // N words result @@ -333,7 +333,7 @@ static void fftp3_convolution (const uintL n, const uintL N, // N = 2^n #else var fftp3_word* const w = cl_alloc_array(fftp3_word,(N>>1)+1); #endif - var uintL i; + var uintC i; // Initialize w[i] to w^i, w a primitive N-th root of unity. w[0] = fftp3_roots_of_1[0]; w[1] = fftp3_roots_of_1[n]; @@ -361,10 +361,10 @@ static void fftp3_convolution (const uintL n, const uintL N, // N = 2^n { var sintL l; /* l = n-1 */ { - var const uintL tmax = N>>1; // tmax = 2^(n-1) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var const uintC tmax = N>>1; // tmax = 2^(n-1) + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Butterfly: replace (x(i1),x(i2)) by // (x(i1) + x(i2), x(i1) - x(i2)). var fftp3_word tmp; @@ -374,13 +374,13 @@ static void fftp3_convolution (const uintL n, const uintL N, // N = 2^n } } for (l = n-2; l>=0; l--) { - var const uintL smax = (uintL)1 << (n-1-l); - var const uintL tmax = (uintL)1 << l; - for (var uintL s = 0; s < smax; s++) { - var uintL exp = bit_reverse(n-1-l,s) << l; - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + var const uintC smax = (uintC)1 << (n-1-l); + var const uintC tmax = (uintC)1 << l; + for (var uintC s = 0; s < smax; s++) { + var uintC exp = bit_reverse(n-1-l,s) << l; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Butterfly: replace (x(i1),x(i2)) by // (x(i1) + w^exp*x(i2), x(i1) - w^exp*x(i2)). var fftp3_word tmp; @@ -395,10 +395,10 @@ static void fftp3_convolution (const uintL n, const uintL N, // N = 2^n if (!squaring) { var sintL l; /* l = n-1 */ { - var uintL const tmax = N>>1; // tmax = 2^(n-1) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var uintC const tmax = N>>1; // tmax = 2^(n-1) + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Butterfly: replace (y(i1),y(i2)) by // (y(i1) + y(i2), y(i1) - y(i2)). var fftp3_word tmp; @@ -408,13 +408,13 @@ static void fftp3_convolution (const uintL n, const uintL N, // N = 2^n } } for (l = n-2; l>=0; l--) { - var const uintL smax = (uintL)1 << (n-1-l); - var const uintL tmax = (uintL)1 << l; - for (var uintL s = 0; s < smax; s++) { - var uintL exp = bit_reverse(n-1-l,s) << l; - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + var const uintC smax = (uintC)1 << (n-1-l); + var const uintC tmax = (uintC)1 << l; + for (var uintC s = 0; s < smax; s++) { + var uintC exp = bit_reverse(n-1-l,s) << l; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Butterfly: replace (y(i1),y(i2)) by // (y(i1) + w^exp*y(i2), y(i1) - w^exp*y(i2)). var fftp3_word tmp; @@ -432,18 +432,18 @@ static void fftp3_convolution (const uintL n, const uintL N, // N = 2^n { var uintL l; for (l = 0; l < n-1; l++) { - var const uintL smax = (uintL)1 << (n-1-l); - var const uintL tmax = (uintL)1 << l; + var const uintC smax = (uintC)1 << (n-1-l); + var const uintC tmax = (uintC)1 << l; #if FFTP3_BACKWARD != CLEVER - for (var uintL s = 0; s < smax; s++) { - var uintL exp = bit_reverse(n-1-l,s) << l; + for (var uintC s = 0; s < smax; s++) { + var uintC exp = bit_reverse(n-1-l,s) << l; #if FFTP3_BACKWARD == RECIPROOT if (exp > 0) exp = N - exp; // negate exp (use w^-1 instead of w) #endif - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (z(i1),z(i2)) by // ((z(i1)+z(i2))/2, (z(i1)-z(i2))/(2*w^exp)). var fftp3_word sum; @@ -456,9 +456,9 @@ static void fftp3_convolution (const uintL n, const uintL N, // N = 2^n } #else // FFTP3_BACKWARD == CLEVER: clever handling of negative exponents /* s = 0, exp = 0 */ { - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (z(i1),z(i2)) by // ((z(i1)+z(i2))/2, (z(i1)-z(i2))/(2*w^exp)), // with exp <-- 0. @@ -470,12 +470,12 @@ static void fftp3_convolution (const uintL n, const uintL N, // N = 2^n shiftp3(diff, z[i2]); } } - for (var uintL s = 1; s < smax; s++) { - var uintL exp = bit_reverse(n-1-l,s) << l; + for (var uintC s = 1; s < smax; s++) { + var uintC exp = bit_reverse(n-1-l,s) << l; exp = (N>>1) - exp; // negate exp (use w^-1 instead of w) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (z(i1),z(i2)) by // ((z(i1)+z(i2))/2, (z(i1)-z(i2))/(2*w^exp)), // with exp <-- (N/2 - exp). @@ -490,10 +490,10 @@ static void fftp3_convolution (const uintL n, const uintL N, // N = 2^n #endif } /* l = n-1 */ { - var const uintL tmax = N>>1; // tmax = 2^(n-1) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var const uintC tmax = N>>1; // tmax = 2^(n-1) + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (z(i1),z(i2)) by // ((z(i1)+z(i2))/2, (z(i1)-z(i2))/2). var fftp3_word sum; @@ -528,8 +528,8 @@ static void mulu_fft_modp3 (const uintD* sourceptr1, uintC len1, // sum(i=0..N-1, x_i T^i), sum(i=0..N-1, y_i T^i) // multipliziert, und zwar durch Fourier-Transformation (s.o.). var uint32 n; - integerlength32(len1-1, n=); // 2^(n-1) < len1 <= 2^n - var uintL len = (uintL)1 << n; // kleinste Zweierpotenz >= len1 + integerlengthC(len1-1, n=); // 2^(n-1) < len1 <= 2^n + var uintC len = (uintC)1 << n; // kleinste Zweierpotenz >= len1 // Wählt man N = len, so hat man ceiling(len2/(len-len1+1)) * FFT(len). // Wählt man N = 2*len, so hat man ceiling(len2/(2*len-len1+1)) * FFT(2*len). // Wir wählen das billigere von beiden: @@ -540,7 +540,7 @@ static void mulu_fft_modp3 (const uintD* sourceptr1, uintC len1, n = n+1; len = len << 1; } - var const uintL N = len; // N = 2^n + var const uintC N = len; // N = 2^n CL_ALLOCA_STACK; var fftp3_word* const x = cl_alloc_array(fftp3_word,N); var fftp3_word* const y = cl_alloc_array(fftp3_word,N); @@ -551,10 +551,10 @@ static void mulu_fft_modp3 (const uintD* sourceptr1, uintC len1, #endif var uintD* const tmpprod = cl_alloc_array(uintD,len1+1); var uintP i; - var uintL destlen = len1+len2; + var uintC destlen = len1+len2; clear_loop_lsp(destptr,destlen); do { - var uintL len2p; // length of a piece of source2 + var uintC len2p; // length of a piece of source2 len2p = N - len1 + 1; if (len2p > len2) len2p = len2; @@ -567,7 +567,7 @@ static void mulu_fft_modp3 (const uintD* sourceptr1, uintC len1, if (inc_loop_lsp(destptr lspop (len1+1),destlen-(len1+1))) cl_abort(); } else { - var uintL destlenp = len1 + len2p - 1; + var uintC destlenp = len1 + len2p - 1; // destlenp = min(N,destlen-1). var bool squaring = ((sourceptr1 == sourceptr2) && (len1 == len2p)); // Fill factor x. diff --git a/src/base/digitseq/cl_DS_mul_fftp3m.h b/src/base/digitseq/cl_DS_mul_fftp3m.h index 14a277c..801d171 100644 --- a/src/base/digitseq/cl_DS_mul_fftp3m.h +++ b/src/base/digitseq/cl_DS_mul_fftp3m.h @@ -483,9 +483,9 @@ static inline void shiftp3m (const fftp3m_word& a, fftp3m_word& b) #ifndef _BIT_REVERSE #define _BIT_REVERSE // Reverse an n-bit number x. n>0. -static uintL bit_reverse (uintL n, uintL x) +static uintC bit_reverse (uintL n, uintC x) { - var uintL y = 0; + var uintC y = 0; do { y <<= 1; y |= (x & 1); @@ -496,7 +496,7 @@ static uintL bit_reverse (uintL n, uintL x) #endif // Compute an convolution mod p using FFT: z[0..N-1] := x[0..N-1] * y[0..N-1]. -static void fftp3m_convolution (const uintL n, const uintL N, // N = 2^n +static void fftp3m_convolution (const uintL n, const uintC N, // N = 2^n fftp3m_word * x, // N words fftp3m_word * y, // N words fftp3m_word * z // N words result @@ -508,7 +508,7 @@ static void fftp3m_convolution (const uintL n, const uintL N, // N = 2^n #else var fftp3m_word* const w = cl_alloc_array(fftp3m_word,(N>>1)+1); #endif - var uintL i; + var uintC i; // Initialize w[i] to w^i, w a primitive N-th root of unity. w[0] = fftp3m_roots_of_1[0]; w[1] = fftp3m_roots_of_1[n]; @@ -540,10 +540,10 @@ static void fftp3m_convolution (const uintL n, const uintL N, // N = 2^n { var sintL l; /* l = n-1 */ { - var const uintL tmax = N>>1; // tmax = 2^(n-1) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var const uintC tmax = N>>1; // tmax = 2^(n-1) + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Butterfly: replace (x(i1),x(i2)) by // (x(i1) + x(i2), x(i1) - x(i2)). var fftp3m_word tmp; @@ -553,13 +553,13 @@ static void fftp3m_convolution (const uintL n, const uintL N, // N = 2^n } } for (l = n-2; l>=0; l--) { - var const uintL smax = (uintL)1 << (n-1-l); - var const uintL tmax = (uintL)1 << l; - for (var uintL s = 0; s < smax; s++) { - var uintL exp = bit_reverse(n-1-l,s) << l; - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + var const uintC smax = (uintC)1 << (n-1-l); + var const uintC tmax = (uintC)1 << l; + for (var uintC s = 0; s < smax; s++) { + var uintC exp = bit_reverse(n-1-l,s) << l; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Butterfly: replace (x(i1),x(i2)) by // (x(i1) + w^exp*x(i2), x(i1) - w^exp*x(i2)). var fftp3m_word tmp; @@ -574,10 +574,10 @@ static void fftp3m_convolution (const uintL n, const uintL N, // N = 2^n if (!squaring) { var sintL l; /* l = n-1 */ { - var uintL const tmax = N>>1; // tmax = 2^(n-1) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var uintC const tmax = N>>1; // tmax = 2^(n-1) + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Butterfly: replace (y(i1),y(i2)) by // (y(i1) + y(i2), y(i1) - y(i2)). var fftp3m_word tmp; @@ -587,13 +587,13 @@ static void fftp3m_convolution (const uintL n, const uintL N, // N = 2^n } } for (l = n-2; l>=0; l--) { - var const uintL smax = (uintL)1 << (n-1-l); - var const uintL tmax = (uintL)1 << l; - for (var uintL s = 0; s < smax; s++) { - var uintL exp = bit_reverse(n-1-l,s) << l; - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + var const uintC smax = (uintC)1 << (n-1-l); + var const uintC tmax = (uintC)1 << l; + for (var uintC s = 0; s < smax; s++) { + var uintC exp = bit_reverse(n-1-l,s) << l; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Butterfly: replace (y(i1),y(i2)) by // (y(i1) + w^exp*y(i2), y(i1) - w^exp*y(i2)). var fftp3m_word tmp; @@ -611,18 +611,18 @@ static void fftp3m_convolution (const uintL n, const uintL N, // N = 2^n { var uintL l; for (l = 0; l < n-1; l++) { - var const uintL smax = (uintL)1 << (n-1-l); - var const uintL tmax = (uintL)1 << l; + var const uintC smax = (uintC)1 << (n-1-l); + var const uintC tmax = (uintC)1 << l; #if FFTP3M_BACKWARD != CLEVER - for (var uintL s = 0; s < smax; s++) { - var uintL exp = bit_reverse(n-1-l,s) << l; + for (var uintC s = 0; s < smax; s++) { + var uintC exp = bit_reverse(n-1-l,s) << l; #if FFTP3M_BACKWARD == RECIPROOT if (exp > 0) exp = N - exp; // negate exp (use w^-1 instead of w) #endif - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (z(i1),z(i2)) by // ((z(i1)+z(i2))/2, (z(i1)-z(i2))/(2*w^exp)). var fftp3m_word sum; @@ -635,9 +635,9 @@ static void fftp3m_convolution (const uintL n, const uintL N, // N = 2^n } #else // FFTP3M_BACKWARD == CLEVER: clever handling of negative exponents /* s = 0, exp = 0 */ { - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (z(i1),z(i2)) by // ((z(i1)+z(i2))/2, (z(i1)-z(i2))/(2*w^exp)), // with exp <-- 0. @@ -649,12 +649,12 @@ static void fftp3m_convolution (const uintL n, const uintL N, // N = 2^n shiftp3m(diff, z[i2]); } } - for (var uintL s = 1; s < smax; s++) { - var uintL exp = bit_reverse(n-1-l,s) << l; + for (var uintC s = 1; s < smax; s++) { + var uintC exp = bit_reverse(n-1-l,s) << l; exp = (N>>1) - exp; // negate exp (use w^-1 instead of w) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (z(i1),z(i2)) by // ((z(i1)+z(i2))/2, (z(i1)-z(i2))/(2*w^exp)), // with exp <-- (N/2 - exp). @@ -669,10 +669,10 @@ static void fftp3m_convolution (const uintL n, const uintL N, // N = 2^n #endif } /* l = n-1 */ { - var const uintL tmax = N>>1; // tmax = 2^(n-1) - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var const uintC tmax = N>>1; // tmax = 2^(n-1) + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (z(i1),z(i2)) by // ((z(i1)+z(i2))/2, (z(i1)-z(i2))/2). var fftp3m_word sum; @@ -707,8 +707,8 @@ static void mulu_fft_modp3m (const uintD* sourceptr1, uintC len1, // sum(i=0..N-1, x_i T^i), sum(i=0..N-1, y_i T^i) // multipliziert, und zwar durch Fourier-Transformation (s.o.). var uint32 n; - integerlength32(len1-1, n=); // 2^(n-1) < len1 <= 2^n - var uintL len = (uintL)1 << n; // kleinste Zweierpotenz >= len1 + integerlengthC(len1-1, n=); // 2^(n-1) < len1 <= 2^n + var uintC len = (uintC)1 << n; // kleinste Zweierpotenz >= len1 // Wählt man N = len, so hat man ceiling(len2/(len-len1+1)) * FFT(len). // Wählt man N = 2*len, so hat man ceiling(len2/(2*len-len1+1)) * FFT(2*len). // Wir wählen das billigere von beiden: @@ -719,7 +719,7 @@ static void mulu_fft_modp3m (const uintD* sourceptr1, uintC len1, n = n+1; len = len << 1; } - var const uintL N = len; // N = 2^n + var const uintC N = len; // N = 2^n CL_ALLOCA_STACK; var fftp3m_word* const x = cl_alloc_array(fftp3m_word,N); var fftp3m_word* const y = cl_alloc_array(fftp3m_word,N); @@ -730,10 +730,10 @@ static void mulu_fft_modp3m (const uintD* sourceptr1, uintC len1, #endif var uintD* const tmpprod = cl_alloc_array(uintD,len1+1); var uintP i; - var uintL destlen = len1+len2; + var uintC destlen = len1+len2; clear_loop_lsp(destptr,destlen); do { - var uintL len2p; // length of a piece of source2 + var uintC len2p; // length of a piece of source2 len2p = N - len1 + 1; if (len2p > len2) len2p = len2; @@ -746,7 +746,7 @@ static void mulu_fft_modp3m (const uintD* sourceptr1, uintC len1, if (inc_loop_lsp(destptr lspop (len1+1),destlen-(len1+1))) cl_abort(); } else { - var uintL destlenp = len1 + len2p - 1; + var uintC destlenp = len1 + len2p - 1; // destlenp = min(N,destlen-1). var bool squaring = ((sourceptr1 == sourceptr2) && (len1 == len2p)); // Fill factor x. diff --git a/src/base/digitseq/cl_DS_mul_fftr.h b/src/base/digitseq/cl_DS_mul_fftr.h index ee81657..588f102 100644 --- a/src/base/digitseq/cl_DS_mul_fftr.h +++ b/src/base/digitseq/cl_DS_mul_fftr.h @@ -398,10 +398,10 @@ static inline void mul (const fftr_complex& a, const fftr_complex& b, fftr_compl r.im = r_im; } -static uintL shuffle (uintL n, uintL x) +static uintC shuffle (uintL n, uintC x) { - var uintL y = 0; - var sintL v = 1; + var uintC y = 0; + var sintC v = 1; // Invariant: y + v*shuffle(n,x). do { if (x & 1) @@ -417,16 +417,16 @@ static uintL shuffle (uintL n, uintL x) } #if 0 // unused -static uintL invshuffle (uintL n, uintL x) +static uintC invshuffle (uintL n, uintC x) { - var uintL y = 0; - var uintL v = 1; + var uintC y = 0; + var uintC v = 1; // Invariant: y + v*invshuffle(n,x). do { - if (x == ((uintL)1 << (n-1))) + if (x == ((uintC)1 << (n-1))) return y + v; - else if (x > ((uintL)1 << (n-1))) { - x = ((uintL)1 << n) - x; + else if (x > ((uintC)1 << (n-1))) { + x = ((uintC)1 << n) - x; y = y+v; } v <<= 1; @@ -436,7 +436,7 @@ static uintL invshuffle (uintL n, uintL x) #endif // Compute a real convolution using FFT: z[0..N-1] := x[0..N-1] * y[0..N-1]. -static void fftr_convolution (const uintL n, const uintL N, // N = 2^n +static void fftr_convolution (const uintL n, const uintC N, // N = 2^n fftr_real * x, // N numbers fftr_real * y, // N numbers fftr_real * z // N numbers result @@ -444,7 +444,7 @@ static void fftr_convolution (const uintL n, const uintL N, // N = 2^n { CL_ALLOCA_STACK; var fftr_cosinus* const w = cl_alloc_array(fftr_cosinus,N>>2); - var uintL i; + var uintC i; // Initialize w[exp].c to exp(2 pi i exp/N). w[0].c = fftr_roots_of_1[0]; { @@ -469,10 +469,10 @@ static void fftr_convolution (const uintL n, const uintL N, // N = 2^n var uintL l; for (l = n-1; l > 0; l--) { /* s = 0 */ { - var const uintL tmax = (uintL)1 << l; - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var const uintC tmax = (uintC)1 << l; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // replace (x[i1],x[i2]) by // (x[i1] + x[i2], x[i1] - x[i2]) var fftr_real tmp; @@ -481,15 +481,15 @@ static void fftr_convolution (const uintL n, const uintL N, // N = 2^n x[i1] = x[i1] + tmp; } } - var const uintL smax = (uintL)1 << (n-1-l); - var const uintL tmax = (uintL)1 << (l-1); - for (var uintL s = 1; s < smax; s++) { - var uintL exp = shuffle(n-1-l,s) << (l-1); - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; - var uintL i3 = i2 + tmax; - var uintL i4 = i3 + tmax; + var const uintC smax = (uintC)1 << (n-1-l); + var const uintC tmax = (uintC)1 << (l-1); + for (var uintC s = 1; s < smax; s++) { + var uintC exp = shuffle(n-1-l,s) << (l-1); + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; + var uintC i3 = i2 + tmax; + var uintC i4 = i3 + tmax; // replace (x[i1],x[i2],x[i3],x[i4]) by // (x[i1]-x[i3] - x[i4]*gam, // x[i3]*gam + x[i2]+x[i4]*(gam^2-1), @@ -523,10 +523,10 @@ static void fftr_convolution (const uintL n, const uintL N, // N = 2^n var uintL l; for (l = n-1; l > 0; l--) { /* s = 0 */ { - var const uintL tmax = (uintL)1 << l; - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var const uintC tmax = (uintC)1 << l; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // replace (y[i1],y[i2]) by // (y[i1] + y[i2], y[i1] - y[i2]) var fftr_real tmp; @@ -535,15 +535,15 @@ static void fftr_convolution (const uintL n, const uintL N, // N = 2^n y[i1] = y[i1] + tmp; } } - var const uintL smax = (uintL)1 << (n-1-l); - var const uintL tmax = (uintL)1 << (l-1); - for (var uintL s = 1; s < smax; s++) { - var uintL exp = shuffle(n-1-l,s) << (l-1); - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; - var uintL i3 = i2 + tmax; - var uintL i4 = i3 + tmax; + var const uintC smax = (uintC)1 << (n-1-l); + var const uintC tmax = (uintC)1 << (l-1); + for (var uintC s = 1; s < smax; s++) { + var uintC exp = shuffle(n-1-l,s) << (l-1); + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; + var uintC i3 = i2 + tmax; + var uintC i4 = i3 + tmax; // replace (y[i1],y[i2],y[i3],y[i4]) by // (y[i1]-y[i3] - y[i4]*gam, // y[i3]*gam + y[i2]+y[i4]*(gam^2-1), @@ -579,11 +579,11 @@ static void fftr_convolution (const uintL n, const uintL N, // N = 2^n // Multiplication mod (z+1). z[1] = x[1] * y[1]; #if 0 // This needs w[1..2^(n-1)-1]. - var const uintL smax = (uintL)1 << (n-1); - for (var uintL s = 1; s < smax; s++) { + var const uintC smax = (uintC)1 << (n-1); + for (var uintC s = 1; s < smax; s++) { // Multiplication mod (z^2 - 2 cos(2 pi j/2^n) z + 1) // with j = shuffle(n-1,s). - var uintL exp = shuffle(n-1,s); + var uintC exp = shuffle(n-1,s); var fftr_real tmp0 = x[2*s] * y[2*s]; var fftr_real tmp1 = x[2*s] * y[2*s+1] + x[2*s+1] * y[2*s]; var fftr_real tmp2 = x[2*s+1] * y[2*s+1]; @@ -599,9 +599,9 @@ static void fftr_convolution (const uintL n, const uintL N, // N = 2^n z[2] = tmp0 - tmp2; z[3] = tmp1; } - var const uintL smax = (uintL)1 << (n-2); - for (var uintL s = 1; s < smax; s++) { - var uintL exp = shuffle(n-2,s); + var const uintC smax = (uintC)1 << (n-2); + for (var uintC s = 1; s < smax; s++) { + var uintC exp = shuffle(n-2,s); // Multiplication mod (z^2 - 2 cos(2 pi j/2^n) z + 1) // with j = shuffle(n-1,2*s) = shuffle(n-2,s). var fftr_real gam = w[exp].gam.d; @@ -636,10 +636,10 @@ static void fftr_convolution (const uintL n, const uintL N, // N = 2^n } for (l = 1; l < n; l++) { /* s = 0 */ { - var const uintL tmax = (uintL)1 << l; - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = t; - var uintL i2 = i1 + tmax; + var const uintC tmax = (uintC)1 << l; + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = t; + var uintC i2 = i1 + tmax; // replace (z[i1],z[i2]) by // ((z[i1]+z[i2])/2, (z[i1]-z[i2])/2) // Do the division by 2 later. @@ -649,15 +649,15 @@ static void fftr_convolution (const uintL n, const uintL N, // N = 2^n z[i1] = z[i1] + tmp; } } - var const uintL smax = (uintL)1 << (n-1-l); - var const uintL tmax = (uintL)1 << (l-1); - for (var uintL s = 1; s < smax; s++) { - var uintL exp = shuffle(n-1-l,s) << (l-1); - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; - var uintL i3 = i2 + tmax; - var uintL i4 = i3 + tmax; + var const uintC smax = (uintC)1 << (n-1-l); + var const uintC tmax = (uintC)1 << (l-1); + for (var uintC s = 1; s < smax; s++) { + var uintC exp = shuffle(n-1-l,s) << (l-1); + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; + var uintC i3 = i2 + tmax; + var uintC i4 = i3 + tmax; // replace (z[i1],z[i2],z[i3],z[i4]) by // ((z[i1]+z[i3]+(z[i2]-z[i4])/gam)/2, // (z[i2]+z[i4]-(z[i3]-z[i1])/gam*(gam^2-1))/2, @@ -707,10 +707,10 @@ static int max_l_table[32+1] = // Split len uintD's below sourceptr into chunks of l bits, thus filling // N real numbers at x. -static void fill_factor (uintL N, fftr_real* x, uintL l, - const uintD* sourceptr, uintL len) +static void fill_factor (uintC N, fftr_real* x, uintL l, + const uintD* sourceptr, uintC len) { - var uintL i; + var uintC i; if (max_l(2) > intDsize && l > intDsize) { // l > intDsize if (max_l(2) > 64 && l > 64) { @@ -827,11 +827,11 @@ static inline fftr_real fftr_ffloor (fftr_real x) // The z[i] are known to be approximately integers >= 0, < N*2^(2*l). // Assumes room for floor(N*l/intDsize)+(1+ceiling((n+2*l)/intDsize)) uintD's // below destptr. Fills len digits and returns (destptr lspop len). -static uintD* unfill_product (uintL n, uintL N, // N = 2^n +static uintD* unfill_product (uintL n, uintC N, // N = 2^n const fftr_real * z, uintL l, uintD* destptr) { - var uintL i; + var uintC i; if (n + 2*l <= intDsize) { // 2-digit carry is sufficient, l < intDsize var uintD carry0 = 0; @@ -977,11 +977,11 @@ static inline void mulu_fftr_nocheck (const uintD* sourceptr1, uintC len1, // is 2*len1*intDsize/l_max - 1 <= 2^k. { var const int l = max_l(2); - var uintL lhs = 2*ceiling((uintL)len1*intDsize,l) - 1; // >=1 + var uintC lhs = 2*ceiling(len1*intDsize,l) - 1; // >=1 if (lhs < 3) k = 2; else - integerlength32(lhs-1, k=); // k>=2 + integerlengthC(lhs-1, k=); // k>=2 } // Try whether this k is ok or whether we have to increase k. for ( ; ; k++) { @@ -990,22 +990,22 @@ static inline void mulu_fftr_nocheck (const uintD* sourceptr1, uintC len1, fprint(std::cerr, "FFT problem: numbers too big, floating point precision not sufficient\n"); cl_abort(); } - if (2*ceiling((uintL)len1*intDsize,max_l_table[k])-1 <= ((uintL)1 << k)) + if (2*ceiling(len1*intDsize,max_l_table[k])-1 <= ((uintC)1 << k)) break; } // We could try to reduce l, keeping the same k. But why should we? // Calculate the number of pieces in which source2 will have to be // split. Each of the pieces must satisfy // ceiling(len1*intDsize/l) + ceiling(len2*intDsize/l) - 1 <= 2^k, - var uintL len2p; + var uintC len2p; // Try once with k, once with k+1. Compare them. { - var uintL remaining_k = ((uintL)1 << k) + 1 - ceiling((uintL)len1*intDsize,max_l_table[k]); - var uintL max_piecelen_k = floor(remaining_k*max_l_table[k],intDsize); - var uintL numpieces_k = ceiling(len2,max_piecelen_k); - var uintL remaining_k1 = ((uintL)1 << (k+1)) + 1 - ceiling((uintL)len1*intDsize,max_l_table[k+1]); - var uintL max_piecelen_k1 = floor(remaining_k1*max_l_table[k+1],intDsize); - var uintL numpieces_k1 = ceiling(len2,max_piecelen_k1); + var uintC remaining_k = ((uintC)1 << k) + 1 - ceiling(len1*intDsize,max_l_table[k]); + var uintC max_piecelen_k = floor(remaining_k*max_l_table[k],intDsize); + var uintC numpieces_k = ceiling(len2,max_piecelen_k); + var uintC remaining_k1 = ((uintC)1 << (k+1)) + 1 - ceiling(len1*intDsize,max_l_table[k+1]); + var uintC max_piecelen_k1 = floor(remaining_k1*max_l_table[k+1],intDsize); + var uintC numpieces_k1 = ceiling(len2,max_piecelen_k1); if (numpieces_k <= 2*numpieces_k1) { // keep k len2p = max_piecelen_k; @@ -1017,7 +1017,7 @@ static inline void mulu_fftr_nocheck (const uintD* sourceptr1, uintC len1, } var const uintL l = max_l_table[k]; var const uintL n = k; - var const uintL N = (uintL)1 << n; + var const uintC N = (uintC)1 << n; CL_ALLOCA_STACK; var fftr_real* const x = cl_alloc_array(fftr_real,N); var fftr_real* const y = cl_alloc_array(fftr_real,N); @@ -1027,9 +1027,9 @@ static inline void mulu_fftr_nocheck (const uintD* sourceptr1, uintC len1, var fftr_real* const z = x; // put z in place of x - saves memory #endif var uintD* const tmpprod1 = cl_alloc_array(uintD,len1+1); - var uintL tmpprod_len = floor(l< len2) @@ -1058,7 +1058,7 @@ static inline void mulu_fftr_nocheck (const uintD* sourceptr1, uintC len1, { var fftr_real re_lo_limit = (fftr_real)(-0.5); var fftr_real re_hi_limit = (fftr_real)N * fftr_pow2_table[l] * fftr_pow2_table[l] + (fftr_real)0.5; - for (var uintL i = 0; i < N; i++) + for (var uintC i = 0; i < N; i++) if (!(z[i] > re_lo_limit && z[i] < re_hi_limit)) cl_abort(); @@ -1066,7 +1066,7 @@ static inline void mulu_fftr_nocheck (const uintD* sourceptr1, uintC len1, #endif var uintD* tmpLSDptr = arrayLSDptr(tmpprod,tmpprod_len); var uintD* tmpMSDptr = unfill_product(n,N,z,l,tmpLSDptr); - var uintL tmplen = + var uintC tmplen = #if CL_DS_BIG_ENDIAN_P tmpLSDptr - tmpMSDptr; #else diff --git a/src/base/digitseq/cl_DS_mul_kara.h b/src/base/digitseq/cl_DS_mul_kara.h index b838fc2..27704d4 100644 --- a/src/base/digitseq/cl_DS_mul_kara.h +++ b/src/base/digitseq/cl_DS_mul_kara.h @@ -73,7 +73,7 @@ { var uintD* prod_MSDptr; var uintD* prod_LSDptr; var uintD* prodhi_LSDptr; - num_stack_small_alloc(2*(uintL)len1,prod_MSDptr=,prod_LSDptr=); + num_stack_small_alloc(2*len1,prod_MSDptr=,prod_LSDptr=); prodhi_LSDptr = prod_LSDptr lspop 2*k_lo; // prod_MSDptr/2*len1/prod_LSDptr wird zuerst die beiden // Produkte x1*y1 in prod_MSDptr/2*k_hi/prodhi_LSDptr @@ -150,7 +150,7 @@ var uintD* prod_MSDptr; var uintC prod_len = len1+len2; var uintD* prod_LSDptr; - num_stack_small_alloc((uintL)prod_len,prod_MSDptr=,prod_LSDptr=); + num_stack_small_alloc(prod_len,prod_MSDptr=,prod_LSDptr=); { var uintC k_hi = floor(len2,2); // Länge der High-Teile: floor(len2/2) >0 var uintC k_lo = len2 - k_hi; // Länge der Low-Teile: ceiling(len2/2) >0 // Es gilt k_hi <= k_lo <= len1 <= len2, k_lo + k_hi = len2. diff --git a/src/base/digitseq/cl_DS_mul_nuss.h b/src/base/digitseq/cl_DS_mul_nuss.h index 33b06a1..f6968e3 100644 --- a/src/base/digitseq/cl_DS_mul_nuss.h +++ b/src/base/digitseq/cl_DS_mul_nuss.h @@ -946,9 +946,9 @@ static inline void shift (const nuss_outword& a, nuss_outword& b) #ifndef _BIT_REVERSE #define _BIT_REVERSE // Reverse an n-bit number x. n>0. -static uintL bit_reverse (uintL n, uintL x) +static uintC bit_reverse (uintL n, uintC x) { - var uintL y = 0; + var uintC y = 0; do { y <<= 1; y |= (x & 1); @@ -966,14 +966,14 @@ static uintL bit_reverse (uintL n, uintL x) // threshold1 = 3: 25.6 sec 16.6 sec // threshold1 = 4: 25.7 sec 17.6 sec // threshold1 = 5: 26.1 sec 18.0 sec -const uintL cl_nuss_threshold1 = 3; +const uintC cl_nuss_threshold1 = 3; // Threshold for recursion base in mulu_nuss_cyclic(). -const uintL cl_nuss_threshold2 = 1; +const uintC cl_nuss_threshold2 = 1; // Computes z[k] := sum(i+j==k mod N, x[i]*y[j]*(-1)^((i+j-k)/N)) // for all k=0..N-1. -static void mulu_nuss_negacyclic (const uintL n, const uintL N, // N = 2^n +static void mulu_nuss_negacyclic (const uintL n, const uintC N, // N = 2^n const nuss_inword * x, // N words const nuss_inword * y, // N words nuss_outword * z // N words result @@ -1003,9 +1003,9 @@ static void mulu_nuss_negacyclic (const uintL n, const uintL N, // N = 2^n } // 1 < n <= cl_nuss_threshold1. #if 0 // straightforward, but slow - var uintL k; + var uintC k; for (k = 0; k < N; k++) { - var uintL i; + var uintC i; var nuss_outword accu; mul(x[0],y[k], accu); for (i = 1; i <= k; i++) { @@ -1021,14 +1021,14 @@ static void mulu_nuss_negacyclic (const uintL n, const uintL N, // N = 2^n z[k] = accu; } #else - var const uintL M = (uintL)1 << (n-1); // M = N/2 - var uintL i, j, k; + var const uintC M = (uintC)1 << (n-1); // M = N/2 + var uintC i, j, k; for (k = 0; k < N; k++) zero(z[k]); for (i = 0; i < M; i++) { - var uintL iM = i+M; + var uintC iM = i+M; for (j = 0; j < M-i; j++) { - var uintL jM = j+M; + var uintC jM = j+M; // z[i+j] += x[i] (y[j] + y[j+M]) - (x[i] + x[i+M]) y[j+M] // z[i+j+M] += x[i] (y[j] + y[j+M]) + (x[i+M] - x[i]) y[j] var nuss_inword x_sum; @@ -1042,7 +1042,7 @@ static void mulu_nuss_negacyclic (const uintL n, const uintL N, // N = 2^n mul(x_sum,y[j], second); add(first,second, temp); add(z[i+j+M],temp, z[i+j+M]); } for (j = M-i; j < M; j++) { - var uintL jM = j+M; + var uintC jM = j+M; // z[i+j] += x[i] (y[j] + y[j+M]) - (x[i] + x[i+M]) y[j+M] // z[i+j-M] -= x[i] (y[j] + y[j+M]) + (x[i+M] - x[i]) y[j] var nuss_inword x_sum; @@ -1062,8 +1062,8 @@ static void mulu_nuss_negacyclic (const uintL n, const uintL N, // N = 2^n // Recursive FFT. var const uintL m = n >> 1; // floor(n/2) var const uintL r = n - m; // ceiling(n/2) - var const uintL M = (uintL)1 << m; // M = 2^m - var const uintL R = (uintL)1 << r; // R = 2^r + var const uintC M = (uintC)1 << m; // M = 2^m + var const uintC R = (uintC)1 << r; // R = 2^r CL_ALLOCA_STACK; var nuss_inword* const auX = cl_alloc_array(nuss_inword,2*N); var nuss_inword* const auY = cl_alloc_array(nuss_inword,2*N); @@ -1075,7 +1075,7 @@ static void mulu_nuss_negacyclic (const uintL n, const uintL N, // N = 2^n var nuss_inword* const tmp2 = cl_alloc_array(nuss_inword,R); var nuss_outword* const tmpZ = cl_alloc_array(nuss_outword,R); var bool squaring = (x == y); - var uintL i, j; + var uintC i, j; // Initialize polynomials X(i) and Y(i). for (i = 0; i < M; i++) { { @@ -1097,13 +1097,13 @@ static void mulu_nuss_negacyclic (const uintL n, const uintL N, // N = 2^n X(i+M,j) = X(i,j); // Level l = m-1..0: for (l = m-1; l>=0; l--) { - var const uintL smax = (uintL)1 << (m-l); - var const uintL tmax = (uintL)1 << l; - for (var uintL s = 0; s < smax; s++) { - var uintL exp = bit_reverse(m-l,s) << (l + r-m); - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + var const uintC smax = (uintC)1 << (m-l); + var const uintC tmax = (uintC)1 << l; + for (var uintC s = 0; s < smax; s++) { + var uintC exp = bit_reverse(m-l,s) << (l + r-m); + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Butterfly: replace (X(i1),X(i2)) by // (X(i1) + w^exp*X(i2), X(i1) - w^exp*X(i2)). for (j = 0; j < exp; j++) { @@ -1132,13 +1132,13 @@ static void mulu_nuss_negacyclic (const uintL n, const uintL N, // N = 2^n Y(i+M,j) = Y(i,j); // Level l = m-1..0: for (l = m-1; l>=0; l--) { - var const uintL smax = (uintL)1 << (m-l); - var const uintL tmax = (uintL)1 << l; - for (var uintL s = 0; s < smax; s++) { - var uintL exp = bit_reverse(m-l,s) << (l + r-m); - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + var const uintC smax = (uintC)1 << (m-l); + var const uintC tmax = (uintC)1 << l; + for (var uintC s = 0; s < smax; s++) { + var uintC exp = bit_reverse(m-l,s) << (l + r-m); + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Butterfly: replace (Y(i1),Y(i2)) by // (Y(i1) + w^exp*Y(i2), Y(i1) - w^exp*Y(i2)). for (j = 0; j < exp; j++) { @@ -1171,13 +1171,13 @@ static void mulu_nuss_negacyclic (const uintL n, const uintL N, // N = 2^n var uintL l; // Level l = 0..m-1: for (l = 0; l < m; l++) { - var const uintL smax = (uintL)1 << (m-l); - var const uintL tmax = (uintL)1 << l; - for (var uintL s = 0; s < smax; s++) { - var uintL exp = bit_reverse(m-l,s) << (l + r-m); - for (var uintL t = 0; t < tmax; t++) { - var uintL i1 = (s << (l+1)) + t; - var uintL i2 = i1 + tmax; + var const uintC smax = (uintC)1 << (m-l); + var const uintC tmax = (uintC)1 << l; + for (var uintC s = 0; s < smax; s++) { + var uintC exp = bit_reverse(m-l,s) << (l + r-m); + for (var uintC t = 0; t < tmax; t++) { + var uintC i1 = (s << (l+1)) + t; + var uintC i2 = i1 + tmax; // Inverse Butterfly: replace (Z(i1),Z(i2)) by // ((Z(i1)+Z(i2))/2, (Z(i1)-Z(i2))/(2*w^exp)). for (j = 0; j < exp; j++) @@ -1196,8 +1196,8 @@ static void mulu_nuss_negacyclic (const uintL n, const uintL N, // N = 2^n } // Level l=m: for (i = 0; i < M; i++) { - var uintL i1 = i; - var uintL i2 = i1 + M; + var uintC i1 = i; + var uintC i2 = i1 + M; // Inverse Butterfly: replace (Z(i1),Z(i2)) by // ((Z(i1)+Z(i2))/2, (Z(i1)-Z(i2))/2). for (j = 0; j < R; j++) { @@ -1223,7 +1223,7 @@ static void mulu_nuss_negacyclic (const uintL n, const uintL N, // N = 2^n // Computes z[k] := sum(i+j==k mod N, x[i]*y[j]) // for all k=0..N-1. -static void mulu_nuss_cyclic (const uintL n, const uintL N, // N = 2^n +static void mulu_nuss_cyclic (const uintL n, const uintC N, // N = 2^n nuss_inword * x, // N words, modified! nuss_inword * y, // N words, modified! nuss_outword * z // N words result @@ -1258,9 +1258,9 @@ static void mulu_nuss_cyclic (const uintL n, const uintL N, // N = 2^n #if 0 // useless code because cl_nuss_threshold2 == 1 if (n <= cl_nuss_threshold2) { #if 0 // straightforward, but slow - var uintL k; + var uintC k; for (k = 0; k < N; k++) { - var uintL i; + var uintC i; var nuss_outword accu; mul(x[0],y[k], accu); for (i = 1; i <= k; i++) { @@ -1276,14 +1276,14 @@ static void mulu_nuss_cyclic (const uintL n, const uintL N, // N = 2^n z[k] = accu; } #else - var const uintL M = (uintL)1 << (n-1); // M = N/2 - var uintL i, j, k; + var const uintC M = (uintC)1 << (n-1); // M = N/2 + var uintC i, j, k; for (k = 0; k < N; k++) zero(z[k]); for (i = 0; i < M; i++) { - var uintL iM = i+M; + var uintC iM = i+M; for (j = 0; j < M; j++) { - var uintL jM = j+M; + var uintC jM = j+M; // z[i+j] += ((x[i] + x[i+M]) (y[j] + y[j+M]) + (x[i] - x[i+M]) (y[j] - y[j+M])) / 2 // z[i+j+M] += ((x[i] + x[i+M]) (y[j] + y[j+M]) - (x[i] - x[i+M]) (y[j] - y[j+M])) / 2 var nuss_inword x_sum; @@ -1298,7 +1298,7 @@ static void mulu_nuss_cyclic (const uintL n, const uintL N, // N = 2^n mul(x_sum,y_sum, first); mul(x_diff,y_diff, second); add(first,second, temp); add(z[i+j],temp, z[i+j]); - var uintL ijM = (i+j+M) & (N-1); + var uintC ijM = (i+j+M) & (N-1); sub(first,second, temp); add(z[ijM],temp, z[ijM]); } } @@ -1309,8 +1309,8 @@ static void mulu_nuss_cyclic (const uintL n, const uintL N, // N = 2^n } #endif var const uintL m = n-1; - var const uintL M = (uintL)1 << m; // M = 2^m = N/2 - var uintL i; + var const uintC M = (uintC)1 << m; // M = 2^m = N/2 + var uintC i; // Chinese remainder theorem: u^N-1 = (u^M-1)*(u^M+1) for (i = 0; i < M; i++) { // Butterfly: replace (x(i),x(i+M)) @@ -1357,8 +1357,8 @@ static void mulu_nussbaumer (const uintD* sourceptr1, uintC len1, // sum(i=0..N-1, x_i T^i), sum(i=0..N-1, y_i T^i) // multipliziert, und zwar durch Fourier-Transformation (s.o.). var uint32 n; - integerlength32(len1-1, n=); // 2^(n-1) < len1 <= 2^n - var uintL len = (uintL)1 << n; // kleinste Zweierpotenz >= len1 + integerlengthC(len1-1, n=); // 2^(n-1) < len1 <= 2^n + var uintC len = (uintC)1 << n; // kleinste Zweierpotenz >= len1 // Wählt man N = len, so hat man ceiling(len2/(len-len1+1)) * FFT(len). // Wählt man N = 2*len, so hat man ceiling(len2/(2*len-len1+1)) * FFT(2*len). // Wir wählen das billigere von beiden: @@ -1369,17 +1369,17 @@ static void mulu_nussbaumer (const uintD* sourceptr1, uintC len1, n = n+1; len = len << 1; } - var const uintL N = len; // N = 2^n + var const uintC N = len; // N = 2^n CL_ALLOCA_STACK; var nuss_inword* const x = cl_alloc_array(nuss_inword,N); var nuss_inword* const y = cl_alloc_array(nuss_inword,N); var nuss_outword* const z = cl_alloc_array(nuss_outword,N); var uintD* const tmpprod = cl_alloc_array(uintD,len1+1); var uintP i; - var uintL destlen = len1+len2; + var uintC destlen = len1+len2; clear_loop_lsp(destptr,destlen); do { - var uintL len2p; // length of a piece of source2 + var uintC len2p; // length of a piece of source2 len2p = N - len1 + 1; if (len2p > len2) len2p = len2; @@ -1392,7 +1392,7 @@ static void mulu_nussbaumer (const uintD* sourceptr1, uintC len1, if (inc_loop_lsp(destptr lspop (len1+1),destlen-(len1+1))) cl_abort(); } else { - var uintL destlenp = len1 + len2p - 1; + var uintC destlenp = len1 + len2p - 1; // destlenp = min(N,destlen-1). var bool squaring = ((sourceptr1 == sourceptr2) && (len1 == len2p)); // Fill factor x. diff --git a/src/base/digitseq/cl_DS_recip.cc b/src/base/digitseq/cl_DS_recip.cc index 6bcb8a2..a4ed47a 100644 --- a/src/base/digitseq/cl_DS_recip.cc +++ b/src/base/digitseq/cl_DS_recip.cc @@ -137,7 +137,7 @@ namespace cln { } // Other steps. var int k; - integerlength32((uint32)b_len-1,k=); + integerlengthC(b_len-1,k=); // 2^(k-1) < b_len <= 2^k, so we need k steps. var uintC n = 1; for (; k>0; k--) diff --git a/src/base/digitseq/cl_DS_recipsqrt.cc b/src/base/digitseq/cl_DS_recipsqrt.cc index 3554cc3..e561c54 100644 --- a/src/base/digitseq/cl_DS_recipsqrt.cc +++ b/src/base/digitseq/cl_DS_recipsqrt.cc @@ -115,7 +115,7 @@ namespace cln { } // Other steps. var int k; - integerlength32((uint32)b_len-1,k=); + integerlengthC(b_len-1,k=); // 2^(k-1) < b_len <= 2^k, so we need k steps, plus one // one more step at the beginning (because step 1 was not complete). var uintC n = 0; diff --git a/src/base/digitseq/cl_DS_sqrt.cc b/src/base/digitseq/cl_DS_sqrt.cc index 385118d..382c391 100644 --- a/src/base/digitseq/cl_DS_sqrt.cc +++ b/src/base/digitseq/cl_DS_sqrt.cc @@ -29,7 +29,7 @@ namespace cln { // Newton faster for 3200= 3200); } #else // Use the old default values from CLN version <= 1.0.3 as a crude estimate. @@ -47,7 +47,7 @@ namespace cln { // 5000 24.1 10.7 // 10000 98 23.2 // -----> Newton faster for 1570 <= N <= 1790 and for N >= 2100. - static inline cl_boolean cl_recipsqrt_suitable (uintL n) + static inline cl_boolean cl_recipsqrt_suitable (uintC n) { return (cl_boolean)(n >= 2100); } #endif @@ -126,7 +126,7 @@ cl_boolean cl_UDS_sqrt (const uintD* a_MSDptr, uintC a_len, const uintD* a_LSDpt // A um 2s Bits nach links verschoben kopieren: var uintD* new_a_MSDptr; { var uintD* new_a_LSDptr; - num_stack_alloc(2*(uintL)n,new_a_MSDptr=,new_a_LSDptr=); // 2n Digits Platz belegen + num_stack_alloc(2*n,new_a_MSDptr=,new_a_LSDptr=); // 2n Digits Platz belegen {var uintL shiftcount = 2*s; if (!((a_len & bit(0)) ==0)) // a_len ungerade? { s += intDsize/2; lsprefnext(new_a_LSDptr) = 0; } // ja -> ein Nulldigit einschieben diff --git a/src/base/digitseq/cl_DS_trandom.cc b/src/base/digitseq/cl_DS_trandom.cc index aebdfca..5ef781f 100644 --- a/src/base/digitseq/cl_DS_trandom.cc +++ b/src/base/digitseq/cl_DS_trandom.cc @@ -20,17 +20,17 @@ void testrandom_UDS (random_state& randomstate, uintD* MSDptr, uintC len) // Idea from Torbjörn Granlund, see his "random2.c" file in gmp 2.0. var uintD* ptr = MSDptr mspop len; DS_clear_loop(MSDptr,len,ptr); - var uintL bit_pos = 0; + var uintC bit_pos = 0; var uint32 ran = 0; var uintC ran_bits = 0; - while (bit_pos < intDsize*(uintL)len) + while (bit_pos < intDsize*len) { if (ran_bits < log2_intDsize+1) { ran = random32(randomstate); ran_bits = 32; } var uintL n_bits = (ran >> 1) % intDsize + 1; // number of bits if (ran & 1) { // put in a bit string of n_bits bits at position bit_pos. - if (bit_pos + n_bits > intDsize*(uintL)len) - { n_bits = intDsize*(uintL)len - bit_pos; } + if (bit_pos + n_bits > intDsize*len) + { n_bits = intDsize*len - bit_pos; } if (bit_pos / intDsize == (bit_pos + n_bits - 1) / intDsize) { // need to modify one digit lspref(ptr,bit_pos/intDsize) |= (((uintD)1 << n_bits) - 1) << (bit_pos%intDsize); diff --git a/src/complex/input/cl_N_read.cc b/src/complex/input/cl_N_read.cc index b741ad0..0c36339 100644 --- a/src/complex/input/cl_N_read.cc +++ b/src/complex/input/cl_N_read.cc @@ -219,9 +219,9 @@ not_rational_syntax: ptr_after_prec = skip_digits(ptr,string_limit,10); if (ptr_after_prec == ptr) goto not_float_syntax; var cl_I prec1 = digits_to_I(ptr,ptr_after_prec-ptr,10); - var uintL prec2 = cl_I_to_UL(prec1); + var uintC prec2 = cl_I_to_ulong(prec1); prec = (float_base==10 ? float_format(prec2) - : (float_format_t)((uintL)((1+prec2)*::log((double)float_base)*1.442695041)+1) + : (float_format_t)((uintC)((1+prec2)*::log((double)float_base)*1.442695041)+1) ); } else { switch (exponent_marker) { @@ -236,14 +236,14 @@ not_rational_syntax: // Count the number of significant digits. ptr = ptr_after_sign; while (ptr < ptr_after_fracpart && (*ptr == '0' || *ptr == '.')) ptr++; - var uintL num_significant_digits = + var uintC num_significant_digits = (ptr_after_fracpart - ptr) - (ptr_before_fracpart > ptr ? 1 : 0); - var uintL prec2 = (num_significant_digits>=2 ? num_significant_digits-2 : 0); + var uintC prec2 = (num_significant_digits>=2 ? num_significant_digits-2 : 0); var float_format_t precx = (float_base==10 ? float_format(prec2) - : (float_format_t)((uintL)((1+prec2)*::log((double)float_base)*1.442695041)+1) + : (float_format_t)((uintC)((1+prec2)*::log((double)float_base)*1.442695041)+1) ); - if ((uintL)precx > (uintL)prec) + if ((uintC)precx > (uintC)prec) prec = precx; } } diff --git a/src/complex/transcendental/cl_C_asinh_aux.cc b/src/complex/transcendental/cl_C_asinh_aux.cc index 572c722..0ee1461 100644 --- a/src/complex/transcendental/cl_C_asinh_aux.cc +++ b/src/complex/transcendental/cl_C_asinh_aux.cc @@ -109,7 +109,7 @@ const cl_C_R asinh (const cl_R& x, const cl_R& y) var cl_F& y = yf; if (zerop(y)) // y=0.0 -> arcsin(y) = y als Ergebnis return cl_C_R(0,y); - if (float_exponent(y) <= (-(sintL)float_digits(y))>>1) + if (float_exponent(y) <= (-(sintC)float_digits(y))>>1) // e <= -d/2 <==> e <= -ceiling(d/2) return cl_C_R(0,y); var cl_F temp = 1-square(y); diff --git a/src/complex/transcendental/cl_C_expt_C.cc b/src/complex/transcendental/cl_C_expt_C.cc index 6edf335..151a9d2 100644 --- a/src/complex/transcendental/cl_C_expt_C.cc +++ b/src/complex/transcendental/cl_C_expt_C.cc @@ -155,7 +155,7 @@ const cl_N expt (const cl_N& x, const cl_N& y) if (cl_false) { complex_rational: // x in Q(i) - var uintL k = power2p(n); + var uintC k = power2p(n); if (k) { // n Zweierpotenz = 2^(k-1). n>1, also k>1 Mutable(cl_N,x); diff --git a/src/float/cl_F.h b/src/float/cl_F.h index 1a48faa..9dd7b20 100644 --- a/src/float/cl_F.h +++ b/src/float/cl_F.h @@ -275,7 +275,7 @@ extern const cl_F cl_F_shortenrelative (const cl_F& x, const cl_F& y); { if ((value) <= float_format_sfloat) { SF_statement } \ elif ((value) <= float_format_ffloat) { FF_statement } \ elif ((value) <= float_format_dfloat) { DF_statement } \ - else { var uintL len = ceiling((uintL)(value),intDsize); LF_statement } \ + else { var uintC len = ceiling((uintC)(value),intDsize); LF_statement } \ } } // namespace cln diff --git a/src/float/conv/cl_F_from_F_f.cc b/src/float/conv/cl_F_from_F_f.cc index cf94877..fc1d0be 100644 --- a/src/float/conv/cl_F_from_F_f.cc +++ b/src/float/conv/cl_F_from_F_f.cc @@ -15,7 +15,7 @@ namespace cln { const cl_F cl_float (const cl_F& x, float_format_t f) { - floatformatcase((uintL)f + floatformatcase((uintC)f , return cl_F_to_SF(x); , return cl_F_to_FF(x); , return cl_F_to_DF(x); diff --git a/src/float/conv/cl_F_from_I_f.cc b/src/float/conv/cl_F_from_I_f.cc index 4aab33d..1b5b8da 100644 --- a/src/float/conv/cl_F_from_I_f.cc +++ b/src/float/conv/cl_F_from_I_f.cc @@ -19,7 +19,7 @@ namespace cln { const cl_F cl_float (const cl_I& x, float_format_t f) { - floatformatcase((uintL)f + floatformatcase((uintC)f , return cl_I_to_SF(x); , return cl_I_to_FF(x); , return cl_I_to_DF(x); diff --git a/src/float/conv/cl_F_from_RA_f.cc b/src/float/conv/cl_F_from_RA_f.cc index f83ba3c..213db2a 100644 --- a/src/float/conv/cl_F_from_RA_f.cc +++ b/src/float/conv/cl_F_from_RA_f.cc @@ -19,7 +19,7 @@ namespace cln { const cl_F cl_float (const cl_RA& x, float_format_t f) { - floatformatcase((uintL)f + floatformatcase((uintC)f , return cl_RA_to_SF(x); , return cl_RA_to_FF(x); , return cl_RA_to_DF(x); diff --git a/src/float/dfloat/conv/cl_I_to_double.cc b/src/float/dfloat/conv/cl_I_to_double.cc index 6223450..8cb841e 100644 --- a/src/float/dfloat/conv/cl_I_to_double.cc +++ b/src/float/dfloat/conv/cl_I_to_double.cc @@ -22,7 +22,7 @@ double double_approx (const cl_I& x) if (eq(x,0)) { return 0.0; } var cl_signean sign = -(cl_signean)minusp(x); // Vorzeichen var cl_I abs_x = (sign==0 ? x : -x); - var uintL exp = integer_length(abs_x); // (integer-length x) + var uintC exp = integer_length(abs_x); // (integer-length x) // NDS zu |x|>0 bilden: var const uintD* MSDptr; var uintC len; diff --git a/src/float/dfloat/conv/cl_RA_to_double.cc b/src/float/dfloat/conv/cl_RA_to_double.cc index bde025f..373702d 100644 --- a/src/float/dfloat/conv/cl_RA_to_double.cc +++ b/src/float/dfloat/conv/cl_RA_to_double.cc @@ -31,8 +31,8 @@ double double_approx (const cl_RA& x) var const cl_I& b = denominator(x); // b var cl_signean sign = -(cl_signean)minusp(a); // Vorzeichen if (!(sign==0)) { a = -a; } // Betrag nehmen, liefert a - var sintL lendiff = (sintL)integer_length(a) // (integer-length a) - - (sintL)integer_length(b); // (integer-length b) + var sintC lendiff = (sintC)integer_length(a) // (integer-length a) + - (sintC)integer_length(b); // (integer-length b) if (lendiff > DF_exp_high-DF_exp_mid) // Exponent >= n-m > Obergrenze ? { #if (cl_word_size==64) diff --git a/src/float/dfloat/elem/cl_DF_from_I.cc b/src/float/dfloat/elem/cl_DF_from_I.cc index a4efd9d..d07225b 100644 --- a/src/float/dfloat/elem/cl_DF_from_I.cc +++ b/src/float/dfloat/elem/cl_DF_from_I.cc @@ -34,7 +34,7 @@ const cl_DF cl_I_to_DF (const cl_I& x) if (eq(x,0)) { return cl_DF_0; } var cl_signean sign = -(cl_signean)minusp(x); // Vorzeichen var cl_I abs_x = (sign==0 ? x : -x); - var uintL exp = integer_length(abs_x); // (integer-length x) + var uintC exp = integer_length(abs_x); // (integer-length x) // NDS zu |x|>0 bilden: var const uintD* MSDptr; var uintC len; diff --git a/src/float/dfloat/elem/cl_DF_from_RA.cc b/src/float/dfloat/elem/cl_DF_from_RA.cc index 4bba2de..f05bbc5 100644 --- a/src/float/dfloat/elem/cl_DF_from_RA.cc +++ b/src/float/dfloat/elem/cl_DF_from_RA.cc @@ -41,8 +41,8 @@ const cl_DF cl_RA_to_DF (const cl_RA& x) var const cl_I& b = denominator(x); // b var cl_signean sign = -(cl_signean)minusp(a); // Vorzeichen if (!(sign==0)) { a = -a; } // Betrag nehmen, liefert a - var sintL lendiff = (sintL)integer_length(a) // (integer-length a) - - (sintL)integer_length(b); // (integer-length b) + var sintC lendiff = (sintC)integer_length(a) // (integer-length a) + - (sintC)integer_length(b); // (integer-length b) if (lendiff > DF_exp_high-DF_exp_mid) // Exponent >= n-m > Obergrenze ? { cl_error_floating_point_overflow(); } // -> Overflow if (lendiff < DF_exp_low-DF_exp_mid-2) // Exponent <= n-m+2 < Untergrenze ? diff --git a/src/float/dfloat/elem/cl_DF_scale.cc b/src/float/dfloat/elem/cl_DF_scale.cc index ac19bcb..b3c1ef0 100644 --- a/src/float/dfloat/elem/cl_DF_scale.cc +++ b/src/float/dfloat/elem/cl_DF_scale.cc @@ -14,7 +14,7 @@ namespace cln { -const cl_DF scale_float (const cl_DF& x, sintL delta) +const cl_DF scale_float (const cl_DF& x, sintC delta) { // Methode: // x=0.0 -> x als Ergebnis @@ -33,7 +33,7 @@ const cl_DF scale_float (const cl_DF& x, sintL delta) #endif if (delta >= 0) // delta>=0 - { var uintL udelta = delta; + { var uintC udelta = delta; if (udelta <= (uintL)(DF_exp_high-DF_exp_low)) { exp = exp+udelta; #if (cl_word_size==64) @@ -47,7 +47,7 @@ const cl_DF scale_float (const cl_DF& x, sintL delta) } else // delta<0 - { var uintL udelta = -delta; + { var uintC udelta = -delta; if (udelta <= (uintL)(DF_exp_high-DF_exp_low)) { exp = exp-udelta; #if (cl_word_size==64) diff --git a/src/float/dfloat/misc/cl_DF_digits.cc b/src/float/dfloat/misc/cl_DF_digits.cc index 53670bf..97b9fed 100644 --- a/src/float/dfloat/misc/cl_DF_digits.cc +++ b/src/float/dfloat/misc/cl_DF_digits.cc @@ -14,7 +14,7 @@ namespace cln { MAYBE_INLINE -uintL float_digits (const cl_DF& x) +uintC float_digits (const cl_DF& x) { unused x; return DF_mant_len+1; // 53 diff --git a/src/float/dfloat/misc/cl_DF_precision.cc b/src/float/dfloat/misc/cl_DF_precision.cc index 5bafced..0e6b289 100644 --- a/src/float/dfloat/misc/cl_DF_precision.cc +++ b/src/float/dfloat/misc/cl_DF_precision.cc @@ -18,7 +18,7 @@ namespace cln { MAYBE_INLINE2 -uintL float_precision (const cl_DF& x) +uintC float_precision (const cl_DF& x) { if (zerop(x)) return 0; return DF_mant_len+1; // 53 diff --git a/src/float/elem/cl_F_scale.cc b/src/float/elem/cl_F_scale.cc index ae3ff38..b3f9f62 100644 --- a/src/float/elem/cl_F_scale.cc +++ b/src/float/elem/cl_F_scale.cc @@ -17,7 +17,7 @@ namespace cln { -const cl_F scale_float (const cl_F& x, sintL delta) +const cl_F scale_float (const cl_F& x, sintC delta) { floatcase(x , return scale_float(x,delta); diff --git a/src/float/ffloat/conv/cl_I_to_float.cc b/src/float/ffloat/conv/cl_I_to_float.cc index 53d80ec..8b0b56e 100644 --- a/src/float/ffloat/conv/cl_I_to_float.cc +++ b/src/float/ffloat/conv/cl_I_to_float.cc @@ -22,7 +22,7 @@ float float_approx (const cl_I& x) if (eq(x,0)) { return 0.0; } var cl_signean sign = -(cl_signean)minusp(x); // Vorzeichen var cl_I abs_x = (sign==0 ? x : -x); - var uintL exp = integer_length(abs_x); // (integer-length x) + var uintC exp = integer_length(abs_x); // (integer-length x) // NDS zu |x|>0 bilden: var const uintD* MSDptr; var uintC len; diff --git a/src/float/ffloat/conv/cl_RA_to_float.cc b/src/float/ffloat/conv/cl_RA_to_float.cc index d9a2ea8..74a146d 100644 --- a/src/float/ffloat/conv/cl_RA_to_float.cc +++ b/src/float/ffloat/conv/cl_RA_to_float.cc @@ -31,8 +31,8 @@ float float_approx (const cl_RA& x) var const cl_I& b = denominator(x); // b var cl_signean sign = -(cl_signean)minusp(a); // Vorzeichen if (!(sign==0)) { a = -a; } // Betrag nehmen, liefert a - var sintL lendiff = (sintL)integer_length(a) // (integer-length a) - - (sintL)integer_length(b); // (integer-length b) + var sintC lendiff = (sintC)integer_length(a) // (integer-length a) + - (sintC)integer_length(b); // (integer-length b) if (lendiff > FF_exp_high-FF_exp_mid) // Exponent >= n-m > Obergrenze ? { u.eksplicit = make_FF_word(sign,bit(FF_exp_len)-1,0); // Infinity return u.machine_float; diff --git a/src/float/ffloat/elem/cl_FF_from_I.cc b/src/float/ffloat/elem/cl_FF_from_I.cc index a459c46..edf5e45 100644 --- a/src/float/ffloat/elem/cl_FF_from_I.cc +++ b/src/float/ffloat/elem/cl_FF_from_I.cc @@ -34,7 +34,7 @@ const cl_FF cl_I_to_FF (const cl_I& x) if (eq(x,0)) { return cl_FF_0; } var cl_signean sign = -(cl_signean)minusp(x); // Vorzeichen var cl_I abs_x = (sign==0 ? x : -x); - var uintL exp = integer_length(abs_x); // (integer-length x) + var uintC exp = integer_length(abs_x); // (integer-length x) // NDS zu |x|>0 bilden: var const uintD* MSDptr; var uintC len; diff --git a/src/float/ffloat/elem/cl_FF_from_RA.cc b/src/float/ffloat/elem/cl_FF_from_RA.cc index 4e276e6..40332a8 100644 --- a/src/float/ffloat/elem/cl_FF_from_RA.cc +++ b/src/float/ffloat/elem/cl_FF_from_RA.cc @@ -41,8 +41,8 @@ const cl_FF cl_RA_to_FF (const cl_RA& x) var const cl_I& b = denominator(x); // b var cl_signean sign = -(cl_signean)minusp(a); // Vorzeichen if (!(sign==0)) { a = -a; } // Betrag nehmen, liefert a - var sintL lendiff = (sintL)integer_length(a) // (integer-length a) - - (sintL)integer_length(b); // (integer-length b) + var sintC lendiff = (sintC)integer_length(a) // (integer-length a) + - (sintC)integer_length(b); // (integer-length b) if (lendiff > FF_exp_high-FF_exp_mid) // Exponent >= n-m > Obergrenze ? { cl_error_floating_point_overflow(); } // -> Overflow if (lendiff < FF_exp_low-FF_exp_mid-2) // Exponent <= n-m+2 < Untergrenze ? diff --git a/src/float/ffloat/elem/cl_FF_scale.cc b/src/float/ffloat/elem/cl_FF_scale.cc index b6dc24d..8cf7b4d 100644 --- a/src/float/ffloat/elem/cl_FF_scale.cc +++ b/src/float/ffloat/elem/cl_FF_scale.cc @@ -14,7 +14,7 @@ namespace cln { -const cl_FF scale_float (const cl_FF& x, sintL delta) +const cl_FF scale_float (const cl_FF& x, sintC delta) { // Methode: // x=0.0 -> x als Ergebnis @@ -27,7 +27,7 @@ const cl_FF scale_float (const cl_FF& x, sintL delta) FF_decode(x, { return x; }, sign=,exp=,mant=); if (delta >= 0) // delta>=0 - { var uintL udelta = delta; + { var uintC udelta = delta; if (udelta <= (uintL)(FF_exp_high-FF_exp_low)) { exp = exp+udelta; return encode_FF(sign,exp,mant); @@ -37,7 +37,7 @@ const cl_FF scale_float (const cl_FF& x, sintL delta) } else // delta<0 - { var uintL udelta = -delta; + { var uintC udelta = -delta; if (udelta <= (uintL)(FF_exp_high-FF_exp_low)) { exp = exp-udelta; return encode_FF(sign,exp,mant); diff --git a/src/float/ffloat/misc/cl_FF_digits.cc b/src/float/ffloat/misc/cl_FF_digits.cc index cff0855..4d209ef 100644 --- a/src/float/ffloat/misc/cl_FF_digits.cc +++ b/src/float/ffloat/misc/cl_FF_digits.cc @@ -14,7 +14,7 @@ namespace cln { MAYBE_INLINE -uintL float_digits (const cl_FF& x) +uintC float_digits (const cl_FF& x) { unused x; return FF_mant_len+1; // 24 diff --git a/src/float/ffloat/misc/cl_FF_precision.cc b/src/float/ffloat/misc/cl_FF_precision.cc index 9133505..e60defc 100644 --- a/src/float/ffloat/misc/cl_FF_precision.cc +++ b/src/float/ffloat/misc/cl_FF_precision.cc @@ -18,7 +18,7 @@ namespace cln { MAYBE_INLINE2 -uintL float_precision (const cl_FF& x) +uintC float_precision (const cl_FF& x) { if (zerop(x)) return 0; return FF_mant_len+1; // 24 diff --git a/src/float/input/cl_F_read.cc b/src/float/input/cl_F_read.cc index 398510b..3ed96bf 100644 --- a/src/float/input/cl_F_read.cc +++ b/src/float/input/cl_F_read.cc @@ -131,9 +131,9 @@ const cl_F read_float (const cl_read_flags& flags, const char * string, const ch ptr_after_prec = skip_digits(ptr,string_limit,10); if (ptr_after_prec == ptr) goto not_float_syntax; var cl_I prec1 = digits_to_I(ptr,ptr_after_prec-ptr,10); - var uintL prec2 = cl_I_to_UL(prec1); + var uintC prec2 = cl_I_to_UL(prec1); prec = (float_base==10 ? float_format(prec2) - : (float_format_t)((uintL)((1+prec2)*::log((double)float_base)*1.442695041)+1) + : (float_format_t)((uintC)((1+prec2)*::log((double)float_base)*1.442695041)+1) ); } else { switch (exponent_marker) { @@ -148,14 +148,14 @@ const cl_F read_float (const cl_read_flags& flags, const char * string, const ch // Count the number of significant digits. ptr = ptr_after_sign; while (ptr < ptr_after_fracpart && (*ptr == '0' || *ptr == '.')) ptr++; - var uintL num_significant_digits = + var uintC num_significant_digits = (ptr_after_fracpart - ptr) - (ptr_before_fracpart > ptr ? 1 : 0); - var uintL prec2 = (num_significant_digits>=2 ? num_significant_digits-2 : 0); + var uintC prec2 = (num_significant_digits>=2 ? num_significant_digits-2 : 0); var float_format_t precx = (float_base==10 ? float_format(prec2) - : (float_format_t)((uintL)((1+prec2)*::log((double)float_base)*1.442695041)+1) + : (float_format_t)((uintC)((1+prec2)*::log((double)float_base)*1.442695041)+1) ); - if ((uintL)precx > (uintL)prec) + if ((uintC)precx > (uintC)prec) prec = precx; } } diff --git a/src/float/lfloat/algebraic/cl_LF_sqrt.cc b/src/float/lfloat/algebraic/cl_LF_sqrt.cc index 613e4fb..87d974c 100644 --- a/src/float/lfloat/algebraic/cl_LF_sqrt.cc +++ b/src/float/lfloat/algebraic/cl_LF_sqrt.cc @@ -42,7 +42,7 @@ const cl_LF sqrt (const cl_LF& x) CL_ALLOCA_STACK; var uintD* r_MSDptr; var uintD* r_LSDptr; - var uintL r_len = 2*(uintL)len+2; // L�ge des Radikanden + var uintC r_len = 2*len+2; // Länge des Radikanden num_stack_alloc(r_len, r_MSDptr=,r_LSDptr=); if ((uexp & bit(0)) == (LF_exp_mid & bit(0))) // Exponent gerade diff --git a/src/float/lfloat/elem/cl_LF_1plus.cc b/src/float/lfloat/elem/cl_LF_1plus.cc index 4c90e50..00fcfe6 100644 --- a/src/float/lfloat/elem/cl_LF_1plus.cc +++ b/src/float/lfloat/elem/cl_LF_1plus.cc @@ -57,7 +57,7 @@ const cl_LF LF_LF_plus_LF (const cl_LF& arg1, const cl_LF& arg2) swap(uintL, uexp1,uexp2); } } - if (expdiff >= intDsize * (uintL)len + 2) // e1-e2 >= 16n+2 ? + if (expdiff >= intDsize * len + 2) // e1-e2 >= 16n+2 ? { return x1; } // ja -> x1 als Ergebnis // neues Long-Float allozieren: var Lfloat y = allocate_lfloat(len,uexp1,TheLfloat(x1)->sign); @@ -153,7 +153,7 @@ const cl_LF LF_LF_plus_LF (const cl_LF& arg1, const cl_LF& arg2) } // UDS y_mantMSDptr/len/y_mantLSDptr/rounding_bits normalisieren: {var uintD* ptr = y_mantMSDptr; - var uintL k = 0; + var uintC k = 0; var uintC count; dotimesC(count,len, { if (!(mspref(ptr,0)==0)) goto nonzero_found; diff --git a/src/float/lfloat/elem/cl_LF_I_div.cc b/src/float/lfloat/elem/cl_LF_I_div.cc index bce4a5a..188f089 100644 --- a/src/float/lfloat/elem/cl_LF_I_div.cc +++ b/src/float/lfloat/elem/cl_LF_I_div.cc @@ -33,7 +33,7 @@ const cl_LF cl_LF_I_div (const cl_LF& x, const cl_I& y) } var cl_signean sign = -(cl_signean)minusp(y); // Vorzeichen von y var cl_I abs_y = (sign==0 ? y : -y); - var uintL y_exp = integer_length(abs_y); + var uintC y_exp = integer_length(abs_y); var uintC len = TheLfloat(x)->len; #ifndef CL_LF_PEDANTIC if (ceiling(y_exp,intDsize) > len) @@ -48,9 +48,9 @@ const cl_LF cl_LF_I_div (const cl_LF& x, const cl_I& y) // y nicht zu einer NUDS normalisieren! (Damit ein Bit Spielraum ist.) // Zähler bilden: x * 2^(intDsize*y_len) var uintD* z_MSDptr; - var uintL z_len; + var uintC z_len; var uintD* z_LSDptr; - z_len = (uintL)len + (uintL)y_len; + z_len = len + y_len; num_stack_alloc(z_len, z_MSDptr=,z_LSDptr=); { var uintD* ptr = copy_loop_msp(arrayMSDptr(TheLfloat(x)->data,len),z_MSDptr,len); // len Digits clear_loop_msp(ptr,y_len); // und y_len Null-Digits diff --git a/src/float/lfloat/elem/cl_LF_I_mul.cc b/src/float/lfloat/elem/cl_LF_I_mul.cc index 4fcafe1..927c268 100644 --- a/src/float/lfloat/elem/cl_LF_I_mul.cc +++ b/src/float/lfloat/elem/cl_LF_I_mul.cc @@ -28,7 +28,7 @@ const cl_R cl_LF_I_mul (const cl_LF& x, const cl_I& y) if (TheLfloat(x)->expo == 0) { return x; } var cl_signean sign = -(cl_signean)minusp(y); // Vorzeichen von y var cl_I abs_y = (sign==0 ? y : -y); - var uintL y_exp = integer_length(abs_y); + var uintC y_exp = integer_length(abs_y); var uintC len = TheLfloat(x)->len; #ifndef CL_LF_PEDANTIC if (ceiling(y_exp,intDsize) > len) diff --git a/src/float/lfloat/elem/cl_LF_div.cc b/src/float/lfloat/elem/cl_LF_div.cc index 3d4aa2a..d41f41d 100644 --- a/src/float/lfloat/elem/cl_LF_div.cc +++ b/src/float/lfloat/elem/cl_LF_div.cc @@ -69,7 +69,7 @@ const cl_LF operator/ (const cl_LF& x1, const cl_LF& x2) TheLfloat(x1)->sign ^ TheLfloat(x2)->sign // Vorzeichen kombinieren ); // Nenner bilden: - var uintL n_len; + var uintC n_len; n_len = len2; #ifndef CL_LF_PEDANTIC if (n_len > len) { n_len = len+1; } @@ -77,7 +77,7 @@ const cl_LF operator/ (const cl_LF& x1, const cl_LF& x2) // Zähler bilden: CL_ALLOCA_STACK; var uintD* z_MSDptr; - var uintL z_len; + var uintC z_len; var uintD* z_LSDptr; z_len = n_len + len + 1; num_stack_alloc(z_len, z_MSDptr=,z_LSDptr=); diff --git a/src/float/lfloat/elem/cl_LF_from_I.cc b/src/float/lfloat/elem/cl_LF_from_I.cc index 7b9ba79..bb9c483 100644 --- a/src/float/lfloat/elem/cl_LF_from_I.cc +++ b/src/float/lfloat/elem/cl_LF_from_I.cc @@ -36,7 +36,7 @@ const cl_LF cl_I_to_LF (const cl_I& x, uintC len) if (eq(x,0)) { return encode_LF0(len); } // x=0 -> Ergebnis 0.0 var cl_signean sign = -(cl_signean)minusp(x); // Vorzeichen von x var cl_I abs_x = (sign==0 ? x : -x); - var uintL exp = integer_length(abs_x); // (integer-length x) < intDsize*2^intCsize + var uintC exp = integer_length(abs_x); // (integer-length x) < intDsize*2^intCsize // Teste, ob exp <= LF_exp_high-LF_exp_mid : if ( (log2_intDsize+intCsize < 32) && ((uintL)(intDsize*bitc(intCsize)-1) <= (uintL)(LF_exp_high-LF_exp_mid)) diff --git a/src/float/lfloat/elem/cl_LF_from_RA.cc b/src/float/lfloat/elem/cl_LF_from_RA.cc index 58f9db1..e180872 100644 --- a/src/float/lfloat/elem/cl_LF_from_RA.cc +++ b/src/float/lfloat/elem/cl_LF_from_RA.cc @@ -55,21 +55,21 @@ const cl_LF cl_RA_to_LF (const cl_RA& x, uintC len) var const cl_I& b = denominator(x); // b var cl_signean sign = -(cl_signean)minusp(a); // Vorzeichen if (!(sign==0)) { a = -a; } // Betrag nehmen, liefert a - var sintL lendiff = (sintL)integer_length(a) // (integer-length a) - - (sintL)integer_length(b); // (integer-length b) + var sintC lendiff = (sintC)integer_length(a) // (integer-length a) + - (sintC)integer_length(b); // (integer-length b) // |lendiff| < intDsize*2^intCsize. Da für LF-Exponenten ein sintL zur // Verfügung steht, braucht man keinen Test auf Overflow oder Underflow. - var uintL difflimit = intDsize*(uintL)len + 1; // 16n+1 + var uintC difflimit = intDsize*len + 1; // 16n+1 var cl_I zaehler; var cl_I nenner; - if (lendiff > (sintL)difflimit) + if (lendiff > (sintC)difflimit) // 0 <= k-m-16n-1 < k < intDsize*2^intCsize - { nenner = ash(b,(uintL)(lendiff - difflimit)); + { nenner = ash(b,(uintC)(lendiff - difflimit)); zaehler = a; } else // 0 < -k+m+16n+1 <= m+1 + 16n < intDsize*2^intCsize + intDsize*2^intCsize - { zaehler = ash(a,(uintL)(difflimit - lendiff)); // (ash a -k+m+16n+1) + { zaehler = ash(a,(uintC)(difflimit - lendiff)); // (ash a -k+m+16n+1) nenner = b; // b } // Division zaehler/nenner durchführen: diff --git a/src/float/lfloat/elem/cl_LF_fround.cc b/src/float/lfloat/elem/cl_LF_fround.cc index 18bc495..8decf62 100644 --- a/src/float/lfloat/elem/cl_LF_fround.cc +++ b/src/float/lfloat/elem/cl_LF_fround.cc @@ -29,7 +29,7 @@ const cl_LF fround (const cl_LF& x) var uintC mantlen; LF_decode(x, { return x; }, sign=,exp=,mantMSDptr=,mantlen=,); if (exp<0) { return encode_LF0(mantlen); } // e<0 -> Ergebnis 0.0 - if ((uintL)exp >= intDsize*(uintL)mantlen) // e>=16n -> x als Ergebnis + if ((uintL)exp >= intDsize*mantlen) // e>=16n -> x als Ergebnis { return x; } else // 0 <= e < 16n @@ -81,7 +81,7 @@ const cl_LF fround (const cl_LF& x) return encode_LF0(len); // e<0 -> Ergebnis 0.0 } var uintL exp = uexp - LF_exp_mid; - if (exp >= intDsize*(uintL)len) // e>=16n -> x als Ergebnis + if (exp >= intDsize*len) // e>=16n -> x als Ergebnis { return x; } // 0 <= e < 16n // alle hinteren 16n-e Bits wegrunden: diff --git a/src/float/lfloat/elem/cl_LF_ftrunc.cc b/src/float/lfloat/elem/cl_LF_ftrunc.cc index a9a2616..764d732 100644 --- a/src/float/lfloat/elem/cl_LF_ftrunc.cc +++ b/src/float/lfloat/elem/cl_LF_ftrunc.cc @@ -29,7 +29,7 @@ const cl_LF ftruncate (const cl_LF& x) var uintC mantlen; LF_decode(x, { return x; }, sign=,exp=,mantMSDptr=,mantlen=,); if (exp<=0) { return encode_LF0(mantlen); } // e<=0 -> Ergebnis 0.0 - if ((uintL)exp >= intDsize*(uintL)mantlen) // e>=16n -> x als Ergebnis + if ((uintL)exp >= intDsize*mantlen) // e>=16n -> x als Ergebnis { return x; } else // 0 < e < 16n @@ -54,7 +54,7 @@ const cl_LF ftruncate (const cl_LF& x) return encode_LF0(len); // e<=0 -> Ergebnis 0.0 } var uintL exp = uexp - LF_exp_mid; - if (exp >= intDsize*(uintL)len) // e>=16n -> x als Ergebnis + if (exp >= intDsize*len) // e>=16n -> x als Ergebnis { return x; } // 0 < e < 16n var Lfloat y = allocate_lfloat(len,uexp,TheLfloat(x)->sign); // neues Long-Float diff --git a/src/float/lfloat/elem/cl_LF_futrunc.cc b/src/float/lfloat/elem/cl_LF_futrunc.cc index c044194..fe31e90 100644 --- a/src/float/lfloat/elem/cl_LF_futrunc.cc +++ b/src/float/lfloat/elem/cl_LF_futrunc.cc @@ -34,7 +34,7 @@ const cl_LF futruncate (const cl_LF& x) var uintC mantlen; LF_decode(x, { return x; }, sign=,exp=,mantMSDptr=,mantlen=,); if (exp<=0) { return encode_LF1s(sign,mantlen); } // e<=0 -> Ergebnis +-1.0 - if ((uintL)exp >= intDsize*(uintL)mantlen) // e>=16n -> x als Ergebnis + if ((uintL)exp >= intDsize*mantlen) // e>=16n -> x als Ergebnis { return x; } else // 0 < e < 16n @@ -70,7 +70,7 @@ const cl_LF futruncate (const cl_LF& x) return encode_LF1s(TheLfloat(x)->sign,len); // e<=0 -> Ergebnis +-1.0 } var uintL exp = uexp - LF_exp_mid; - if (exp >= intDsize*(uintL)len) // e>=16n -> x als Ergebnis + if (exp >= intDsize*len) // e>=16n -> x als Ergebnis { return x; } // 0 < e < 16n // Testen, ob alle hinteren 16n-e Bits =0 sind: diff --git a/src/float/lfloat/elem/cl_LF_scale.cc b/src/float/lfloat/elem/cl_LF_scale.cc index bcbb519..3ec4909 100644 --- a/src/float/lfloat/elem/cl_LF_scale.cc +++ b/src/float/lfloat/elem/cl_LF_scale.cc @@ -15,7 +15,7 @@ namespace cln { -const cl_LF scale_float (const cl_LF& x, sintL delta) +const cl_LF scale_float (const cl_LF& x, sintC delta) { // Methode: // delta=0 -> x als Ergebnis @@ -25,7 +25,7 @@ const cl_LF scale_float (const cl_LF& x, sintL delta) if (delta == 0) { return x; } // delta=0 -> x als Ergebnis var uintL uexp = TheLfloat(x)->expo; if (uexp==0) { return x; } - var uintL udelta = delta; + var uintC udelta = delta; if (delta >= 0) { // udelta = delta >=0 if ( ((uexp = uexp+udelta) < udelta) // Exponent-Überlauf? @@ -33,8 +33,8 @@ const cl_LF scale_float (const cl_LF& x, sintL delta) ) { cl_error_floating_point_overflow(); } } else { - // delta <0, udelta = 2^32+delta - if ( ((uexp = uexp+udelta) >= udelta) // oder Exponent-Unterlauf? + // delta <0, udelta = 2^intCsize+delta + if ( ((uintL)(-(uexp = uexp+udelta)) <= (uintC)(-udelta)) // oder Exponent-Unterlauf? || (uexp < LF_exp_low) // oder Exponent zu klein? ) { cl_error_floating_point_underflow(); } diff --git a/src/float/lfloat/elem/cl_LF_to_I.cc b/src/float/lfloat/elem/cl_LF_to_I.cc index c0f32ba..d91421e 100644 --- a/src/float/lfloat/elem/cl_LF_to_I.cc +++ b/src/float/lfloat/elem/cl_LF_to_I.cc @@ -42,7 +42,7 @@ const cl_I cl_LF_to_I (const cl_LF& x) // Vorzeichen*Mantisse ist die DS MSDptr/len1/LSDptr. // (ASH Vorzeichen*Mantisse (- e 16n)) durchführen: return ash(DS_to_I(MSDptr,len1), - minus(uexp, LF_exp_mid + intDsize*(uintL)len) + minus(uexp, LF_exp_mid + intDsize*len) ); } diff --git a/src/float/lfloat/misc/cl_LF_digits.cc b/src/float/lfloat/misc/cl_LF_digits.cc index 76a8139..d1e323a 100644 --- a/src/float/lfloat/misc/cl_LF_digits.cc +++ b/src/float/lfloat/misc/cl_LF_digits.cc @@ -14,9 +14,9 @@ namespace cln { MAYBE_INLINE -uintL float_digits (const cl_LF& x) +uintC float_digits (const cl_LF& x) { - return intDsize*(uintL)(TheLfloat(x)->len); + return intDsize*(uintC)(TheLfloat(x)->len); } } // namespace cln diff --git a/src/float/lfloat/misc/cl_LF_idecode.cc b/src/float/lfloat/misc/cl_LF_idecode.cc index 06c8d09..b21490c 100644 --- a/src/float/lfloat/misc/cl_LF_idecode.cc +++ b/src/float/lfloat/misc/cl_LF_idecode.cc @@ -34,7 +34,7 @@ const cl_idecoded_float integer_decode_float (const cl_LF& x) // Mantisse mant, // e-intDsize*n = uexp-LF_exp_mid-intDsize*n als Integer - minus(uexp, LF_exp_mid + intDsize*(uintL)len), + minus(uexp, LF_exp_mid + intDsize*len), (sign>=0 ? cl_I(1) : cl_I(-1)) // (-1)^s erzeugen ); } diff --git a/src/float/lfloat/misc/cl_LF_leninc.cc b/src/float/lfloat/misc/cl_LF_leninc.cc index b05c875..4266867 100644 --- a/src/float/lfloat/misc/cl_LF_leninc.cc +++ b/src/float/lfloat/misc/cl_LF_leninc.cc @@ -27,9 +27,9 @@ uintC cl_LF_len_incsqrt (uintC n) // <==> intDsize*n < intDsize^2*inc^2 - 4*intDsize*inc + 4 // <==> n <= intDsize*inc^2 - 4*inc return - #define NMAX(k) (uintL)((intDsize*(k)-4)*(k)) + #define NMAX(k) (uintC)((intDsize*(k)-4)*(k)) #define FITS(n,k) ((n) <= NMAX(k)) - #define n_max (uintL)(bitm(intCsize)-1) + #define n_max (uintC)(bitm(intCsize)-1) #define TRYINC(inc) FITS(n_max,inc) || FITS(n,inc) ? RETINC(inc) : #define RETINC(inc) \ /* at this point we know n <= NMAX(inc) */ \ diff --git a/src/float/lfloat/misc/cl_LF_lenincx.cc b/src/float/lfloat/misc/cl_LF_lenincx.cc index 76620d6..0a670f6 100644 --- a/src/float/lfloat/misc/cl_LF_lenincx.cc +++ b/src/float/lfloat/misc/cl_LF_lenincx.cc @@ -20,9 +20,9 @@ uintC cl_LF_len_incsqrtx (uintC n) // <==> intDsize*n < intDsize^2*inc^2 - 66*intDsize*inc + 1089 // <==> n <= intDsize*inc^2 - 66*inc + floor(1089/intDsize) return - #define NMAX(k) (uintL)((intDsize*(k)-66)*(k)+floor(1089,intDsize)) + #define NMAX(k) (uintC)((intDsize*(k)-66)*(k)+floor(1089,intDsize)) #define FITS(n,k) ((intDsize*(k) > 33) && ((n) <= NMAX(k))) - #define n_max (uintL)(bitm(intCsize)-1) + #define n_max (uintC)(bitm(intCsize)-1) #define TRYINC(inc) FITS(n_max,inc) || FITS(n,inc) ? RETINC(inc) : #define RETINC(inc) \ /* at this point we know n <= NMAX(inc) */ \ diff --git a/src/float/lfloat/misc/cl_LF_precision.cc b/src/float/lfloat/misc/cl_LF_precision.cc index 2a2a411..90c0247 100644 --- a/src/float/lfloat/misc/cl_LF_precision.cc +++ b/src/float/lfloat/misc/cl_LF_precision.cc @@ -18,10 +18,10 @@ namespace cln { MAYBE_INLINE2 -uintL float_precision (const cl_LF& x) +uintC float_precision (const cl_LF& x) { if (zerop(x)) return 0; - return intDsize*(uintL)(TheLfloat(x)->len); + return intDsize*(uintC)(TheLfloat(x)->len); } } // namespace cln diff --git a/src/float/lfloat/misc/cl_LF_shortenrel.cc b/src/float/lfloat/misc/cl_LF_shortenrel.cc index e37e72e..3207bda 100644 --- a/src/float/lfloat/misc/cl_LF_shortenrel.cc +++ b/src/float/lfloat/misc/cl_LF_shortenrel.cc @@ -29,11 +29,11 @@ const cl_LF cl_LF_shortenrelative (const cl_LF& x, const cl_LF& y) // 1 ulp(x) = 2^(ex-dx), 1 ulp(y) = 2^(ey-dy). // Falls ex-dx < ey-dy, x von Precision dx auf dy-ey+ex verkürzen. var sintL ey = float_exponent(y); - var sintL dy = float_precision(y); + var sintC dy = float_precision(y); if (dy==0) // zerop(y) ? cl_abort(); var sintL ex = float_exponent(x); - var sintL dx = float_precision(x); + var sintC dx = float_precision(x); if (dx==0) // zerop(x) ? return x; var sintL d = ex - ey; @@ -43,11 +43,11 @@ const cl_LF cl_LF_shortenrelative (const cl_LF& x, const cl_LF& y) return LF_to_LF(x,LF_minlen); if (d >= dx - dy) return x; - var uintL new_dx = dy + d; - var uintL len = ceiling(new_dx,intDsize); + var uintC new_dx = dy + d; + var uintC len = ceiling(new_dx,intDsize); if (len < LF_minlen) len = LF_minlen; - if (intDsize*len < (uintL)dx) + if (intDsize*len < (uintC)dx) return shorten(x,len); else return x; diff --git a/src/float/lfloat/misc/cl_LF_shortenwith.cc b/src/float/lfloat/misc/cl_LF_shortenwith.cc index 551c00e..f0ed744 100644 --- a/src/float/lfloat/misc/cl_LF_shortenwith.cc +++ b/src/float/lfloat/misc/cl_LF_shortenwith.cc @@ -29,7 +29,7 @@ const cl_LF cl_LF_shortenwith (const cl_LF& x, const cl_LF& y) // Falls ex-dx < ey, x von Precision dx auf ex-ey verkürzen. var sintL ey = float_exponent(y); var sintL ex = float_exponent(x); - var uintL dx = float_precision(x); + var uintC dx = float_precision(x); if (dx==0) // zerop(x) ? return x; var sintL ulpx = ex - dx; diff --git a/src/float/misc/cl_F_digits.cc b/src/float/misc/cl_F_digits.cc index 0c2212d..635063d 100644 --- a/src/float/misc/cl_F_digits.cc +++ b/src/float/misc/cl_F_digits.cc @@ -20,7 +20,7 @@ namespace cln { -uintL float_digits (const cl_F& x) +uintC float_digits (const cl_F& x) { floatcase(x , return float_digits(x); diff --git a/src/float/misc/cl_F_epsneg.cc b/src/float/misc/cl_F_epsneg.cc index 89935d8..8a8ba5a 100644 --- a/src/float/misc/cl_F_epsneg.cc +++ b/src/float/misc/cl_F_epsneg.cc @@ -38,7 +38,7 @@ static const cl_DF DF_negative_epsilon = inline const cl_LF LF_negative_epsilon (uintC len) { - var Lfloat erg = allocate_lfloat(len,LF_exp_mid-intDsize*(uintL)len,0); + var Lfloat erg = allocate_lfloat(len,LF_exp_mid-intDsize*len,0); var uintD* ptr = &TheLfloat(erg)->data[0]; #if CL_DS_BIG_ENDIAN_P *ptr++ = bit(intDsize-1); @@ -54,7 +54,7 @@ inline const cl_LF LF_negative_epsilon (uintC len) const cl_F float_negative_epsilon (float_format_t f) { - floatformatcase((uintL)f + floatformatcase((uintC)f , return SF_negative_epsilon; , return FF_negative_epsilon; , return DF_negative_epsilon; diff --git a/src/float/misc/cl_F_epspos.cc b/src/float/misc/cl_F_epspos.cc index 52385c0..f3ade60 100644 --- a/src/float/misc/cl_F_epspos.cc +++ b/src/float/misc/cl_F_epspos.cc @@ -37,7 +37,7 @@ static const cl_DF DF_epsilon = inline const cl_LF LF_epsilon (uintC len) { - var Lfloat erg = allocate_lfloat(len,LF_exp_mid+1-intDsize*(uintL)len,0); + var Lfloat erg = allocate_lfloat(len,LF_exp_mid+1-intDsize*len,0); var uintD* ptr = &TheLfloat(erg)->data[0]; #if CL_DS_BIG_ENDIAN_P *ptr++ = bit(intDsize-1); @@ -53,7 +53,7 @@ inline const cl_LF LF_epsilon (uintC len) const cl_F float_epsilon (float_format_t f) { - floatformatcase((uintL)f + floatformatcase((uintC)f , return SF_epsilon; , return FF_epsilon; , return DF_epsilon; diff --git a/src/float/misc/cl_F_leastneg.cc b/src/float/misc/cl_F_leastneg.cc index 8e669e8..63a01ce 100644 --- a/src/float/misc/cl_F_leastneg.cc +++ b/src/float/misc/cl_F_leastneg.cc @@ -49,7 +49,7 @@ inline const cl_LF least_negative_LF (uintC len) const cl_F least_negative_float (float_format_t f) { - floatformatcase((uintL)f + floatformatcase((uintC)f , return least_negative_SF; , return least_negative_FF; , return least_negative_DF; diff --git a/src/float/misc/cl_F_leastpos.cc b/src/float/misc/cl_F_leastpos.cc index d85014e..16fdecc 100644 --- a/src/float/misc/cl_F_leastpos.cc +++ b/src/float/misc/cl_F_leastpos.cc @@ -49,7 +49,7 @@ inline const cl_LF least_positive_LF (uintC len) const cl_F least_positive_float (float_format_t f) { - floatformatcase((uintL)f + floatformatcase((uintC)f , return least_positive_SF; , return least_positive_FF; , return least_positive_DF; diff --git a/src/float/misc/cl_F_mostneg.cc b/src/float/misc/cl_F_mostneg.cc index 1aa14b2..ca1d467 100644 --- a/src/float/misc/cl_F_mostneg.cc +++ b/src/float/misc/cl_F_mostneg.cc @@ -43,7 +43,7 @@ inline const cl_LF most_negative_LF (uintC len) const cl_F most_negative_float (float_format_t f) { - floatformatcase((uintL)f + floatformatcase((uintC)f , return most_negative_SF; , return most_negative_FF; , return most_negative_DF; diff --git a/src/float/misc/cl_F_mostpos.cc b/src/float/misc/cl_F_mostpos.cc index ee3a42f..daed686 100644 --- a/src/float/misc/cl_F_mostpos.cc +++ b/src/float/misc/cl_F_mostpos.cc @@ -43,7 +43,7 @@ inline const cl_LF most_positive_LF (uintC len) const cl_F most_positive_float (float_format_t f) { - floatformatcase((uintL)f + floatformatcase((uintC)f , return most_positive_SF; , return most_positive_FF; , return most_positive_DF; diff --git a/src/float/misc/cl_F_precision.cc b/src/float/misc/cl_F_precision.cc index a2a167c..ab4f215 100644 --- a/src/float/misc/cl_F_precision.cc +++ b/src/float/misc/cl_F_precision.cc @@ -20,7 +20,7 @@ namespace cln { -uintL float_precision (const cl_F& x) +uintC float_precision (const cl_F& x) { floatcase(x , return float_precision(x); diff --git a/src/float/misc/cl_F_rational.cc b/src/float/misc/cl_F_rational.cc index fdbc1ff..e14590a 100644 --- a/src/float/misc/cl_F_rational.cc +++ b/src/float/misc/cl_F_rational.cc @@ -38,14 +38,14 @@ const cl_RA rational (const cl_F& x) // 0 < -e <= LF_exp_mid-LF_exp_low + intDsize*len < 2^32, var cl_I minus_e = -e; var uintL _e = cl_I_to_UL(minus_e); // daher kein Überlauf - var uintL k = ord2(n); + var uintC k = ord2(n); if (k >= _e) // Kürze mit 2^(-e). return ash(n,e); else // Kürze mit 2^k, 0 <= k < -e. - return I_I_to_RT(ash(n,-(sintL)k), - ash(1,minus_e-UL_to_I(k))); + return I_I_to_RT(ash(n,-(sintC)k), + ash(1,minus_e-(cl_I)(unsigned long)k)); #endif } } diff --git a/src/float/misc/cl_F_shortenrel.cc b/src/float/misc/cl_F_shortenrel.cc index 2438a76..d4bea6d 100644 --- a/src/float/misc/cl_F_shortenrel.cc +++ b/src/float/misc/cl_F_shortenrel.cc @@ -23,11 +23,11 @@ const cl_F cl_F_shortenrelative (const cl_F& x, const cl_F& y) // 1 ulp(x) = 2^(ex-dx), 1 ulp(y) = 2^(ey-dy). // Falls ex-dx < ey-dy, x von Precision dx auf dy-ey+ex verkürzen. var sintL ey = float_exponent(y); - var sintL dy = float_precision(y); + var sintC dy = float_precision(y); if (dy==0) // zerop(y) ? cl_abort(); var sintL ex = float_exponent(x); - var sintL dx = float_precision(x); + var sintC dx = float_precision(x); if (dx==0) // zerop(x) ? return x; var sintL d = ex - ey; @@ -37,12 +37,12 @@ const cl_F cl_F_shortenrelative (const cl_F& x, const cl_F& y) return cl_F_to_SF(x); if (d >= dx - dy) return x; - var uintL new_dx = dy + d; + var uintC new_dx = dy + d; floatformatcase(new_dx , return cl_F_to_SF(x); , return cl_F_to_FF(x); , return cl_F_to_DF(x); - , if (intDsize*len < (uintL)dx) + , if (intDsize*len < (uintC)dx) return shorten(The(cl_LF)(x),len); else return x; diff --git a/src/float/output/cl_F_dprint.cc b/src/float/output/cl_F_dprint.cc index 993b44b..79d182c 100644 --- a/src/float/output/cl_F_dprint.cc +++ b/src/float/output/cl_F_dprint.cc @@ -80,7 +80,7 @@ static const cl_decimal_decoded_float decode_float_decimal (const cl_F& x) // x/=0, also ist sign das Vorzeichen von x und // |x| = 2^binexpo * float(binmant,x) . Ab jetzt oBdA x>0. // Also x = 2^binexpo * float(binmant,x) . - var uintL l = integer_length(binmant); // Anzahl der Bits von binmant, >=3 + var uintC l = integer_length(binmant); // Anzahl der Bits von binmant, >=3 var cl_I binmant2 = ash(binmant,1); // 2*binmant var cl_I oben = plus1(binmant2); // obere Intervallgrenze ist // (x+x2)/2 = 2^(binexpo-1) * oben @@ -101,7 +101,7 @@ static const cl_decimal_decoded_float decode_float_decimal (const cl_F& x) // Wandle dazu 2^e := 2^(binexpo-1) ins Dezimalsystem um. var cl_I e = binexpo - 1; var bool e_gross = (abs(e) > ash(l,1)); // Ist |e| recht groß, >2*l ? - var uintL g; // Hilfsvariablen für den Fall, daß |e| groß ist + var uintC g; // Hilfsvariablen für den Fall, daß |e| groß ist var cl_I f; // var cl_I zehn_d; // Hilfsvariable 10^|d| für den Fall, daß |e| klein ist var cl_I d; // Ergebnisvariablen diff --git a/src/float/random/cl_F_random.cc b/src/float/random/cl_F_random.cc index 64c6dc0..80cb9a8 100644 --- a/src/float/random/cl_F_random.cc +++ b/src/float/random/cl_F_random.cc @@ -17,10 +17,10 @@ namespace cln { const cl_F random_F (random_state& randomstate, const cl_F& n) { - var uintL d = float_digits(n); // d = (float-digits n) > 0 + var uintC d = float_digits(n); // d = (float-digits n) > 0 // Bilde neue UDS mit d Zufallsbits: CL_ALLOCA_STACK; - var uintL len = ceiling(d,intDsize); + var uintC len = ceiling(d,intDsize); var uintD* MSDptr; num_stack_alloc_1(len,MSDptr=,); random_UDS(randomstate,MSDptr,len); // len (>0) Zufallsdigits @@ -30,7 +30,7 @@ const cl_F random_F (random_state& randomstate, const cl_F& n) var cl_I mant = UDS_to_I(MSDptr,len); // Bilde Zufalls-Float zwischen 0 und 1 // = (scale-float (float Zufalls-Integer,d_Bits n) (- d)) : - var cl_F result = scale_float(cl_float(mant,n),-(sintL)d) * n; + var cl_F result = scale_float(cl_float(mant,n),-(sintC)d) * n; // result ist ein Zufalls-Float >=0, <=n. if (result == n) // falls (durch Rundung) result=n, durch 0 ersetzen: diff --git a/src/float/sfloat/elem/cl_SF_from_I.cc b/src/float/sfloat/elem/cl_SF_from_I.cc index 1ba7b77..e3f0029 100644 --- a/src/float/sfloat/elem/cl_SF_from_I.cc +++ b/src/float/sfloat/elem/cl_SF_from_I.cc @@ -33,7 +33,7 @@ const cl_SF cl_I_to_SF (const cl_I& x) if (eq(x,0)) { return SF_0; } var cl_signean sign = -(cl_signean)minusp(x); // Vorzeichen var cl_I abs_x = (sign==0 ? x : -x); - var uintL exp = integer_length(abs_x); // (integer-length x) + var uintC exp = integer_length(abs_x); // (integer-length x) // NDS zu |x|>0 bilden: var const uintD* MSDptr; var uintC len; diff --git a/src/float/sfloat/elem/cl_SF_from_RA.cc b/src/float/sfloat/elem/cl_SF_from_RA.cc index fb866cf..fe5eec1 100644 --- a/src/float/sfloat/elem/cl_SF_from_RA.cc +++ b/src/float/sfloat/elem/cl_SF_from_RA.cc @@ -40,8 +40,8 @@ const cl_SF cl_RA_to_SF (const cl_RA& x) var const cl_I& b = denominator(x); // b var cl_signean sign = -(cl_signean)minusp(a); // Vorzeichen if (!(sign==0)) { a = -a; } // Betrag nehmen, liefert a - var sintL lendiff = (sintL)integer_length(a) // (integer-length a) - - (sintL)integer_length(b); // (integer-length b) + var sintC lendiff = (sintC)integer_length(a) // (integer-length a) + - (sintC)integer_length(b); // (integer-length b) if (lendiff > SF_exp_high-SF_exp_mid) // Exponent >= n-m > Obergrenze ? { cl_error_floating_point_overflow(); } // -> Overflow if (lendiff < SF_exp_low-SF_exp_mid-2) // Exponent <= n-m+2 < Untergrenze ? diff --git a/src/float/sfloat/elem/cl_SF_scale.cc b/src/float/sfloat/elem/cl_SF_scale.cc index 7e7e142..e88afde 100644 --- a/src/float/sfloat/elem/cl_SF_scale.cc +++ b/src/float/sfloat/elem/cl_SF_scale.cc @@ -14,7 +14,7 @@ namespace cln { -const cl_SF scale_float (const cl_SF& x, sintL delta) +const cl_SF scale_float (const cl_SF& x, sintC delta) { // Methode: // x=0.0 -> x als Ergebnis @@ -27,7 +27,7 @@ const cl_SF scale_float (const cl_SF& x, sintL delta) SF_decode(x, { return x; }, sign=,exp=,mant=); if (delta >= 0) // delta>=0 - { var uintL udelta = delta; + { var uintC udelta = delta; if (udelta <= (uintL)(SF_exp_high-SF_exp_low)) { exp = exp+udelta; return encode_SF(sign,exp,mant); @@ -37,7 +37,7 @@ const cl_SF scale_float (const cl_SF& x, sintL delta) } else // delta<0 - { var uintL udelta = -delta; + { var uintC udelta = -delta; if (udelta <= (uintL)(SF_exp_high-SF_exp_low)) { exp = exp-udelta; return encode_SF(sign,exp,mant); diff --git a/src/float/sfloat/misc/cl_SF_digits.cc b/src/float/sfloat/misc/cl_SF_digits.cc index 35043de..378a287 100644 --- a/src/float/sfloat/misc/cl_SF_digits.cc +++ b/src/float/sfloat/misc/cl_SF_digits.cc @@ -14,7 +14,7 @@ namespace cln { MAYBE_INLINE -uintL float_digits (const cl_SF& x) +uintC float_digits (const cl_SF& x) { unused x; return SF_mant_len+1; // 17 diff --git a/src/float/sfloat/misc/cl_SF_precision.cc b/src/float/sfloat/misc/cl_SF_precision.cc index 68e17d4..5752264 100644 --- a/src/float/sfloat/misc/cl_SF_precision.cc +++ b/src/float/sfloat/misc/cl_SF_precision.cc @@ -18,7 +18,7 @@ namespace cln { MAYBE_INLINE2 -uintL float_precision (const cl_SF& x) +uintC float_precision (const cl_SF& x) { if (zerop(x)) return 0; return SF_mant_len+1; // 17 diff --git a/src/float/transcendental/cl_F_atanhx.cc b/src/float/transcendental/cl_F_atanhx.cc index fc732eb..2d15ede 100644 --- a/src/float/transcendental/cl_F_atanhx.cc +++ b/src/float/transcendental/cl_F_atanhx.cc @@ -51,10 +51,10 @@ const cl_LF atanhx (const cl_LF& x) { if (zerop(x)) return x; - var uintL actuallen = TheLfloat(x)->len; - var uintL d = float_digits(x); + var uintC actuallen = TheLfloat(x)->len; + var uintC d = float_digits(x); var sintL e = float_exponent(x); - if (e <= (sintL)(-d)>>1) // e <= -d/2 <==> e <= -ceiling(d/2) + if (e <= (sintC)(-d)>>1) // e <= -d/2 <==> e <= -ceiling(d/2) return x; // ja -> x als Ergebnis if (actuallen >= 34) { DeclareType(cl_LF,x); @@ -105,7 +105,7 @@ const cl_LF atanhx (const cl_LF& x) } else { // naive2: // floating-point representation with smooth precision reduction - var cl_LF eps = scale_float(b,-(sintL)d-10); + var cl_LF eps = scale_float(b,-(sintC)d-10); loop { var cl_LF new_sum = sum + LF_to_LF(b/(cl_I)i,actuallen); // (+ sum (/ b i)) if (new_sum == sum) // = sum ? @@ -129,9 +129,9 @@ const cl_F atanhx (const cl_F& x) } if (zerop(x)) return x; - var uintL d = float_digits(x); + var uintC d = float_digits(x); var sintL e = float_exponent(x); - if (e <= (sintL)(-d)>>1) // e <= -d/2 <==> e <= -ceiling(d/2) + if (e <= (sintC)(-d)>>1) // e <= -d/2 <==> e <= -ceiling(d/2) return x; // ja -> x als Ergebnis var uintL k = 0; // Rekursionszähler k:=0 // Bei e <= -1-limit_slope*floor(sqrt(d)) kann die Potenzreihe diff --git a/src/float/transcendental/cl_F_atanx.cc b/src/float/transcendental/cl_F_atanx.cc index 9a8cc10..ad852a1 100644 --- a/src/float/transcendental/cl_F_atanx.cc +++ b/src/float/transcendental/cl_F_atanx.cc @@ -49,10 +49,10 @@ static const cl_LF atanx_naive (const cl_LF& x) { if (zerop(x)) return x; - var uintL actuallen = TheLfloat(x)->len; - var uintL d = float_digits(x); + var uintC actuallen = TheLfloat(x)->len; + var uintC d = float_digits(x); var sintL e = float_exponent(x); - if (e <= (sintL)(-d)>>1) // e <= -d/2 <==> e <= -ceiling(d/2) + if (e <= (sintC)(-d)>>1) // e <= -d/2 <==> e <= -ceiling(d/2) return x; // ja -> x als Ergebnis var uintL k = 0; // Rekursionszähler k:=0 // Bei e <= -1-limit_slope*floor(sqrt(d)) kann die Potenzreihe @@ -99,7 +99,7 @@ static const cl_LF atanx_naive (const cl_LF& x) } else { // naive2: // floating-point representation with smooth precision reduction - var cl_LF eps = scale_float(b,-(sintL)d-10); + var cl_LF eps = scale_float(b,-(sintC)d-10); loop { var cl_LF new_sum = sum + LF_to_LF(b/(cl_I)i,actuallen); // (+ sum (/ b i)) if (new_sum == sum) // = sum ? @@ -119,9 +119,9 @@ static const cl_F atanx_naive (const cl_F& x) { if (zerop(x)) return x; - var uintL d = float_digits(x); + var uintC d = float_digits(x); var sintL e = float_exponent(x); - if (e <= (sintL)(-d)>>1) // e <= -d/2 <==> e <= -ceiling(d/2) + if (e <= (sintC)(-d)>>1) // e <= -d/2 <==> e <= -ceiling(d/2) return x; // ja -> x als Ergebnis var uintL k = 0; // Rekursionszähler k:=0 var uintL sqrt_d = floor(isqrt(d),2); // limit_slope*floor(sqrt(d)) @@ -183,21 +183,21 @@ static const cl_LF atanx_ratseries (const cl_LF& t) // z' = truncate(y*2^(2n))/2^(2n). // Set z := z + z' and x+i*y := (x+i*y)*exp(-i*z'). var uintC len = TheLfloat(t)->len; - var uintL d = intDsize*(uintL)len; - if (zerop(t) || (float_exponent(t) <= (sintL)(-d)>>1)) + var uintC d = intDsize*len; + if (zerop(t) || (float_exponent(t) <= (sintC)(-d)>>1)) return t; var cl_LF x = recip(sqrt(cl_I_to_LF(1,len) + square(t))); var cl_LF y = t*x; var cl_LF z = cl_I_to_LF(0,len); loop { - if (zerop(y) || (float_exponent(y) <= (sintL)(-d)>>1)) + if (zerop(y) || (float_exponent(y) <= (sintC)(-d)>>1)) break; var cl_idecoded_float y_ = integer_decode_float(y); // y = (-1)^sign * 2^exponent * mantissa - var uintL lm = integer_length(y_.mantissa); + var uintC lm = integer_length(y_.mantissa); var uintL me = cl_I_to_UL(- y_.exponent); var cl_I p; - var uintL lq; + var uintC lq; var cl_boolean last_step = cl_false; if (lm >= me) { // |y| >= 1/2 ? p = y_.sign; // 1 or -1 @@ -221,7 +221,7 @@ static const cl_LF atanx_ratseries (const cl_LF& t) if (2*n >= lm) last_step = cl_true; } - z = z + scale_float(cl_I_to_LF(p,len),-(sintL)lq); + z = z + scale_float(cl_I_to_LF(p,len),-(sintC)lq); if (last_step) break; var cl_LF_cos_sin_t cis_z = cl_cossin_aux(-p,lq,len); diff --git a/src/float/transcendental/cl_F_catalanconst_f.cc b/src/float/transcendental/cl_F_catalanconst_f.cc index bd40e28..bbdc176 100644 --- a/src/float/transcendental/cl_F_catalanconst_f.cc +++ b/src/float/transcendental/cl_F_catalanconst_f.cc @@ -16,7 +16,7 @@ namespace cln { const cl_F catalanconst (float_format_t f) { - floatformatcase((uintL)f + floatformatcase((uintC)f , return cl_SF_catalanconst; , return cl_FF_catalanconst; , return cl_DF_catalanconst; diff --git a/src/float/transcendental/cl_F_cos.cc b/src/float/transcendental/cl_F_cos.cc index 4c18531..1cb5a5e 100644 --- a/src/float/transcendental/cl_F_cos.cc +++ b/src/float/transcendental/cl_F_cos.cc @@ -51,7 +51,7 @@ const cl_F cos (const cl_F& x) var cl_F_div_t q_r = cl_round_pi(cl_F_extendsqrt(x)); var cl_I& q = q_r.quotient; var cl_LF r = The(cl_LF)(q_r.remainder); - if (zerop(r) || (float_exponent(r) <= (-(sintL)float_digits(r))>>1)) + if (zerop(r) || (float_exponent(r) <= (-(sintC)float_digits(r))>>1)) cos_r = cl_float(1,x); // (cos r) = 1.0 else { var cl_LF s = scale_float(r,-1); // s := r/2 @@ -66,7 +66,7 @@ const cl_F cos (const cl_F& x) var cl_F_div_t q_r = cl_round_pi(cl_F_extendsqrt(x)); var cl_I& q = q_r.quotient; var cl_F& r = q_r.remainder; - if (zerop(r) || (float_exponent(r) <= (-(sintL)float_digits(r))>>1)) + if (zerop(r) || (float_exponent(r) <= (-(sintC)float_digits(r))>>1)) cos_r = cl_float(1,x); // (cos r) = 1.0 else { var cl_F s = scale_float(r,-1); // s := r/2 diff --git a/src/float/transcendental/cl_F_cosh.cc b/src/float/transcendental/cl_F_cosh.cc index 3bab201..da29b15 100644 --- a/src/float/transcendental/cl_F_cosh.cc +++ b/src/float/transcendental/cl_F_cosh.cc @@ -34,8 +34,8 @@ const cl_F cosh (const cl_F& x) // e<0 if (zerop(x)) return cl_float(1,x); - var uintL d = float_digits(x); - if (e <= (1-(sintL)d)>>1) // e <= (1-d)/2 <==> e <= -ceiling((d-1)/2) ? + var uintC d = float_digits(x); + if (e <= (1-(sintC)d)>>1) // e <= (1-d)/2 <==> e <= -ceiling((d-1)/2) ? return cl_float(1,x); // ja -> 1.0 als Ergebnis // Rechengenauigkeit erhöhen if (longfloatp(x)) { diff --git a/src/float/transcendental/cl_F_coshsinh.cc b/src/float/transcendental/cl_F_coshsinh.cc index 1713299..7888285 100644 --- a/src/float/transcendental/cl_F_coshsinh.cc +++ b/src/float/transcendental/cl_F_coshsinh.cc @@ -36,7 +36,7 @@ const cosh_sinh_t cosh_sinh (const cl_F& x) var sintL e = float_exponent(x); if (e < 0) { // Exponent e abtesten // e<0 - if (zerop(x) || (e <= (1-(sintL)float_digits(x))>>1)) + if (zerop(x) || (e <= (1-(sintC)float_digits(x))>>1)) // e <= (1-d)/2 <==> e <= -ceiling((d-1)/2) return cosh_sinh_t(cl_float(1,x),x); // Rechengenauigkeit erhöhen diff --git a/src/float/transcendental/cl_F_cossin.cc b/src/float/transcendental/cl_F_cossin.cc index ea5dede..486bacd 100644 --- a/src/float/transcendental/cl_F_cossin.cc +++ b/src/float/transcendental/cl_F_cossin.cc @@ -56,7 +56,7 @@ const cos_sin_t cos_sin (const cl_F& x) var cl_LF r = The(cl_LF)(q_r.remainder); var cl_LF y = sinx_naive(r); // y := sin(r)^2 // erste Komponente cos(r) berechnen: - if (zerop(r) || (float_exponent(r) <= (-(sintL)float_digits(r))>>1)) + if (zerop(r) || (float_exponent(r) <= (-(sintC)float_digits(r))>>1)) cos_r = cl_float(1,x); // cos(r) = 1.0 else cos_r = cl_float(sqrt(1-y),x); // cos(r) = sqrt(1-y) @@ -71,7 +71,7 @@ const cos_sin_t cos_sin (const cl_F& x) var cl_F& r = q_r.remainder; var cl_F y = sinxbyx_naive(r); // y := (sin(r)/r)^2 // erste Komponente cos(r) berechnen: - if (zerop(r) || (float_exponent(r) <= (-(sintL)float_digits(r))>>1)) + if (zerop(r) || (float_exponent(r) <= (-(sintC)float_digits(r))>>1)) cos_r = cl_float(1,x); // cos(r) = 1.0 else cos_r = cl_float(sqrt(1 - square(r)*y),x); // sqrt(1-r^2*y) diff --git a/src/float/transcendental/cl_F_eulerconst_f.cc b/src/float/transcendental/cl_F_eulerconst_f.cc index 153cbac..e97e2cb 100644 --- a/src/float/transcendental/cl_F_eulerconst_f.cc +++ b/src/float/transcendental/cl_F_eulerconst_f.cc @@ -16,7 +16,7 @@ namespace cln { const cl_F eulerconst (float_format_t f) { - floatformatcase((uintL)f + floatformatcase((uintC)f , return cl_SF_eulerconst; , return cl_FF_eulerconst; , return cl_DF_eulerconst; diff --git a/src/float/transcendental/cl_F_exp1_f.cc b/src/float/transcendental/cl_F_exp1_f.cc index 4e23f0a..1e18b6d 100644 --- a/src/float/transcendental/cl_F_exp1_f.cc +++ b/src/float/transcendental/cl_F_exp1_f.cc @@ -16,7 +16,7 @@ namespace cln { const cl_F exp1 (float_format_t f) { - floatformatcase((uintL)f + floatformatcase((uintC)f , return cl_SF_exp1; , return cl_FF_exp1; , return cl_DF_exp1; diff --git a/src/float/transcendental/cl_F_expx.cc b/src/float/transcendental/cl_F_expx.cc index 8069264..1695723 100644 --- a/src/float/transcendental/cl_F_expx.cc +++ b/src/float/transcendental/cl_F_expx.cc @@ -47,9 +47,9 @@ const cl_LF expx_naive (const cl_LF& x) if (zerop(x)) return cl_float(1,x); var uintL actuallen = TheLfloat(x)->len; - var uintL d = float_digits(x); + var uintC d = float_digits(x); var sintL e = float_exponent(x); - if (e < -(sintL)d) // e < -d ? + if (e < -(sintC)d) // e < -d ? return cl_float(1,x); // ja -> 1.0 als Ergebnis { Mutable(cl_LF,x); var uintL k = 0; // Rekursionszähler k:=0 @@ -66,7 +66,7 @@ const cl_LF expx_naive (const cl_LF& x) // Potenzreihe anwenden: var int i = 0; var cl_LF b = cl_float(1,x); // b := (float 1 x) - var cl_LF eps = scale_float(b,-(sintL)d-10); + var cl_LF eps = scale_float(b,-(sintC)d-10); var cl_LF sum = cl_float(0,x); // sum := (float 0 x) loop { var cl_LF new_sum = sum + LF_to_LF(b,actuallen); @@ -93,9 +93,9 @@ const cl_F expx_naive (const cl_F& x) } if (zerop(x)) return cl_float(1,x); - var uintL d = float_digits(x); + var uintC d = float_digits(x); var sintL e = float_exponent(x); - if (e < -(sintL)d) // e < -d ? + if (e < -(sintC)d) // e < -d ? return cl_float(1,x); // ja -> 1.0 als Ergebnis { Mutable(cl_F,x); var uintL k = 0; // Rekursionszähler k:=0 diff --git a/src/float/transcendental/cl_F_ln10_f.cc b/src/float/transcendental/cl_F_ln10_f.cc index f4f2d84..2c0332b 100644 --- a/src/float/transcendental/cl_F_ln10_f.cc +++ b/src/float/transcendental/cl_F_ln10_f.cc @@ -15,7 +15,7 @@ namespace cln { const cl_F cl_ln10 (float_format_t f) { - floatformatcase((uintL)f + floatformatcase((uintC)f , return cl_SF_ln10; , return cl_FF_ln10; , return cl_DF_ln10; diff --git a/src/float/transcendental/cl_F_ln2_f.cc b/src/float/transcendental/cl_F_ln2_f.cc index 68faaec..9882bb3 100644 --- a/src/float/transcendental/cl_F_ln2_f.cc +++ b/src/float/transcendental/cl_F_ln2_f.cc @@ -15,7 +15,7 @@ namespace cln { const cl_F cl_ln2 (float_format_t f) { - floatformatcase((uintL)f + floatformatcase((uintC)f , return cl_SF_ln2; , return cl_FF_ln2; , return cl_DF_ln2; diff --git a/src/float/transcendental/cl_F_lnx.cc b/src/float/transcendental/cl_F_lnx.cc index c2a406c..73af930 100644 --- a/src/float/transcendental/cl_F_lnx.cc +++ b/src/float/transcendental/cl_F_lnx.cc @@ -48,9 +48,9 @@ const cl_LF lnx_naive (const cl_LF& x) if (zerop(y)) // y=0.0 -> y als Ergebnis return y; var uintL actuallen = TheLfloat(x)->len; - var uintL d = float_digits(x); + var uintC d = float_digits(x); var sintL e = float_exponent(y); - if (e <= -(sintL)d) // e <= -d ? + if (e <= -(sintC)d) // e <= -d ? return y; // ja -> y als Ergebnis { Mutable(cl_LF,x); var uintL k = 0; // Rekursionszähler k:=0 @@ -88,7 +88,7 @@ const cl_LF lnx_naive (const cl_LF& x) } else { // naive2: // floating-point representation with smooth precision reduction - var cl_LF eps = scale_float(b,-(sintL)d-10); + var cl_LF eps = scale_float(b,-(sintC)d-10); loop { var cl_LF new_sum = sum + LF_to_LF(b/(cl_I)i,actuallen); // (+ sum (/ b i)) if (new_sum == sum) // = sum ? @@ -121,7 +121,7 @@ const cl_LF lnx_naive (const cl_LF& x) } else { // naive2: // floating-point representation with smooth precision reduction - var cl_LF eps = scale_float(b,-(sintL)d-10); + var cl_LF eps = scale_float(b,-(sintC)d-10); loop { var cl_LF new_sum = sum + LF_to_LF(b/(cl_I)i,actuallen); // (+ sum (/ b i)) if (new_sum == sum) // = sum ? @@ -146,9 +146,9 @@ const cl_F lnx_naive (const cl_F& x) var cl_F y = x-cl_float(1,x); if (zerop(y)) // y=0.0 -> y als Ergebnis return y; - var uintL d = float_digits(x); + var uintC d = float_digits(x); var sintL e = float_exponent(y); - if (e <= -(sintL)d) // e <= -d ? + if (e <= -(sintC)d) // e <= -d ? return y; // ja -> y als Ergebnis { Mutable(cl_F,x); var uintL k = 0; // Rekursionszähler k:=0 @@ -200,10 +200,10 @@ const cl_LF lnx_ratseries (const cl_LF& x) // x1 = (-1)^sign * 2^exponent * mantissa if (zerop(x1_.mantissa)) break; - var uintL lm = integer_length(x1_.mantissa); + var uintC lm = integer_length(x1_.mantissa); var uintL me = cl_I_to_UL(- x1_.exponent); var cl_I p; - var uintL lq; + var uintC lq; var cl_boolean last_step = cl_false; if (lm >= me) { // |x'| >= 1/2 ? p = x1_.sign; // 1 or -1 @@ -227,7 +227,7 @@ const cl_LF lnx_ratseries (const cl_LF& x) if (2*n >= lm) last_step = cl_true; } - y = y + scale_float(cl_I_to_LF(p,len),-(sintL)lq); + y = y + scale_float(cl_I_to_LF(p,len),-(sintC)lq); if (last_step) break; x = x * cl_exp_aux(-p,lq,len); diff --git a/src/float/transcendental/cl_F_pi_f.cc b/src/float/transcendental/cl_F_pi_f.cc index c8444ec..d6ea053 100644 --- a/src/float/transcendental/cl_F_pi_f.cc +++ b/src/float/transcendental/cl_F_pi_f.cc @@ -16,7 +16,7 @@ namespace cln { const cl_F pi (float_format_t f) { - floatformatcase((uintL)f + floatformatcase((uintC)f , return cl_SF_pi; , return cl_FF_pi; , return cl_DF_pi; diff --git a/src/float/transcendental/cl_F_sin.cc b/src/float/transcendental/cl_F_sin.cc index 6411442..0c31bc4 100644 --- a/src/float/transcendental/cl_F_sin.cc +++ b/src/float/transcendental/cl_F_sin.cc @@ -61,7 +61,7 @@ const cl_F sin (const cl_F& x) z = -z; } else { // cos(r) berechnen: - if (zerop(r) || (float_exponent(r) <= (-(sintL)float_digits(r))>>1)) + if (zerop(r) || (float_exponent(r) <= (-(sintC)float_digits(r))>>1)) z = cl_float(1,x); // cos(r) = 1.0 else z = cl_float(sqrt(1 - y),x); // sqrt(1-y) @@ -77,7 +77,7 @@ const cl_F sin (const cl_F& x) z = cl_float(r*sqrt(y),x); } else { // cos(r) berechnen: - if (zerop(r) || (float_exponent(r) <= (-(sintL)float_digits(r))>>1)) + if (zerop(r) || (float_exponent(r) <= (-(sintC)float_digits(r))>>1)) z = cl_float(1,x); // cos(r) = 1.0 else z = cl_float(sqrt(1 - square(r)*y),x); // sqrt(1-r^2*y) diff --git a/src/float/transcendental/cl_F_sinh.cc b/src/float/transcendental/cl_F_sinh.cc index 7ffdb1a..b1f0bfc 100644 --- a/src/float/transcendental/cl_F_sinh.cc +++ b/src/float/transcendental/cl_F_sinh.cc @@ -37,7 +37,7 @@ const cl_F sinh (const cl_F& x) } else #endif if ((TheLfloat(x)->len >= 500) - && (float_exponent(x) > (-(sintL)float_digits(x))>>1)) { + && (float_exponent(x) > (-(sintC)float_digits(x))>>1)) { // verwende exp(x), schneller als cl_coshsinh_ratseries // (aber nur bei 0 > e > -d/2, denn wir müssen, um // Auslöschung zu verhindern, |e| Bits dazunehmen) diff --git a/src/float/transcendental/cl_F_sinhx.cc b/src/float/transcendental/cl_F_sinhx.cc index ea6d1c5..e5fd97c 100644 --- a/src/float/transcendental/cl_F_sinhx.cc +++ b/src/float/transcendental/cl_F_sinhx.cc @@ -51,9 +51,9 @@ const cl_F sinhxbyx_naive (const cl_F& x) if (zerop(x)) return cl_float(1,x); - var uintL d = float_digits(x); + var uintC d = float_digits(x); var sintL e = float_exponent(x); - if (e <= (1-(sintL)d)>>1) // e <= (1-d)/2 <==> e <= -ceiling((d-1)/2) ? + if (e <= (1-(sintC)d)>>1) // e <= (1-d)/2 <==> e <= -ceiling((d-1)/2) ? return cl_float(1,x); // ja -> 1.0 als Ergebnis { Mutable(cl_F,x); // Bei e <= -1-limit_slope*floor(sqrt(d)) kann die Potenzreihe @@ -115,9 +115,9 @@ const cl_LF sinhx_naive (const cl_LF& x) if (zerop(x)) return x; var uintL actuallen = TheLfloat(x)->len; - var uintL d = float_digits(x); + var uintC d = float_digits(x); var sintL e = float_exponent(x); - if (e <= (1-(sintL)d)>>1) // e <= (1-d)/2 <==> e <= -ceiling((d-1)/2) ? + if (e <= (1-(sintC)d)>>1) // e <= (1-d)/2 <==> e <= -ceiling((d-1)/2) ? return square(x); // ja -> x^2 als Ergebnis { Mutable(cl_LF,x); var sintL ee = e; @@ -147,7 +147,7 @@ const cl_LF sinhx_naive (const cl_LF& x) b = round1(round1(The(cl_LF)(b*a)),(cl_I)((i+1)*(i+2))); i = i+2; } - powser_value = scale_float(cl_float(sum,x),-d); + powser_value = scale_float(cl_float(sum,x),-(sintC)d); } else if (actuallen <= 7) { // Break-even-Point before extendsqrt: N<=6 // naive2: // floating-point representation @@ -166,7 +166,7 @@ const cl_LF sinhx_naive (const cl_LF& x) // naive3: // floating-point representation with smooth precision reduction var cl_LF b = x; // b := x - var cl_LF eps = scale_float(b,-(sintL)d-10); + var cl_LF eps = scale_float(b,-(sintC)d-10); var cl_LF sum = cl_float(0,x); // sum := (float 0 x) loop { var cl_LF new_sum = sum + LF_to_LF(b,actuallen); diff --git a/src/float/transcendental/cl_F_sinx.cc b/src/float/transcendental/cl_F_sinx.cc index f74fe22..5dc12b1 100644 --- a/src/float/transcendental/cl_F_sinx.cc +++ b/src/float/transcendental/cl_F_sinx.cc @@ -51,9 +51,9 @@ const cl_F sinxbyx_naive (const cl_F& x) if (zerop(x)) return cl_float(1,x); - var uintL d = float_digits(x); + var uintC d = float_digits(x); var sintL e = float_exponent(x); - if (e <= (-(sintL)d)>>1) // e <= (-d)/2 <==> e <= -ceiling(d/2) ? + if (e <= (-(sintC)d)>>1) // e <= (-d)/2 <==> e <= -ceiling(d/2) ? return cl_float(1,x); // ja -> 1.0 als Ergebnis { Mutable(cl_F,x); // Bei e <= -1-limit_slope*floor(sqrt(d)) kann die Potenzreihe @@ -124,9 +124,9 @@ const cl_LF sinx_naive (const cl_LF& x) if (zerop(x)) return x; var uintL actuallen = TheLfloat(x)->len; - var uintL d = float_digits(x); + var uintC d = float_digits(x); var sintL e = float_exponent(x); - if (e <= (-(sintL)d)>>1) // e <= (-d)/2 <==> e <= -ceiling(d/2) ? + if (e <= (-(sintC)d)>>1) // e <= (-d)/2 <==> e <= -ceiling(d/2) ? return square(x); // ja -> x^2 als Ergebnis { Mutable(cl_LF,x); var sintL ee = e; @@ -157,7 +157,7 @@ const cl_LF sinx_naive (const cl_LF& x) b = round1(round1(The(cl_LF)(b*a)),(cl_I)((i+1)*(i+2))); i = i+2; } - powser_value = scale_float(cl_float(sum,x),-d); + powser_value = scale_float(cl_float(sum,x),-(sintC)d); } else if (actuallen <= 7) { // Break-even-Point before extendsqrt: N<=6 // naive2: // floating-point representation @@ -176,7 +176,7 @@ const cl_LF sinx_naive (const cl_LF& x) // naive3: // floating-point representation with smooth precision reduction var cl_LF b = x; // b := x - var cl_LF eps = scale_float(b,-(sintL)d-10); + var cl_LF eps = scale_float(b,-(sintC)d-10); var cl_LF sum = cl_float(0,x); // sum := (float 0 x) loop { var cl_LF new_sum = sum + LF_to_LF(b,actuallen); diff --git a/src/float/transcendental/cl_F_tran.h b/src/float/transcendental/cl_F_tran.h index c49965d..739226b 100644 --- a/src/float/transcendental/cl_F_tran.h +++ b/src/float/transcendental/cl_F_tran.h @@ -19,7 +19,7 @@ extern const cl_LF pi (uintC len); // computes it even further // cl_exp_aux(p,lq,len) liefert die Zahl exp(p/2^lq) mit len Digits. // 0 < |p| < 2^lq. // Es sollte |p|^2 < 2^lq sein, sonst ist das nicht effizient. -extern const cl_LF cl_exp_aux (const cl_I& p, uintL lq, uintC len); +extern const cl_LF cl_exp_aux (const cl_I& p, uintC lq, uintC len); // cl_cossin_aux(p,lq,len) liefert cos(p/2^lq) und sin(p/2^lq) mit len Digits. // 0 < |p| < 2^lq. @@ -31,7 +31,7 @@ struct cl_LF_cos_sin_t { cl_LF_cos_sin_t (const cl_LF& u, const cl_LF& v) : cos (u), sin (v) {} cl_LF_cos_sin_t () {} }; -extern const cl_LF_cos_sin_t cl_cossin_aux (const cl_I& p, uintL lq, uintC len); +extern const cl_LF_cos_sin_t cl_cossin_aux (const cl_I& p, uintC lq, uintC len); // cl_coshsinh_aux(p,lq,len) liefert cosh(p/2^lq) und sinh(p/2^lq) mit len Digits. // 0 < |p| < 2^lq. @@ -43,7 +43,7 @@ struct cl_LF_cosh_sinh_t { cl_LF_cosh_sinh_t (const cl_LF& u, const cl_LF& v) : cosh (u), sinh (v) {} cl_LF_cosh_sinh_t () {} }; -extern const cl_LF_cosh_sinh_t cl_coshsinh_aux (const cl_I& p, uintL lq, uintC len); +extern const cl_LF_cosh_sinh_t cl_coshsinh_aux (const cl_I& p, uintC lq, uintC len); // atanhx(x) liefert zu einem Float x (betragsmäßig <1/2) atanh(x) als Float. extern const cl_F atanhx (const cl_F& x); diff --git a/src/float/transcendental/cl_F_zeta_int_f.cc b/src/float/transcendental/cl_F_zeta_int_f.cc index 84f3cea..7fd1b55 100644 --- a/src/float/transcendental/cl_F_zeta_int_f.cc +++ b/src/float/transcendental/cl_F_zeta_int_f.cc @@ -17,7 +17,7 @@ namespace cln { const cl_F zeta (int s, float_format_t f) { - floatformatcase((uintL)f + floatformatcase((uintC)f , return cl_LF_to_SF(zeta(s,LF_minlen)); , return cl_LF_to_FF(zeta(s,LF_minlen)); , return cl_LF_to_DF(zeta(s,LF_minlen)); diff --git a/src/float/transcendental/cl_LF_atan_recip.cc b/src/float/transcendental/cl_LF_atan_recip.cc index a12c0ef..832ac02 100644 --- a/src/float/transcendental/cl_LF_atan_recip.cc +++ b/src/float/transcendental/cl_LF_atan_recip.cc @@ -29,11 +29,11 @@ const cl_LF cl_atan_recip (cl_I m, uintC len) { var uintC actuallen = len + 1; var cl_I m2 = m*m+1; - var uintL N = (uintL)(0.69314718*intDsize*actuallen/::log(double_approx(m2))) + 1; + var uintC N = (uintC)(0.69314718*intDsize*actuallen/::log(double_approx(m2))) + 1; CL_ALLOCA_STACK; var cl_I* pv = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I)); - var uintL n; + var uintC n; new (&pv[0]) cl_I (m); new (&qv[0]) cl_I (m2); for (n = 1; n < N; n++) { diff --git a/src/float/transcendental/cl_LF_atanh_recip.cc b/src/float/transcendental/cl_LF_atanh_recip.cc index b550481..113dfc0 100644 --- a/src/float/transcendental/cl_LF_atanh_recip.cc +++ b/src/float/transcendental/cl_LF_atanh_recip.cc @@ -29,11 +29,11 @@ const cl_LF cl_atanh_recip (cl_I m, uintC len) { var uintC actuallen = len + 1; var cl_I m2 = m*m; - var uintL N = (uintL)(0.69314718*intDsize/2*actuallen/::log(double_approx(m))) + 1; + var uintC N = (uintC)(0.69314718*intDsize/2*actuallen/::log(double_approx(m))) + 1; CL_ALLOCA_STACK; var cl_I* bv = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I)); - var uintL n; + var uintC n; for (n = 0; n < N; n++) { new (&bv[n]) cl_I ((cl_I)(2*n+1)); new (&qv[n]) cl_I (n==0 ? m : m2); diff --git a/src/float/transcendental/cl_LF_catalanconst.cc b/src/float/transcendental/cl_LF_catalanconst.cc index 866c956..eea0258 100644 --- a/src/float/transcendental/cl_LF_catalanconst.cc +++ b/src/float/transcendental/cl_LF_catalanconst.cc @@ -26,8 +26,8 @@ const cl_LF compute_catalanconst_ramanujan (uintC len) // Every summand gives 0.6 new decimal digits in precision. // The sum is best evaluated using fixed-point arithmetic, // so that the precision is reduced for the later summands. - var uintL actuallen = len + 2; // 2 Schutz-Digits - var sintL scale = intDsize*actuallen; + var uintC actuallen = len + 2; // 2 Schutz-Digits + var sintC scale = intDsize*actuallen; var cl_I sum = 0; var cl_I n = 0; var cl_I factor = ash(1,scale); @@ -50,18 +50,18 @@ const cl_LF compute_catalanconst_ramanujan_fast (uintC len) { // Same formula as above, using a binary splitting evaluation. // See [Borwein, Borwein, section 10.2.3]. - var uintL actuallen = len + 2; // 2 Schutz-Digits + var uintC actuallen = len + 2; // 2 Schutz-Digits // Evaluate a sum(0 <= n < N, a(n)/b(n) * (p(0)...p(n))/(q(0)...q(n))) // with appropriate N, and // a(n) = 1, b(n) = 2*n+1, // p(n) = n for n>0, q(n) = 2*(2*n+1) for n>0. - var uintL N = (intDsize/2)*actuallen; + var uintC N = (intDsize/2)*actuallen; // 4^-N <= 2^(-intDsize*actuallen). CL_ALLOCA_STACK; var cl_I* bv = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* pv = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I)); - var uintL n; + var uintC n; init1(cl_I, bv[0]) (1); init1(cl_I, pv[0]) (1); init1(cl_I, qv[0]) (1); @@ -92,13 +92,13 @@ const cl_LF compute_catalanconst_expintegral1 (uintC len) { // We compute f(x) classically and g(x) using the partial sums of f(x). var uintC actuallen = len+2; // 2 Schutz-Digits - var uintL x = (uintL)(0.693148*intDsize*actuallen)+1; - var uintL N = (uintL)(2.718281828*x); + var uintC x = (uintC)(0.693148*intDsize*actuallen)+1; + var uintC N = (uintC)(2.718281828*x); var cl_LF fterm = cl_I_to_LF(1,actuallen); var cl_LF fsum = fterm; var cl_LF gterm = fterm; var cl_LF gsum = gterm; - var uintL n; + var uintC n; // After n loops // fterm = x^n/n!, fsum = 1 + x/1! + ... + x^n/n!, // gterm = S_n*x^n/n!, gsum = S_0*x^0/0! + ... + S_n*x^n/n!. @@ -122,11 +122,11 @@ const cl_LF compute_catalanconst_expintegral1 (uintC len) const cl_LF compute_catalanconst_expintegral2 (uintC len) { var uintC actuallen = len+2; // 2 Schutz-Digits - var uintL x = (uintL)(0.693148*intDsize*actuallen)+1; - var uintL N = (uintL)(2.718281828*x); + var uintC x = (uintC)(0.693148*intDsize*actuallen)+1; + var uintC N = (uintC)(2.718281828*x); CL_ALLOCA_STACK; var cl_pqd_series_term* args = (cl_pqd_series_term*) cl_alloca(N*sizeof(cl_pqd_series_term)); - var uintL n; + var uintC n; for (n = 0; n < N; n++) { if (n==0) { init1(cl_I, args[n].p) (1); @@ -153,13 +153,13 @@ const cl_LF compute_catalanconst_expintegral2 (uintC len) const cl_LF compute_catalanconst_cvz1 (uintC len) { var uintC actuallen = len+2; // 2 Schutz-Digits - var uintL N = (uintL)(0.39321985*intDsize*actuallen)+1; + var uintC N = (uintC)(0.39321985*intDsize*actuallen)+1; #if 0 var cl_LF fterm = cl_I_to_LF(2*(cl_I)N*(cl_I)N,actuallen); var cl_LF fsum = fterm; var cl_LF gterm = fterm; var cl_LF gsum = gterm; - var uintL n; + var uintC n; // After n loops // fterm = (N+n)!N/(2n+2)!(N-n-1)!*2^(2n+2), fsum = ... + fterm, // gterm = S_n*fterm, gsum = ... + gterm. @@ -180,7 +180,7 @@ const cl_LF compute_catalanconst_cvz1 (uintC len) var cl_I fsum = fterm; var cl_LF gterm = cl_I_to_LF(fterm,actuallen); var cl_LF gsum = gterm; - var uintL n; + var uintC n; // After n loops // fterm = (N+n)!N/(2n+2)!(N-n-1)!*2^(2n+2), fsum = ... + fterm, // gterm = S_n*fterm, gsum = ... + gterm. @@ -204,10 +204,10 @@ const cl_LF compute_catalanconst_cvz1 (uintC len) const cl_LF compute_catalanconst_cvz2 (uintC len) { var uintC actuallen = len+2; // 2 Schutz-Digits - var uintL N = (uintL)(0.39321985*intDsize*actuallen)+1; + var uintC N = (uintC)(0.39321985*intDsize*actuallen)+1; CL_ALLOCA_STACK; var cl_pqd_series_term* args = (cl_pqd_series_term*) cl_alloca(N*sizeof(cl_pqd_series_term)); - var uintL n; + var uintC n; for (n = 0; n < N; n++) { init1(cl_I, args[n].p) (2*(cl_I)(N-n)*(cl_I)(N+n)); init1(cl_I, args[n].q) ((cl_I)(2*n+1)*(cl_I)(n+1)); diff --git a/src/float/transcendental/cl_LF_coshsinh_aux.cc b/src/float/transcendental/cl_LF_coshsinh_aux.cc index a5c9cab..ee68f82 100644 --- a/src/float/transcendental/cl_LF_coshsinh_aux.cc +++ b/src/float/transcendental/cl_LF_coshsinh_aux.cc @@ -26,15 +26,15 @@ namespace cln { // by a power series evaluation brings 20% speedup, even more for small lengths. #define TRIVIAL_SPEEDUP -const cl_LF_cosh_sinh_t cl_coshsinh_aux (const cl_I& p, uintL lq, uintC len) +const cl_LF_cosh_sinh_t cl_coshsinh_aux (const cl_I& p, uintC lq, uintC len) { { Mutable(cl_I,p); - var uintL lp = integer_length(p); // now |p| < 2^lp. + var uintC lp = integer_length(p); // now |p| < 2^lp. if (!(lp <= lq)) cl_abort(); lp = lq - lp; // now |p/2^lq| < 2^-lp. // Minimize lq (saves computation time). { - var uintL lp2 = ord2(p); + var uintC lp2 = ord2(p); if (lp2 > 0) { p = p >> lp2; lq = lq - lp2; @@ -65,16 +65,16 @@ const cl_LF_cosh_sinh_t cl_coshsinh_aux (const cl_I& p, uintL lq, uintC len) // Third approximation: // N2 = ceiling(M*log(2)/(log(N1)-1+lp*log(2))), slightly too large. // N = N2+2, two more terms for safety. - var uintL N0 = intDsize*actuallen; - var uintL N1 = (uintL)(0.693147*intDsize*actuallen/(::log((double)N0)-1.0+0.693148*lp)); - var uintL N2 = (uintL)(0.693148*intDsize*actuallen/(::log((double)N1)-1.0+0.693147*lp))+1; - var uintL N = N2+2; + var uintC N0 = intDsize*actuallen; + var uintC N1 = (uintC)(0.693147*intDsize*actuallen/(::log((double)N0)-1.0+0.693148*lp)); + var uintC N2 = (uintC)(0.693148*intDsize*actuallen/(::log((double)N1)-1.0+0.693147*lp))+1; + var uintC N = N2+2; N = ceiling(N,2); CL_ALLOCA_STACK; var cl_I* pv = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I)); - var uintL* qsv = (uintL*) cl_alloca(N*sizeof(uintL)); - var uintL n; + var uintC* qsv = (uintC*) cl_alloca(N*sizeof(uintC)); + var uintC n; var cl_I p2 = square(p); var cl_LF sinhsum; { diff --git a/src/float/transcendental/cl_LF_cossin_aux.cc b/src/float/transcendental/cl_LF_cossin_aux.cc index 5e3e0b3..32d0b77 100644 --- a/src/float/transcendental/cl_LF_cossin_aux.cc +++ b/src/float/transcendental/cl_LF_cossin_aux.cc @@ -26,15 +26,15 @@ namespace cln { // by a power series evaluation brings 20% speedup, even more for small lengths. #define TRIVIAL_SPEEDUP -const cl_LF_cos_sin_t cl_cossin_aux (const cl_I& p, uintL lq, uintC len) +const cl_LF_cos_sin_t cl_cossin_aux (const cl_I& p, uintC lq, uintC len) { { Mutable(cl_I,p); - var uintL lp = integer_length(p); // now |p| < 2^lp. + var uintC lp = integer_length(p); // now |p| < 2^lp. if (!(lp <= lq)) cl_abort(); lp = lq - lp; // now |p/2^lq| < 2^-lp. // Minimize lq (saves computation time). { - var uintL lp2 = ord2(p); + var uintC lp2 = ord2(p); if (lp2 > 0) { p = p >> lp2; lq = lq - lp2; @@ -65,16 +65,16 @@ const cl_LF_cos_sin_t cl_cossin_aux (const cl_I& p, uintL lq, uintC len) // Third approximation: // N2 = ceiling(M*log(2)/(log(N1)-1+lp*log(2))), slightly too large. // N = N2+2, two more terms for safety. - var uintL N0 = intDsize*actuallen; - var uintL N1 = (uintL)(0.693147*intDsize*actuallen/(::log((double)N0)-1.0+0.693148*lp)); - var uintL N2 = (uintL)(0.693148*intDsize*actuallen/(::log((double)N1)-1.0+0.693147*lp))+1; - var uintL N = N2+2; + var uintC N0 = intDsize*actuallen; + var uintC N1 = (uintC)(0.693147*intDsize*actuallen/(::log((double)N0)-1.0+0.693148*lp)); + var uintC N2 = (uintC)(0.693148*intDsize*actuallen/(::log((double)N1)-1.0+0.693147*lp))+1; + var uintC N = N2+2; N = ceiling(N,2); CL_ALLOCA_STACK; var cl_I* pv = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I)); - var uintL* qsv = (uintL*) cl_alloca(N*sizeof(uintL)); - var uintL n; + var uintC* qsv = (uintC*) cl_alloca(N*sizeof(uintC)); + var uintC n; var cl_I p2 = -square(p); var cl_LF sinsum; { diff --git a/src/float/transcendental/cl_LF_eulerconst.cc b/src/float/transcendental/cl_LF_eulerconst.cc index 9738f48..3ab99de 100644 --- a/src/float/transcendental/cl_LF_eulerconst.cc +++ b/src/float/transcendental/cl_LF_eulerconst.cc @@ -72,13 +72,13 @@ const cl_LF compute_eulerconst_expintegral (uintC len) // to more than double the floating-point precision because of the large // extinction which takes place. But luckily we compute with integers. var uintC actuallen = len+1; // 1 Schutz-Digit - var uintL z = (uintL)(0.693148*intDsize*actuallen)+1; - var uintL N = (uintL)(3.591121477*z); + var uintC z = (uintC)(0.693148*intDsize*actuallen)+1; + var uintC N = (uintC)(3.591121477*z); CL_ALLOCA_STACK; var cl_I* bv = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* pv = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I)); - var uintL n; + var uintC n; for (n = 0; n < N; n++) { init1(cl_I, bv[n]) (n+1); init1(cl_I, pv[n]) (n==0 ? (cl_I)z : -(cl_I)z); @@ -147,14 +147,14 @@ const cl_LF compute_eulerconst_expintegral1 (uintC len) // each. // We compute f(x) classically and g(x) using the partial sums of f(x). var uintC actuallen = len+2; // 2 Schutz-Digits - var uintL x = (uintL)(0.693148*intDsize*actuallen)+1; - var uintL N = (uintL)(2.718281828*x); + var uintC x = (uintC)(0.693148*intDsize*actuallen)+1; + var uintC N = (uintC)(2.718281828*x); var cl_LF one = cl_I_to_LF(1,actuallen); var cl_LF fterm = one; var cl_LF fsum = fterm; var cl_LF gterm = cl_I_to_LF(0,actuallen); var cl_LF gsum = gterm; - var uintL n; + var uintC n; // After n loops // fterm = x^n/n!, fsum = 1 + x/1! + ... + x^n/n!, // gterm = H_n*x^n/n!, gsum = H_1*x/1! + ... + H_n*x^n/n!. @@ -187,11 +187,11 @@ const cl_LF compute_eulerconst_expintegral1 (uintC len) const cl_LF compute_eulerconst_expintegral2 (uintC len) { var uintC actuallen = len+2; // 2 Schutz-Digits - var uintL x = (uintL)(0.693148*intDsize*actuallen)+1; - var uintL N = (uintL)(2.718281828*x); + var uintC x = (uintC)(0.693148*intDsize*actuallen)+1; + var uintC N = (uintC)(2.718281828*x); CL_ALLOCA_STACK; var cl_pqd_series_term* args = (cl_pqd_series_term*) cl_alloca(N*sizeof(cl_pqd_series_term)); - var uintL n; + var uintC n; for (n = 0; n < N; n++) { init1(cl_I, args[n].p) (x); init1(cl_I, args[n].q) (n+1); @@ -277,15 +277,15 @@ const cl_LF compute_eulerconst_besselintegral1 (uintC len) { // We compute f(x) classically and g(x) using the partial sums of f(x). var uintC actuallen = len+1; // 1 Schutz-Digit - var uintL sx = (uintL)(0.25*0.693148*intDsize*actuallen)+1; - var uintL N = (uintL)(3.591121477*sx); + var uintC sx = (uintC)(0.25*0.693148*intDsize*actuallen)+1; + var uintC N = (uintC)(3.591121477*sx); var cl_I x = square((cl_I)sx); - var cl_LF eps = scale_float(cl_I_to_LF(1,LF_minlen),-(sintL)(sx*2.88539+10)); + var cl_LF eps = scale_float(cl_I_to_LF(1,LF_minlen),-(sintC)(sx*2.88539+10)); var cl_LF fterm = cl_I_to_LF(1,actuallen); var cl_LF fsum = fterm; var cl_LF gterm = cl_I_to_LF(0,actuallen); var cl_LF gsum = gterm; - var uintL n; + var uintC n; // After n loops // fterm = x^n/n!^2, fsum = 1 + x/1!^2 + ... + x^n/n!^2, // gterm = H_n*x^n/n!^2, gsum = H_1*x/1!^2 + ... + H_n*x^n/n!^2. @@ -327,14 +327,14 @@ const cl_LF compute_eulerconst_besselintegral2 (uintC len) // (Because HD_n grows like exp(n), hence HN_n grows like exp(n) as // well, and we store all HN_n values in an array!) var uintC actuallen = len+1; // 1 Schutz-Digit - var uintL sx = (uintL)(0.25*0.693148*intDsize*actuallen)+1; - var uintL N = (uintL)(3.591121477*sx); + var uintC sx = (uintC)(0.25*0.693148*intDsize*actuallen)+1; + var uintC N = (uintC)(3.591121477*sx); var cl_I x = square((cl_I)sx); CL_ALLOCA_STACK; var cl_I* av = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* pv = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I)); - var uintL n; + var uintC n; // Evaluate f(x). init1(cl_I, pv[0]) (1); init1(cl_I, qv[0]) (1); @@ -409,13 +409,13 @@ struct cl_rational_series_for_g : cl_pqa_series_stream { const cl_LF compute_eulerconst_besselintegral3 (uintC len) { var uintC actuallen = len+1; // 1 Schutz-Digit - var uintL sx = (uintL)(0.25*0.693148*intDsize*actuallen)+1; - var uintL N = (uintL)(3.591121477*sx); + var uintC sx = (uintC)(0.25*0.693148*intDsize*actuallen)+1; + var uintC N = (uintC)(3.591121477*sx); var cl_I x = square((cl_I)sx); CL_ALLOCA_STACK; var cl_I* pv = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I)); - var uintL n; + var uintC n; // Evaluate f(x). init1(cl_I, pv[0]) (1); init1(cl_I, qv[0]) (1); @@ -445,12 +445,12 @@ const cl_LF compute_eulerconst_besselintegral3 (uintC len) const cl_LF compute_eulerconst_besselintegral4 (uintC len) { var uintC actuallen = len+2; // 2 Schutz-Digits - var uintL sx = (uintL)(0.25*0.693148*intDsize*actuallen)+1; - var uintL N = (uintL)(3.591121477*sx); + var uintC sx = (uintC)(0.25*0.693148*intDsize*actuallen)+1; + var uintC N = (uintC)(3.591121477*sx); var cl_I x = square((cl_I)sx); CL_ALLOCA_STACK; var cl_pqd_series_term* args = (cl_pqd_series_term*) cl_alloca(N*sizeof(cl_pqd_series_term)); - var uintL n; + var uintC n; for (n = 0; n < N; n++) { init1(cl_I, args[n].p) (x); init1(cl_I, args[n].q) (square((cl_I)(n+1))); diff --git a/src/float/transcendental/cl_LF_exp1.cc b/src/float/transcendental/cl_LF_exp1.cc index 713e2dd..f8827f8 100644 --- a/src/float/transcendental/cl_LF_exp1.cc +++ b/src/float/transcendental/cl_LF_exp1.cc @@ -38,14 +38,14 @@ const cl_LF compute_exp1 (uintC len) // Third approximation: // N2 = ceiling(M*log(2)/(log(N1)-1)), slightly too large. // N = N2+2, two more terms for safety. - var uintL N0 = intDsize*actuallen; - var uintL N1 = (uintL)(0.693147*intDsize*actuallen/(::log((double)N0)-1.0)); - var uintL N2 = (uintL)(0.693148*intDsize*actuallen/(::log((double)N1)-1.0))+1; - var uintL N = N2+2; + var uintC N0 = intDsize*actuallen; + var uintC N1 = (uintC)(0.693147*intDsize*actuallen/(::log((double)N0)-1.0)); + var uintC N2 = (uintC)(0.693148*intDsize*actuallen/(::log((double)N1)-1.0))+1; + var uintC N = N2+2; CL_ALLOCA_STACK; var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I)); - var uintL* qsv = (uintL*) cl_alloca(N*sizeof(uintL)); - var uintL n; + var uintC* qsv = (uintC*) cl_alloca(N*sizeof(uintC)); + var uintC n; for (n = 0; n < N; n++) { init1(cl_I, qv[n]) (n==0 ? 1 : n); } diff --git a/src/float/transcendental/cl_LF_exp_aux.cc b/src/float/transcendental/cl_LF_exp_aux.cc index a0dfc3c..1dda6d2 100644 --- a/src/float/transcendental/cl_LF_exp_aux.cc +++ b/src/float/transcendental/cl_LF_exp_aux.cc @@ -22,15 +22,15 @@ namespace cln { -const cl_LF cl_exp_aux (const cl_I& p, uintL lq, uintC len) +const cl_LF cl_exp_aux (const cl_I& p, uintC lq, uintC len) { { Mutable(cl_I,p); - var uintL lp = integer_length(p); // now |p| < 2^lp. + var uintC lp = integer_length(p); // now |p| < 2^lp. if (!(lp <= lq)) cl_abort(); lp = lq - lp; // now |p/2^lq| < 2^-lp. // Minimize lq (saves computation time). { - var uintL lp2 = ord2(p); + var uintC lp2 = ord2(p); if (lp2 > 0) { p = p >> lp2; lq = lq - lp2; @@ -52,15 +52,15 @@ const cl_LF cl_exp_aux (const cl_I& p, uintL lq, uintC len) // Third approximation: // N2 = ceiling(M*log(2)/(log(N1)-1+lp*log(2))), slightly too large. // N = N2+2, two more terms for safety. - var uintL N0 = intDsize*actuallen; - var uintL N1 = (uintL)(0.693147*intDsize*actuallen/(::log((double)N0)-1.0+0.693148*lp)); - var uintL N2 = (uintL)(0.693148*intDsize*actuallen/(::log((double)N1)-1.0+0.693147*lp))+1; - var uintL N = N2+2; + var uintC N0 = intDsize*actuallen; + var uintC N1 = (uintC)(0.693147*intDsize*actuallen/(::log((double)N0)-1.0+0.693148*lp)); + var uintC N2 = (uintC)(0.693148*intDsize*actuallen/(::log((double)N1)-1.0+0.693147*lp))+1; + var uintC N = N2+2; CL_ALLOCA_STACK; var cl_I* pv = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I)); - var uintL* qsv = (uintL*) cl_alloca(N*sizeof(uintL)); - var uintL n; + var uintC* qsv = (uintC*) cl_alloca(N*sizeof(uintC)); + var uintC n; init1(cl_I, pv[0]) (1); init1(cl_I, qv[0]) (1); for (n = 1; n < N; n++) { diff --git a/src/float/transcendental/cl_LF_pi.cc b/src/float/transcendental/cl_LF_pi.cc index 284ad1a..311ce3b 100644 --- a/src/float/transcendental/cl_LF_pi.cc +++ b/src/float/transcendental/cl_LF_pi.cc @@ -62,7 +62,7 @@ const cl_LF compute_pi_brent_salamin (uintC len) // (/ (expt a 2) t) // ) var uintC actuallen = len + 1; // 1 Schutz-Digit - var uintL uexp_limit = LF_exp_mid - intDsize*(uintL)len; + var uintC uexp_limit = LF_exp_mid - intDsize*len; // Ein Long-Float ist genau dann betragsmäßig <2^-n, wenn // sein Exponent < LF_exp_mid-n = uexp_limit ist. var cl_LF a = cl_I_to_LF(1,actuallen); @@ -112,7 +112,7 @@ const cl_LF compute_pi_brent_salamin_quartic (uintC len) // Hence, // pi = AGM(1,1/sqrt(2))^2 * 1/(1/2 - sum(k even, 2^k*[....])). var uintC actuallen = len + 1; // 1 Schutz-Digit - var uintL uexp_limit = LF_exp_mid - intDsize*(uintL)len; + var uintC uexp_limit = LF_exp_mid - intDsize*len; var cl_LF one = cl_I_to_LF(1,actuallen); var cl_LF a = one; var cl_LF wa = one; @@ -154,8 +154,8 @@ const cl_LF compute_pi_ramanujan_163 (uintC len) // in precision. // The sum is best evaluated using fixed-point arithmetic, // so that the precision is reduced for the later summands. - var uintL actuallen = len + 4; // 4 Schutz-Digits - var sintL scale = intDsize*actuallen; + var uintC actuallen = len + 4; // 4 Schutz-Digits + var sintC scale = intDsize*actuallen; static const cl_I A = "163096908"; static const cl_I B = "6541681608"; //static const cl_I J1 = "10939058860032000"; // 72*abs(J) @@ -191,7 +191,7 @@ const cl_LF compute_pi_ramanujan_163_fast (uintC len) { // Same formula as above, using a binary splitting evaluation. // See [Borwein, Borwein, section 10.2.3]. - var uintL actuallen = len + 4; // 4 Schutz-Digits + var uintC actuallen = len + 4; // 4 Schutz-Digits static const cl_I A = "163096908"; static const cl_I B = "6541681608"; static const cl_I J1 = "10939058860032000"; // 72*abs(J) @@ -200,17 +200,17 @@ const cl_LF compute_pi_ramanujan_163_fast (uintC len) // a(n) = A+n*B, b(n) = 1, // p(n) = -(6n-5)(2n-1)(6n-1) for n>0, // q(n) = 72*|J|*n^3 for n>0. - var const uintL n_slope = (uintL)(intDsize*32*0.02122673)+1; + var const uintC n_slope = (uintC)(intDsize*32*0.02122673)+1; // n_slope >= 32*intDsize*log(2)/log(|J|), normally n_slope = 22. - var uintL N = (n_slope*actuallen)/32 + 1; + var uintC N = (n_slope*actuallen)/32 + 1; // N > intDsize*log(2)/log(|J|) * actuallen, hence // |J|^-N < 2^(-intDsize*actuallen). CL_ALLOCA_STACK; var cl_I* av = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* pv = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I)); - var uintL* qsv = (uintL*) cl_alloca(N*sizeof(uintL)); - var uintL n; + var uintC* qsv = (uintC*) cl_alloca(N*sizeof(uintC)); + var uintC n; for (n = 0; n < N; n++) { init1(cl_I, av[n]) (A+n*B); if (n==0) { diff --git a/src/float/transcendental/cl_LF_ratseries.cc b/src/float/transcendental/cl_LF_ratseries.cc index 5e15e61..7dbcbc8 100644 --- a/src/float/transcendental/cl_LF_ratseries.cc +++ b/src/float/transcendental/cl_LF_ratseries.cc @@ -17,7 +17,7 @@ namespace cln { // and T = B*Q*S (all integers). On entry N1 < N2. // P will not be computed if a NULL pointer is passed. -const cl_LF eval_rational_series (uintL N, const cl_rational_series& args, uintC len) +const cl_LF eval_rational_series (uintC N, const cl_rational_series& args, uintC len) { if (args.pv) if (args.qv) diff --git a/src/float/transcendental/cl_LF_ratseries_.cc b/src/float/transcendental/cl_LF_ratseries_.cc index c08135f..537ea15 100644 --- a/src/float/transcendental/cl_LF_ratseries_.cc +++ b/src/float/transcendental/cl_LF_ratseries_.cc @@ -22,7 +22,7 @@ namespace cln { // and T = B*Q*S (all integers). On entry N1 < N2. // P will not be computed if a NULL pointer is passed. -static inline void eval__series_aux (uintL N1, uintL N2, +static inline void eval__series_aux (uintC N1, uintC N2, const cl__series& args, cl_I* T) { @@ -30,7 +30,7 @@ static inline void eval__series_aux (uintL N1, uintL N2, *T = N2-N1; } -const cl_LF eval_rational_series (uintL N, const cl__series& args, uintC len) +const cl_LF eval_rational_series (uintC N, const cl__series& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); diff --git a/src/float/transcendental/cl_LF_ratseries_a.cc b/src/float/transcendental/cl_LF_ratseries_a.cc index 1b467c7..b8338da 100644 --- a/src/float/transcendental/cl_LF_ratseries_a.cc +++ b/src/float/transcendental/cl_LF_ratseries_a.cc @@ -22,7 +22,7 @@ namespace cln { // and T = B*Q*S (all integers). On entry N1 < N2. // P will not be computed if a NULL pointer is passed. -static void eval_a_series_aux (uintL N1, uintL N2, +static void eval_a_series_aux (uintC N1, uintC N2, const cl_a_series& args, cl_I* T) { @@ -51,7 +51,7 @@ static void eval_a_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LT; eval_a_series_aux(N1,Nm,args,<); @@ -66,7 +66,7 @@ static void eval_a_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, const cl_a_series& args, uintC len) +const cl_LF eval_rational_series (uintC N, const cl_a_series& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); diff --git a/src/float/transcendental/cl_LF_ratseries_ab.cc b/src/float/transcendental/cl_LF_ratseries_ab.cc index e1544f1..e5f50fb 100644 --- a/src/float/transcendental/cl_LF_ratseries_ab.cc +++ b/src/float/transcendental/cl_LF_ratseries_ab.cc @@ -22,7 +22,7 @@ namespace cln { // and T = B*Q*S (all integers). On entry N1 < N2. // P will not be computed if a NULL pointer is passed. -static void eval_ab_series_aux (uintL N1, uintL N2, +static void eval_ab_series_aux (uintC N1, uintC N2, const cl_ab_series& args, cl_I* B, cl_I* T) { @@ -58,7 +58,7 @@ static void eval_ab_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LB, LT; eval_ab_series_aux(N1,Nm,args,&LB,<); @@ -74,7 +74,7 @@ static void eval_ab_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, const cl_ab_series& args, uintC len) +const cl_LF eval_rational_series (uintC N, const cl_ab_series& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); diff --git a/src/float/transcendental/cl_LF_ratseries_b.cc b/src/float/transcendental/cl_LF_ratseries_b.cc index 0532361..5c3ce3c 100644 --- a/src/float/transcendental/cl_LF_ratseries_b.cc +++ b/src/float/transcendental/cl_LF_ratseries_b.cc @@ -22,7 +22,7 @@ namespace cln { // and T = B*Q*S (all integers). On entry N1 < N2. // P will not be computed if a NULL pointer is passed. -static void eval_b_series_aux (uintL N1, uintL N2, +static void eval_b_series_aux (uintC N1, uintC N2, const cl_b_series& args, cl_I* B, cl_I* T) { @@ -58,7 +58,7 @@ static void eval_b_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LB, LT; eval_b_series_aux(N1,Nm,args,&LB,<); @@ -74,7 +74,7 @@ static void eval_b_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, const cl_b_series& args, uintC len) +const cl_LF eval_rational_series (uintC N, const cl_b_series& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); diff --git a/src/float/transcendental/cl_LF_ratseries_p.cc b/src/float/transcendental/cl_LF_ratseries_p.cc index ce9130f..65ef9b5 100644 --- a/src/float/transcendental/cl_LF_ratseries_p.cc +++ b/src/float/transcendental/cl_LF_ratseries_p.cc @@ -22,7 +22,7 @@ namespace cln { // and T = B*Q*S (all integers). On entry N1 < N2. // P will not be computed if a NULL pointer is passed. -static void eval_p_series_aux (uintL N1, uintL N2, +static void eval_p_series_aux (uintC N1, uintC N2, const cl_p_series& args, cl_I* P, cl_I* T) { @@ -61,7 +61,7 @@ static void eval_p_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LP, LT; eval_p_series_aux(N1,Nm,args,&LP,<); @@ -77,7 +77,7 @@ static void eval_p_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, const cl_p_series& args, uintC len) +const cl_LF eval_rational_series (uintC N, const cl_p_series& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); diff --git a/src/float/transcendental/cl_LF_ratseries_pa.cc b/src/float/transcendental/cl_LF_ratseries_pa.cc index 74f8b81..6382f84 100644 --- a/src/float/transcendental/cl_LF_ratseries_pa.cc +++ b/src/float/transcendental/cl_LF_ratseries_pa.cc @@ -22,7 +22,7 @@ namespace cln { // and T = B*Q*S (all integers). On entry N1 < N2. // P will not be computed if a NULL pointer is passed. -static void eval_pa_series_aux (uintL N1, uintL N2, +static void eval_pa_series_aux (uintC N1, uintC N2, const cl_pa_series& args, cl_I* P, cl_I* T) { @@ -61,7 +61,7 @@ static void eval_pa_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LP, LT; eval_pa_series_aux(N1,Nm,args,&LP,<); @@ -77,7 +77,7 @@ static void eval_pa_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, const cl_pa_series& args, uintC len) +const cl_LF eval_rational_series (uintC N, const cl_pa_series& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); diff --git a/src/float/transcendental/cl_LF_ratseries_pab.cc b/src/float/transcendental/cl_LF_ratseries_pab.cc index cfec8d1..ee97f06 100644 --- a/src/float/transcendental/cl_LF_ratseries_pab.cc +++ b/src/float/transcendental/cl_LF_ratseries_pab.cc @@ -22,7 +22,7 @@ namespace cln { // and T = B*Q*S (all integers). On entry N1 < N2. // P will not be computed if a NULL pointer is passed. -static void eval_pab_series_aux (uintL N1, uintL N2, +static void eval_pab_series_aux (uintC N1, uintC N2, const cl_pab_series& args, cl_I* P, cl_I* B, cl_I* T) { @@ -68,7 +68,7 @@ static void eval_pab_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LP, LB, LT; eval_pab_series_aux(N1,Nm,args,&LP,&LB,<); @@ -85,7 +85,7 @@ static void eval_pab_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, const cl_pab_series& args, uintC len) +const cl_LF eval_rational_series (uintC N, const cl_pab_series& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); diff --git a/src/float/transcendental/cl_LF_ratseries_pb.cc b/src/float/transcendental/cl_LF_ratseries_pb.cc index 9ddf079..eedd587 100644 --- a/src/float/transcendental/cl_LF_ratseries_pb.cc +++ b/src/float/transcendental/cl_LF_ratseries_pb.cc @@ -22,7 +22,7 @@ namespace cln { // and T = B*Q*S (all integers). On entry N1 < N2. // P will not be computed if a NULL pointer is passed. -static void eval_pb_series_aux (uintL N1, uintL N2, +static void eval_pb_series_aux (uintC N1, uintC N2, const cl_pb_series& args, cl_I* P, cl_I* B, cl_I* T) { @@ -68,7 +68,7 @@ static void eval_pb_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LP, LB, LT; eval_pb_series_aux(N1,Nm,args,&LP,&LB,<); @@ -85,7 +85,7 @@ static void eval_pb_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, const cl_pb_series& args, uintC len) +const cl_LF eval_rational_series (uintC N, const cl_pb_series& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); diff --git a/src/float/transcendental/cl_LF_ratseries_pq.cc b/src/float/transcendental/cl_LF_ratseries_pq.cc index a5eb904..ce90e8b 100644 --- a/src/float/transcendental/cl_LF_ratseries_pq.cc +++ b/src/float/transcendental/cl_LF_ratseries_pq.cc @@ -22,7 +22,7 @@ namespace cln { // and T = B*Q*S (all integers). On entry N1 < N2. // P will not be computed if a NULL pointer is passed. -static void eval_pq_series_aux (uintL N1, uintL N2, +static void eval_pq_series_aux (uintC N1, uintC N2, const cl_pq_series& args, cl_I* P, cl_I* Q, cl_I* T) { @@ -68,7 +68,7 @@ static void eval_pq_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LP, LQ, LT; eval_pq_series_aux(N1,Nm,args,&LP,&LQ,<); @@ -85,9 +85,9 @@ static void eval_pq_series_aux (uintL N1, uintL N2, } } -static void eval_pqs_series_aux (uintL N1, uintL N2, +static void eval_pqs_series_aux (uintC N1, uintC N2, const cl_pq_series& args, - cl_I* P, cl_I* Q, uintL* QS, cl_I* T) + cl_I* P, cl_I* Q, uintC* QS, cl_I* T) { switch (N2 - N1) { case 0: @@ -135,14 +135,14 @@ static void eval_pqs_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LP, LQ, LT; - var uintL LQS; + var uintC LQS; eval_pqs_series_aux(N1,Nm,args,&LP,&LQ,&LQS,<); // Compute right part. var cl_I RP, RQ, RT; - var uintL RQS; + var uintC RQS; eval_pqs_series_aux(Nm,N2,args,(P?&RP:(cl_I*)0),&RQ,&RQS,&RT); // Put together partial results. if (P) { *P = LP*RP; } @@ -155,7 +155,7 @@ static void eval_pqs_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, const cl_pq_series& args, uintC len) +const cl_LF eval_rational_series (uintC N, const cl_pq_series& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); @@ -168,10 +168,10 @@ const cl_LF eval_rational_series (uintL N, const cl_pq_series& args, uintC len) // Split qv[n] into qv[n]*2^qsv[n]. { var cl_I* qp = args.qv; - var uintL* qsp = args.qsv; - for (var uintL n = 0; n < N; n++, qp++, qsp++) { + var uintC* qsp = args.qsv; + for (var uintC n = 0; n < N; n++, qp++, qsp++) { // Pull out maximal power of 2 out of *qp = args.qv[n]. - var uintL qs = 0; + var uintC qs = 0; if (!zerop(*qp)) { qs = ord2(*qp); if (qs > 0) @@ -181,7 +181,7 @@ const cl_LF eval_rational_series (uintL N, const cl_pq_series& args, uintC len) } } // Main computation. - var uintL QS; + var uintC QS; eval_pqs_series_aux(0,N,args,NULL,&Q,&QS,&T); return cl_I_to_LF(T,len) / scale_float(cl_I_to_LF(Q,len),QS); } diff --git a/src/float/transcendental/cl_LF_ratseries_pqa.cc b/src/float/transcendental/cl_LF_ratseries_pqa.cc index 05aa743..95c6e03 100644 --- a/src/float/transcendental/cl_LF_ratseries_pqa.cc +++ b/src/float/transcendental/cl_LF_ratseries_pqa.cc @@ -22,7 +22,7 @@ namespace cln { // and T = B*Q*S (all integers). On entry N1 < N2. // P will not be computed if a NULL pointer is passed. -static void eval_pqa_series_aux (uintL N1, uintL N2, +static void eval_pqa_series_aux (uintC N1, uintC N2, const cl_pqa_series& args, cl_I* P, cl_I* Q, cl_I* T) { @@ -68,7 +68,7 @@ static void eval_pqa_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LP, LQ, LT; eval_pqa_series_aux(N1,Nm,args,&LP,&LQ,<); @@ -85,9 +85,9 @@ static void eval_pqa_series_aux (uintL N1, uintL N2, } } -static void eval_pqsa_series_aux (uintL N1, uintL N2, +static void eval_pqsa_series_aux (uintC N1, uintC N2, const cl_pqa_series& args, - cl_I* P, cl_I* Q, uintL* QS, cl_I* T) + cl_I* P, cl_I* Q, uintC* QS, cl_I* T) { switch (N2 - N1) { case 0: @@ -135,14 +135,14 @@ static void eval_pqsa_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LP, LQ, LT; - var uintL LQS; + var uintC LQS; eval_pqsa_series_aux(N1,Nm,args,&LP,&LQ,&LQS,<); // Compute right part. var cl_I RP, RQ, RT; - var uintL RQS; + var uintC RQS; eval_pqsa_series_aux(Nm,N2,args,(P?&RP:(cl_I*)0),&RQ,&RQS,&RT); // Put together partial results. if (P) { *P = LP*RP; } @@ -155,7 +155,7 @@ static void eval_pqsa_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, const cl_pqa_series& args, uintC len) +const cl_LF eval_rational_series (uintC N, const cl_pqa_series& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); @@ -168,10 +168,10 @@ const cl_LF eval_rational_series (uintL N, const cl_pqa_series& args, uintC len) // Split qv[n] into qv[n]*2^qsv[n]. { var cl_I* qp = args.qv; - var uintL* qsp = args.qsv; - for (var uintL n = 0; n < N; n++, qp++, qsp++) { + var uintC* qsp = args.qsv; + for (var uintC n = 0; n < N; n++, qp++, qsp++) { // Pull out maximal power of 2 out of *qp = args.qv[n]. - var uintL qs = 0; + var uintC qs = 0; if (!zerop(*qp)) { qs = ord2(*qp); if (qs > 0) @@ -181,7 +181,7 @@ const cl_LF eval_rational_series (uintL N, const cl_pqa_series& args, uintC len) } } // Main computation. - var uintL QS; + var uintC QS; eval_pqsa_series_aux(0,N,args,NULL,&Q,&QS,&T); return cl_I_to_LF(T,len) / scale_float(cl_I_to_LF(Q,len),QS); } diff --git a/src/float/transcendental/cl_LF_ratseries_pqab.cc b/src/float/transcendental/cl_LF_ratseries_pqab.cc index 4680893..1d9ef3e 100644 --- a/src/float/transcendental/cl_LF_ratseries_pqab.cc +++ b/src/float/transcendental/cl_LF_ratseries_pqab.cc @@ -22,7 +22,7 @@ namespace cln { // and T = B*Q*S (all integers). On entry N1 < N2. // P will not be computed if a NULL pointer is passed. -static void eval_pqab_series_aux (uintL N1, uintL N2, +static void eval_pqab_series_aux (uintC N1, uintC N2, const cl_pqab_series& args, cl_I* P, cl_I* Q, cl_I* B, cl_I* T) { @@ -75,7 +75,7 @@ static void eval_pqab_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LP, LQ, LB, LT; eval_pqab_series_aux(N1,Nm,args,&LP,&LQ,&LB,<); @@ -93,9 +93,9 @@ static void eval_pqab_series_aux (uintL N1, uintL N2, } } -static void eval_pqsab_series_aux (uintL N1, uintL N2, +static void eval_pqsab_series_aux (uintC N1, uintC N2, const cl_pqab_series& args, - cl_I* P, cl_I* Q, uintL* QS, cl_I* B, cl_I* T) + cl_I* P, cl_I* Q, uintC* QS, cl_I* B, cl_I* T) { switch (N2 - N1) { case 0: @@ -150,14 +150,14 @@ static void eval_pqsab_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LP, LQ, LB, LT; - var uintL LQS; + var uintC LQS; eval_pqsab_series_aux(N1,Nm,args,&LP,&LQ,&LQS,&LB,<); // Compute right part. var cl_I RP, RQ, RB, RT; - var uintL RQS; + var uintC RQS; eval_pqsab_series_aux(Nm,N2,args,(P?&RP:(cl_I*)0),&RQ,&RQS,&RB,&RT); // Put together partial results. if (P) { *P = LP*RP; } @@ -171,7 +171,7 @@ static void eval_pqsab_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, const cl_pqab_series& args, uintC len) +const cl_LF eval_rational_series (uintC N, const cl_pqab_series& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); @@ -184,10 +184,10 @@ const cl_LF eval_rational_series (uintL N, const cl_pqab_series& args, uintC len // Split qv[n] into qv[n]*2^qsv[n]. { var cl_I* qp = args.qv; - var uintL* qsp = args.qsv; - for (var uintL n = 0; n < N; n++, qp++, qsp++) { + var uintC* qsp = args.qsv; + for (var uintC n = 0; n < N; n++, qp++, qsp++) { // Pull out maximal power of 2 out of *qp = args.qv[n]. - var uintL qs = 0; + var uintC qs = 0; if (!zerop(*qp)) { qs = ord2(*qp); if (qs > 0) @@ -197,7 +197,7 @@ const cl_LF eval_rational_series (uintL N, const cl_pqab_series& args, uintC len } } // Main computation. - var uintL QS; + var uintC QS; eval_pqsab_series_aux(0,N,args,NULL,&Q,&QS,&B,&T); return cl_I_to_LF(T,len) / scale_float(cl_I_to_LF(B*Q,len),QS); } diff --git a/src/float/transcendental/cl_LF_ratseries_pqb.cc b/src/float/transcendental/cl_LF_ratseries_pqb.cc index cee4716..69cf1d2 100644 --- a/src/float/transcendental/cl_LF_ratseries_pqb.cc +++ b/src/float/transcendental/cl_LF_ratseries_pqb.cc @@ -22,7 +22,7 @@ namespace cln { // and T = B*Q*S (all integers). On entry N1 < N2. // P will not be computed if a NULL pointer is passed. -static void eval_pqb_series_aux (uintL N1, uintL N2, +static void eval_pqb_series_aux (uintC N1, uintC N2, const cl_pqb_series& args, cl_I* P, cl_I* Q, cl_I* B, cl_I* T) { @@ -75,7 +75,7 @@ static void eval_pqb_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LP, LQ, LB, LT; eval_pqb_series_aux(N1,Nm,args,&LP,&LQ,&LB,<); @@ -93,9 +93,9 @@ static void eval_pqb_series_aux (uintL N1, uintL N2, } } -static void eval_pqsb_series_aux (uintL N1, uintL N2, +static void eval_pqsb_series_aux (uintC N1, uintC N2, const cl_pqb_series& args, - cl_I* P, cl_I* Q, uintL* QS, cl_I* B, cl_I* T) + cl_I* P, cl_I* Q, uintC* QS, cl_I* B, cl_I* T) { switch (N2 - N1) { case 0: @@ -150,14 +150,14 @@ static void eval_pqsb_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LP, LQ, LB, LT; - var uintL LQS; + var uintC LQS; eval_pqsb_series_aux(N1,Nm,args,&LP,&LQ,&LQS,&LB,<); // Compute right part. var cl_I RP, RQ, RB, RT; - var uintL RQS; + var uintC RQS; eval_pqsb_series_aux(Nm,N2,args,(P?&RP:(cl_I*)0),&RQ,&RQS,&RB,&RT); // Put together partial results. if (P) { *P = LP*RP; } @@ -171,7 +171,7 @@ static void eval_pqsb_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, const cl_pqb_series& args, uintC len) +const cl_LF eval_rational_series (uintC N, const cl_pqb_series& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); @@ -184,10 +184,10 @@ const cl_LF eval_rational_series (uintL N, const cl_pqb_series& args, uintC len) // Split qv[n] into qv[n]*2^qsv[n]. { var cl_I* qp = args.qv; - var uintL* qsp = args.qsv; - for (var uintL n = 0; n < N; n++, qp++, qsp++) { + var uintC* qsp = args.qsv; + for (var uintC n = 0; n < N; n++, qp++, qsp++) { // Pull out maximal power of 2 out of *qp = args.qv[n]. - var uintL qs = 0; + var uintC qs = 0; if (!zerop(*qp)) { qs = ord2(*qp); if (qs > 0) @@ -197,7 +197,7 @@ const cl_LF eval_rational_series (uintL N, const cl_pqb_series& args, uintC len) } } // Main computation. - var uintL QS; + var uintC QS; eval_pqsb_series_aux(0,N,args,NULL,&Q,&QS,&B,&T); return cl_I_to_LF(T,len) / scale_float(cl_I_to_LF(B*Q,len),QS); } diff --git a/src/float/transcendental/cl_LF_ratseries_q.cc b/src/float/transcendental/cl_LF_ratseries_q.cc index b664e71..7897bb2 100644 --- a/src/float/transcendental/cl_LF_ratseries_q.cc +++ b/src/float/transcendental/cl_LF_ratseries_q.cc @@ -22,7 +22,7 @@ namespace cln { // and T = B*Q*S (all integers). On entry N1 < N2. // P will not be computed if a NULL pointer is passed. -static void eval_q_series_aux (uintL N1, uintL N2, +static void eval_q_series_aux (uintC N1, uintC N2, const cl_q_series& args, cl_I* Q, cl_I* T) { @@ -58,7 +58,7 @@ static void eval_q_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LQ, LT; eval_q_series_aux(N1,Nm,args,&LQ,<); @@ -74,7 +74,7 @@ static void eval_q_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, const cl_q_series& args, uintC len) +const cl_LF eval_rational_series (uintC N, const cl_q_series& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); diff --git a/src/float/transcendental/cl_LF_ratseries_qa.cc b/src/float/transcendental/cl_LF_ratseries_qa.cc index 94554c7..f94c754 100644 --- a/src/float/transcendental/cl_LF_ratseries_qa.cc +++ b/src/float/transcendental/cl_LF_ratseries_qa.cc @@ -22,7 +22,7 @@ namespace cln { // and T = B*Q*S (all integers). On entry N1 < N2. // P will not be computed if a NULL pointer is passed. -static void eval_qa_series_aux (uintL N1, uintL N2, +static void eval_qa_series_aux (uintC N1, uintC N2, const cl_qa_series& args, cl_I* Q, cl_I* T) { @@ -58,7 +58,7 @@ static void eval_qa_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LQ, LT; eval_qa_series_aux(N1,Nm,args,&LQ,<); @@ -74,7 +74,7 @@ static void eval_qa_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, const cl_qa_series& args, uintC len) +const cl_LF eval_rational_series (uintC N, const cl_qa_series& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); diff --git a/src/float/transcendental/cl_LF_ratseries_qab.cc b/src/float/transcendental/cl_LF_ratseries_qab.cc index 5bdd6eb..4dadb3b 100644 --- a/src/float/transcendental/cl_LF_ratseries_qab.cc +++ b/src/float/transcendental/cl_LF_ratseries_qab.cc @@ -22,7 +22,7 @@ namespace cln { // and T = B*Q*S (all integers). On entry N1 < N2. // P will not be computed if a NULL pointer is passed. -static void eval_qab_series_aux (uintL N1, uintL N2, +static void eval_qab_series_aux (uintC N1, uintC N2, const cl_qab_series& args, cl_I* Q, cl_I* B, cl_I* T) { @@ -65,7 +65,7 @@ static void eval_qab_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LQ, LB, LT; eval_qab_series_aux(N1,Nm,args,&LQ,&LB,<); @@ -82,7 +82,7 @@ static void eval_qab_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, const cl_qab_series& args, uintC len) +const cl_LF eval_rational_series (uintC N, const cl_qab_series& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); diff --git a/src/float/transcendental/cl_LF_ratseries_qb.cc b/src/float/transcendental/cl_LF_ratseries_qb.cc index 761de51..58ae23e 100644 --- a/src/float/transcendental/cl_LF_ratseries_qb.cc +++ b/src/float/transcendental/cl_LF_ratseries_qb.cc @@ -22,7 +22,7 @@ namespace cln { // and T = B*Q*S (all integers). On entry N1 < N2. // P will not be computed if a NULL pointer is passed. -static void eval_qb_series_aux (uintL N1, uintL N2, +static void eval_qb_series_aux (uintC N1, uintC N2, const cl_qb_series& args, cl_I* Q, cl_I* B, cl_I* T) { @@ -65,7 +65,7 @@ static void eval_qb_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LQ, LB, LT; eval_qb_series_aux(N1,Nm,args,&LQ,&LB,<); @@ -82,7 +82,7 @@ static void eval_qb_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, const cl_qb_series& args, uintC len) +const cl_LF eval_rational_series (uintC N, const cl_qb_series& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); diff --git a/src/float/transcendental/cl_LF_ratseries_stream_pq.cc b/src/float/transcendental/cl_LF_ratseries_stream_pq.cc index 0d8fa64..440f85d 100644 --- a/src/float/transcendental/cl_LF_ratseries_stream_pq.cc +++ b/src/float/transcendental/cl_LF_ratseries_stream_pq.cc @@ -16,7 +16,7 @@ namespace cln { -static void eval_pq_series_aux (uintL N1, uintL N2, +static void eval_pq_series_aux (uintC N1, uintC N2, cl_pq_series_stream& args, cl_I* P, cl_I* Q, cl_I* T) { @@ -73,7 +73,7 @@ static void eval_pq_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LP, LQ, LT; eval_pq_series_aux(N1,Nm,args,&LP,&LQ,<); @@ -90,7 +90,7 @@ static void eval_pq_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, cl_pq_series_stream& args, uintC len) +const cl_LF eval_rational_series (uintC N, cl_pq_series_stream& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); diff --git a/src/float/transcendental/cl_LF_ratseries_stream_pqa.cc b/src/float/transcendental/cl_LF_ratseries_stream_pqa.cc index 5b34c86..1bc6e30 100644 --- a/src/float/transcendental/cl_LF_ratseries_stream_pqa.cc +++ b/src/float/transcendental/cl_LF_ratseries_stream_pqa.cc @@ -16,7 +16,7 @@ namespace cln { -static void eval_pqa_series_aux (uintL N1, uintL N2, +static void eval_pqa_series_aux (uintC N1, uintC N2, cl_pqa_series_stream& args, cl_I* P, cl_I* Q, cl_I* T) { @@ -73,7 +73,7 @@ static void eval_pqa_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LP, LQ, LT; eval_pqa_series_aux(N1,Nm,args,&LP,&LQ,<); @@ -90,7 +90,7 @@ static void eval_pqa_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, cl_pqa_series_stream& args, uintC len) +const cl_LF eval_rational_series (uintC N, cl_pqa_series_stream& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); diff --git a/src/float/transcendental/cl_LF_ratseries_stream_pqab.cc b/src/float/transcendental/cl_LF_ratseries_stream_pqab.cc index cc3cec8..376d88a 100644 --- a/src/float/transcendental/cl_LF_ratseries_stream_pqab.cc +++ b/src/float/transcendental/cl_LF_ratseries_stream_pqab.cc @@ -16,7 +16,7 @@ namespace cln { -static void eval_pqab_series_aux (uintL N1, uintL N2, +static void eval_pqab_series_aux (uintC N1, uintC N2, cl_pqab_series_stream& args, cl_I* P, cl_I* Q, cl_I* B, cl_I* T) { @@ -80,7 +80,7 @@ static void eval_pqab_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LP, LQ, LB, LT; eval_pqab_series_aux(N1,Nm,args,&LP,&LQ,&LB,<); @@ -98,7 +98,7 @@ static void eval_pqab_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, cl_pqab_series_stream& args, uintC len) +const cl_LF eval_rational_series (uintC N, cl_pqab_series_stream& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); diff --git a/src/float/transcendental/cl_LF_ratseries_stream_pqb.cc b/src/float/transcendental/cl_LF_ratseries_stream_pqb.cc index 3ce7485..2cfc32a 100644 --- a/src/float/transcendental/cl_LF_ratseries_stream_pqb.cc +++ b/src/float/transcendental/cl_LF_ratseries_stream_pqb.cc @@ -16,7 +16,7 @@ namespace cln { -static void eval_pqb_series_aux (uintL N1, uintL N2, +static void eval_pqb_series_aux (uintC N1, uintC N2, cl_pqb_series_stream& args, cl_I* P, cl_I* Q, cl_I* B, cl_I* T) { @@ -80,7 +80,7 @@ static void eval_pqb_series_aux (uintL N1, uintL N2, break; } default: { - var uintL Nm = (N1+N2)/2; // midpoint + var uintC Nm = (N1+N2)/2; // midpoint // Compute left part. var cl_I LP, LQ, LB, LT; eval_pqb_series_aux(N1,Nm,args,&LP,&LQ,&LB,<); @@ -98,7 +98,7 @@ static void eval_pqb_series_aux (uintL N1, uintL N2, } } -const cl_LF eval_rational_series (uintL N, cl_pqb_series_stream& args, uintC len) +const cl_LF eval_rational_series (uintC N, cl_pqb_series_stream& args, uintC len) { if (N==0) return cl_I_to_LF(0,len); diff --git a/src/float/transcendental/cl_LF_ratsumseries_pqcd.cc b/src/float/transcendental/cl_LF_ratsumseries_pqcd.cc index 618c994..7c22c81 100644 --- a/src/float/transcendental/cl_LF_ratsumseries_pqcd.cc +++ b/src/float/transcendental/cl_LF_ratsumseries_pqcd.cc @@ -16,7 +16,7 @@ namespace cln { -const cl_LF eval_pqcd_series (uintL N, cl_pqcd_series_term* args, uintC len) +const cl_LF eval_pqcd_series (uintC N, cl_pqcd_series_term* args, uintC len) { if (N==0) return cl_I_to_LF(0,len); diff --git a/src/float/transcendental/cl_LF_ratsumseries_pqcd_aux.cc b/src/float/transcendental/cl_LF_ratsumseries_pqcd_aux.cc index 3365389..232214e 100644 --- a/src/float/transcendental/cl_LF_ratsumseries_pqcd_aux.cc +++ b/src/float/transcendental/cl_LF_ratsumseries_pqcd_aux.cc @@ -14,7 +14,7 @@ namespace cln { -void eval_pqcd_series_aux (uintL N, cl_pqcd_series_term* args, cl_pqcd_series_result& Z, cl_boolean rightmost) +void eval_pqcd_series_aux (uintC N, cl_pqcd_series_term* args, cl_pqcd_series_result& Z, cl_boolean rightmost) { // N = N2-N1 switch (N) { @@ -57,7 +57,7 @@ void eval_pqcd_series_aux (uintL N, cl_pqcd_series_term* args, cl_pqcd_series_re break; } default: { - var uintL Nm = N/2; // midpoint + var uintC Nm = N/2; // midpoint // Compute left part. var cl_pqcd_series_result L; eval_pqcd_series_aux(Nm,args+0,L,cl_false); diff --git a/src/float/transcendental/cl_LF_ratsumseries_pqd.cc b/src/float/transcendental/cl_LF_ratsumseries_pqd.cc index fab0ff2..7db496c 100644 --- a/src/float/transcendental/cl_LF_ratsumseries_pqd.cc +++ b/src/float/transcendental/cl_LF_ratsumseries_pqd.cc @@ -16,7 +16,7 @@ namespace cln { -const cl_LF eval_pqd_series (uintL N, cl_pqd_series_term* args, uintC len) +const cl_LF eval_pqd_series (uintC N, cl_pqd_series_term* args, uintC len) { if (N==0) return cl_I_to_LF(0,len); diff --git a/src/float/transcendental/cl_LF_ratsumseries_pqd_aux.cc b/src/float/transcendental/cl_LF_ratsumseries_pqd_aux.cc index 25f7d83..7abf666 100644 --- a/src/float/transcendental/cl_LF_ratsumseries_pqd_aux.cc +++ b/src/float/transcendental/cl_LF_ratsumseries_pqd_aux.cc @@ -14,7 +14,7 @@ namespace cln { -void eval_pqd_series_aux (uintL N, cl_pqd_series_term* args, cl_pqd_series_result& Z, cl_boolean rightmost) +void eval_pqd_series_aux (uintC N, cl_pqd_series_term* args, cl_pqd_series_result& Z, cl_boolean rightmost) { // N = N2-N1 switch (N) { @@ -53,7 +53,7 @@ void eval_pqd_series_aux (uintL N, cl_pqd_series_term* args, cl_pqd_series_resul break; } default: { - var uintL Nm = N/2; // midpoint + var uintC Nm = N/2; // midpoint // Compute left part. var cl_pqd_series_result L; eval_pqd_series_aux(Nm,args+0,L,cl_false); diff --git a/src/float/transcendental/cl_LF_tran.h b/src/float/transcendental/cl_LF_tran.h index 05ab5aa..3dedf50 100644 --- a/src/float/transcendental/cl_LF_tran.h +++ b/src/float/transcendental/cl_LF_tran.h @@ -28,9 +28,9 @@ struct cl_rational_series { cl_I* qv; const cl_I* av; const cl_I* bv; - uintL* qsv; + uintC* qsv; }; -extern const cl_LF eval_rational_series (uintL N, const cl_rational_series& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, const cl_rational_series& args, uintC len); // In each the special cases below, none of (a,b,p,q) can be NULL. But qs can // still be given or NULL. @@ -40,104 +40,104 @@ struct cl_pqab_series { cl_I* qv; const cl_I* av; const cl_I* bv; - uintL* qsv; + uintC* qsv; }; -extern const cl_LF eval_rational_series (uintL N, const cl_pqab_series& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, const cl_pqab_series& args, uintC len); struct cl_pqb_series { const cl_I* pv; cl_I* qv; const cl_I* bv; - uintL* qsv; + uintC* qsv; }; -extern const cl_LF eval_rational_series (uintL N, const cl_pqb_series& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, const cl_pqb_series& args, uintC len); struct cl_pqa_series { const cl_I* pv; cl_I* qv; const cl_I* av; - uintL* qsv; + uintC* qsv; }; -extern const cl_LF eval_rational_series (uintL N, const cl_pqa_series& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, const cl_pqa_series& args, uintC len); struct cl_pq_series { const cl_I* pv; cl_I* qv; - uintL* qsv; + uintC* qsv; }; -extern const cl_LF eval_rational_series (uintL N, const cl_pq_series& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, const cl_pq_series& args, uintC len); struct cl_pab_series { const cl_I* pv; const cl_I* av; const cl_I* bv; }; -extern const cl_LF eval_rational_series (uintL N, const cl_pab_series& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, const cl_pab_series& args, uintC len); struct cl_pb_series { const cl_I* pv; const cl_I* bv; }; -extern const cl_LF eval_rational_series (uintL N, const cl_pb_series& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, const cl_pb_series& args, uintC len); struct cl_pa_series { const cl_I* pv; const cl_I* av; }; -extern const cl_LF eval_rational_series (uintL N, const cl_pa_series& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, const cl_pa_series& args, uintC len); struct cl_p_series { const cl_I* pv; }; -extern const cl_LF eval_rational_series (uintL N, const cl_p_series& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, const cl_p_series& args, uintC len); struct cl_qab_series { cl_I* qv; const cl_I* av; const cl_I* bv; - uintL* qsv; + uintC* qsv; }; -extern const cl_LF eval_rational_series (uintL N, const cl_qab_series& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, const cl_qab_series& args, uintC len); struct cl_qb_series { cl_I* qv; const cl_I* bv; - uintL* qsv; + uintC* qsv; }; -extern const cl_LF eval_rational_series (uintL N, const cl_qb_series& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, const cl_qb_series& args, uintC len); struct cl_qa_series { cl_I* qv; const cl_I* av; - uintL* qsv; + uintC* qsv; }; -extern const cl_LF eval_rational_series (uintL N, const cl_qa_series& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, const cl_qa_series& args, uintC len); struct cl_q_series { cl_I* qv; - uintL* qsv; + uintC* qsv; }; -extern const cl_LF eval_rational_series (uintL N, const cl_q_series& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, const cl_q_series& args, uintC len); struct cl_ab_series { const cl_I* av; const cl_I* bv; }; -extern const cl_LF eval_rational_series (uintL N, const cl_ab_series& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, const cl_ab_series& args, uintC len); struct cl_b_series { const cl_I* bv; }; -extern const cl_LF eval_rational_series (uintL N, const cl_b_series& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, const cl_b_series& args, uintC len); struct cl_a_series { const cl_I* av; }; -extern const cl_LF eval_rational_series (uintL N, const cl_a_series& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, const cl_a_series& args, uintC len); struct cl__series { }; -extern const cl_LF eval_rational_series (uintL N, const cl__series& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, const cl__series& args, uintC len); // In this alternate implementation the series is not represented as a couple @@ -160,7 +160,7 @@ struct cl_pqab_series_stream { // Constructor. cl_pqab_series_stream (cl_pqab_series_term (*n)(cl_pqab_series_stream&)) : nextfn (n) {} }; -extern const cl_LF eval_rational_series (uintL N, cl_pqab_series_stream& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, cl_pqab_series_stream& args, uintC len); struct cl_pqb_series_term { cl_I p; @@ -173,7 +173,7 @@ struct cl_pqb_series_stream { // Constructor. cl_pqb_series_stream (cl_pqb_series_term (*n)(cl_pqb_series_stream&)) : nextfn (n) {} }; -extern const cl_LF eval_rational_series (uintL N, cl_pqb_series_stream& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, cl_pqb_series_stream& args, uintC len); struct cl_pqa_series_term { cl_I p; @@ -186,7 +186,7 @@ struct cl_pqa_series_stream { // Constructor. cl_pqa_series_stream (cl_pqa_series_term (*n)(cl_pqa_series_stream&)) : nextfn (n) {} }; -extern const cl_LF eval_rational_series (uintL N, cl_pqa_series_stream& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, cl_pqa_series_stream& args, uintC len); struct cl_pq_series_term { cl_I p; @@ -198,7 +198,7 @@ struct cl_pq_series_stream { // Constructor. cl_pq_series_stream (cl_pq_series_term (*n)(cl_pq_series_stream&)) : nextfn (n) {} }; -extern const cl_LF eval_rational_series (uintL N, cl_pq_series_stream& args, uintC len); +extern const cl_LF eval_rational_series (uintC N, cl_pq_series_stream& args, uintC len); // [Generalization.] @@ -227,9 +227,9 @@ struct cl_pqcd_series_result { cl_I D; cl_I V; }; -extern void eval_pqcd_series_aux (uintL N, cl_pqcd_series_term* args, cl_pqcd_series_result& Z, cl_boolean rightmost = cl_true); +extern void eval_pqcd_series_aux (uintC N, cl_pqcd_series_term* args, cl_pqcd_series_result& Z, cl_boolean rightmost = cl_true); // Ditto, but returns U/S. -extern const cl_LF eval_pqcd_series (uintL N, cl_pqcd_series_term* args, uintC len); +extern const cl_LF eval_pqcd_series (uintC N, cl_pqcd_series_term* args, uintC len); // [Special case c(n)=1.] // Subroutine: @@ -255,9 +255,9 @@ struct cl_pqd_series_result { cl_I D; cl_I V; }; -extern void eval_pqd_series_aux (uintL N, cl_pqd_series_term* args, cl_pqd_series_result& Z, cl_boolean rightmost = cl_true); +extern void eval_pqd_series_aux (uintC N, cl_pqd_series_term* args, cl_pqd_series_result& Z, cl_boolean rightmost = cl_true); // Ditto, but returns U/S. -extern const cl_LF eval_pqd_series (uintL N, cl_pqd_series_term* args, uintC len); +extern const cl_LF eval_pqd_series (uintC N, cl_pqd_series_term* args, uintC len); } // namespace cln diff --git a/src/float/transcendental/cl_LF_zeta3.cc b/src/float/transcendental/cl_LF_zeta3.cc index 980eec2..459b28d 100644 --- a/src/float/transcendental/cl_LF_zeta3.cc +++ b/src/float/transcendental/cl_LF_zeta3.cc @@ -39,13 +39,13 @@ const cl_LF zeta3 (uintC len) // a(n) = 205*n^2+250*n+77, b(n) = 1, // p(0) = 1, p(n) = -n^5 for n>0, q(n) = 32*(2n+1)^5. var uintC actuallen = len+2; // 2 Schutz-Digits - var uintL N = ceiling(actuallen*intDsize,10); + var uintC N = ceiling(actuallen*intDsize,10); // 1024^-N <= 2^(-intDsize*actuallen). CL_ALLOCA_STACK; var cl_I* av = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* pv = (cl_I*) cl_alloca(N*sizeof(cl_I)); var cl_I* qv = (cl_I*) cl_alloca(N*sizeof(cl_I)); - var uintL n; + var uintC n; for (n = 0; n < N; n++) { init1(cl_I, av[n]) (205*square((cl_I)n) + 250*(cl_I)n + 77); if (n==0) diff --git a/src/float/transcendental/cl_LF_zeta_int.cc b/src/float/transcendental/cl_LF_zeta_int.cc index 281f763..6070fd5 100644 --- a/src/float/transcendental/cl_LF_zeta_int.cc +++ b/src/float/transcendental/cl_LF_zeta_int.cc @@ -25,11 +25,11 @@ const cl_LF compute_zeta_exp (int s, uintC len) // with convergence acceleration through exp(x), and evaluated // using the binary-splitting algorithm. var uintC actuallen = len+2; // 2 Schutz-Digits - var uintL x = (uintL)(0.693148*intDsize*actuallen)+1; - var uintL N = (uintL)(2.718281828*x); + var uintC x = (uintC)(0.693148*intDsize*actuallen)+1; + var uintC N = (uintC)(2.718281828*x); CL_ALLOCA_STACK; var cl_pqd_series_term* args = (cl_pqd_series_term*) cl_alloca(N*sizeof(cl_pqd_series_term)); - var uintL n; + var uintC n; for (n = 0; n < N; n++) { if (n==0) { init1(cl_I, args[n].p) (1); @@ -60,12 +60,12 @@ const cl_LF compute_zeta_cvz1 (int s, uintC len) // zeta(s) = 1/(1-2^(1-s)) sum(n=0..infty, (-1)^n/(n+1)^s), // with Cohen-Villegas-Zagier convergence acceleration. var uintC actuallen = len+2; // 2 Schutz-Digits - var uintL N = (uintL)(0.39321985*intDsize*actuallen)+1; + var uintC N = (uintC)(0.39321985*intDsize*actuallen)+1; var cl_I fterm = 2*(cl_I)N*(cl_I)N; var cl_I fsum = fterm; var cl_LF gterm = cl_I_to_LF(fterm,actuallen); var cl_LF gsum = gterm; - var uintL n; + var uintC n; // After n loops // fterm = (N+n)!N/(2n+2)!(N-n-1)!*2^(2n+2), fsum = ... + fterm, // gterm = S_n*fterm, gsum = ... + gterm. @@ -93,10 +93,10 @@ const cl_LF compute_zeta_cvz2 (int s, uintC len) // with Cohen-Villegas-Zagier convergence acceleration, and // evaluated using the binary splitting algorithm. var uintC actuallen = len+2; // 2 Schutz-Digits - var uintL N = (uintL)(0.39321985*intDsize*actuallen)+1; + var uintC N = (uintC)(0.39321985*intDsize*actuallen)+1; CL_ALLOCA_STACK; var cl_pqd_series_term* args = (cl_pqd_series_term*) cl_alloca(N*sizeof(cl_pqd_series_term)); - var uintL n; + var uintC n; for (n = 0; n < N; n++) { init1(cl_I, args[n].p) (2*(cl_I)(N-n)*(cl_I)(N+n)); init1(cl_I, args[n].q) ((cl_I)(2*n+1)*(cl_I)(n+1)); diff --git a/src/integer/algebraic/cl_I_rootp_I.cc b/src/integer/algebraic/cl_I_rootp_I.cc index 497f10a..678a314 100644 --- a/src/integer/algebraic/cl_I_rootp_I.cc +++ b/src/integer/algebraic/cl_I_rootp_I.cc @@ -23,10 +23,10 @@ cl_boolean rootp (const cl_I& x, const cl_I& n, cl_I* w) { if (eq(x,0) || eq(x,1)) // x=0 oder x=1 ? { *w = x; return cl_true; } // ja -> x als Ergebnis - if (n >= UL_to_I(integer_length(x))) + if (n >= (cl_I)(unsigned long)integer_length(x)) { return cl_false; } - // Nun ist n < (integer-length x). Also paßt n in ein uintL. - return cl_rootp_aux(x,cl_I_to_UL(n),w); + // Nun ist n < (integer-length x). Also paßt n in ein uintC. + return cl_rootp_aux(x,cl_I_to_ulong(n),w); } } // namespace cln diff --git a/src/integer/algebraic/cl_I_rootp_aux.cc b/src/integer/algebraic/cl_I_rootp_aux.cc index 4e53d1c..ad0a890 100644 --- a/src/integer/algebraic/cl_I_rootp_aux.cc +++ b/src/integer/algebraic/cl_I_rootp_aux.cc @@ -64,14 +64,14 @@ cl_boolean cl_rootp_aux (cl_I x, uintL n, cl_I* w) } // Nun ist n ungerade. if (n==1) { *w = x; return cl_true; } // n=1 -> x als Ergebnis - var uintL oq = 0; // Shift von y am Schluß - {var uintL o = ord2(x); + var uintC oq = 0; // Shift von y am Schluß + {var uintC o = ord2(x); if (!(o==0)) {var uintL o_r; divu_3232_3232(o,n, oq=,o_r=); // o_r = o mod n if (!(o_r==0)) { return cl_false; } // o nicht durch n teilbar -> fertig // oq = o/n. // dividiere x durch 2^o: - x = ash(x,-(sintL)o); + x = ash(x,-(sintC)o); } } // Nun ist n ungerade, x ungerade. CL_ALLOCA_STACK; @@ -110,21 +110,21 @@ cl_boolean cl_rootp_aux (cl_I x, uintL n, cl_I* w) y_lsd_ok: ASSERT(expt_pos(y_lsd,n)==x_lsd); // Nun ist y_lsd^n == x_lsd mod beta=2^intDsize. - { var uintL m = ceiling((uintL)x_len,n); // für y nötige Länge, >0, <=x_len + { var uintC m = ceiling(x_len,n); // für y nötige Länge, >0, <=x_len var uintD* y_LSDptr; { var uintD* z1_LSDptr; var uintD* z2_LSDptr; var uintD* z3_LSDptr; num_stack_alloc_1(m, ,y_LSDptr=); // Platz für y - {var uintL need = 2*m+(32/intDsize-1); // >= max(2*m,m+32/intDsize) + {var uintC need = 2*m+(32/intDsize-1); // >= max(2*m,m+32/intDsize) num_stack_alloc(need, ,z1_LSDptr=); // Platz für Rechenregister 1 num_stack_alloc(need, ,z2_LSDptr=); // Platz für Rechenregister 2 num_stack_alloc(need, ,z3_LSDptr=); // Platz für Rechenregister 3 } - {var uintL k = 1; // y ist bisher mod beta^k bekannt + {var uintC k = 1; // y ist bisher mod beta^k bekannt lspref(y_LSDptr,0) = y_lsd; // Startwert von y until (k==m) - { var uintL k2 = 2*k; if (k2>m) { k2=m; } // k2 = min(2*k,m) > k + { var uintC k2 = 2*k; if (k2>m) { k2=m; } // k2 = min(2*k,m) > k // bisheriges y mod beta^k2 mit n-1 potenzieren: // Methode für z := y^(n-1) : // zz:=y, e:=n-1. diff --git a/src/integer/bitwise/cl_I_ash.cc b/src/integer/bitwise/cl_I_ash.cc index bde719b..db355e4 100644 --- a/src/integer/bitwise/cl_I_ash.cc +++ b/src/integer/bitwise/cl_I_ash.cc @@ -15,7 +15,7 @@ namespace cln { -const cl_I ash (const cl_I& x, sintL y) +const cl_I ash (const cl_I& x, sintC y) { // Methode: // x = 0 -> 0 als Ergebnis @@ -34,14 +34,14 @@ const cl_I ash (const cl_I& x, sintL y) CL_ALLOCA_STACK; if (y >= 0) { // y>0 - var uintL y_ = (uintL)y; + var uintC y_ = (uintC)y; var uintL i = y_%intDsize; // i = y mod intDsize, >=0, =0, <2^intCsize + var uintC k = floor(y_,intDsize); // k = y div intDsize, >=0, <2^intCsize var uintD* LSDptr; var uintC len; var const uintD* x_LSDptr; I_to_NDS_nocopy(x, ,len=,x_LSDptr=,cl_false,); // DS zu x bilden. - if (k >= (uintC)(~(uintC)len)) // kann len+k+1 Überlauf geben? + if (k >= (uintC)(~len)) // kann len+k+1 Überlauf geben? { cl_ash_error(y); } // ja -> Fehler num_stack_alloc_1(len+k,,LSDptr=); LSDptr = clear_loop_lsp(LSDptr,k); // k Nulldigits @@ -66,9 +66,9 @@ const cl_I ash (const cl_I& x, sintL y) } } else { // y<0 - var uintL y_ = (uintL)(-y); // Wert von -y, >0 + var uintC y_ = (uintC)(-y); // Wert von -y, >0 var uintL i = y_%intDsize; // i = (-y) mod intDsize, >=0, =0 + var uintC k = floor(y_,intDsize); // k = (-y) div intDsize, >=0 // DS zu x bilden: var uintD* MSDptr; var uintC len; diff --git a/src/integer/bitwise/cl_I_ash_I.cc b/src/integer/bitwise/cl_I_ash_I.cc index 0775e55..f10e2e7 100644 --- a/src/integer/bitwise/cl_I_ash_I.cc +++ b/src/integer/bitwise/cl_I_ash_I.cc @@ -35,7 +35,7 @@ const cl_I ash (const cl_I& x, const cl_I& y) if (!minusp(y)) { // y>=0 var uintL i; // i = y mod intDsize, >=0, =0, <2^intCsize + var uintC k; // k = y div intDsize, >=0, <2^intCsize if (bignump(y)) { #if (log2_intDsize+intCsize <= cl_value_len-1) // y >= 2^(cl_value_len-1) >= intDsize*2^intCsize @@ -86,7 +86,7 @@ const cl_I ash (const cl_I& x, const cl_I& y) var uintC len; var const uintD* x_LSDptr; I_to_NDS_nocopy(x, ,len=,x_LSDptr=,cl_false,); // DS zu x bilden. - if (k >= (uintC)(~(uintC)len)) // kann len+k+1 Überlauf geben? + if (k >= (uintC)(~len)) // kann len+k+1 Überlauf geben? { cl_ash_error(y); } // ja -> Fehler num_stack_alloc_1(len+k,,LSDptr=); LSDptr = clear_loop_lsp(LSDptr,k); // k Nulldigits @@ -111,7 +111,7 @@ const cl_I ash (const cl_I& x, const cl_I& y) } else { // y<0 var uintL i; // i = (-y) mod intDsize, >=0, =0, <2^intCsize + var uintC k; // k = (-y) div intDsize, >=0, <2^intCsize if (bignump(y)) { #if (log2_intDsize+intCsize <= cl_value_len-1) // -y-1 >= 2^(cl_value_len-1) >= intDsize*2^intCsize diff --git a/src/integer/bitwise/cl_I_byte.h b/src/integer/bitwise/cl_I_byte.h index 2505d8f..6ef57d2 100644 --- a/src/integer/bitwise/cl_I_byte.h +++ b/src/integer/bitwise/cl_I_byte.h @@ -11,22 +11,22 @@ namespace cln { // cl_fullbyte(p,q) liefert zu p,q die Zahl 2^q-2^p als Integer, // wobei p und q uintL sind. Bei p<=q ist das Ergebnis also // ein Integer >=0, bei dem genau die Bits p,...,q-1 gesetzt sind. -extern const cl_I cl_fullbyte (uintL p, uintL q); +extern const cl_I cl_fullbyte (uintC p, uintC q); // Extrahiere die Bits p,...,q-1 der Zahl x, // wobei 0 <= p <= q <= l = (integer-length x). // Ergebnis (wie bei LDB) ein Integer >=0. -extern const cl_I ldb_extract (const cl_I& x, uintL p, uintL q); +extern const cl_I ldb_extract (const cl_I& x, uintC p, uintC q); // Teste, ob eines der Bits p,...,q-1 der Zahl x /=0 ist, // wobei 0 <= p <= q <= l = (integer-length x). // Ergebnis (wie bei LDB-TEST) cl_false wenn nein, cl_true wenn ja. -extern cl_boolean ldb_extract_test (const cl_I& x, uintL p, uintL q); +extern cl_boolean ldb_extract_test (const cl_I& x, uintC p, uintC q); // Extrahiere die Bits p,...,q-1 der Zahl x, // wobei 0 <= p <= q <= l = (integer-length x). // Ergebnis (wie bei MASK-FIELD) ein Integer >=0. -extern const cl_I mkf_extract (const cl_I& x, uintL p, uintL q); +extern const cl_I mkf_extract (const cl_I& x, uintC p, uintC q); } // namespace cln diff --git a/src/integer/bitwise/cl_I_fullbyte.cc b/src/integer/bitwise/cl_I_fullbyte.cc index 8177a4c..06cf65e 100644 --- a/src/integer/bitwise/cl_I_fullbyte.cc +++ b/src/integer/bitwise/cl_I_fullbyte.cc @@ -14,12 +14,12 @@ namespace cln { -const cl_I cl_fullbyte (uintL p, uintL q) +const cl_I cl_fullbyte (uintC p, uintC q) { if (p==q) return 0; else - return ash(-1,UL_to_I(p)) + ash(1,UL_to_I(q)); + return ash(-1,(cl_I)(unsigned long)p) + ash(1,(cl_I)(unsigned long)q); } } // namespace cln diff --git a/src/integer/bitwise/cl_I_ilength.cc b/src/integer/bitwise/cl_I_ilength.cc index 4bebae0..5620e85 100644 --- a/src/integer/bitwise/cl_I_ilength.cc +++ b/src/integer/bitwise/cl_I_ilength.cc @@ -14,7 +14,7 @@ namespace cln { -uintL integer_length (const cl_I& x) +uintC integer_length (const cl_I& x) { if (fixnump(x)) { var uintL bitcount = 0; @@ -33,7 +33,7 @@ uintL integer_length (const cl_I& x) { var const uintD* MSDptr; var uintC len; BN_to_NDS_nocopy(x, MSDptr=,len=,); // normalisierte DS zu x bilden. - var uintL bitcount = intDsize*(uintL)(len-1); // Anzahl Digits mal intDsize + var uintC bitcount = intDsize*(len-1); // Anzahl Digits mal intDsize // MSDigit nehmen, testen, welches das höchste Bit ist, das vom // Vorzeichenbit abweicht: var uintD msd = mspref(MSDptr,0); // MSDigit diff --git a/src/integer/bitwise/cl_I_ldb.cc b/src/integer/bitwise/cl_I_ldb.cc index 43d6fc3..81fecaf 100644 --- a/src/integer/bitwise/cl_I_ldb.cc +++ b/src/integer/bitwise/cl_I_ldb.cc @@ -26,9 +26,9 @@ const cl_I ldb (const cl_I& n, const cl_byte& b) // q:=min(p+s,l). // Extrahiere die Bits p,...,q-1 von n. // Falls p+s>l und n<0, füge p+s-l Einsenbits an (addiere 2^s-2^(l-p)). - var uintL s = b.size; - var uintL p = b.position; - var uintL l = integer_length(n); // l = (integer-length n) + var uintC s = b.size; + var uintC p = b.position; + var uintC l = integer_length(n); // l = (integer-length n) if (l<=p) // l<=p if (!minusp(n)) @@ -40,7 +40,7 @@ const cl_I ldb (const cl_I& n, const cl_byte& b) else // l>p { var cl_I erg = ldb_extract(n,p,(p+slp) && minusp(n)) // s>l-p und n<0 ? { return logior(erg,cl_fullbyte(lp,s)); } // setze Bits l-p,...,s-1 // (logisches Exklusiv-Oder oder Addition ginge auch) diff --git a/src/integer/bitwise/cl_I_ldbtest.cc b/src/integer/bitwise/cl_I_ldbtest.cc index 9b62a97..c902008 100644 --- a/src/integer/bitwise/cl_I_ldbtest.cc +++ b/src/integer/bitwise/cl_I_ldbtest.cc @@ -29,10 +29,10 @@ cl_boolean ldb_test (const cl_I& n, const cl_byte& b) // und bei n<0 sind Bits p+s-1..l =1. // Falls p+s<=l, // extrahiere die Bits p,...,p+s-1 von n und teste sie. - var uintL s = b.size; - var uintL p = b.position; + var uintC s = b.size; + var uintC p = b.position; if (s==0) return cl_false; - var uintL l = integer_length(n); // l = (integer-length n) + var uintC l = integer_length(n); // l = (integer-length n) if (l<=p) // l<=p if (!minusp(n)) @@ -41,7 +41,7 @@ cl_boolean ldb_test (const cl_I& n, const cl_byte& b) return cl_true; // n<0 else // l>p - { var uintL ps = p+s; + { var uintC ps = p+s; if (ps>l) // p+s>l ? return cl_true; // Bits p,...,q-1 mit q = min(p+s,l) = p+s extrahieren und testen: diff --git a/src/integer/bitwise/cl_I_ldbx.cc b/src/integer/bitwise/cl_I_ldbx.cc index 788133b..2a01516 100644 --- a/src/integer/bitwise/cl_I_ldbx.cc +++ b/src/integer/bitwise/cl_I_ldbx.cc @@ -15,21 +15,21 @@ namespace cln { -const cl_I ldb_extract (const cl_I& x, uintL p, uintL q) +const cl_I ldb_extract (const cl_I& x, uintC p, uintC q) { CL_ALLOCA_STACK; var const uintD* MSDptr; var uintC len; var const uintD* LSDptr; I_to_NDS_nocopy(x, MSDptr=,len=,LSDptr=,cl_true, { return 0; } ); // NDS zu x bilden // MSDptr erhöhen und len erniedrigen, so daß len = ceiling(q/intDsize) wird: - { var uintL qD = ceiling(q,intDsize); // ceiling(q/intDsize) + { var uintC qD = ceiling(q,intDsize); // ceiling(q/intDsize) // wegen q<=l ist qD = ceiling(q/intDsize) <= ceiling((l+1)/intDsize) = len, also // paßt qD ebenso wie len in ein uintC. - MSDptr = MSDptr mspop ((uintL)len - qD); // MSDptr um len-qD Digits erhöhen + MSDptr = MSDptr mspop (len - qD); // MSDptr um len-qD Digits erhöhen len = qD; // len um len-qD erniedrigen } // LSDptr und len um floor(p/intDsize) erniedrigen: - { var uintL pD = floor(p,intDsize); // floor(p/intDsize) + { var uintC pD = floor(p,intDsize); // floor(p/intDsize) LSDptr = LSDptr lspop pD; len -= pD; } @@ -37,7 +37,7 @@ const cl_I ldb_extract (const cl_I& x, uintL p, uintL q) var uintD* newMSDptr; { var uintL i = p%intDsize; // p mod intDsize // Kopiere sie und schiebe sie dabei um i Bits nach rechts: - num_stack_alloc_1((uintL)len, newMSDptr=,); // neue UDS newMSDptr/len/.. + num_stack_alloc_1(len, newMSDptr=,); // neue UDS newMSDptr/len/.. if (i==0) { copy_loop_msp(MSDptr,newMSDptr,len); } else @@ -45,7 +45,7 @@ const cl_I ldb_extract (const cl_I& x, uintL p, uintL q) } // newMSDptr/len/.. = geschobene Kopie der maßgeblichen Digits // Ausblenden der Bits mit Nummern >= q-p: - { var uintL bitcount = intDsize*(uintL)len - (q-p); + { var uintC bitcount = intDsize*len - (q-p); // Anzahl vorne auszublendender Bits ( >=0, <= intDsize-1 + intDsize-1 ) if (bitcount>=intDsize) { bitcount -= intDsize; msshrink(newMSDptr); len -= 1; } // intDsize Bits ausblenden diff --git a/src/integer/bitwise/cl_I_ldbxtest.cc b/src/integer/bitwise/cl_I_ldbxtest.cc index 9ee0767..d5447e7 100644 --- a/src/integer/bitwise/cl_I_ldbxtest.cc +++ b/src/integer/bitwise/cl_I_ldbxtest.cc @@ -15,20 +15,20 @@ namespace cln { -cl_boolean ldb_extract_test (const cl_I& x, uintL p, uintL q) +cl_boolean ldb_extract_test (const cl_I& x, uintC p, uintC q) { var const uintD* MSDptr; var uintC len; var const uintD* LSDptr; I_to_NDS_nocopy(x, MSDptr=,len=,LSDptr=,cl_true, { return cl_false; } ); // NDS zu x bilden // MSDptr erhöhen und len erniedrigen, so daß len = ceiling(q/intDsize) wird: - { var uintL qD = ceiling(q,intDsize); // ceiling(q/intDsize) + { var uintC qD = ceiling(q,intDsize); // ceiling(q/intDsize) // wegen q<=l ist qD = ceiling(q/intDsize) <= ceiling((l+1)/intDsize) = len, also // paßt qD ebenso wie len in ein uintC. - MSDptr = MSDptr mspop ((uintL)len - qD); // MSDptr um len-qD Digits erhöhen + MSDptr = MSDptr mspop (len - qD); // MSDptr um len-qD Digits erhöhen len = qD; // len um len-qD erniedrigen } // LSDptr und len um floor(p/intDsize) erniedrigen: - { var uintL pD = p/intDsize; // floor(p/intDsize) + { var uintC pD = p/intDsize; // floor(p/intDsize) LSDptr = LSDptr lspop pD; len -= pD; } diff --git a/src/integer/bitwise/cl_I_logbitp.cc b/src/integer/bitwise/cl_I_logbitp.cc index 5eedaa5..8227b2e 100644 --- a/src/integer/bitwise/cl_I_logbitp.cc +++ b/src/integer/bitwise/cl_I_logbitp.cc @@ -14,7 +14,7 @@ namespace cln { -cl_boolean logbitp (uintL x, const cl_I& y) +cl_boolean logbitp (uintC x, const cl_I& y) { // Methode: // Falls x>=intDsize*Länge(y), teste Vorzeichen von y. @@ -24,7 +24,7 @@ cl_boolean logbitp (uintL x, const cl_I& y) var uintC ylen; var const uintD* yLSDptr; I_to_NDS_nocopy(y, yMSDptr=,ylen=,yLSDptr=,cl_true, { return cl_false; } ); // DS zu y - if (x < intDsize*(uintL)ylen) + if (x < intDsize*ylen) // x ist >=0, < intDsize*ylen { if (lspref(yLSDptr,floor(x,intDsize)) & bit(x%intDsize)) return cl_true; diff --git a/src/integer/bitwise/cl_I_logbitp_I.cc b/src/integer/bitwise/cl_I_logbitp_I.cc index 2c40a1d..c1b87ad 100644 --- a/src/integer/bitwise/cl_I_logbitp_I.cc +++ b/src/integer/bitwise/cl_I_logbitp_I.cc @@ -29,7 +29,7 @@ cl_boolean logbitp (const cl_I& x, const cl_I& y) var uintC ylen; var const uintD* yLSDptr; I_to_NDS_nocopy(y, ,ylen=,yLSDptr=,cl_true, { return cl_false; } ); // DS zu y - if (x_ < intDsize*(uintL)ylen) + if (x_ < intDsize*ylen) // x ist ein Fixnum >=0, < intDsize*ylen { if (lspref(yLSDptr,floor(x_,intDsize)) & bit(x_%intDsize)) return cl_true; diff --git a/src/integer/bitwise/cl_I_logcount.cc b/src/integer/bitwise/cl_I_logcount.cc index dd293bf..62a1814 100644 --- a/src/integer/bitwise/cl_I_logcount.cc +++ b/src/integer/bitwise/cl_I_logcount.cc @@ -16,7 +16,7 @@ namespace cln { -uintL logcount (const cl_I& x) +uintC logcount (const cl_I& x) { if (fixnump(x)) { var uintV x32 = FN_to_V(x); // x als intDsize-Bit-Zahl @@ -34,11 +34,11 @@ uintL logcount (const cl_I& x) { var const uintD* MSDptr; var uintC len; BN_to_NDS_nocopy(x, MSDptr=,len=,); // DS zu x bilden, len>0. - var uintL bitcount = 0; // Bitzähler + var uintC bitcount = 0; // Bitzähler var const uintD* ptr = MSDptr; // läuft durch die Digits durch var uintD sign = sign_of_sintD(mspref(ptr,0)); // Vorzeichen dotimespC(len,len, - { bitcount += (uintL)logcountD(msprefnext(ptr) ^ sign); }); + { bitcount += (uintC)logcountD(msprefnext(ptr) ^ sign); }); // 0 <= bitcount < intDsize*2^intCsize. return bitcount; } diff --git a/src/integer/bitwise/cl_I_mkf.cc b/src/integer/bitwise/cl_I_mkf.cc index f496376..86c49ea 100644 --- a/src/integer/bitwise/cl_I_mkf.cc +++ b/src/integer/bitwise/cl_I_mkf.cc @@ -26,10 +26,10 @@ const cl_I mask_field (const cl_I& n, const cl_byte& b) // q:=min(p+s,l). // Extrahiere die Bits p,...,q-1 von n. // Falls p+s>l und n<0, füge p+s-l Einsenbits an (addiere 2^(p+s)-2^l). - var uintL s = b.size; - var uintL p = b.position; - {var uintL ps = p+s; - var uintL l = integer_length(n); // l = (integer-length n) + var uintC s = b.size; + var uintC p = b.position; + {var uintC ps = p+s; + var uintC l = integer_length(n); // l = (integer-length n) if (l<=p) // l<=p if (!minusp(n)) diff --git a/src/integer/bitwise/cl_I_mkfx.cc b/src/integer/bitwise/cl_I_mkfx.cc index dd6b423..9df0edf 100644 --- a/src/integer/bitwise/cl_I_mkfx.cc +++ b/src/integer/bitwise/cl_I_mkfx.cc @@ -15,7 +15,7 @@ namespace cln { -const cl_I mkf_extract (const cl_I& x, uintL p, uintL q) +const cl_I mkf_extract (const cl_I& x, uintC p, uintC q) { CL_ALLOCA_STACK; var const uintD* MSDptr; @@ -23,20 +23,20 @@ const cl_I mkf_extract (const cl_I& x, uintL p, uintL q) var const uintD* LSDptr; I_to_NDS_nocopy(x, MSDptr=,len=,LSDptr=,cl_true, { return 0; } ); // NDS zu x bilden // MSDptr erhöhen und len erniedrigen, so daß len = ceiling(q/intDsize) wird: - { var uintL qD = ceiling(q,intDsize); // ceiling(q/intDsize) + { var uintC qD = ceiling(q,intDsize); // ceiling(q/intDsize) // wegen q<=l ist qD = ceiling(q/intDsize) <= ceiling((l+1)/intDsize) = len, also // paßt qD ebenso wie len in ein uintC. - MSDptr = MSDptr mspop ((uintL)len - qD); // MSDptr um len-qD Digits erhöhen + MSDptr = MSDptr mspop (len - qD); // MSDptr um len-qD Digits erhöhen len = qD; // len um len-qD erniedrigen } // Platz (len Digits) für die neue UDS bereitstellen: var uintD* newMSDptr; - num_stack_alloc_1((uintL)len, newMSDptr = ,); // Platz belegen - {var uintL pD = p/intDsize; // floor(p/intDsize), paßt in ein uintC + num_stack_alloc_1(len, newMSDptr = ,); // Platz belegen + {var uintC pD = p/intDsize; // floor(p/intDsize), paßt in ein uintC // Kopiere len-pD Digits aus der DS zu x heraus: - var uintD* midptr = copy_loop_msp(MSDptr,newMSDptr,len-(uintC)pD); + var uintD* midptr = copy_loop_msp(MSDptr,newMSDptr,len-pD); // Lösche p-intDsize*floor(p/intDsize) Bits im Digit unterhalb von midptr: - {var uintL p_D = p%intDsize; + {var uintC p_D = p%intDsize; if (!(p_D==0)) { lspref(midptr,0) &= minus_bit(p_D); } } // Lösche pD Digits darüber: diff --git a/src/integer/cl_I.h b/src/integer/cl_I.h index 5d5fa8a..52c137d 100644 --- a/src/integer/cl_I.h +++ b/src/integer/cl_I.h @@ -42,7 +42,7 @@ inline cl_uint cl_FN_word (const cl_I& x) // Bignums. struct cl_heap_bignum : cl_heap { - unsigned int length; // length (in digits) + uintC length; // length (in digits) uintD data[1]; // number in two's complement representation }; @@ -51,7 +51,7 @@ inline cl_heap_bignum* TheBignum (cl_heap_bignum* p) inline cl_heap_bignum* TheBignum (const cl_number& obj) { return (cl_heap_bignum*)(obj.pointer); } -inline cl_heap_bignum* allocate_bignum (unsigned int length) +inline cl_heap_bignum* allocate_bignum (uintC length) { cl_heap_bignum* p = (cl_heap_bignum*) malloc_hook(offsetofa(cl_heap_bignum,data)+sizeof(uintD)*length); p->refcount = 1; @@ -662,14 +662,14 @@ inline sintD FN_MSD (cl_uint word) // > MSBptr/len/..: Ziffernfolge, bestehend aus Punkten (werden überlesen) // und Ziffern/Buchstaben mit Wert < base. // < ergebnis: der dargestellte Integer >=0 - extern const cl_I digits_to_I (const char * MSBptr, uintL len, uintD base); + extern const cl_I digits_to_I (const char * MSBptr, uintC len, uintD base); // Hilfsfunktion zur Ausgabe von Integers // cl_digits_need(len,base) liefert eine obere Abschätzung für die Anzahl der // Ziffern im Stellenwertsystem der Basis base, die x >= 0 braucht. - extern uintL cl_digits_need (const cl_I& x, uintL base); + extern uintC cl_digits_need (const cl_I& x, uintL base); // Wandelt ein Integer in ein Stellensystem um. // I_to_digits(x,base, &ergebnis); @@ -677,7 +677,7 @@ inline sintD FN_MSD (cl_uint word) // > base: Stellensystem-Basis, 2 <= base <= 36. // > ergebnis.LSBptr: darunter ist mindestens digits_need(len) Bytes Platz // < ergebnis: fertige Folge MSBptr/len/LSBptr von Ziffern - typedef struct { uintB* MSBptr; uintL len; uintB* LSBptr; } cl_digits; + typedef struct { uintB* MSBptr; uintC len; uintB* LSBptr; } cl_digits; extern void I_to_digits (const cl_I& x, uintD base, cl_digits* erg); diff --git a/src/integer/conv/cl_I_cached_power.h b/src/integer/conv/cl_I_cached_power.h index 1c6899a..78324dc 100644 --- a/src/integer/conv/cl_I_cached_power.h +++ b/src/integer/conv/cl_I_cached_power.h @@ -31,7 +31,7 @@ struct cached_power_table_entry { }; struct cached_power_table { - cached_power_table_entry element[30]; + cached_power_table_entry element[40]; // Constructor and destructor - nothing special. cached_power_table () {} ~cached_power_table () {} diff --git a/src/integer/conv/cl_I_digits_need.cc b/src/integer/conv/cl_I_digits_need.cc index aefaab9..50ca374 100644 --- a/src/integer/conv/cl_I_digits_need.cc +++ b/src/integer/conv/cl_I_digits_need.cc @@ -11,14 +11,14 @@ namespace cln { -uintL cl_digits_need (const cl_I& x, uintL base) +uintC cl_digits_need (const cl_I& x, uintL base) { if (fixnump(x)) { return cl_value_len; } // x < 2^cl_value_len, base >= 2, also reicht das else { var uintC len = TheBignum(x)->length; // 1+ceiling(len * intDsize*log(2)/log(base)) Bytes oder etwas mehr - var uintL need = 1+floor(len,1024/intDsize); // > ceiling(len*intDsize/1024) >= 0 + var uintC need = 1+floor(len,1024/intDsize); // > ceiling(len*intDsize/1024) >= 0 switch (base) // need mit ceiling(1024*log(2)/log(base)) multiplizieren: { case 2: need = 1024*need; break; case 3: need = 647*need; break; diff --git a/src/integer/conv/cl_I_from_digits.cc b/src/integer/conv/cl_I_from_digits.cc index bbb1a51..82fc71e 100644 --- a/src/integer/conv/cl_I_from_digits.cc +++ b/src/integer/conv/cl_I_from_digits.cc @@ -14,7 +14,7 @@ namespace cln { -static const cl_I digits_to_I_base2 (const char * MSBptr, uintL len, uintD base) +static const cl_I digits_to_I_base2 (const char * MSBptr, uintC len, uintD base) { // base is a power of two: write the digits from least significant // to most significant into the result NUDS. Result needs @@ -58,7 +58,7 @@ static const cl_I digits_to_I_base2 (const char * MSBptr, uintL len, uintD base) return NUDS_to_I(erg_MSDptr,erg_len); } -static const cl_I digits_to_I_baseN (const char * MSBptr, uintL len, uintD base) +static const cl_I digits_to_I_baseN (const char * MSBptr, uintC len, uintD base) { // base is not a power of two: Add digits one by one. Result nees // 1+ceiling(len*log(base)/(intDsize*log(2))) or some more digits. @@ -66,7 +66,7 @@ static const cl_I digits_to_I_baseN (const char * MSBptr, uintL len, uintD base) var uintD* erg_MSDptr; var uintC erg_len; var uintD* erg_LSDptr; - var uintL need = 1+floor(len,intDsize*256); // > len/(intDsize*256) >=0 + var uintC need = 1+floor(len,intDsize*256); // > len/(intDsize*256) >=0 switch (base) { // multiply need with ceiling(256*log(base)/log(2)): case 2: need = 256*need; break; case 3: need = 406*need; break; @@ -142,7 +142,7 @@ static const cl_I digits_to_I_baseN (const char * MSBptr, uintL len, uintD base) return NUDS_to_I(erg_MSDptr,erg_len); } -const cl_I digits_to_I (const char * MSBptr, uintL len, uintD base) +const cl_I digits_to_I (const char * MSBptr, uintC len, uintD base) { if ((base & (base-1)) == 0) { return digits_to_I_base2(MSBptr, len, base); diff --git a/src/integer/conv/cl_I_to_digits.cc b/src/integer/conv/cl_I_to_digits.cc index abe48b9..b5d8a84 100644 --- a/src/integer/conv/cl_I_to_digits.cc +++ b/src/integer/conv/cl_I_to_digits.cc @@ -46,11 +46,11 @@ namespace cln { const int cl_digits_algo = 1; // like I_to_digits, except that the result has exactly erg_len characters. -static inline void I_to_digits_noshrink (const cl_I& X, uintD base, uintL erg_len, cl_digits* erg) +static inline void I_to_digits_noshrink (const cl_I& X, uintD base, uintC erg_len, cl_digits* erg) { I_to_digits(X,base,erg); if (erg->len > erg_len) cl_abort(); - var uintL count = erg_len - erg->len; + var uintC count = erg_len - erg->len; if (count > 0) { var uintB* ptr = erg->MSBptr; do { *--ptr = '0'; } while (--count > 0); @@ -159,9 +159,9 @@ void I_to_digits (const cl_I& X, uintD base, cl_digits* erg) // for k*2^i characters, convert X1 to string. (Have to convert // X0 first because the conversion may temporarily prepend some // zero characters.) - var uintL ilen_X = integer_length(X); + var uintC ilen_X = integer_length(X); var const cached_power_table_entry * p; - var uintL ilen_B; + var uintC ilen_B; var uintL i; for (i = 0; ; i++) { p = cached_power(base,i); diff --git a/src/integer/gcd/cl_I_gcd.cc b/src/integer/gcd/cl_I_gcd.cc index 30b5c58..357fccf 100644 --- a/src/integer/gcd/cl_I_gcd.cc +++ b/src/integer/gcd/cl_I_gcd.cc @@ -324,7 +324,7 @@ namespace cln { {var uintD* divroomptr; // Platz für Divisionsergebnis var uintD* c_LSDptr; var uintD* d_LSDptr; - {var uintL c_len = (uintL)(a_len>=b_len ? a_len : b_len) + 1; + {var uintC c_len = (a_len>=b_len ? a_len : b_len) + 1; num_stack_alloc(c_len,divroomptr=,c_LSDptr=); num_stack_alloc(c_len,,d_LSDptr=); // Jetzt ist ../c_len/c_LSDptr, ../c_len/d_LSDptr frei. diff --git a/src/integer/gcd/cl_I_xgcd.cc b/src/integer/gcd/cl_I_xgcd.cc index d99272a..b8618de 100644 --- a/src/integer/gcd/cl_I_xgcd.cc +++ b/src/integer/gcd/cl_I_xgcd.cc @@ -279,7 +279,7 @@ namespace cln { // uBb = uBb.MSDptr/uBb.len/uBb.LSDptr, // alles NUDS. // Platz für zwei Rechenregister besorgen, mit je max(a_len,b_len)+1 Digits: - {var uintL c_len = (uintL)(a_len>=b_len ? a_len : b_len) + 1; + {var uintC c_len = (a_len>=b_len ? a_len : b_len) + 1; num_stack_alloc(c_len,,c_LSDptr=); num_stack_alloc(c_len,divroomptr=,d_LSDptr=); // Jetzt ist ../c_len/c_LSDptr, ../c_len/d_LSDptr frei. diff --git a/src/integer/misc/cl_I_eqhashcode.cc b/src/integer/misc/cl_I_eqhashcode.cc index 5c790d0..572be44 100644 --- a/src/integer/misc/cl_I_eqhashcode.cc +++ b/src/integer/misc/cl_I_eqhashcode.cc @@ -63,7 +63,7 @@ inline uint32 equal_hashcode (const cl_BN& x) } else { sign = 0; } - var sintL exp = (uintL)len * intDsize; + var sintC exp = len * intDsize; // Nicht alle führenden 65 Bits sind =0. if (msd==0) { msd = msd2; @@ -108,7 +108,7 @@ inline uint32 equal_hashcode (const cl_BN& x) } else { sign = 0; } - var sintL exp = (uintL)len * intDsize; + var sintC exp = len * intDsize; // Nicht alle führenden intDsize+1 Bits sind =0. // Wegen intDsize<=32: Nicht alle führenden 33 Bits sind =0. if (msd==0) { diff --git a/src/integer/misc/cl_I_ord2.cc b/src/integer/misc/cl_I_ord2.cc index f9beb78..46a7977 100644 --- a/src/integer/misc/cl_I_ord2.cc +++ b/src/integer/misc/cl_I_ord2.cc @@ -28,7 +28,7 @@ namespace cln { // (ord2 x) = intDsize * Anzahl der Nulldigits am Schluß // + Anzahl der Nullbits am Ende des letzten Digits /=0. -uintL ord2 (const cl_I& x) // x /= 0 +uintC ord2 (const cl_I& x) // x /= 0 { if (fixnump(x)) { var uintV x_ = FN_to_V(x); // x als intVsize-Bit-Zahl @@ -40,7 +40,7 @@ uintL ord2 (const cl_I& x) // x /= 0 #endif } else - { var uintL bitcount = 0; + { var uintC bitcount = 0; var const uintD* ptr; BN_to_NDS_nocopy(x, ,,ptr=); // normalisierte DS zu x bilden. while (lspref(ptr,0) == 0) { lsshrink(ptr); bitcount += intDsize; } // Nulldigits abzählen diff --git a/src/integer/misc/cl_I_power2p.cc b/src/integer/misc/cl_I_power2p.cc index df0f760..dc29c24 100644 --- a/src/integer/misc/cl_I_power2p.cc +++ b/src/integer/misc/cl_I_power2p.cc @@ -14,7 +14,7 @@ namespace cln { -uintL power2p (const cl_I& x) // x > 0 +uintC power2p (const cl_I& x) // x > 0 { // Methode 1: Wenn ord2(x) = integer_length(x)-1. // Methode 2: Wenn logand(x,x-1) = 0. @@ -41,7 +41,7 @@ uintL power2p (const cl_I& x) // x > 0 if (DS_test_loop(MSDptr mspop 1,len-1,LSDptr)) return 0; // danach alles Nullen {var uintL msdlen; integerlengthD(msd, msdlen=); - return intDsize*(uintL)(len-1) + msdlen; // integer_length(x) als Ergebnis + return intDsize*(len-1) + msdlen; // integer_length(x) als Ergebnis }} } diff --git a/src/integer/output/cl_I_decstring.cc b/src/integer/output/cl_I_decstring.cc index 26f9b68..14f8236 100644 --- a/src/integer/output/cl_I_decstring.cc +++ b/src/integer/output/cl_I_decstring.cc @@ -18,7 +18,7 @@ namespace cln { char * cl_decimal_string (const cl_I& x) { CL_ALLOCA_STACK; - var uintL need = cl_digits_need(x,10); + var uintC need = cl_digits_need(x,10); var uintB* ziffern = cl_alloc_array(uintB,need); // Platz für die Ziffern var cl_digits erg; erg.LSBptr = &ziffern[need]; I_to_digits(x,10,&erg); // Umwandlung in Ziffern diff --git a/src/integer/output/cl_I_print.cc b/src/integer/output/cl_I_print.cc index 65688b4..b8447f9 100644 --- a/src/integer/output/cl_I_print.cc +++ b/src/integer/output/cl_I_print.cc @@ -25,14 +25,14 @@ void print_integer (std::ostream& stream, unsigned int base, const cl_I& z) } else abs_z = z; CL_ALLOCA_STACK; - var uintL need = cl_digits_need(abs_z,base); + var uintC need = cl_digits_need(abs_z,base); var uintB* ziffern = cl_alloc_array(uintB,need); // Platz für die Ziffern var cl_digits erg; erg.LSBptr = &ziffern[need]; I_to_digits(abs_z,(uintD)base,&erg); // Umwandlung in Ziffern // Ziffern ausgeben: { var uintB* ptr = erg.MSBptr; - var uintL count = erg.len; + var uintC count = erg.len; do { fprintchar(stream,*ptr++); } until (--count==0); } } diff --git a/src/integer/output/cl_I_print_string.cc b/src/integer/output/cl_I_print_string.cc index b6cb465..49391e2 100644 --- a/src/integer/output/cl_I_print_string.cc +++ b/src/integer/output/cl_I_print_string.cc @@ -26,7 +26,7 @@ char * print_integer_to_string (unsigned int base, const cl_I& z) } else abs_z = z; CL_ALLOCA_STACK; - var uintL need = 1+cl_digits_need(abs_z,base); + var uintC need = 1+cl_digits_need(abs_z,base); var uintB* ziffern = cl_alloc_array(uintB,need); // Platz für die Ziffern var cl_digits erg; erg.LSBptr = &ziffern[need]; I_to_digits(abs_z,(uintD)base,&erg); // Umwandlung in Ziffern diff --git a/src/modinteger/cl_MI.cc b/src/modinteger/cl_MI.cc index a15b2c3..297718d 100644 --- a/src/modinteger/cl_MI.cc +++ b/src/modinteger/cl_MI.cc @@ -44,13 +44,13 @@ cl_heap_modint_ring::cl_heap_modint_ring (cl_I m, cl_modint_setops* setopv, cl_m type = &cl_class_modint_ring; if (minusp(m)) cl_abort(); if (!cln::zerop(m)) { - var uintL b = integer_length(m-1); + var uintC b = integer_length(m-1); // m <= 2^b, hence one needs b bits for a representative mod m. if (b <= 1) { log2_bits = 0; bits = 1; } else if (b <= cl_word_size) { var uintL bb; - integerlength32(b-1,bb=); // b <= 2^bb with bb minimal + integerlengthC(b-1,bb=); // b <= 2^bb with bb minimal log2_bits = bb; bits = 1<= 0 return new cl_heap_modint_ring_int(); // Now m > 0. { - var uintL log2_m = power2p(m); + var uintC log2_m = power2p(m); if (log2_m) return new cl_heap_modint_ring_pow2(m,log2_m-1); } // Now m > 1. { - var uintL log2_m = integer_length(m); // = integerlength(m-1) + var uintC log2_m = integer_length(m); // = integerlength(m-1) if (log2_m < 16) // m < 0x10000 return new cl_heap_modint_ring_fix16(m); #if (cl_value_len <= 32) @@ -110,12 +110,12 @@ static inline cl_heap_modint_ring* make_modint_ring (const cl_I& m) // m >= 0 #endif } { - var uintL m1 = power2p(m+1); + var uintC m1 = power2p(m+1); if (m1) return new cl_heap_modint_ring_pow2m1(m,m1-1); } { - var uintL m1 = power2p(m-1); + var uintC m1 = power2p(m-1); if (m1) return new cl_heap_modint_ring_pow2p1(m,m1-1); } diff --git a/src/modinteger/cl_MI_lshift.cc b/src/modinteger/cl_MI_lshift.cc index 7f501b5..9c8146e 100644 --- a/src/modinteger/cl_MI_lshift.cc +++ b/src/modinteger/cl_MI_lshift.cc @@ -13,7 +13,7 @@ namespace cln { -const cl_MI operator<< (const cl_MI& x, sintL y) // assume 0 <= y < 2^31 +const cl_MI operator<< (const cl_MI& x, sintC y) // assume 0 <= y < 2^(intCsize-1) { if (y == 0) return x; diff --git a/src/modinteger/cl_MI_montgom.h b/src/modinteger/cl_MI_montgom.h index 06222ee..c5c7a4c 100644 --- a/src/modinteger/cl_MI_montgom.h +++ b/src/modinteger/cl_MI_montgom.h @@ -179,7 +179,7 @@ static cl_heap_modint_ring* try_make_modint_ring_montgom (const cl_I& M) { if (!oddp(M)) return NULL; - var uintL m = integer_length(M); + var uintC m = integer_length(M); CL_ALLOCA_STACK; var uintC len; var const uintD* M_LSDptr; @@ -191,9 +191,9 @@ static cl_heap_modint_ring* try_make_modint_ring_montgom (const cl_I& M) recip2adic(len,M_LSDptr,U_LSDptr); // Look at U's bits. #define U_bit(i) (lspref(U_LSDptr,floor(i,intDsize)) & ((uintD)1 << ((i)%intDsize))) - var uintL i_min; - var uintL i_max; - var uintL i = floor(m,2); + var uintC i_min; + var uintC i_max; + var uintC i = floor(m,2); var cl_boolean negative; if (U_bit(i)) { for (; --i > 0; ) @@ -218,7 +218,7 @@ static cl_heap_modint_ring* try_make_modint_ring_montgom (const cl_I& M) // OK, all the bits i_max-1..i_min of U are equal. if (i_max - i_min <= floor(m,2)) return NULL; - var uintL n = i_max; + var uintC n = i_max; // Turn U (mod 2^n) into a signed integer. if (n % intDsize) { if (negative) @@ -226,7 +226,7 @@ static cl_heap_modint_ring* try_make_modint_ring_montgom (const cl_I& M) else lspref(U_LSDptr,floor(n,intDsize)) &= ((uintD)1 << (n % intDsize)) - 1; } - var uintL U_len = ceiling(n,intDsize); + var uintC U_len = ceiling(n,intDsize); var cl_I U = DS_to_I(U_LSDptr lspop U_len,U_len); var cl_I V_N = 1 - U*M; if (ldb_test(V_N,cl_byte(n,0))) diff --git a/src/modinteger/cl_MI_pow2.h b/src/modinteger/cl_MI_pow2.h index 6746899..8511600 100644 --- a/src/modinteger/cl_MI_pow2.h +++ b/src/modinteger/cl_MI_pow2.h @@ -6,11 +6,11 @@ class cl_heap_modint_ring_pow2 : public cl_heap_modint_ring { SUBCLASS_cl_heap_modint_ring() public: // Constructor. - cl_heap_modint_ring_pow2 (const cl_I& m, uintL m1); // m = 2^m1 + cl_heap_modint_ring_pow2 (const cl_I& m, uintC m1); // m = 2^m1 // Destructor. ~cl_heap_modint_ring_pow2 () {} // Additional information. - uintL m1; + uintC m1; }; static inline const cl_I pow2_reduce_modulo (cl_heap_modint_ring* _R, const cl_I& x) @@ -148,7 +148,7 @@ cl_class cl_class_modint_ring_pow2 = { }; // Constructor. -inline cl_heap_modint_ring_pow2::cl_heap_modint_ring_pow2 (const cl_I& m, uintL _m1) +inline cl_heap_modint_ring_pow2::cl_heap_modint_ring_pow2 (const cl_I& m, uintC _m1) : cl_heap_modint_ring (m, &std_setops, &pow2_addops, &pow2_mulops), m1 (_m1) { type = &cl_class_modint_ring_pow2; diff --git a/src/modinteger/cl_MI_pow2m1.h b/src/modinteger/cl_MI_pow2m1.h index 2a36cfe..9daecad 100644 --- a/src/modinteger/cl_MI_pow2m1.h +++ b/src/modinteger/cl_MI_pow2m1.h @@ -6,11 +6,11 @@ class cl_heap_modint_ring_pow2m1 : public cl_heap_modint_ring { SUBCLASS_cl_heap_modint_ring() public: // Constructor. - cl_heap_modint_ring_pow2m1 (const cl_I& m, uintL m1); // m = 2^m1 - 1 + cl_heap_modint_ring_pow2m1 (const cl_I& m, uintC m1); // m = 2^m1 - 1 // Destructor. ~cl_heap_modint_ring_pow2m1 () {} // Additional information. - uintL m1; + uintC m1; }; static inline const cl_I pow2m1_reduce_modulo (cl_heap_modint_ring* _R, const cl_I& x) @@ -24,13 +24,13 @@ static inline const cl_I pow2m1_reduce_modulo (cl_heap_modint_ring* _R, const cl { Mutable(cl_I,x); var cl_boolean sign = minusp(x); if (sign) { x = lognot(x); } - var const uintL m1 = R->m1; + var const uintC m1 = R->m1; if (x >= R->modulus) { x = plus1(x); // avoid staying at x = m do { - var uintL xlen = integer_length(x); + var uintC xlen = integer_length(x); var cl_I y = ldb(x,cl_byte(m1,0)); - for (var uintL i = m1; i < xlen; i += m1) + for (var uintC i = m1; i < xlen; i += m1) y = y + ldb(x,cl_byte(m1,i)); x = y; } while (x > R->modulus); @@ -49,7 +49,7 @@ static const _cl_MI pow2m1_canonhom (cl_heap_modint_ring* R, const cl_I& x) static const _cl_MI pow2m1_mul (cl_heap_modint_ring* _R, const _cl_MI& x, const _cl_MI& y) { var cl_heap_modint_ring_pow2m1* R = (cl_heap_modint_ring_pow2m1*)_R; - var const uintL m1 = R->m1; + var const uintC m1 = R->m1; var cl_I zr = x.rep * y.rep; zr = ldb(zr,cl_byte(m1,m1)) + ldb(zr,cl_byte(m1,0)); return _cl_MI(R, zr >= R->modulus ? zr - R->modulus : zr); @@ -58,7 +58,7 @@ static const _cl_MI pow2m1_mul (cl_heap_modint_ring* _R, const _cl_MI& x, const static const _cl_MI pow2m1_square (cl_heap_modint_ring* _R, const _cl_MI& x) { var cl_heap_modint_ring_pow2m1* R = (cl_heap_modint_ring_pow2m1*)_R; - var const uintL m1 = R->m1; + var const uintC m1 = R->m1; var cl_I zr = square(x.rep); zr = ldb(zr,cl_byte(m1,m1)) + ldb(zr,cl_byte(m1,0)); return _cl_MI(R, zr >= R->modulus ? zr - R->modulus : zr); @@ -89,7 +89,7 @@ cl_class cl_class_modint_ring_pow2m1 = { }; // Constructor. -inline cl_heap_modint_ring_pow2m1::cl_heap_modint_ring_pow2m1 (const cl_I& m, uintL _m1) +inline cl_heap_modint_ring_pow2m1::cl_heap_modint_ring_pow2m1 (const cl_I& m, uintC _m1) : cl_heap_modint_ring (m, &std_setops, &pow2m1_addops, &pow2m1_mulops), m1 (_m1) { type = &cl_class_modint_ring_pow2m1; diff --git a/src/modinteger/cl_MI_pow2p1.h b/src/modinteger/cl_MI_pow2p1.h index 06477c8..cd5a180 100644 --- a/src/modinteger/cl_MI_pow2p1.h +++ b/src/modinteger/cl_MI_pow2p1.h @@ -6,11 +6,11 @@ class cl_heap_modint_ring_pow2p1 : public cl_heap_modint_ring { SUBCLASS_cl_heap_modint_ring() public: // Constructor. - cl_heap_modint_ring_pow2p1 (const cl_I& m, uintL m1); // m = 2^m1 + 1 + cl_heap_modint_ring_pow2p1 (const cl_I& m, uintC m1); // m = 2^m1 + 1 // Destructor. ~cl_heap_modint_ring_pow2p1 () {} // Additional information. - uintL m1; + uintC m1; }; static inline const cl_I pow2p1_reduce_modulo (cl_heap_modint_ring* _R, const cl_I& x) @@ -24,11 +24,11 @@ static inline const cl_I pow2p1_reduce_modulo (cl_heap_modint_ring* _R, const cl { Mutable(cl_I,x); var bool sign = minusp(x); if (sign) { x = lognot(x); } - var const uintL m1 = R->m1; + var const uintC m1 = R->m1; while (x >= R->modulus) { - var uintL xlen = integer_length(x); + var uintC xlen = integer_length(x); var cl_I y = ldb(x,cl_byte(m1,0)); - for (var uintL i = m1; ; ) { + for (var uintC i = m1; ; ) { y = y - ldb(x,cl_byte(m1,i)); i += m1; if (i >= xlen) @@ -56,7 +56,7 @@ static const _cl_MI pow2p1_canonhom (cl_heap_modint_ring* R, const cl_I& x) static const _cl_MI pow2p1_mul (cl_heap_modint_ring* _R, const _cl_MI& x, const _cl_MI& y) { var cl_heap_modint_ring_pow2p1* R = (cl_heap_modint_ring_pow2p1*)_R; - var const uintL m1 = R->m1; + var const uintC m1 = R->m1; var cl_I zr = x.rep * y.rep; // Now 0 <= zr <= 2^(2*m1). zr = ldb(zr,cl_byte(1,2*m1)) - ldb(zr,cl_byte(m1,m1)) + ldb(zr,cl_byte(m1,0)); @@ -67,7 +67,7 @@ static const _cl_MI pow2p1_mul (cl_heap_modint_ring* _R, const _cl_MI& x, const static const _cl_MI pow2p1_square (cl_heap_modint_ring* _R, const _cl_MI& x) { var cl_heap_modint_ring_pow2p1* R = (cl_heap_modint_ring_pow2p1*)_R; - var const uintL m1 = R->m1; + var const uintC m1 = R->m1; var cl_I zr = square(x.rep); // Now 0 <= zr <= 2^(2*m1). zr = ldb(zr,cl_byte(1,2*m1)) - ldb(zr,cl_byte(m1,m1)) + ldb(zr,cl_byte(m1,0)); @@ -100,7 +100,7 @@ cl_class cl_class_modint_ring_pow2p1 = { }; // Constructor. -inline cl_heap_modint_ring_pow2p1::cl_heap_modint_ring_pow2p1 (const cl_I& m, uintL _m1) +inline cl_heap_modint_ring_pow2p1::cl_heap_modint_ring_pow2p1 (const cl_I& m, uintC _m1) : cl_heap_modint_ring (m, &std_setops, &pow2p1_addops, &pow2p1_mulops), m1 (_m1) { type = &cl_class_modint_ring_pow2p1; diff --git a/src/modinteger/cl_MI_rshift.cc b/src/modinteger/cl_MI_rshift.cc index ca975e3..957d170 100644 --- a/src/modinteger/cl_MI_rshift.cc +++ b/src/modinteger/cl_MI_rshift.cc @@ -15,7 +15,7 @@ namespace cln { -const cl_MI operator>> (const cl_MI& x, sintL y) // assume 0 <= y < 2^31 +const cl_MI operator>> (const cl_MI& x, sintC y) // assume 0 <= y < 2^(intCsize-1) { if (y == 0) return x; diff --git a/src/modinteger/cl_MI_std.h b/src/modinteger/cl_MI_std.h index 9ec9694..04fd37b 100644 --- a/src/modinteger/cl_MI_std.h +++ b/src/modinteger/cl_MI_std.h @@ -171,7 +171,7 @@ static const _cl_MI std_expt_pos (cl_heap_modint_ring* R, const _cl_MI& x, const // k = 3 for nn <= 69.8 // ... k for nn <= k*(k+1)*2^(2k)/(2^(k+1)-k-2) var cl_I n = y; - var uintL nn = integer_length(n); + var uintC nn = integer_length(n); // n has nn bits. if (nn <= 8) { // k = 1, normal Left-Right Binary algorithm. @@ -202,7 +202,7 @@ static const _cl_MI std_expt_pos (cl_heap_modint_ring* R, const _cl_MI& x, const else if (nn <= 1721160) k = 14; else if (nn <= 3933180) k = 15; else /* if (nn <= 8914120) */ k = 16; - var uintL nnk = ceiling(nn,k); // number of base-2^k digits in n + var uintC nnk = ceiling(nn,k); // number of base-2^k digits in n var uint16* n_digits = cl_alloc_array(uint16,nnk); // Split n into base-2^k digits. { @@ -212,7 +212,7 @@ static const _cl_MI std_expt_pos (cl_heap_modint_ring* R, const _cl_MI& x, const var const uintL k_mask = bit(k)-1; var uintD carry = 0; var unsigned int carrybits = 0; - for (var uintL i = 0; i < nnk; i++) { + for (var uintC i = 0; i < nnk; i++) { if (carrybits >= k) { n_digits[i] = carry & k_mask; carry = carry >> k; @@ -229,7 +229,7 @@ static const _cl_MI std_expt_pos (cl_heap_modint_ring* R, const _cl_MI& x, const // Compute maximum odd base-2^k digit. var uintL maxodd = 1; if (k <= 8) { - for (var uintL i = 0; i < nnk; i++) { + for (var uintC i = 0; i < nnk; i++) { var uintL d = n_digits[i]; if (d > 0) { d = odd_table[d]; @@ -237,7 +237,7 @@ static const _cl_MI std_expt_pos (cl_heap_modint_ring* R, const _cl_MI& x, const } } } else { - for (var uintL i = 0; i < nnk; i++) { + for (var uintC i = 0; i < nnk; i++) { var uintL d = n_digits[i]; if (d > 0) { var uintL d2; ord2_32(d,d2=); @@ -275,7 +275,7 @@ static const _cl_MI std_expt_pos (cl_heap_modint_ring* R, const _cl_MI& x, const for ( ; d2>0; d2--) a = R->_square(a); } - for (var sintL i = nnk-2; i >= 0; i--) { + for (var sintC i = nnk-2; i >= 0; i--) { // Compute a := a^(2^k) * x^n_digits[i]. var uintL d = n_digits[i]; var uintL d2; diff --git a/src/numtheory/cl_IF_millerrabin.cc b/src/numtheory/cl_IF_millerrabin.cc index b720419..cd8b773 100644 --- a/src/numtheory/cl_IF_millerrabin.cc +++ b/src/numtheory/cl_IF_millerrabin.cc @@ -18,7 +18,7 @@ cl_boolean cl_miller_rabin_test (const cl_I& n, int count, cl_I* factor) // [Cohen], section 8.2, algorithm 8.2.2. var cl_modint_ring R = find_modint_ring(n); // Z/nZ var cl_I m = n-1; - var uintL e = ord2(m); + var uintC e = ord2(m); m = m>>e; // n-1 = 2^e*m var cl_MI one = R->one(); @@ -37,7 +37,7 @@ cl_boolean cl_miller_rabin_test (const cl_I& n, int count, cl_I* factor) var cl_MI b = R->expt_pos(a,m); // b = a^m if (b == one) goto passed; - for (uintL s = e; s > 0; s--) { + for (uintC s = e; s > 0; s--) { if (b == minusone) goto passed; var cl_MI new_b = R->square(b); diff --git a/src/numtheory/cl_nt_isprobprime.cc b/src/numtheory/cl_nt_isprobprime.cc index 3b79d2f..a761cf9 100644 --- a/src/numtheory/cl_nt_isprobprime.cc +++ b/src/numtheory/cl_nt_isprobprime.cc @@ -23,7 +23,7 @@ cl_boolean isprobprime (const cl_I& n) var int count = 50; // Step 1: Trial division (rules out 87% of all numbers quickly). const uint32 trialdivide_limit = 70; - var uintL l = integer_length(n); + var uintC l = integer_length(n); if (l <= 32) { var uint32 nn = cl_I_to_UL(n); if (nn <= cl_small_prime_table_limit) { diff --git a/src/numtheory/cl_nt_sqrtmodp.cc b/src/numtheory/cl_nt_sqrtmodp.cc index 8208b6d..3b95574 100644 --- a/src/numtheory/cl_nt_sqrtmodp.cc +++ b/src/numtheory/cl_nt_sqrtmodp.cc @@ -209,11 +209,11 @@ static const sqrt_mod_p_t tonelli_shanks_sqrt (const cl_modint_ring& R, const cl // take h in G_(j+1) \ G_j, so that h^2 in G_j \ G_(j-1), and // a^-1*b^2*h^2 is in G_(j-1). So multiply b with h. var cl_I& p = R->modulus; - var uintL e = ord2(p-1); + var uintC e = ord2(p-1); var cl_I m = (p-1) >> e; // p-1 = 2^e*m, m odd. // We will have the invariant c = a^-1*b^2 in G/G_j. - var uintL j = e; + var uintC j = e; // Initialize b = a^((m+1)/2), c = a^m, but avoid to divide by a. var cl_MI c = R->expt_pos(a,(m-1)>>1); var cl_MI b = R->mul(a,c); @@ -248,7 +248,7 @@ static const sqrt_mod_p_t tonelli_shanks_sqrt (const cl_modint_ring& R, const cl do { // Now c = a^-1*b^2 in G_j, h in G_j \ G_(j-1). // Determine the smallest i such that c in G_i. - var uintL i = 0; + var uintC i = 0; var cl_MI ci = c; // c_i = c^(2^i) for ( ; i < j; i++, ci = R->square(ci)) if (ci == R->one()) @@ -259,7 +259,7 @@ static const sqrt_mod_p_t tonelli_shanks_sqrt (const cl_modint_ring& R, const cl // Indicates that p is not prime. return new cl_composite_condition(p); // OK, i < j. - for (var uintL count = j-i-1; count > 0; count--) + for (var uintC count = j-i-1; count > 0; count--) h = R->square(h); // Now h in G_(i+1) \ G_i. b = R->mul(b,h); @@ -312,8 +312,8 @@ const sqrt_mod_p_t sqrt_mod_p (const cl_modint_ring& R, const cl_MI& a) else return sqrt_mod_p_t(2,R->canonhom(x1),R->canonhom(x2)); } - var uintL l = integer_length(p); - var uintL e = ord2(p-1); + var uintC l = integer_length(p); + var uintC e = ord2(p-1); //if (e > 30 && e > l/(::log((double)l)*0.72-1)) if (e > 30 && e > l/(::log((double)l)*0.92-2.41)) // Algorithm 2. diff --git a/src/polynomial/elem/cl_UP_GF2.h b/src/polynomial/elem/cl_UP_GF2.h index 2011b34..fa2c5b1 100644 --- a/src/polynomial/elem/cl_UP_GF2.h +++ b/src/polynomial/elem/cl_UP_GF2.h @@ -992,7 +992,7 @@ static const cl_ring_element gf2_eval (cl_heap_univpoly_ring* UPR, const _cl_UP& return cl_MI(R, x[0]); else { var uintL count = ceiling(len,intDsize); - var uintL bitcount = 0; + var uintC bitcount = 0; do { count--; bitcount += logcountD(xv->data[count]); diff --git a/src/real/conv/cl_F_from_R_f.cc b/src/real/conv/cl_F_from_R_f.cc index a88e05e..4be26ea 100644 --- a/src/real/conv/cl_F_from_R_f.cc +++ b/src/real/conv/cl_F_from_R_f.cc @@ -17,7 +17,7 @@ namespace cln { const cl_F cl_float (const cl_R& x, float_format_t f) { - floatformatcase((uintL)f + floatformatcase((uintC)f , return cl_R_to_SF(x); , return cl_R_to_FF(x); , return cl_R_to_DF(x); diff --git a/src/real/format-output/cl_fmt_floatstring.cc b/src/real/format-output/cl_fmt_floatstring.cc index fc98ae8..caabb20 100644 --- a/src/real/format-output/cl_fmt_floatstring.cc +++ b/src/real/format-output/cl_fmt_floatstring.cc @@ -65,7 +65,7 @@ const digits_with_dot format_float_to_string (const cl_F& arg, const sintL width var cl_idecoded_float decoded = integer_decode_float(arg); var const cl_I& significand = decoded.mantissa; var const cl_I& expon = decoded.exponent; - var uintL mantprec = float_digits(arg)-1; + var uintC mantprec = float_digits(arg)-1; var cl_I numerator = significand; var cl_I denominator = 1; var cl_I abrund_einh = 1; // Abrundungseinheit: diff --git a/src/real/input/cl_R_read.cc b/src/real/input/cl_R_read.cc index b9c3dda..d31cf69 100644 --- a/src/real/input/cl_R_read.cc +++ b/src/real/input/cl_R_read.cc @@ -220,9 +220,9 @@ not_rational_syntax: ptr_after_prec = skip_digits(ptr,string_limit,10); if (ptr_after_prec == ptr) goto not_float_syntax; var cl_I prec1 = digits_to_I(ptr,ptr_after_prec-ptr,10); - var uintL prec2 = cl_I_to_UL(prec1); + var uintC prec2 = cl_I_to_ulong(prec1); prec = (float_base==10 ? float_format(prec2) - : (float_format_t)((uintL)((1+prec2)*::log((double)float_base)*1.442695041)+1) + : (float_format_t)((uintC)((1+prec2)*::log((double)float_base)*1.442695041)+1) ); } else { switch (exponent_marker) { @@ -237,14 +237,14 @@ not_rational_syntax: // Count the number of significant digits. ptr = ptr_after_sign; while (ptr < ptr_after_fracpart && (*ptr == '0' || *ptr == '.')) ptr++; - var uintL num_significant_digits = + var uintC num_significant_digits = (ptr_after_fracpart - ptr) - (ptr_before_fracpart > ptr ? 1 : 0); - var uintL prec2 = (num_significant_digits>=2 ? num_significant_digits-2 : 0); + var uintC prec2 = (num_significant_digits>=2 ? num_significant_digits-2 : 0); var float_format_t precx = (float_base==10 ? float_format(prec2) - : (float_format_t)((uintL)((1+prec2)*::log((double)float_base)*1.442695041)+1) + : (float_format_t)((uintC)((1+prec2)*::log((double)float_base)*1.442695041)+1) ); - if ((uintL)precx > (uintL)prec) + if ((uintC)precx > (uintC)prec) prec = precx; } } diff --git a/src/vector/cl_GV_I.cc b/src/vector/cl_GV_I.cc index 7fdcd81..1471cef 100644 --- a/src/vector/cl_GV_I.cc +++ b/src/vector/cl_GV_I.cc @@ -56,7 +56,7 @@ static inline const cl_heap_GV_I * outcast (const cl_GV_inner* vec) struct cl_GV_I_vectorops { cl_GV_vectorops ops; - sintL m; // for maxbits + sintC m; // for maxbits }; static inline cl_GV_I_vectorops* outcast (cl_GV_vectorops* vectorops) @@ -77,12 +77,12 @@ struct cl_heap_GV_I_general : public cl_heap_GV_I { cl_heap_GV_I_general (); }; -static const cl_I general_element (const cl_GV_inner* vec, uintL index) +static const cl_I general_element (const cl_GV_inner* vec, uintC index) { return ((const cl_heap_GV_I_general *) outcast(vec))->data[index]; } -static void general_set_element (cl_GV_inner* vec, uintL index, const cl_I& x) +static void general_set_element (cl_GV_inner* vec, uintC index, const cl_I& x) { ((cl_heap_GV_I_general *) outcast(vec))->data[index] = x; } @@ -90,20 +90,20 @@ static void general_set_element (cl_GV_inner* vec, uintL index, const cl_I static void general_do_delete (cl_GV_inner* vec) { var cl_heap_GV_I_general* hv = (cl_heap_GV_I_general *) outcast(vec); - var uintL len = hv->v.length(); - for (var uintL i = 0; i < len; i++) + var uintC len = hv->v.length(); + for (var uintC i = 0; i < len; i++) hv->data[i].~cl_I(); } -static void general_copy_elements (const cl_GV_inner* srcvec, uintL srcindex, cl_GV_inner* destvec, uintL destindex, uintL count) +static void general_copy_elements (const cl_GV_inner* srcvec, uintC srcindex, cl_GV_inner* destvec, uintC destindex, uintC count) { if (count > 0) { var const cl_heap_GV_I_general* srcv = (const cl_heap_GV_I_general *) outcast(srcvec); var cl_heap_GV_I_general* destv = (cl_heap_GV_I_general *) outcast(destvec); - var uintL srclen = srcv->v.length(); - var uintL destlen = destv->v.length(); + var uintC srclen = srcv->v.length(); + var uintC destlen = destv->v.length(); if (!(srcindex <= srcindex+count && srcindex+count <= srclen)) cl_abort(); if (!(destindex <= destindex+count && destindex+count <= destlen)) @@ -122,13 +122,13 @@ static cl_GV_I_vectorops general_vectorops = {{ -1 }; -cl_heap_GV_I* cl_make_heap_GV_I (uintL len) +cl_heap_GV_I* cl_make_heap_GV_I (uintC len) { var cl_heap_GV_I_general* hv = (cl_heap_GV_I_general*) malloc_hook(offsetofa(cl_heap_GV_I_general,data)+sizeof(cl_I)*len); hv->refcount = 1; hv->type = &cl_class_gvector_integer; new (&hv->v) cl_GV_inner (len,&general_vectorops.ops); - for (var uintL i = 0; i < len; i++) + for (var uintC i = 0; i < len; i++) init1(cl_I, hv->data[i]) (); return hv; } @@ -146,17 +146,17 @@ struct cl_heap_GV_I_bits##m : public cl_heap_GV_I { \ /* No default constructor. */ \ cl_heap_GV_I_bits##m (); \ }; \ -static const cl_I bits##m##_element (const cl_GV_inner* vec, uintL index); \ -static void bits##m##_set_element (cl_GV_inner* vec, uintL index, const cl_I& x); \ -static void bits##m##_copy_elements (const cl_GV_inner* srcvec, uintL srcindex, cl_GV_inner* destvec, uintL destindex, uintL count) \ +static const cl_I bits##m##_element (const cl_GV_inner* vec, uintC index); \ +static void bits##m##_set_element (cl_GV_inner* vec, uintC index, const cl_I& x); \ +static void bits##m##_copy_elements (const cl_GV_inner* srcvec, uintC srcindex, cl_GV_inner* destvec, uintC destindex, uintC count) \ { \ if (count > 0) { \ var const cl_heap_GV_I_bits##m * srcv = \ (const cl_heap_GV_I_bits##m *) outcast(srcvec); \ var cl_heap_GV_I_bits##m * destv = \ (cl_heap_GV_I_bits##m *) outcast(destvec); \ - var uintL srclen = srcv->v.length(); \ - var uintL destlen = destv->v.length(); \ + var uintC srclen = srcv->v.length(); \ + var uintC destlen = destv->v.length(); \ if (!(srcindex <= srcindex+count && srcindex+count <= srclen)) \ cl_abort(); \ if (!(destindex <= destindex+count && destindex+count <= destlen)) \ @@ -186,7 +186,7 @@ static void bits_do_delete (cl_GV_inner* vec) // Copy bits srcptr.bits[srcindex..srcindex+count-1] into destptr.bits[destindex..destindex+count-1]. // Assumes that all range checks have already been performed. -static void bits_copy (const uintD* srcptr, uintL srcindex, uintD* destptr, uintL destindex, uintL count) +static void bits_copy (const uintD* srcptr, uintC srcindex, uintD* destptr, uintC destindex, uintC count) { srcptr += floor(srcindex,intDsize); destptr += floor(destindex,intDsize); @@ -206,7 +206,7 @@ static void bits_copy (const uintD* srcptr, uintL srcindex, uintD* destptr, uint count -= intDsize-srcindex; } // Now srcindex and destindex can be assumed to be 0. - var uintL count1 = count%intDsize; + var uintC count1 = count%intDsize; count = floor(count,intDsize); if (count > 0) { do { @@ -217,7 +217,7 @@ static void bits_copy (const uintD* srcptr, uintL srcindex, uintD* destptr, uint *destptr ^= (*destptr ^ *srcptr) & (uintD)(bit(count1)-1); } } else { - var uintL i = destindex - srcindex; + var uintC i = destindex - srcindex; var uintD tmp; if (destindex >= srcindex) { // i > 0 if (count <= intDsize-destindex) { @@ -239,7 +239,7 @@ static void bits_copy (const uintD* srcptr, uintL srcindex, uintD* destptr, uint } srcptr++; // tmp now contains the low i bits to be put into *destptr. - var uintL count1 = count%intDsize; + var uintC count1 = count%intDsize; count = floor(count,intDsize); var uintD lastdest; if (count == 0) @@ -277,11 +277,11 @@ static void bits_copy (const uintD* srcptr, uintL srcindex, uintD* destptr, uint DEFINE_cl_heap_GV_I_bits(1,uintD) -static const cl_I bits1_element (const cl_GV_inner* vec, uintL index) +static const cl_I bits1_element (const cl_GV_inner* vec, uintC index) { return (unsigned int)((((const cl_heap_GV_I_bits1 *) outcast(vec))->data[index/intDsize] >> (index%intDsize)) & 0x1); } -static void bits1_set_element (cl_GV_inner* vec, uintL index, const cl_I& x) +static void bits1_set_element (cl_GV_inner* vec, uintC index, const cl_I& x) { var uintV xval; if (fixnump(x)) { @@ -299,11 +299,11 @@ static void bits1_set_element (cl_GV_inner* vec, uintL index, const cl_I& DEFINE_cl_heap_GV_I_bits(2,uintD) -static const cl_I bits2_element (const cl_GV_inner* vec, uintL index) +static const cl_I bits2_element (const cl_GV_inner* vec, uintC index) { return (unsigned int)((((const cl_heap_GV_I_bits2 *) outcast(vec))->data[index/(intDsize/2)] >> (2*(index%(intDsize/2)))) & 0x3); } -static void bits2_set_element (cl_GV_inner* vec, uintL index, const cl_I& x) +static void bits2_set_element (cl_GV_inner* vec, uintC index, const cl_I& x) { var uintV xval; if (fixnump(x)) { @@ -321,11 +321,11 @@ static void bits2_set_element (cl_GV_inner* vec, uintL index, const cl_I& DEFINE_cl_heap_GV_I_bits(4,uintD) -static const cl_I bits4_element (const cl_GV_inner* vec, uintL index) +static const cl_I bits4_element (const cl_GV_inner* vec, uintC index) { return (unsigned int)((((const cl_heap_GV_I_bits4 *) outcast(vec))->data[index/(intDsize/4)] >> (4*(index%(intDsize/4)))) & 0xF); } -static void bits4_set_element (cl_GV_inner* vec, uintL index, const cl_I& x) +static void bits4_set_element (cl_GV_inner* vec, uintC index, const cl_I& x) { var uintV xval; if (fixnump(x)) { @@ -343,7 +343,7 @@ static void bits4_set_element (cl_GV_inner* vec, uintL index, const cl_I& DEFINE_cl_heap_GV_I_bits(8,uintD) -static const cl_I bits8_element (const cl_GV_inner* vec, uintL index) +static const cl_I bits8_element (const cl_GV_inner* vec, uintC index) { #if CL_CPU_BIG_ENDIAN_P return (unsigned int)((((const cl_heap_GV_I_bits8 *) outcast(vec))->data[index/(intDsize/8)] >> (8*(index%(intDsize/8)))) & 0xFF); @@ -352,7 +352,7 @@ static const cl_I bits8_element (const cl_GV_inner* vec, uintL index) return (unsigned int)(((uint8*)(((const cl_heap_GV_I_bits8 *) outcast(vec))->data))[index]); #endif } -static void bits8_set_element (cl_GV_inner* vec, uintL index, const cl_I& x) +static void bits8_set_element (cl_GV_inner* vec, uintC index, const cl_I& x) { var uintV xval; if (fixnump(x)) { @@ -375,7 +375,7 @@ static void bits8_set_element (cl_GV_inner* vec, uintL index, const cl_I& DEFINE_cl_heap_GV_I_bits(16,uintD) -static const cl_I bits16_element (const cl_GV_inner* vec, uintL index) +static const cl_I bits16_element (const cl_GV_inner* vec, uintC index) { #if CL_CPU_BIG_ENDIAN_P return (unsigned int)((((const cl_heap_GV_I_bits16 *) outcast(vec))->data[index/(intDsize/16)] >> (16*(index%(intDsize/16)))) & 0xFFFF); @@ -384,7 +384,7 @@ static const cl_I bits16_element (const cl_GV_inner* vec, uintL index) return (unsigned int)(((uint16*)(((const cl_heap_GV_I_bits16 *) outcast(vec))->data))[index]); #endif } -static void bits16_set_element (cl_GV_inner* vec, uintL index, const cl_I& x) +static void bits16_set_element (cl_GV_inner* vec, uintC index, const cl_I& x) { var uintV xval; if (fixnump(x)) { @@ -407,7 +407,7 @@ static void bits16_set_element (cl_GV_inner* vec, uintL index, const cl_I& DEFINE_cl_heap_GV_I_bits(32,uintD) -static const cl_I bits32_element (const cl_GV_inner* vec, uintL index) +static const cl_I bits32_element (const cl_GV_inner* vec, uintC index) { #if (intDsize==32) return (unsigned long)(((const cl_heap_GV_I_bits32 *) outcast(vec))->data[index]); @@ -418,7 +418,7 @@ static const cl_I bits32_element (const cl_GV_inner* vec, uintL index) return (unsigned long)(((uint32*)(((const cl_heap_GV_I_bits32 *) outcast(vec))->data))[index]); #endif } -static void bits32_set_element (cl_GV_inner* vec, uintL index, const cl_I& x) +static void bits32_set_element (cl_GV_inner* vec, uintC index, const cl_I& x) { var uint32 xval = cl_I_to_UL(x); #if (intDsize==32) @@ -443,7 +443,7 @@ static cl_GV_I_vectorops* bits_vectorops[6] = { &bits32_vectorops }; -cl_heap_GV_I* cl_make_heap_GV_I (uintL len, sintL m) +cl_heap_GV_I* cl_make_heap_GV_I (uintC len, sintC m) { // Determine log2(bits). var uintL log2_bits; @@ -468,27 +468,27 @@ cl_heap_GV_I* cl_make_heap_GV_I (uintL len, sintL m) return cl_make_heap_GV_I(len); } // For room allocation purposes, be pessimistic: assume the uintD case (since intDsize>=32). - var uintL words = // ceiling(len*2^log2_bits,intDsize) - (((sintL)len-1)>>(log2_intDsize-log2_bits))+1; + var uintC words = // ceiling(len*2^log2_bits,intDsize) + (((sintC)len-1)>>(log2_intDsize-log2_bits))+1; var cl_heap_GV_I_bits32* hv = (cl_heap_GV_I_bits32*) malloc_hook(offsetofa(cl_heap_GV_I_bits32,data)+sizeof(uintD)*words); hv->refcount = 1; hv->type = &cl_class_gvector_integer; new (&hv->v) cl_GV_inner (len,&bits_vectorops[log2_bits]->ops); var uintD* ptr = (uintD*)(hv->data); - for (var uintL i = 0; i < words; i++) + for (var uintC i = 0; i < words; i++) ptr[i] = 0; return (cl_heap_GV_I*) hv; } -sintL cl_heap_GV_I::maxbits () const +sintC cl_heap_GV_I::maxbits () const { return outcast(v.vectorops)->m; } // An empty vector. -const cl_GV_I cl_null_GV_I = cl_GV_I((uintL)0); +const cl_GV_I cl_null_GV_I = cl_GV_I((uintC)0); } // namespace cln diff --git a/src/vector/cl_GV_I_copy.cc b/src/vector/cl_GV_I_copy.cc index 2cbc88f..8a0533b 100644 --- a/src/vector/cl_GV_I_copy.cc +++ b/src/vector/cl_GV_I_copy.cc @@ -14,7 +14,7 @@ namespace cln { const cl_GV_I copy (const cl_GV_I& v) { - var uintL len = v.length(); + var uintC len = v.length(); var cl_GV_I w = cl_GV_I(len,v.maxbits()); cl_GV_I::copy_elements(v,0,w,0,len); return w; diff --git a/src/vector/cl_GV_number.cc b/src/vector/cl_GV_number.cc index 4b019ee..20af58a 100644 --- a/src/vector/cl_GV_number.cc +++ b/src/vector/cl_GV_number.cc @@ -53,12 +53,12 @@ struct cl_heap_GV_number_general : public cl_heap_GV_number { cl_heap_GV_number_general (); }; -static const cl_number general_element (const cl_GV_inner* vec, uintL index) +static const cl_number general_element (const cl_GV_inner* vec, uintC index) { return ((const cl_heap_GV_number_general *) outcast(vec))->data[index]; } -static void general_set_element (cl_GV_inner* vec, uintL index, const cl_number& x) +static void general_set_element (cl_GV_inner* vec, uintC index, const cl_number& x) { ((cl_heap_GV_number_general *) outcast(vec))->data[index] = x; } @@ -66,20 +66,20 @@ static void general_set_element (cl_GV_inner* vec, uintL index, const static void general_do_delete (cl_GV_inner* vec) { var cl_heap_GV_number_general* hv = (cl_heap_GV_number_general *) outcast(vec); - var uintL len = hv->v.length(); - for (var uintL i = 0; i < len; i++) + var uintC len = hv->v.length(); + for (var uintC i = 0; i < len; i++) hv->data[i].~cl_number(); } -static void general_copy_elements (const cl_GV_inner* srcvec, uintL srcindex, cl_GV_inner* destvec, uintL destindex, uintL count) +static void general_copy_elements (const cl_GV_inner* srcvec, uintC srcindex, cl_GV_inner* destvec, uintC destindex, uintC count) { if (count > 0) { var const cl_heap_GV_number_general* srcv = (const cl_heap_GV_number_general *) outcast(srcvec); var cl_heap_GV_number_general* destv = (cl_heap_GV_number_general *) outcast(destvec); - var uintL srclen = srcv->v.length(); - var uintL destlen = destv->v.length(); + var uintC srclen = srcv->v.length(); + var uintC destlen = destv->v.length(); if (!(srcindex <= srcindex+count && srcindex+count <= srclen)) cl_abort(); if (!(destindex <= destindex+count && destindex+count <= destlen)) @@ -97,19 +97,19 @@ static cl_GV_vectorops general_vectorops = { general_copy_elements }; -cl_heap_GV_number* cl_make_heap_GV_number (uintL len) +cl_heap_GV_number* cl_make_heap_GV_number (uintC len) { var cl_heap_GV_number_general* hv = (cl_heap_GV_number_general*) malloc_hook(offsetofa(cl_heap_GV_number_general,data)+sizeof(cl_number)*len); hv->refcount = 1; hv->type = &cl_class_gvector_number; new (&hv->v) cl_GV_inner (len,&general_vectorops); - for (var uintL i = 0; i < len; i++) + for (var uintC i = 0; i < len; i++) init1(cl_number, hv->data[i]) (); return hv; } // An empty vector. -const cl_GV_number cl_null_GV_number = cl_GV_number((uintL)0); +const cl_GV_number cl_null_GV_number = cl_GV_number((uintC)0); } // namespace cln diff --git a/src/vector/cl_GV_number_copy.cc b/src/vector/cl_GV_number_copy.cc index 9622f19..3164f2a 100644 --- a/src/vector/cl_GV_number_copy.cc +++ b/src/vector/cl_GV_number_copy.cc @@ -14,7 +14,7 @@ namespace cln { const cl_GV_number copy (const cl_GV_number& v) { - var uintL len = v.length(); + var uintC len = v.length(); var cl_GV_number w = cl_GV_number(len); cl_GV_number::copy_elements(v,0,w,0,len); return w; diff --git a/src/vector/cl_SV_copy.cc b/src/vector/cl_SV_copy.cc index 9277c29..45690fa 100644 --- a/src/vector/cl_SV_copy.cc +++ b/src/vector/cl_SV_copy.cc @@ -16,12 +16,12 @@ namespace cln { const cl_SV_any copy (const cl_SV_any& src) { - var uintL len = src.length(); + var uintC len = src.length(); var cl_heap_SV_any* hv = (cl_heap_SV_any*) malloc_hook(sizeof(cl_heap_SV_any)+sizeof(cl_gcobject)*len); hv->refcount = 1; hv->type = src.pointer_type(); new (&hv->v) cl_SV_inner (len); - for (var uintL i = 0; i < len; i++) + for (var uintC i = 0; i < len; i++) init1(cl_gcobject, hv->v[i]) (src[i]); return hv; } diff --git a/src/vector/cl_SV_number.cc b/src/vector/cl_SV_number.cc index d694ab4..80b5a5d 100644 --- a/src/vector/cl_SV_number.cc +++ b/src/vector/cl_SV_number.cc @@ -29,7 +29,7 @@ cl_class cl_class_svector_number = { 0 }; -cl_heap_SV_number* cl_make_heap_SV_number_uninit (uintL len) +cl_heap_SV_number* cl_make_heap_SV_number_uninit (uintC len) { var cl_heap_SV_number* hv = (cl_heap_SV_number*) malloc_hook(sizeof(cl_heap_SV_number)+sizeof(cl_number)*len); hv->refcount = 1; @@ -39,19 +39,19 @@ cl_heap_SV_number* cl_make_heap_SV_number_uninit (uintL len) return hv; } -cl_heap_SV_number* cl_make_heap_SV_number (uintL len) +cl_heap_SV_number* cl_make_heap_SV_number (uintC len) { var cl_heap_SV_number* hv = (cl_heap_SV_number*) malloc_hook(sizeof(cl_heap_SV_number)+sizeof(cl_number)*len); hv->refcount = 1; hv->type = &cl_class_svector_number; new (&hv->v) cl_SV_inner (len); - for (var uintL i = 0; i < len; i++) + for (var uintC i = 0; i < len; i++) init1(cl_number, hv->v[i]) (0); return hv; } // An empty vector. -const cl_SV_number cl_null_SV_number = cl_SV_number((uintL)0); +const cl_SV_number cl_null_SV_number = cl_SV_number((uintC)0); } // namespace cln diff --git a/src/vector/cl_SV_ringelt.cc b/src/vector/cl_SV_ringelt.cc index 4071daa..48587ae 100644 --- a/src/vector/cl_SV_ringelt.cc +++ b/src/vector/cl_SV_ringelt.cc @@ -29,7 +29,7 @@ cl_class cl_class_svector_ringelt = { 0 }; -cl_heap_SV_ringelt* cl_make_heap_SV_ringelt_uninit (uintL len) +cl_heap_SV_ringelt* cl_make_heap_SV_ringelt_uninit (uintC len) { var cl_heap_SV_ringelt* hv = (cl_heap_SV_ringelt*) malloc_hook(sizeof(cl_heap_SV_ringelt)+sizeof(_cl_ring_element)*len); hv->refcount = 1; @@ -39,19 +39,19 @@ cl_heap_SV_ringelt* cl_make_heap_SV_ringelt_uninit (uintL len) return hv; } -cl_heap_SV_ringelt* cl_make_heap_SV_ringelt (uintL len) +cl_heap_SV_ringelt* cl_make_heap_SV_ringelt (uintC len) { var cl_heap_SV_ringelt* hv = (cl_heap_SV_ringelt*) malloc_hook(sizeof(cl_heap_SV_ringelt)+sizeof(_cl_ring_element)*len); hv->refcount = 1; hv->type = &cl_class_svector_ringelt; new (&hv->v) cl_SV_inner<_cl_ring_element> (len); - for (var uintL i = 0; i < len; i++) + for (var uintC i = 0; i < len; i++) init1(_cl_ring_element, hv->v[i]) (); return hv; } // An empty vector. -const cl_SV_ringelt cl_null_SV_ringelt = cl_SV_ringelt((uintL)0); +const cl_SV_ringelt cl_null_SV_ringelt = cl_SV_ringelt((uintC)0); } // namespace cln diff --git a/tests/main.cc b/tests/main.cc index e928abf..136eb56 100644 --- a/tests/main.cc +++ b/tests/main.cc @@ -82,7 +82,7 @@ int main (int argc, char* argv[]) #if 0 float_format_t f = float_format(atoi(argv[1])); extern cl_LF zeta3 (uintC len); - uintC len = (uintL)f/intDsize+1; + uintC len = (uintC)f/intDsize+1; { CL_TIMING; cout << zeta(2,f) << endl; } { CL_TIMING; cout << expt(pi(f),2)/6 << endl; } { CL_TIMING; cout << zeta(3,f) << endl; } diff --git a/tests/test_I_ilength.cc b/tests/test_I_ilength.cc index 9a45a4d..600b4b5 100644 --- a/tests/test_I_ilength.cc +++ b/tests/test_I_ilength.cc @@ -7,7 +7,7 @@ int test_I_integer_length (int iterations) // Check against ash. for (i = iterations; i > 0; i--) { cl_I a = testrandom_I(); - uintL l = integer_length(a); + uintC l = integer_length(a); if (a >= 0) { int b = 0; if (a < ash(1,l)) { diff --git a/tests/test_I_ord2.cc b/tests/test_I_ord2.cc index b4c1bd4..36fd58c 100644 --- a/tests/test_I_ord2.cc +++ b/tests/test_I_ord2.cc @@ -8,10 +8,10 @@ int test_I_ord2 (int iterations) for (i = iterations; i > 0; i--) { cl_I a = testrandom_I(); if (a != 0) { - uintL n = ord2(a); - cl_I b = ash(a,-(sintL)n); + uintC n = ord2(a); + cl_I b = ash(a,-(sintC)n); ASSERT1(oddp(b), a); - ASSERT1(a == ash(b,(sintL)n), a); + ASSERT1(a == ash(b,(sintC)n), a); } } return error; -- 2.49.0