
Hello Roberto,
Yes, applying the idea in the link works. I attach a snapshot of the key code on godbolt:
https://godbolt.org/z/b9EaPMvbq
I have a few follow-up queries.
(1) What is the difference between
if (!guarded_read(in, rational_coefficients[i])) {
https://github.com/BUGSENG/PPL/blob/92d0704d3309d55f39a647595f8383b86fcd57e1...
and
if (!guarded_read(in, d)) {
https://github.com/BUGSENG/PPL/blob/92d0704d3309d55f39a647595f8383b86fcd57e1...
The first is for rationals and the second is for reals. Does the rationals part of the code read in separately the numerator (2) and denominator (3, say) while the reals part of the code read in a decimal, say, in this case, 0.6666666666667, directly?
(2) In the code I have (link of godbolt provided), I store in rational_coefficients[ ] a double which is obtained by (double)numerator/(double)denominator. Could you please confirm that this is the canonical/right way to input points / rays with noninteger coefficients -- that is where numerator and denominator are integer type?
(3) Is there an interface in PPL which accepts from the user only the integer numerator and integer denominator and within PPL converts these into appropriate rationals? The reason why I ask is that within another package (unmaintained now), PORTA, the user is able to separately enter the integer numerator and integer denominator and the code manages these "appropriately" within its internals. See for e.g., file inout.c within the PORTA package https://porta.zib.de/porta-1.4.1.zip function scan_line. As a naive end user, it appears to me that treating fractions could be compiler/OS dependent and hence user explicitly providing rational input as (double)numerator/(double)denominator could give rise to different ways in which rational_coefficients[] data structure is stored depending on the compiler/OS on which the program is run. Would it not be better and more robust to ask from the user only for the integer numerator and integer denominator and "convert" these appropriately (as the function "normalize" in PPL does) in a fashion which is independent of the OS/compiler used? Again, this is a naive question as an end user. Please let me know if my concern is not relevant here.
Thank you for your help.