Remove exception hooks in favor of real C++ exceptions:
* include/cln/exception.h: New file...
* include/cln/cln.h: ...included here...
* include/cln/rational.h: ...and here.
* include/cln/abort.h: Removed.
* include/cln/integer.h (ash_exception, exquo_exception): Add exception
types.
* include/cln/float.h (floating_point_exception,
floating_point_nan_exception, floating_point_overflow_exception,
floating_point_underflow_exception): Likewise.
* include/cln/number_io.h (read_number_exception,
read_number_bad_syntax_exception, read_number_junk_exception,
read_number_eof_exception): Likewise.
* include/cln/object.h (CL_DEFINE_CONVERTER): Replace dynamic assertion
with a compile-time assertion.
* include/cln/GV.h: Replace nonreturning functions with exceptions.
* include/cln/modinteger.h: Likewise.
* include/cln/SV.h: Likewise.
* include/cln/ring.h: Likewise.
* include/cln/string.h: Likewise.
* include/cln/univpoly.h: Likewise.
* src/base/cl_abort.cc: Removed.
* src/base/cl_N_err_d0.cc: Removed.
* src/base/cl_d0_exception.cc: New file.
* src/base/cl_as_err.cc: Removed.
* src/base/cl_as_exception.cc: New file.
* src/base/cl_notreached.cc: Removed.
* src/base/cl_notreached_exception.cc: New file.
* src/base/input/cl_read_err_bad.cc: Removed.
* src/base/input/cl_read_bad_syntax_exception.cc: New file.
* src/base/input/cl_read_err_junk.cc: Removed.
* src/base/input/cl_read_junk_exception.cc: New file.
* src/base/input/cl_read_err_eof.cc: Removed.
* src/base/input/cl_read_eof_exception.cc: New file.
* src/base/cl_N.h (cl_as_error): Removed (see cln/exception.h).
* src/base/macros.h (NOTREACHED): Throw.
* src/base/cl_malloc.cc (xmalloc): Throw.
* src/base/digitseq/cl_2DS_div.cc: Throw.
* src/base/digitseq/cl_DS_div.cc: Throw.
* src/base/digitseq/cl_DS_mul.cc: Throw.
* src/base/digitseq/cl_DS_mul_fftc.h: Throw.
* src/base/digitseq/cl_DS_mul_fftcs.h: Throw.
* src/base/digitseq/cl_DS_mul_fftm.h: Throw.
* src/base/digitseq/cl_DS_mul_fftp.h: Throw.
* src/base/digitseq/cl_DS_mul_fftp3.h: Throw.
* src/base/digitseq/cl_DS_mul_fftp3m.h: Throw.
* src/base/digitseq/cl_DS_mul_fftr.h: Throw.
* src/base/digitseq/cl_DS_mul_nuss.h: Throw.
* src/base/digitseq/cl_DS_recipsqrt.cc: Throw.
* src/base/digitseq/cl_DS_sqrt.cc: Throw.
* src/base/hash/cl_hash.h: Throw.
* src/base/hash/cl_hash1.h: Throw.
* src/base/hash/cl_hash1weak.h: Throw.
* src/base/hash/cl_hash2.h: Throw.
* src/base/hash/cl_hash2weak.h: Throw.
* src/base/hash/cl_hashset.h: Throw.
* src/base/hash/cl_hashuniq.h: Throw.
* src/base/hash/cl_hashuniqweak.h: Throw.
* src/base/proplist/cl_pl_add.cc: Throw.
* src/base/ring/cl_no_ring.cc: Throw.
* src/base/string/cl_spushstring.h: Throw.
* src/base/symbol/cl_symbol.cc: Throw.
* src/integer/bitwise/cl_I_ash.h: Removed (see cln/integer.h.)
* src/integer/bitwise/cl_I_asherr.cc: Removed.
* src/integer/bitwise/cl_I_ash_exception.cc: New file.
* src/integer/division/cl_I_exquoerr.cc: Removed.
* src/integer/division/cl_I_exquo_exception.cc: New file.
* src/integer/cl_I.h: Throw.
* src/integer/division/cl_I_exquopos.cc: Throw.
* src/integer/bitwise/cl_I_logbitp_I.cc: Throw.
* src/integer/bitwise/cl_I_ash.cc: Throw.
* src/integer/bitwise/cl_I_ash_I.cc: Throw.
* src/integer/division/cl_I_exquo.cc: Throw.
* src/integer/gcd/cl_I_gcd_aux2.cc: Throw.
* src/integer/conv/cl_I_to_L.cc: Throw.
* src/integer/conv/cl_I_to_Q.cc: Throw.
* src/integer/conv/cl_I_to_UL.cc: Throw.
* src/integer/conv/cl_I_to_UQ.cc: Throw.
* src/integer/conv/cl_I_to_digits.cc: Throw.
* src/integer/elem/cl_I_div.cc: Throw.
* src/integer/algebraic/cl_I_sqrt.cc: Throw.
* src/integer/input/cl_I_read.cc: Throw.
* src/integer/input/cl_I_read_stream.cc: Throw.
* src/integer/misc/cl_I_as.cc: Throw.
* src/rational/elem/cl_RA_from_I_I_div.cc: Throw.
* src/rational/elem/cl_RA_recip.cc: Throw.
* src/rational/input/cl_RA_read.cc: Throw.
* src/rational/input/cl_RA_read_stream.cc: Throw.
* src/rational/input/cl_RA_readparsed.cc: Throw.
* src/rational/misc/cl_RA_as.cc: Throw.
* src/float/base/cl_F_err_nan.cc: Removed.
* src/float/base/cl_F_nan_exception.cc: New file.
* src/float/base/cl_F_err_un.cc: Removed.
* src/float/base/cl_F_underflow_exception.cc: New file.
* src/float/base/cl_F_err_ov.cc: Removed.
* src/float/base/cl_F_overflow_exception.cc: New file.
* src/float/cl_F.h (cl_error_floating_point_nan,
cl_error_floating_point_overflow, cl_error_floating_point_underflow):
Removed (see cln/float.h.)
* src/float/sfloat/cl_SF.h: Throw.
* src/float/sfloat/elem/cl_SF_div.cc: Throw.
* src/float/sfloat/elem/cl_SF_from_RA.cc: Throw.
* src/float/sfloat/elem/cl_SF_scale.cc: Throw.
* src/float/sfloat/elem/cl_SF_scale_I.cc: Throw.
* src/float/sfloat/misc/cl_SF_as.cc: Throw.
* src/float/ffloat/cl_FF.h: Throw.
* src/float/ffloat/conv/cl_FF_from_float.cc: Throw.
* src/float/ffloat/elem/cl_FF_div.cc: Throw.
* src/float/ffloat/elem/cl_FF_from_RA.cc: Throw.
* src/float/ffloat/elem/cl_FF_scale.cc: Throw.
* src/float/ffloat/elem/cl_FF_scale_I.cc: Throw.
* src/float/ffloat/misc/cl_FF_as.cc: Throw.
* src/float/dfloat/cl_DF.h: Throw.
* src/float/dfloat/conv/cl_DF_from_double.cc: Throw.
* src/float/dfloat/elem/cl_DF_div.cc: Throw.
* src/float/dfloat/elem/cl_DF_from_RA.cc: Throw.
* src/float/dfloat/elem/cl_DF_scale.cc: Throw.
* src/float/dfloat/elem/cl_DF_scale_I.cc: Throw.
* src/float/dfloat/misc/cl_DF_as.cc: Throw.
* src/float/lfloat/algebraic/cl_LF_sqrt.cc: Throw.
* src/float/lfloat/elem/cl_LF_1plus.cc: Throw.
* src/float/lfloat/elem/cl_LF_I_div.cc: Throw.
* src/float/lfloat/elem/cl_LF_I_mul.cc: Throw.
* src/float/lfloat/elem/cl_LF_div.cc: Throw.
* src/float/lfloat/elem/cl_LF_from_I.cc: Throw.
* src/float/lfloat/elem/cl_LF_mul.cc: Throw.
* src/float/lfloat/elem/cl_LF_scale.cc: Throw.
* src/float/lfloat/elem/cl_LF_scale_I.cc: Throw.
* src/float/lfloat/elem/cl_LF_square.cc: Throw.
* src/float/lfloat/misc/cl_LF_as.cc: Throw.
* src/float/lfloat/misc/cl_LF_shorten.cc: Throw.
* src/float/lfloat/misc/cl_LF_shortenrel.cc: Throw.
* src/float/lfloat/misc/cl_LF_shortenwith.cc: Throw.
* src/float/input/cl_F_read.cc: Throw.
* src/float/input/cl_F_read_stream.cc: Throw.
* src/float/misc/cl_F_as.cc: Throw.
* src/float/misc/cl_F_shortenrel.cc: Throw.
* src/float/transcendental/cl_LF_coshsinh_aux.cc: Throw.
* src/float/transcendental/cl_LF_cossin_aux.cc: Throw.
* src/float/transcendental/cl_LF_exp_aux.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_a.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_ab.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_b.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_p.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_pa.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_pab.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_pb.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_pq.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_pqa.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_pqab.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_pqb.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_q.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_qa.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_qab.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_qb.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_stream_pq.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_stream_pqa.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_stream_pqab.cc: Throw.
* src/float/transcendental/cl_LF_ratseries_stream_pqb.cc: Throw.
* src/float/transcendental/cl_LF_ratsumseries_pqcd_aux.cc: Throw.
* src/float/transcendental/cl_LF_ratsumseries_pqd.cc: Throw.
* src/float/transcendental/cl_LF_ratsumseries_pqd_aux.cc: Throw.
* src/float/transcendental/cl_LF_zeta_int.cc: Throw.
* src/real/elem/cl_R_div.cc: Throw.
* src/real/format-output/cl_fmt_cardinal.cc: Throw.
* src/real/format-output/cl_fmt_newroman.cc: Throw.
* src/real/format-output/cl_fmt_oldroman.cc: Throw.
* src/real/input/cl_R_read.cc: Throw.
* src/real/input/cl_R_read_stream.cc: Throw.
* src/real/misc/cl_R_as.cc: Throw.
* src/real/random/cl_R_random.cc: Throw.
* src/real/transcendental/cl_R_atan2.cc: Throw.
* src/real/transcendental/cl_R_log.cc: Throw.
* src/complex/input/cl_N_read.cc: Throw.
* src/complex/input/cl_N_read_stream.cc: Throw.
* src/complex/misc/cl_N_as.cc: Throw.
* src/complex/transcendental/cl_C_atanh_aux.cc: Throw.
* src/complex/transcendental/cl_C_expt_C.cc: Throw.
* src/complex/transcendental/cl_C_log.cc: Throw.
* src/complex/transcendental/cl_C_log2.cc: Throw.
* src/numtheory/cl_nt_cornacchia1.cc: Throw.
* src/numtheory/cl_nt_cornacchia4.cc: Throw.
* src/numtheory/cl_nt_isprobprime.cc: Throw.
* src/numtheory/cl_nt_jacobi.cc: Throw.
* src/numtheory/cl_nt_jacobi_low.cc: Throw.
* src/numtheory/cl_nt_sqrtmodp.cc: Throw.
* src/modinteger/cl_MI.cc: Throw.
* src/modinteger/cl_MI_int.h: Throw.
* src/modinteger/cl_MI_montgom.h: Throw.
* src/modinteger/cl_MI_pow2.h: Throw.
* src/modinteger/cl_MI_rshift.cc: Throw.
* src/modinteger/cl_MI_std.h: Throw.
* src/polynomial/elem/cl_UP_GF2.h: Throw.
* src/polynomial/elem/cl_UP_MI.h: Throw.
* src/polynomial/elem/cl_UP_gen.h: Throw.
* src/polynomial/elem/cl_UP_named.cc: Throw.
* src/polynomial/elem/cl_UP_no_ring.cc (uninitialized_error,
uninitialized_ring): Removed (see cln/ring.h.)
* src/polynomial/elem/cl_UP_number.h: Throw.
* src/polynomial/elem/cl_UP_unnamed.cc: Throw.
* src/vector/cl_GV_I.cc: Throw.
* src/vector/cl_GV_number.cc: Throw.
* tests/timediv2adic-compare.cc: Use default abort(), not cl_abort().
* tests/timeprint-compare.cc: Likewise.
* tests/timerecip2adic-compare.cc: Likewise.
* doc/cln.tex: Document the exception classes.
* examples/contfrac.cc: Use try/catch instead of setjmp/longjmp.
* INSTALL: undocument -fno-exceptions.
* README: Add exceptions to list of used C++ features.
18 years ago |
|
// Public rational number operations.
#ifndef _CL_RATIONAL_H
#define _CL_RATIONAL_H
#include "cln/number.h"
#include "cln/rational_class.h"
#include "cln/integer_class.h"
#include "cln/exception.h"
namespace cln {
CL_DEFINE_AS_CONVERSION(cl_RA)
// numerator(r) liefert den Zähler der rationalen Zahl r.
extern const cl_I numerator (const cl_RA& r);
// denominator(r) liefert den Nenner (> 0) der rationalen Zahl r.
extern const cl_I denominator (const cl_RA& r);
// Liefert (- r), wo r eine rationale Zahl ist.
extern const cl_RA operator- (const cl_RA& r);
// (+ r s), wo r und s rationale Zahlen sind.
extern const cl_RA operator+ (const cl_RA& r, const cl_RA& s); // Dem C++-Compiler muß man auch das Folgende sagen:
inline const cl_RA operator+ (const int x, const cl_RA& y) { return cl_I(x) + y; } inline const cl_RA operator+ (const unsigned int x, const cl_RA& y) { return cl_I(x) + y; } inline const cl_RA operator+ (const long x, const cl_RA& y) { return cl_I(x) + y; } inline const cl_RA operator+ (const unsigned long x, const cl_RA& y) { return cl_I(x) + y; } #ifdef HAVE_LONGLONG
inline const cl_RA operator+ (const long long x, const cl_RA& y) { return cl_I(x) + y; } inline const cl_RA operator+ (const unsigned long long x, const cl_RA& y) { return cl_I(x) + y; } #endif
inline const cl_RA operator+ (const cl_RA& x, const int y) { return x + cl_I(y); } inline const cl_RA operator+ (const cl_RA& x, const unsigned int y) { return x + cl_I(y); } inline const cl_RA operator+ (const cl_RA& x, const long y) { return x + cl_I(y); } inline const cl_RA operator+ (const cl_RA& x, const unsigned long y) { return x + cl_I(y); } #ifdef HAVE_LONGLONG
inline const cl_RA operator+ (const cl_RA& x, const long long y) { return x + cl_I(y); } inline const cl_RA operator+ (const cl_RA& x, const unsigned long long y) { return x + cl_I(y); } #endif
// (- r s), wo r und s rationale Zahlen sind.
extern const cl_RA operator- (const cl_RA& r, const cl_RA& s); // Dem C++-Compiler muß man auch das Folgende sagen:
inline const cl_RA operator- (const int x, const cl_RA& y) { return cl_I(x) - y; } inline const cl_RA operator- (const unsigned int x, const cl_RA& y) { return cl_I(x) - y; } inline const cl_RA operator- (const long x, const cl_RA& y) { return cl_I(x) - y; } inline const cl_RA operator- (const unsigned long x, const cl_RA& y) { return cl_I(x) - y; } #ifdef HAVE_LONGLONG
inline const cl_RA operator- (const long long x, const cl_RA& y) { return cl_I(x) - y; } inline const cl_RA operator- (const unsigned long long x, const cl_RA& y) { return cl_I(x) - y; } #endif
inline const cl_RA operator- (const cl_RA& x, const int y) { return x - cl_I(y); } inline const cl_RA operator- (const cl_RA& x, const unsigned int y) { return x - cl_I(y); } inline const cl_RA operator- (const cl_RA& x, const long y) { return x - cl_I(y); } inline const cl_RA operator- (const cl_RA& x, const unsigned long y) { return x - cl_I(y); } #ifdef HAVE_LONGLONG
inline const cl_RA operator- (const cl_RA& x, const long long y) { return x - cl_I(y); } inline const cl_RA operator- (const cl_RA& x, const unsigned long long y) { return x - cl_I(y); } #endif
// (1+ r), wo r eine rationale Zahl ist.
extern const cl_RA plus1 (const cl_RA& r);
// (1- r), wo r eine rationale Zahl ist.
extern const cl_RA minus1 (const cl_RA& r);
// (abs r), wo r eine rationale Zahl ist.
extern const cl_RA abs (const cl_RA& r);
// equal(r,s) vergleicht zwei rationale Zahlen r und s auf Gleichheit.
extern bool equal (const cl_RA& r, const cl_RA& s); // equal_hashcode(r) liefert einen equal-invarianten Hashcode für r.
extern uint32 equal_hashcode (const cl_RA& r);
// compare(r,s) vergleicht zwei rationale Zahlen r und s.
// Ergebnis: 0 falls r=s, +1 falls r>s, -1 falls r<s.
extern cl_signean compare (const cl_RA& r, const cl_RA& s);
inline bool operator== (const cl_RA& x, const cl_RA& y) { return equal(x,y); } inline bool operator!= (const cl_RA& x, const cl_RA& y) { return !equal(x,y); } inline bool operator<= (const cl_RA& x, const cl_RA& y) { return compare(x,y)<=0; } inline bool operator< (const cl_RA& x, const cl_RA& y) { return compare(x,y)<0; } inline bool operator>= (const cl_RA& x, const cl_RA& y) { return compare(x,y)>=0; } inline bool operator> (const cl_RA& x, const cl_RA& y) { return compare(x,y)>0; }
// minusp(x) == (< x 0)
extern bool minusp (const cl_RA& x);
// zerop(x) stellt fest, ob eine rationale Zahl = 0 ist.
extern bool zerop (const cl_RA& x);
// plusp(x) == (> x 0)
extern bool plusp (const cl_RA& x);
// Kehrwert (/ r), wo r eine rationale Zahl ist.
extern const cl_RA recip (const cl_RA& r);
// Liefert (* r s), wo r und s rationale Zahlen sind.
extern const cl_RA operator* (const cl_RA& r, const cl_RA& s); // Dem C++-Compiler muß man auch das Folgende sagen:
inline const cl_RA operator* (const int x, const cl_RA& y) { return cl_I(x) * y; } inline const cl_RA operator* (const unsigned int x, const cl_RA& y) { return cl_I(x) * y; } inline const cl_RA operator* (const long x, const cl_RA& y) { return cl_I(x) * y; } inline const cl_RA operator* (const unsigned long x, const cl_RA& y) { return cl_I(x) * y; } #ifdef HAVE_LONGLONG
inline const cl_RA operator* (const long long x, const cl_RA& y) { return cl_I(x) * y; } inline const cl_RA operator* (const unsigned long long x, const cl_RA& y) { return cl_I(x) * y; } #endif
inline const cl_RA operator* (const cl_RA& x, const int y) { return x * cl_I(y); } inline const cl_RA operator* (const cl_RA& x, const unsigned int y) { return x * cl_I(y); } inline const cl_RA operator* (const cl_RA& x, const long y) { return x * cl_I(y); } inline const cl_RA operator* (const cl_RA& x, const unsigned long y) { return x * cl_I(y); } #ifdef HAVE_LONGLONG
inline const cl_RA operator* (const cl_RA& x, const long long y) { return x * cl_I(y); } inline const cl_RA operator* (const cl_RA& x, const unsigned long long y) { return x * cl_I(y); } #endif
// Quadrat (* r r), wo r eine rationale Zahl ist.
extern const cl_RA square (const cl_RA& r);
// Liefert (/ r s), wo r und s rationale Zahlen sind.
extern const cl_RA operator/ (const cl_RA& r, const cl_RA& s); // Dem C++-Compiler muß man auch das Folgende sagen:
inline const cl_RA operator/ (const int x, const cl_RA& y) { return cl_I(x) / y; } inline const cl_RA operator/ (const unsigned int x, const cl_RA& y) { return cl_I(x) / y; } inline const cl_RA operator/ (const long x, const cl_RA& y) { return cl_I(x) / y; } inline const cl_RA operator/ (const unsigned long x, const cl_RA& y) { return cl_I(x) / y; } #ifdef HAVE_LONGLONG
inline const cl_RA operator/ (const long long x, const cl_RA& y) { return cl_I(x) / y; } inline const cl_RA operator/ (const unsigned long long x, const cl_RA& y) { return cl_I(x) / y; } #endif
inline const cl_RA operator/ (const cl_RA& x, const int y) { return x / cl_I(y); } inline const cl_RA operator/ (const cl_RA& x, const unsigned int y) { return x / cl_I(y); } inline const cl_RA operator/ (const cl_RA& x, const long y) { return x / cl_I(y); } inline const cl_RA operator/ (const cl_RA& x, const unsigned long y) { return x / cl_I(y); } #ifdef HAVE_LONGLONG
inline const cl_RA operator/ (const cl_RA& x, const long long y) { return x / cl_I(y); } inline const cl_RA operator/ (const cl_RA& x, const unsigned long long y) { return x / cl_I(y); } #endif
// Return type for rounding operators.
// x / y --> (q,r) with x = y*q+r.
struct cl_RA_div_t { cl_I quotient; cl_RA remainder; // Constructor.
cl_RA_div_t () {} cl_RA_div_t (const cl_I& q, const cl_RA& r) : quotient(q), remainder(r) {} };
// Liefert ganzzahligen und gebrochenen Anteil einer rationalen Zahl.
// (q,r) := (floor x)
// floor2(x)
// > x: rationale Zahl
// < q,r: Quotient q, ein Integer, Rest r, eine rationale Zahl
extern const cl_RA_div_t floor2 (const cl_RA& x); extern const cl_I floor1 (const cl_RA& x);
// Liefert ganzzahligen und gebrochenen Anteil einer rationalen Zahl.
// (q,r) := (ceiling x)
// ceiling2(x)
// > x: rationale Zahl
// < q,r: Quotient q, ein Integer, Rest r, eine rationale Zahl
extern const cl_RA_div_t ceiling2 (const cl_RA& x); extern const cl_I ceiling1 (const cl_RA& x);
// Liefert ganzzahligen und gebrochenen Anteil einer rationalen Zahl.
// (q,r) := (truncate x)
// truncate2(x)
// > x: rationale Zahl
// < q,r: Quotient q, ein Integer, Rest r, eine rationale Zahl
extern const cl_RA_div_t truncate2 (const cl_RA& x); extern const cl_I truncate1 (const cl_RA& x);
// Liefert ganzzahligen und gebrochenen Anteil einer rationalen Zahl.
// (q,r) := (round x)
// round2(x)
// > x: rationale Zahl
// < q,r: Quotient q, ein Integer, Rest r, eine rationale Zahl
extern const cl_RA_div_t round2 (const cl_RA& x); extern const cl_I round1 (const cl_RA& x);
// floor2(x,y) liefert (floor x y).
extern const cl_RA_div_t floor2 (const cl_RA& x, const cl_RA& y); extern const cl_I floor1 (const cl_RA& x, const cl_RA& y);
// ceiling2(x,y) liefert (ceiling x y).
extern const cl_RA_div_t ceiling2 (const cl_RA& x, const cl_RA& y); extern const cl_I ceiling1 (const cl_RA& x, const cl_RA& y);
// truncate2(x,y) liefert (truncate x y).
extern const cl_RA_div_t truncate2 (const cl_RA& x, const cl_RA& y); extern const cl_I truncate1 (const cl_RA& x, const cl_RA& y);
// round2(x,y) liefert (round x y).
extern const cl_RA_div_t round2 (const cl_RA& x, const cl_RA& y); extern const cl_I round1 (const cl_RA& x, const cl_RA& y);
// max(x,y) liefert (max x y), wo x und y rationale Zahlen sind.
extern const cl_RA max (const cl_RA& x, const cl_RA& y);
// min(x,y) liefert (min x y), wo x und y rationale Zahlen sind.
extern const cl_RA min (const cl_RA& x, const cl_RA& y);
// signum(x) liefert (signum x), wo x eine rationale Zahl ist.
extern const cl_RA signum (const cl_RA& x);
// (expt x y), wo x eine rationale Zahl und y ein Integer >0 ist.
extern const cl_RA expt_pos (const cl_RA& x, uintL y); extern const cl_RA expt_pos (const cl_RA& x, const cl_I& y);
// (expt x y), wo x eine rationale Zahl und y ein Integer ist.
extern const cl_RA expt (const cl_RA& x, sintL y); extern const cl_RA expt (const cl_RA& x, const cl_I& y);
// Stellt fest, ob eine rationale Zahl >=0 das Quadrat einer rationalen Zahl
// ist.
// sqrtp(x,&w)
// > x: eine rationale Zahl >=0
// < w: rationale Zahl (sqrt x) falls x Quadratzahl
// < ergebnis: true ..................., false sonst
extern bool sqrtp (const cl_RA& x, cl_RA* w);
// Stellt fest, ob eine rationale Zahl >=0 die n-te Potenz einer rationalen Zahl
// ist.
// rootp(x,n,&w)
// > x: eine rationale Zahl >=0
// > n: ein Integer >0
// < w: exakte n-te Wurzel (expt x (/ n)) falls x eine n-te Potenz
// < ergebnis: true ........................, false sonst
extern bool rootp (const cl_RA& x, uintL n, cl_RA* w); extern bool rootp (const cl_RA& x, const cl_I& n, cl_RA* w);
// Liefert zu Integers a>0, b>1 den Logarithmus log(a,b),
// falls er eine rationale Zahl ist.
// logp(a,b,&l)
// > a: ein Integer >0
// > b: ein Integer >1
// < l: log(a,b) falls er eine exakte rationale Zahl ist
// < ergebnis: true ......................................., false sonst
extern bool logp (const cl_I& a, const cl_I& b, cl_RA* l);
// Liefert zu rationalen Zahlen a>0, b>0 den Logarithmus log(a,b),
// falls er eine rationale Zahl ist.
// logp(a,b,&l)
// > a: eine rationale Zahl >0
// > b: eine rationale Zahl >0, /=1
// < l: log(a,b) falls er eine exakte rationale Zahl ist
// < ergebnis: true ......................................., false sonst
extern bool logp (const cl_RA& a, const cl_RA& b, cl_RA* l);
// Konversion zu einem C "float".
extern float float_approx (const cl_RA& x);
// Konversion zu einem C "double".
extern double double_approx (const cl_RA& x);
#ifdef WANT_OBFUSCATING_OPERATORS
// This could be optimized to use in-place operations.
inline cl_RA& operator+= (cl_RA& x, const cl_RA& y) { return x = x + y; } inline cl_RA& operator+= (cl_RA& x, const int y) { return x = x + y; } inline cl_RA& operator+= (cl_RA& x, const unsigned int y) { return x = x + y; } inline cl_RA& operator+= (cl_RA& x, const long y) { return x = x + y; } inline cl_RA& operator+= (cl_RA& x, const unsigned long y) { return x = x + y; } #ifdef HAVE_LONGLONG
inline cl_RA& operator+= (cl_RA& x, const long long y) { return x = x + y; } inline cl_RA& operator+= (cl_RA& x, const unsigned long long y) { return x = x + y; } #endif
inline cl_RA& operator++ /* prefix */ (cl_RA& x) { return x = plus1(x); } inline void operator++ /* postfix */ (cl_RA& x, int dummy) { (void)dummy; x = plus1(x); } inline cl_RA& operator-= (cl_RA& x, const cl_RA& y) { return x = x - y; } inline cl_RA& operator-= (cl_RA& x, const int y) { return x = x - y; } inline cl_RA& operator-= (cl_RA& x, const unsigned int y) { return x = x - y; } inline cl_RA& operator-= (cl_RA& x, const long y) { return x = x - y; } inline cl_RA& operator-= (cl_RA& x, const unsigned long y) { return x = x - y; } #ifdef HAVE_LONGLONG
inline cl_RA& operator-= (cl_RA& x, const long long y) { return x = x - y; } inline cl_RA& operator-= (cl_RA& x, const unsigned long long y) { return x = x - y; } #endif
inline cl_RA& operator-- /* prefix */ (cl_RA& x) { return x = minus1(x); } inline void operator-- /* postfix */ (cl_RA& x, int dummy) { (void)dummy; x = minus1(x); } inline cl_RA& operator*= (cl_RA& x, const cl_RA& y) { return x = x * y; } inline cl_RA& operator/= (cl_RA& x, const cl_RA& y) { return x = x / y; } #endif
// Runtime typing support.
extern cl_class cl_class_ratio;
// Debugging support.
#ifdef CL_DEBUG
extern int cl_RA_debug_module; CL_FORCE_LINK(cl_RA_debug_dummy, cl_RA_debug_module) #endif
} // namespace cln
#endif /* _CL_RATIONAL_H */
|