Received: (at 74031) by debbugs.gnu.org; 26 Oct 2024 21:07:25 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 26 17:07:25 2024 Received: from localhost ([127.0.0.1]:42745 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1t4o0L-0002EO-2f for submit <at> debbugs.gnu.org; Sat, 26 Oct 2024 17:07:25 -0400 Received: from wolfsden.cz ([37.205.8.62]:41446) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <~@wolfsden.cz>) id 1t4o0I-0002E2-J6 for 74031 <at> debbugs.gnu.org; Sat, 26 Oct 2024 17:07:23 -0400 Received: by wolfsden.cz (Postfix, from userid 104) id 0CC87335B0A; Sat, 26 Oct 2024 21:06:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1729976807; bh=ii8BZY6IVT9wUz4BQrcVGmhvU1XZMv/7MswH82RB3Cg=; h=From:To:Cc:Subject:Date; b=A+p4fLDjjfOOiXFuZa7XR6pW7tNQe9OKSdOqQMBN0qL0yi8HWXYMXoaI5ypaSR+UY BMgCLGRA5ZxPZVJZg9rTXvJ1V+Yv2WgmdRuwIaX85nAMIcJ30/aQ+qzK65yuvOiHka WB4iVCdHUaUYT+I9efjb+AcNIjTIHIG7Y5DmG3rPD0zg5/wMkwlNqDQUw+JRKyjtz0 6/tu9exEjeLq/gdBHjGHQvhFGmGf8mM/Eui68P5iHc8bixpUABtbvsFUrW/QzTyzhJ IBAytws97O5M5+rm7REaPt4VRnQJH0LPgZWOE0JMfAE8t5A5KfGyDQLJ7+WYE+cx2L grZoTG9zRsRs/PYUMvJ8+iY5awS39/es6PqWXsHtSR1+QSdZmLHa1gViWQZ9rzdvrA DoDEtKMxsnZbi2lP02ZSUoCbNhvh7sPpzUTQf04VSrLKwfVJZWbh/cOEv1EMMkQImM pGmz+lVs7dwP6zvr3evY4DRbS2WAfsb5C+lcdSXabkxhwj8rTAbzSq3rUAUHSUQyQf rRsSIJAxXZNXSaDsQ0hFRchY2zhH2R4s1+xNRaNz8IPB5IQ8CitSW7kzDnNjUpzcf+ d2qcmFeqTaRmZUvGYPqnvFHP3shSPodv8bky5/Q3DiAot+ZiJNAfOonaWI/3ZT8OBA 0j0dlCnU4bfZ8W/AerW09NLw= X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on wolfsden X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id AC656334D45; Sat, 26 Oct 2024 21:06:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1729976806; bh=ii8BZY6IVT9wUz4BQrcVGmhvU1XZMv/7MswH82RB3Cg=; h=From:To:Cc:Subject:Date; b=pwpt+Hp308Yjqog7dX2sNenUF47YW45g40bLe3uftC8CvcfOdfQlXRA/PIlFxfzyy nQWqyV7GdqLFQT50QB8ENjvpQB6bTZdxaJ2iqOS9BwkwsGeX8qfnmKXx4XxG9xVXWX dixyoFAPWhVAlZ7wKXazp+taraXT3S9m46U+ekqtJ7sKUWHmN4ygquUrWy47zD8EsP iJmAGYBmf4ci3znW1xjdq46UamKUU8osThJn/Fan0Vs5xKMGUh5p1YLNQnkzQaclt4 NWSHBc88mR1S00EvGm3INrRo/0RzVVu323N41Mi8HlTRo8Drk2WjUT/Fb+IJMNCswH 5Kx3twc+RvS5iVfk9Ey74TkiH8ibuKanJ92N8OMzGSWBvzg4+ZTehFyA8T9ko/Mn8q 3rDVJzIb6qic3KnnuIhFG6Wz5QLXZCwM9UVnMfqow9nPVdpPGclhRd3RkAHkbmbhwg dlPydsot+EvbxJtBKYshVFpZC3Kv4rSlOPFjW3GWzCWI1eXic2jABUdYBxOh0h4Fhb gAAvyNas7Ck7hFdRYWGl7gqQGdSZVmGcZcYmhC5jQfM062yOwST7iezFNLOUvC9r8+ ZVZv3LwwWTC5xn1QIvj5mMQGSojWBZKWpqwQ91mWzBrq/4Yu8Vcz6mpeBFoc30gud6 2tmc3nE36wa0Ffad+cMv/E/I= From: Tomas Volf <~@wolfsden.cz> To: 74031 <at> debbugs.gnu.org Subject: [PATCH v3] srfi-64: Accept complex numbers in test-approximate. Date: Sat, 26 Oct 2024 23:06:09 +0200 Message-ID: <20241026210644.12227-1-~@wolfsden.cz> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 74031 Cc: Tomas Volf <~@wolfsden.cz> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) 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. --- v2: Use the same test logic as the reference implementation. v3: Also adjust the docstring. module/srfi/srfi-64.scm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/module/srfi/srfi-64.scm b/module/srfi/srfi-64.scm index 1f60a72e5..0f1b5c117 100644 --- a/module/srfi/srfi-64.scm +++ b/module/srfi/srfi-64.scm @@ -776,8 +776,14 @@ Test whether result of @var{test-expr} matches @var{expected} using (define (within-epsilon ε) (λ (expected actual) - (and (>= actual (- expected ε)) - (<= actual (+ expected ε))))) + (let ((e-r (real-part expected)) + (e-i (imag-part expected)) + (a-r (real-part actual)) + (a-i (imag-part actual))) + (and (>= a-r (- e-r ε)) + (<= a-r (+ e-r ε)) + (>= a-i (- e-i ε)) + (<= a-i (+ e-i ε)))))) (define-syntax %test-approximate (λ (x) @@ -808,6 +814,10 @@ Test whether result of @var{test-expr} matches @var{expected} using Test whether result of @var{test-expr} is within @var{error} of @var{expected}. +As implementation extension, complex numbers are supported as well. It tests +whether both real and imaginary parts of @var{test-expr} are within +@var{error} of real and imaginary parts of @var{expected}. + @end defspec") (define-syntax %test-error -- 2.46.0
bug-guile@HIDDEN
:bug#74031
; Package guile
.
Full text available.Received: (at 74031) by debbugs.gnu.org; 26 Oct 2024 20:26:40 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 26 16:26:40 2024 Received: from localhost ([127.0.0.1]:42715 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1t4nMu-0000Jz-91 for submit <at> debbugs.gnu.org; Sat, 26 Oct 2024 16:26:40 -0400 Received: from wolfsden.cz ([37.205.8.62]:36142) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <~@wolfsden.cz>) id 1t4nMs-0000Jo-0F for 74031 <at> debbugs.gnu.org; Sat, 26 Oct 2024 16:26:39 -0400 Received: by wolfsden.cz (Postfix, from userid 104) id 2D9A632AC29; Sat, 26 Oct 2024 20:26:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1729974363; bh=ASx+xwSPXU+uvuOhhqeNwKXZcIIIcGgGDFbNUOiXxts=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=nyqyiZbILaxWW+FwTzu2ft2NSr6Du2phOdyfw/LTKt8g/b1Tx+lZpbDufsGyZ/Xjm DUbRXSyW3M9RNlPe9gD+KTynpZA+22l2reSuvbbncY9qHPd+yUj7aiwLJCsyCHOV+t qnheb5xZWcjD3p6M1+wbonq04f2XVEHDMEu5HejN3ym+Lw49Q7/Y/Un3lO7uoBoddB HazHXI1XM6hV12p8Lb6lUa/LKmlTEV+a3yAj3XU8R2J+d2kKYGEgKm8MTNAk3oVN9y yxt3pdPcmKyWfw9X3Q9+7xPaliB4kiryV8fKZMsJj/HLtSgGvVX30LiwnPDwDR7v53 pXxYDT7sSXnbprVSdBmQgijsfPQx5F4FxkN/CiqUvDdX9t4NrQ3qKkp5v6iT1w9s5Y UwsbU6LooNn7n7cS6rfm8cj0ziAMGUrFclKppq66uidwHMsCfG8ftBq6aBSztDU/pN AfuWWugZYYWXJ+r3StJVlMSZnodpG63VOhrhx9HQe/k3AedtQBFOAdyyI7iT5J5nF9 kZtJ5hrMwB0BF5w/GvJvlcjaolPQNb1/TAYqrJFmFaOb5I9ch5PZrzh/0yvbOTZGYX Sx/YqOm79jIi271+DatiMpZI9OaMrr5iMGP8pVhUZeAsGm/ngMEcdVaCGheOJyFc63 Vb1qiAPjDuwhaaRmmdZQvQLw= X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on wolfsden X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id BE05D334261; Sat, 26 Oct 2024 20:26:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1729974362; bh=ASx+xwSPXU+uvuOhhqeNwKXZcIIIcGgGDFbNUOiXxts=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=F3EdC4mPFR6vLrLkU08upSc2OSQKivMxnEHHOFgoyoVGfpUTHuOhsPZORYoaXpqQ2 EIqUwogWHA4DcKR0zDK7r9LbfN7brdqz/hAi3G7qzw+CJttNFlb2g2dz4FnVPPZr2X Oxw32ofJTsg/PpBiye2c8pK/NuLFeUbtbRYTb/y4TydRrR5ZtdFeqmoLYsOkagZPD6 JfTNKIfOGSjqgPCL6nO/jofjlcauCWYAroQQMGYOForgIIA92EH3ZhCrs5bF2WUBio TmzsOG+BzY52/h85bilY2dgojDJ6RlVRKsg0SBIE8MkNURaqIl7CYY3kjAcEvR/CkK wKOlvTNhY6AczfygDRJRrsmDLDydQKSisazSzphXIRJfi94F8zShhhlQsRt2r0jhwW 65SjwSMDH8eW76oWH3lGEEGvbIGT16ieJnSaMKFTQIbHtpzRj/QEjV6QqYB3Poqhyw pL8BZoeVM7abKFry/Uuy3JApZTBGP1sMilIG4qooi1xPl0WQryotjdkKja1aNt4Ruq 60CEUJ8DWvotDLIBGIp5mKxd03cV2Eeo/O8G+3XzQkZXpcCVLBGlFKOyPNEQl2KPdb lR4YqUCIh7u/Gj3/42QNTKjPkceAeN5ey4syjpsz+Ry/iI3FZ8ziXKZyEy34vOlEzY aVmBWEV3L8I5l2JXHDi3GkRs= From: Tomas Volf <~@wolfsden.cz> To: lloda <lloda@HIDDEN> Subject: Re: bug#74031: [PATCH] srfi-64: Accept complex numbers in test-approximate. In-Reply-To: <40FEB680-90BC-4915-AFE9-88F4B638E59A@HIDDEN> (lloda@HIDDEN's message of "Sat, 26 Oct 2024 20:46:25 +0200") References: <20241026161015.21049-1-~@wolfsden.cz> <87ed42vkwp.fsf@HIDDEN> <40FEB680-90BC-4915-AFE9-88F4B638E59A@HIDDEN> Date: Sat, 26 Oct 2024 22:26:02 +0200 Message-ID: <87ed42k3vp.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 74031 Cc: 74031 <at> debbugs.gnu.org, Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, lloda <lloda@HIDDEN> writes: >> On 26 Oct 2024, at 19:22, Ludovic Court=C3=A8s <ludo@HIDDEN> wrote: >>=20 >> Hi, >>=20 >> (Cc: lloda.) >>=20 >> Tomas Volf <~@wolfsden.cz> skribis: >>=20 >>> The specification mandates reals, but the reference implementation >>> supports complex numbers. So as implementation extension, support them >>> as well. >>>=20 >>> * 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 pa= rts. >>>=20 >>> To me, that seems weird. I would consider it useful to be able to have >>> different errors for real and imaginary parts. >>>=20 >>> 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 thin= k? >>=20 >> Not sure either. Daniel, is that what you would expect? >>=20 >> Perhaps we should check the reference implementation? >>=20 >> Ludo=E2=80=99. > > Sorry, I didn't notice this. I replied on another message, but to be clea= r, 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 =2D-=20 There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----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----- --=-=-=--
bug-guile@HIDDEN
:bug#74031
; Package guile
.
Full text available.Received: (at 74031) by debbugs.gnu.org; 26 Oct 2024 20:21:58 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 26 16:21:58 2024 Received: from localhost ([127.0.0.1]:42701 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1t4nIJ-00005E-Vk for submit <at> debbugs.gnu.org; Sat, 26 Oct 2024 16:21:58 -0400 Received: from wolfsden.cz ([37.205.8.62]:38856) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <~@wolfsden.cz>) id 1t4nIG-000052-Ot for 74031 <at> debbugs.gnu.org; Sat, 26 Oct 2024 16:21:54 -0400 Received: by wolfsden.cz (Postfix, from userid 104) id 584573350AD; Sat, 26 Oct 2024 20:21:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1729974077; bh=W7YF5HGySgBmmcySlogBcnaTrKmgdXyQNq03S8O3U5U=; h=From:To:Cc:Subject:Date; b=lu38OwEeo+7Etb1QtATr/KUAmTeaWOgtKC5gQQjWtXIAxvSZkONUJoUxEJ3TaorYs 3frvQw7r44dS5AsG9KeW4HbTBDE3REA4ymNrDkGZPeNHaeetIkQBUf+cn3quzWfG+l 4GFxcu9l2yMcMVWMotIudL9kf5wqwT+PHuSoimpRidSO0Kv/nDPGGxkkOnlr87QRbP Jmcb5azmLfyDAyTA9/JB1jmf7bZB5ktpDuC0znFzLKvhOHQZsJgimg3qC4pr9XH+eu CSmhLR12WgEJnF0xrVuj500EwvqwoDAry69ZBhUsbXPRKYMlUsCYw3UVJETQ6sUfIv FX0s2Oj/lehy9Y9yajUGzvNo4dv8BpHim5ORNcvVSj+j0CKn7OU8lThJGs16kphpvP dp6PXHu7GvaMoOkGOyjDp4a2f3ZEwL5IlSQ2fTCNNOfESNl7f5v74zpMXsvGqw9ODH YjBnUj0EN4zJRDXuBjRyKzvktvEUDQkPZs82otQTWvblPh7Syt+hGQCMm3dBWG3+vB TJEhHsQKE57i5nxiLwTL2SAyzsDZo7uaK1bYkk1Tms7EsITWLFNqKzQXEpda03dPqa lsqoBFox42yDkCG4Y1qQUDrgR+Zaj7SrzbsmYt7itiv4pBga3fN+OBJc1MXqbwjmBn oc0ci/YyLNITzlwJcjzzbETk= X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on wolfsden X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id 82ABC33570A; Sat, 26 Oct 2024 20:21:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1729974076; bh=W7YF5HGySgBmmcySlogBcnaTrKmgdXyQNq03S8O3U5U=; h=From:To:Cc:Subject:Date; b=IhrWwU7bBhMplFVWkguiWySisVEjnXvEcgu9HT2z3nRm4nE2wZG8RtD5sGyeNLHLX hjYhePp59Wcmn0s+MwgwwaIEb0lbprijsr0gefTJF13PV74LWyoKPb81PfWAhBbt// jD4vtmFha4o54s/ZO688L+7esVAp3wUPYUF/qRbmAeS7/bLfMaJ/ztjsIbJKgkj6qi Tw+G3wBUMHfBCTwAnqSrz4A12DU++kjPyDDjgqgMeVn62iFCEQ/exKiNfTzlKekkUg +IC4Vl4FfVSw5qiz92P8qpl+36SYz6UX6BwC7z/hhd/bFkNsqFRMGgn4MvrN0rcYaZ 6mjOmKNrPYX+wWqEFtkgIjVfFkkL+EegILfzyJv21O9HieoIRn8tb5DCkHd77mof6Q GpV6AVJ8iXrtsiYQNf0gH8CNFTGqJ2eIiqfcP08ghoa32TjumyInGh5QHWIGIqdO8K Hbc2p45uvFDjtqdETn68g25uY/4LAGQ5t0R/3MTgm4vqpNIbYlcX6D1dXlxmBSYH8Z K4+BOVK9vDWFulI9hBXCD+63BxUQr3PPfFBpl6DlmExeps11LHyrx4KTfotspYWjXJ uI9zX5qfbhMBc0OFu3kyof6Cbp+237hePUByarffKaTJwhcvPAhrwMKfiIgMVw4hJU DkpCuJza7RVn0ynCfqRm22vI= From: Tomas Volf <~@wolfsden.cz> To: 74031 <at> debbugs.gnu.org Subject: [PATCH v2] srfi-64: Accept complex numbers in test-approximate. Date: Sat, 26 Oct 2024 22:19:26 +0200 Message-ID: <20241026202113.9329-1-~@wolfsden.cz> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 74031 Cc: Tomas Volf <~@wolfsden.cz> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) 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. --- Require error to be real number and check using (checks notes) Chebyshev distance. module/srfi/srfi-64.scm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/module/srfi/srfi-64.scm b/module/srfi/srfi-64.scm index 1f60a72e5..453296364 100644 --- a/module/srfi/srfi-64.scm +++ b/module/srfi/srfi-64.scm @@ -776,8 +776,14 @@ Test whether result of @var{test-expr} matches @var{expected} using (define (within-epsilon ε) (λ (expected actual) - (and (>= actual (- expected ε)) - (<= actual (+ expected ε))))) + (let ((e-r (real-part expected)) + (e-i (imag-part expected)) + (a-r (real-part actual)) + (a-i (imag-part actual))) + (and (>= a-r (- e-r ε)) + (<= a-r (+ e-r ε)) + (>= a-i (- e-i ε)) + (<= a-i (+ e-i ε)))))) (define-syntax %test-approximate (λ (x) @@ -808,6 +814,10 @@ Test whether result of @var{test-expr} matches @var{expected} using Test whether result of @var{test-expr} is within @var{error} of @var{expected}. +As implementation extension, complex numbers are supported as well. It tests +whether real parts are within @code{(real-part @var{error})}, and imaginary +parts within @code{(imag-part @var{error})}. + @end defspec") (define-syntax %test-error -- 2.46.0
bug-guile@HIDDEN
:bug#74031
; Package guile
.
Full text available.Received: (at 74031) by debbugs.gnu.org; 26 Oct 2024 18:47:12 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 26 14:47:12 2024 Received: from localhost ([127.0.0.1]:42589 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1t4lod-0004EK-Lg for submit <at> debbugs.gnu.org; Sat, 26 Oct 2024 14:47:12 -0400 Received: from mta-14-3.privateemail.com ([198.54.127.110]:38100) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <lloda@HIDDEN>) id 1t4lob-0004E3-Pi for 74031 <at> debbugs.gnu.org; Sat, 26 Oct 2024 14:47:10 -0400 Received: from mta-14.privateemail.com (localhost [127.0.0.1]) by mta-14.privateemail.com (Postfix) with ESMTP id 8014118000A9; Sat, 26 Oct 2024 14:46:30 -0400 (EDT) Received: from [192.168.1.16] (unknown [51.154.167.214]) by mta-14.privateemail.com (Postfix) with ESMTPA; Sat, 26 Oct 2024 14:46:27 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: bug#74031: [PATCH] srfi-64: Accept complex numbers in test-approximate. From: lloda <lloda@HIDDEN> In-Reply-To: <87ed42vkwp.fsf@HIDDEN> Date: Sat, 26 Oct 2024 20:46:25 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <40FEB680-90BC-4915-AFE9-88F4B638E59A@HIDDEN> References: <20241026161015.21049-1-~@wolfsden.cz> <87ed42vkwp.fsf@HIDDEN> To: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN> X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 74031 Cc: 74031 <at> debbugs.gnu.org, Tomas Volf <~@wolfsden.cz> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) > On 26 Oct 2024, at 19:22, Ludovic Court=C3=A8s <ludo@HIDDEN> wrote: >=20 > Hi, >=20 > (Cc: lloda.) >=20 > Tomas Volf <~@wolfsden.cz> skribis: >=20 >> The specification mandates reals, but the reference implementation >> supports complex numbers. So as implementation extension, support = them >> as well. >>=20 >> * 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. >>=20 >> To me, that seems weird. I would consider it useful to be able to = have >> different errors for real and imaginary parts. >>=20 >> 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? >=20 > Not sure either. Daniel, is that what you would expect? >=20 > Perhaps we should check the reference implementation? >=20 > Ludo=E2=80=99. 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. 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. Regards=20 Daniel
bug-guile@HIDDEN
:bug#74031
; Package guile
.
Full text available.Received: (at 74031) by debbugs.gnu.org; 26 Oct 2024 18:36:22 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 26 14:36:22 2024 Received: from localhost ([127.0.0.1]:42578 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1t4leA-0003lF-5r for submit <at> debbugs.gnu.org; Sat, 26 Oct 2024 14:36:22 -0400 Received: from mta-10-4.privateemail.com ([198.54.122.149]:45278) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <lloda@HIDDEN>) id 1t4le7-0003l0-US for 74031 <at> debbugs.gnu.org; Sat, 26 Oct 2024 14:36:20 -0400 Received: from mta-10.privateemail.com (localhost [127.0.0.1]) by mta-10.privateemail.com (Postfix) with ESMTP id 323F618000AA; Sat, 26 Oct 2024 14:35:40 -0400 (EDT) Received: from [192.168.1.16] (unknown [51.154.167.214]) by mta-10.privateemail.com (Postfix) with ESMTPA; Sat, 26 Oct 2024 14:35:38 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: bug#74031: [PATCH] srfi-64: Accept complex numbers in test-approximate. From: lloda <lloda@HIDDEN> In-Reply-To: <20241026161015.21049-1-~@wolfsden.cz> Date: Sat, 26 Oct 2024 20:35:36 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <231BD3C0-36C3-4528-9124-7427B133E832@HIDDEN> References: <20241026161015.21049-1-~@wolfsden.cz> To: Tomas Volf <~@wolfsden.cz> X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 74031 Cc: 74031 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Like I wrote in a separate message, I think test-approximate should = check the https://en.wikipedia.org/wiki/Euclidean_distance : (<=3D (magnitude (- expected value)) epsilon) For real numbers, it means the same as the current test. It would also = work for other types for which the user has defined - and magnitude, = like vectors. I just checked the old impl: -(define (%test-approximate=3D error) - (lambda (value expected) - (let ((rval (real-part value)) - (ival (imag-part value)) - (rexp (real-part expected)) - (iexp (imag-part expected))) - (and (>=3D rval (- rexp error)) - (>=3D ival (- iexp error)) - (<=3D rval (+ rexp error)) - (<=3D ival (+ iexp error)))))) This is still *a* distance = (https://en.wikipedia.org/wiki/Chebyshev_distance), and close numbers = will be close either way, but speaking as an engineer who uses complex = numbers all day, Euclidean distance is the only one I've ever wanted to = use. Regards lloda
bug-guile@HIDDEN
:bug#74031
; Package guile
.
Full text available.Received: (at 74031) by debbugs.gnu.org; 26 Oct 2024 17:23:35 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 26 13:23:34 2024 Received: from localhost ([127.0.0.1]:42428 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1t4kVi-0000An-FO for submit <at> debbugs.gnu.org; Sat, 26 Oct 2024 13:23:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40450) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <ludo@HIDDEN>) id 1t4kVh-0000AY-Cr for 74031 <at> debbugs.gnu.org; Sat, 26 Oct 2024 13:23:33 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <ludo@HIDDEN>) id 1t4kV3-0008AE-MP; Sat, 26 Oct 2024 13:22:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=lC1/9PKNTH8q+5iOXSouWTCi+1gKxEgDouRA7d+aG8M=; b=lowrqnfVMaT2cwb7VAMW 2bjNC9f63dJ9mXi6k7TiSWd3QUodol3fS84D2Sha/NF8ja1lH2t3mtDzFYAJ7QSSDdJwWyR+ba5e6 TDO5lqVoSvqLVzxCGGYS2Wt4hBll0ClAwl5JGUvQ1dvX2Y6UuFusTbSq2unqUqI3jahMBT9/7PteI JF4gKq+k+e7BXxYaK0G4zr4mBe//ZjVmOkMBMbF90RKXVTjji1R5akQBIzEygWkB1W608rsbtx2jl tPXuehEhW7InLUghivt+sFy9fEpcMJWOgiav3K3KZZGjsnEHJfnWCTR/MRKyPoSogh3o4H1nltx+f qp0bwgAi8yWTdA==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN> To: Tomas Volf <~@wolfsden.cz> Subject: Re: bug#74031: [PATCH] srfi-64: Accept complex numbers in test-approximate. In-Reply-To: <20241026161015.21049-1-~@wolfsden.cz> (Tomas Volf's message of "Sat, 26 Oct 2024 18:07:06 +0200") References: <20241026161015.21049-1-~@wolfsden.cz> Date: Sat, 26 Oct 2024 19:22:46 +0200 Message-ID: <87ed42vkwp.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74031 Cc: 74031 <at> debbugs.gnu.org, lloda <lloda@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) Hi, (Cc: lloda.) Tomas Volf <~@wolfsden.cz> 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 b= e a > real number, and used it for comparing both real parts and imaginary part= s. > > 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=E2=80=99.
bug-guile@HIDDEN
:bug#74031
; Package guile
.
Full text available.Received: (at submit) by debbugs.gnu.org; 26 Oct 2024 16:11:00 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 26 12:11:00 2024 Received: from localhost ([127.0.0.1]:42354 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1t4jNT-0005Cn-QQ for submit <at> debbugs.gnu.org; Sat, 26 Oct 2024 12:11:00 -0400 Received: from lists.gnu.org ([209.51.188.17]:50612) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <~@wolfsden.cz>) id 1t4jNQ-0005Cd-SW for submit <at> debbugs.gnu.org; Sat, 26 Oct 2024 12:10:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <~@wolfsden.cz>) id 1t4jMs-00060P-Dx for bug-guile@HIDDEN; Sat, 26 Oct 2024 12:10:22 -0400 Received: from wolfsden.cz ([37.205.8.62]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <~@wolfsden.cz>) id 1t4jMq-0006Je-7P for bug-guile@HIDDEN; Sat, 26 Oct 2024 12:10:22 -0400 Received: by wolfsden.cz (Postfix, from userid 104) id 1EFD93346DF; Sat, 26 Oct 2024 16:10:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1729959017; bh=O1F114eJ7v7MFRMTdIX5PqUuxypjO46l9VhNEvexM90=; h=From:To:Cc:Subject:Date; b=LTEIBFpguIY5/gWbdcigvzdNfRVO1Cmqm3B6vgvenh3OBvwwDjr4DCN7NdxIrUCKm eUl4s2OEK1DHG683NiKXewnUmgThSo2w8DljSy2jZjc16Q2AK5ym+nYt0c/RGFGtoB mkmeE1qNqE0dLJxzadzEUuKy4XIOqj+IU+G9IB60Kmp7OlD6dFFWNNXts8Rc1Fmue+ u/s/Y07MRHaMpLR6nOVD7PBuc2/Mng4hFFjoOqkwh2xFSpiw6SJL9SM/4cUFIPN6J2 YMZ9a9cRNiUJFo4RIW6nzyuabGApiSZ9DkEc8t5D6lan+W2F7elELHdFWNaagcGbXh fL5VkSx9bB1l9ys1i1u8ajxZ4iRcK/G4QM4kkUVhaHpMyfR1/1FPgIK5O4QEE4Dwih pPpoVRFDIEpw1qsFHf//uMVp0FLuioFPkHoK9SN9IHMIrWI52sw0qyf5ti9h7c1Xy/ UdUjmNa1ROq9jHSBMKDDajEcQaYOauG1FcJoTY3b19koPup4Usxfio7dBrhYrBTNwh Tn1u/E4bdticxE/XYvIIL9H2v27vjTjuOxem/bE2hR37hdEfouWSPMF/k4px5XntEO x5faOTuaSK3JkX0CGFk1JmPbjWT9JsiEFsrxoKyXH4Cux+3AFx1gLRHg3Yrrz91H4w a0fdzzRTgb7Kp9MGyfh+YJHY= X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on wolfsden X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id AE785332068; Sat, 26 Oct 2024 16:10:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1729959016; bh=O1F114eJ7v7MFRMTdIX5PqUuxypjO46l9VhNEvexM90=; h=From:To:Cc:Subject:Date; b=OX7czHiNHEKsjMQA4qkR71XVwa2ByOu8cxA7TwKfkaqPDV3vhNB9hbTZlVPRkEr2r K4xw96SPN4hTe2qv6vOC669FAWdnVxADPmzAuQqfdFFCHpiUzhw0aWG3EoCYVmKyI8 gvPX+TeIa7i57JhgHmzSi9dBXQdfzcVUabGugsXPs2tJ16yhe6/SJiVXyENLdjUz4V PqyRPVoZ3ce7jTImQ+1SCLLhfvh0BqqBltlSucl4fL9w6Wlb7Mpt7ermkzVFWBhIuw SDdtGC9yYAMzUOANR5ixqZv41EjsMRcxAmE7Lw8IIuARfNDqBRidZ4YxJteMwoldX1 Lei8vc0qCgJtZaEtNt82tD4xaHJal4HqkJZ9KhHNo00WnPeZXOcVlgfUju+CgDzTiq 4SAvBnfJFuSp4uexmYG2j9JxZ7lCxtzgsaAdljWSAoTfKHBdLqysdFKFRFWX9sStIS yBEOKdrK8Pt16GFbk6TDgPhuiB28Uz92ibtUBbUbJf8jYwUPTTb8tpSCBnJ0C68Kop djmq6/37nUBPj/vgzPozY9MCLytoDcyQRtZV7xUdandwwSCP1avunvw+KmVH+l1xNJ d2fVbsNEgVKGR0LrSvlu12QnSqzeKTeOp6n8MP8Bqx58y6Xrzj7arMzpQYf4SO6Fz/ WXnOVtRZ8o27lhqvmkK+8mOY= From: Tomas Volf <~@wolfsden.cz> To: bug-guile@HIDDEN Subject: [PATCH] srfi-64: Accept complex numbers in test-approximate. Date: Sat, 26 Oct 2024 18:07:06 +0200 Message-ID: <20241026161015.21049-1-~@wolfsden.cz> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=37.205.8.62; envelope-from=~@wolfsden.cz; helo=wolfsden.cz X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: Tomas Volf <~@wolfsden.cz> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.3 (--) 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? module/srfi/srfi-64.scm | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/module/srfi/srfi-64.scm b/module/srfi/srfi-64.scm index 1f60a72e5..5fc23e28a 100644 --- a/module/srfi/srfi-64.scm +++ b/module/srfi/srfi-64.scm @@ -776,8 +776,16 @@ Test whether result of @var{test-expr} matches @var{expected} using (define (within-epsilon ε) (λ (expected actual) - (and (>= actual (- expected ε)) - (<= actual (+ expected ε))))) + (let ((e-r (real-part expected)) + (e-i (imag-part expected)) + (a-r (real-part actual)) + (a-i (imag-part actual)) + (ε-r (real-part ε)) + (ε-i (imag-part ε))) + (and (>= a-r (- e-r ε-r)) + (<= a-r (+ e-r ε-r)) + (>= a-i (- e-i ε-i)) + (<= a-i (+ e-i ε-i)))))) (define-syntax %test-approximate (λ (x) @@ -808,6 +816,10 @@ Test whether result of @var{test-expr} matches @var{expected} using Test whether result of @var{test-expr} is within @var{error} of @var{expected}. +As implementation extension, complex numbers are supported as well. It tests +whether real parts are within @code{(real-part @var{error})}, and imaginary +parts within @code{(imag-part @var{error})}. + @end defspec") (define-syntax %test-error -- 2.46.0
Tomas Volf <~@wolfsden.cz>
:bug-guile@HIDDEN
.
Full text available.bug-guile@HIDDEN
:bug#74031
; Package guile
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.