bug#74031: [PATCH] srfi-64: Accept complex numbers in test-approximate.

Tomas Volf <[email protected]> Sat, 26 Oct 2024 22:26:02 +0200
Newsgroups gmane.lisp.guile.bugs
Message-ID <[email protected]>
Hello,

lloda <[email protected]> writes:

>> On 26 Oct 2024, at 19:22, Ludovic Courtès <[email protected]> wrote:
>> 
>> Hi,
>> 
>> (Cc: lloda.)
>> 
>> Tomas Volf <[email protected]> skribis:
>> 
>>> The specification mandates reals, but the reference implementation
>>> supports complex numbers.  So as implementation extension, support them
>>> as well.
>>> 
>>> * module/srfi/srfi-64.scm (within-epsilon): Support complex arguments.
>>> ---
>>> Proposal for how to extend test-approximate to handle complex arguments.
>>> However it differs from the original one.  That one expected `error' to be a
>>> real number, and used it for comparing both real parts and imaginary parts.
>>> 
>>> To me, that seems weird.  I would consider it useful to be able to have
>>> different errors for real and imaginary parts.
>>> 
>>> However I cannot remember the last time I have used complex numbers, so I am not
>>> sure I am qualified to have an opinion here.  What do other people think?
>> 
>> Not sure either.  Daniel, is that what you would expect?
>> 
>> Perhaps we should check the reference implementation?
>> 
>> Ludo’.
>
> Sorry, I didn't notice this. I replied on another message, but to be clear, the
> expected error should always be a real number, no matter what you're
> comparing.

Got it, I have sent v2 using the same logic the original implementation
did (according to your message "Chebyshev distance").  Since we are
doing this for purpose of backwards compatibility, it makes sense to
just restore the original behavior as it was.

> If one wants to have separate errors for real and imaginary parts,
> then one can simply use test-approximate on the real and imaginary parts
> separately.

By the same logic, if one wants to use the standard compliant
test-approximate with complex numbers, one can simply call it on real
and imaginary parts separately. ^_^

Tomas

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
signature.asc (application/pgp-signature, 853 B)
-----BEGIN PGP SIGNATURE-----

iQJCBAEBCgAsFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmcdUFoOHH5Ad29sZnNk
ZW4uY3oACgkQL7/ufbZ/wam5hA//ceD3IFcvRJoLKMPdqhMH4A2vgcFgxwrm/HWI
a+gLEvFCJPIOx9E/TxwvdMhZbtyjU7sdba+hXrqRFBKIzHxJy4z2aWwMP+ZZBzzp
yopx/anqBFSSZbQ30FIVdM/m0fvBXYDT/g/rrkaOwafciCKh7Lr4c7ZDgMpVf2ah
zokJmL+buO+NF9Cn7hZk36W/d7FkPe1VA/C4QoO+XRiR0YPZFWNtS86zXF1ydUUk
aARzRmdYsmXKuV/6s8aX6/7CkhVOu0chNvIqMDQ+HpIkt0Z5lGd0qvj7h00poHqa
u/9bGYZ7gx0VWIZLFfpCv56js6H+UyVMTN246fnRQ2lC6gYEvVvjw4SwO18ZXl8l
CmQtocmcZWN6w9z4vSsnhokdEv0YXQ+8GHwu/Mvj64T7Bx6WNgi/X+o9RDzfBc5f
+yXogq0R7tQtBtWwGwWFmPDIqvPI3W+qR6XFfrUgKPIYUxNr5HurXvkfvBykk6xg
6voDaPGQrall6slhS34wGutyrZMogzV42Gje2iqjfrSD4fcwAO4gkfv/sEwAb/OR
4ePjpcVQZomwgsPKO4PJDCKyNX4I1p+mjKETPdUKSR+xRKquB2KAMAeQQEEl2AI2
EMKkLrgrLCUOi6l52OuKs5wOeyDQKkhWVBJOHhu0Jkyf2YVQ1BAjegFSAp6VksQ6
PPGTc3U=
=VpvS
-----END PGP SIGNATURE-----