Next: Intervals, Previous: Scalars & Intervals & Coefficients, Up: Scalars & Intervals & Coefficients
typedef enum ap_scalar_discr_t { AP_SCALAR_DOUBLE, /* floating-point with double */ AP_SCALAR_MPQ /* rational with multi-precision GMP */ } ap_scalar_discr_t;
Discriminant indicating the underlying type of a scalar number.
typedef struct ap_scalar_t { ap_scalar_discr_t discr; union { double dbl; mpq_ptr mpq; /* +infty coded by 1/0, -infty coded by -1/0 */ } val; } ap_scalar_t;
A scalar number is either a double, or a multi-precision rational, as implemented by GMP.
• Initializing scalars | ||
• Assigning scalars | ||
• Converting scalars | ||
• Comparing scalars | ||
• Other operations on scalars |
Next: Assigning scalars, Previous: Scalars, Up: Scalars
Allocate a scalar, of default type DOUBLE (the most economical)
Deallocate a scalar.
Change the type of an already allocated scalar (mainly for internal use)
Initialize and clear a scalar \‘a la GMP (internal use).
Next: Converting scalars, Previous: Initializing scalars, Up: Scalars
Set the value of rop from op.
Change the type of rop to MPQ and set its value to resp. mpq, i, and i/j.
Change the type of rop to DOUBLE and set its value to k.
Set the value of rop to sgn*infinity. Keep the type of the rop.
Combined allocation and assignement.
Next: Comparing scalars, Previous: Assigning scalars, Up: Scalars
Set mpq with the value of op, possibly converting from DOUBLE type.
round currently unused.
Return the value of op in DOUBLE type, possibly converting from MPQ type.
Conversion may be not exact. round currently unused.
Next: Other operations on scalars, Previous: Converting scalars, Up: Scalars
Return -1
if op is set to +infty, -1
if set to
-infty, and 0
otherwise.
Return the sign of op (+1
, 0
or -1
).
Exact comparison between two scalars (resp. a scalar and an integer).
Return -1
if op1 is less than op2, 0
if they
are equal, and +1
if op1
is greater than op2.
Equality test between two scalars (resp. a scalar and an integer).
Return true
if equality.
Previous: Comparing scalars, Up: Scalars
Negation.
Inversion. Not exact for DOUBLE type.
Exchange the values of op1 and op2.
Return an hash code (for instance for OCaml interface).
Print op on the stream stream.
Previous: Comparing scalars, Up: Scalars