Message ID | LO4P265MB59145B0C9C2889DFD7498E5C80C3A@LO4P265MB5914.GBRP265.PROD.OUTLOOK.COM |
---|---|
State | New |
Headers |
Return-Path: <newlib-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E881F385C6E9 for <patchwork@sourceware.org>; Tue, 26 Sep 2023 11:07:37 +0000 (GMT) X-Original-To: newlib@sourceware.org Delivered-To: newlib@sourceware.org Received: from mx08-00376f01.pphosted.com (mx08-00376f01.pphosted.com [91.207.212.86]) by sourceware.org (Postfix) with ESMTPS id CEC3F3858D35 for <newlib@sourceware.org>; Tue, 26 Sep 2023 11:07:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CEC3F3858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=imgtec.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=imgtec.com Received: from pps.filterd (m0168888.ppops.net [127.0.0.1]) by mx08-00376f01.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 38Q7o2bQ000911 for <newlib@sourceware.org>; Tue, 26 Sep 2023 12:07:25 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=imgtec.com; h= from:to:subject:date:message-id:content-type:mime-version; s= dk201812; bh=KMsJDM0BMFEs2RNXmLbeSASFOVgneeV/gIgTsYqBMZs=; b=ihu y35Y6199FHoREzk4LW7BERPnU0a73lRSxC/UmMsBsi33+YNNV6tG1NQuhF0RmTTG usmSUZmkY0ix7daJMb1yCIht2unOJsA6X/bzoKCQFUTIs4hkunC313s5IDOlXacs 1VMM7iHfm5gimc8d47fep4B7OP3KqpUMeVneTtR+r26cGsN8hQowqBPVsEGiD54z VRyk9FhWbEYrABpoRVvNNB168EcQjhaFmqZVOjLCNDP2gsPwN8msXFdow84IeyeF B/fIJpkxSL4ru/ZaTQ6JpFdryW1UIWuzpjJUG8Yjnfi9d2TYMsFpfMbvUVJvMIr6 hru2sgelCEktCbaScMQ== Received: from hhmail05.hh.imgtec.org ([217.156.249.195]) by mx08-00376f01.pphosted.com (PPS) with ESMTPS id 3t9p9p2a1b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for <newlib@sourceware.org>; Tue, 26 Sep 2023 12:07:25 +0100 (BST) Received: from HHMAIL04.hh.imgtec.org (10.100.10.119) by HHMAIL05.hh.imgtec.org (10.100.10.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 26 Sep 2023 12:07:11 +0100 Received: from GBR01-CWX-obe.outbound.protection.outlook.com (104.47.85.41) by email.imgtec.com (10.100.10.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31 via Frontend Transport; Tue, 26 Sep 2023 12:07:11 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q3kQA9CHlexU9IJOrd9xVvmET9kn8PM/UPduJuNGPsbgOHO11TR83/k+EHXElk8srD21Uu1dPeonD38QapmV6JtjD17PH1OdKhzBoreVqOgDTg3zUHBa4A9TWbu4sdqIfZlMnYKg3/ZKgF0ge/wpdJ5xDza9lSTuLVd8bDx/Z4UPklSSMUI9hv3LfChD6LBGOC0UwQVuNMaqa3vNiPnGGYKhbJaS6BQhnkF1FOZvMkB9K6nPnOrzg0IzeUiFMCbCcLVPKdQ7GxslkkScB50lKkKbj6xyo3vAoLq3qfLt1iToPeBwqufduueVOa6Br5/wkfEeiSCjoyqVQ/aGY8Cosg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KMsJDM0BMFEs2RNXmLbeSASFOVgneeV/gIgTsYqBMZs=; b=NC91q/2FnHOMm53YcJwS/fF3joMM5L2+5GBIlenfYHEKFRE71C6ZvCnbd1/SDSTnMk35wtmsKZowtZ3A5ivLQTLz3TP7Qwz+Gyf9J2d2cJDzdPzQaiF94cds4XdOGhNHAu8j5jyL5qmNQM4o3jbZJTjIeNVSJ0W7mdGZr6iL6B7c0ew/MXn38yXV02r5WNCSY4u2a4t4yyxvOhqDInQI4wGk0WUI04tJtidxYxc1ztifgHXy8tr315512fcOgZPgWfPTnD1J92X83csPzWg0zeAFWvqsSZWgAY4GmJb/XG/gETkOwiURAZ/uEZDWHy4kkFhurI6+OGurG2Wb24nr0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=imgtec.com; dmarc=pass action=none header.from=imgtec.com; dkim=pass header.d=imgtec.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=IMGTecCRM.onmicrosoft.com; s=selector2-IMGTecCRM-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KMsJDM0BMFEs2RNXmLbeSASFOVgneeV/gIgTsYqBMZs=; b=JbqUvq5LEblsgg1WDZ5pbcsmItzlvhbjwv6IopHt8deMjxdn/3jnvEHov8mopk9Z6OP/3UNGSpn9m2PNwAiqMyfRAuCNKPWPCYF0TrCXdnxmlfY7ohI+tW6AFGCOVJxDEgDydePBQB5d5YfxFtOrAJCNBz410awzxVHHtseAaxc= Received: from LO4P265MB5914.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:29f::11) by LOYP265MB2047.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:114::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.28; Tue, 26 Sep 2023 11:07:11 +0000 Received: from LO4P265MB5914.GBRP265.PROD.OUTLOOK.COM ([fe80::3fac:2722:f9cf:2f39]) by LO4P265MB5914.GBRP265.PROD.OUTLOOK.COM ([fe80::3fac:2722:f9cf:2f39%4]) with mapi id 15.20.6813.027; Tue, 26 Sep 2023 11:07:10 +0000 From: Joseph Faulls <Joseph.Faulls@imgtec.com> To: "newlib@sourceware.org" <newlib@sourceware.org> Subject: [PATCH 1/1] newlib: libm: fix complex atan for +/- 1 + 0i Thread-Topic: [PATCH 1/1] newlib: libm: fix complex atan for +/- 1 + 0i Thread-Index: AdnwaTdJham5JY5IQfile86zmuCWMQ== Date: Tue, 26 Sep 2023 11:07:10 +0000 Message-ID: <LO4P265MB59145B0C9C2889DFD7498E5C80C3A@LO4P265MB5914.GBRP265.PROD.OUTLOOK.COM> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: LO4P265MB5914:EE_|LOYP265MB2047:EE_ x-ms-office365-filtering-correlation-id: d3365f18-9e7f-4cee-a18e-08dbbe80bb25 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: h2FoTHdTLuaxjoD6/ToaxWJJweVHXwiwQMVW+fMiv6iWpGiIkY3P8auXdMm0afkhmoPMCy0ThNQ/xGgaKrJuugnxCGPkWcEKTK9rP4O2m/FWhnHxOP53qkOWPa3srhxsfxvQxjiTlcWilbWgSN2ifpOdcdCqFb6yZBQqrBLR0r09+RG3r4BLMUzNx4MrGdAYhJQoPwA4Unq/TxWzTbQFDwqz+QdgUbQyOIvol3z8YsPzDhV4/XauIE7ia9RdYIbE/nzbAg/qRx2nh69KZBnDcd5MJAjCgL62O1ja87J3DHpsnNg10NPg1Q1v710Pi1wK3jK793ufOToT1yb6Cc9ywuvR2n30u5GVyVJSTETL0ft/K6oDli+/Pl8qC+fbVkamuxe1B/dOax9wC9aAJohR6RgyI65d1x56SDUnHn9TyeHfEmQycGxxU7cuIh99ZECfhkt+plHbnut9n1I2CdYJqNNWpr2LHwVdqzbEUPXvPV/RChXqsvFhWnYdeq96O1bhnOVsLe3f79+eg7UCdhuPL1MozIrFBoTLhobpwvTV3r3Af2YwAOSNuFBfEkOplfBgalYT9U8f53A3aZIo4LdiCOZI1D67Jh+WJ1KAaqU6SZGsDsTN6Mx1egecUkhZ2pR8 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:LO4P265MB5914.GBRP265.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230031)(396003)(376002)(366004)(39850400004)(346002)(136003)(230922051799003)(451199024)(1800799009)(186009)(8676002)(8936002)(55016003)(26005)(52536014)(2906002)(4744005)(478600001)(66476007)(41300700001)(76116006)(316002)(6916009)(66446008)(66946007)(66556008)(5660300002)(64756008)(6506007)(7696005)(71200400001)(9686003)(83380400001)(33656002)(38070700005)(122000001)(86362001)(38100700002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: qHUhYbGq7vnuiFcL07R4nUkW+UL/bThxxb9gWNRM+RJ7M8LG8YybRaCJ6LMNFhE7Yo3hEvm1MmYs+qRrAI9sJ3tL5AlicF1tBb4/+NEG9iceLXdgo24mt1c57EJOWjXhIyqWMS8PY2AS/DuRRHaVODQSYjoBcJYnBhnvrZwpbTNTKChwFsj3pY7jAITPZOEdx3gT48f8ZKirExoo+h06b7ZZZ++dY/0AxeDcArelfVa9nGXUXyUDSWTGqwiQbiudrX5lv1nyw2/ksKfUWiEzQj6z1peRyrvAxNsf0PMb1hwLVXIj6EIqUYdTnPu6AZENdUEZz55OBjecN3penaQuHg8IKJqvPNaUmeXtZVhNK9dyhhBoFVQAWFCaSOqSRULagONSMh3INdw/ex2Te4QAyjZROm7qPEj6adWu21Qe/epNdjNgeW2YbxYNyqpyHgfF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FCNTkFHoi2OIWHrR/kNlkYz+nFp5lyP7gCdP4zMpMI6jqmuvIXiBazvu1fW9Uz MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: LO4P265MB5914.GBRP265.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: d3365f18-9e7f-4cee-a18e-08dbbe80bb25 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Sep 2023 11:07:10.7557 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0d5fd8bb-e8c2-4e0a-8dd5-2c264f7140fe X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: gJw2rSYH2jtuAO3eGZIViIHy2FCh8HqQaNA2e/CKRSJY5hw81qFgbt7nLp5uLefQ4QRWIHHd/m1TmWigyLDfUBfaPafOPvffxUI0qEP93V0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LOYP265MB2047 X-OriginatorOrg: imgtec.com X-EXCLAIMER-MD-CONFIG: 15a78312-3e47-46eb-9010-2e54d84a9631 X-Proofpoint-ORIG-GUID: -v6-1Fpcq7G9y8wTyR5N-ttK9o7Za8FW X-Proofpoint-GUID: -v6-1Fpcq7G9y8wTyR5N-ttK9o7Za8FW X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.30 X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Newlib mailing list <newlib.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/newlib>, <mailto:newlib-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/newlib/> List-Post: <mailto:newlib@sourceware.org> List-Help: <mailto:newlib-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/newlib>, <mailto:newlib-request@sourceware.org?subject=subscribe> Errors-To: newlib-bounces+patchwork=sourceware.org@sourceware.org Sender: "Newlib" <newlib-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
[1/1] newlib: libm: fix complex atan for +/- 1 + 0i
|
|
Commit Message
Joseph Faulls
Sept. 26, 2023, 11:07 a.m. UTC
Delete check which ensured atan2 was not called with x=0. This is not necessary as atan2 is defined for x=0 when y != 0. The check incorrectly resulted in catan returning nan + inf i for when real part is +/- 1 and imaginary part is 0. The check could also have implications when called with imaginary number x + yi where x^2 + y^2 == 1.0. Although this is unlikely due to floating point precision. --- newlib/libm/complex/catan.c | 2 -- 1 file changed, 2 deletions(-) -- 2.34.1
Comments
Ping
From: Joseph Faulls
Sent: Tuesday, September 26, 2023 12:07 PM
To: newlib@sourceware.org
Subject: [PATCH 1/1] newlib: libm: fix complex atan for +/- 1 + 0i
Delete check which ensured atan2 was not called with x=0. This is not
necessary as atan2 is defined for x=0 when y != 0. The check incorrectly
resulted in catan returning nan + inf i for when real part is +/- 1 and
imaginary part is 0.
The check could also have implications when called with imaginary number
x + yi where x^2 + y^2 == 1.0. Although this is unlikely due to floating
point precision.
---
newlib/libm/complex/catan.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/newlib/libm/complex/catan.c b/newlib/libm/complex/catan.c
index 77510ec2f..34d75b849 100644
--- a/newlib/libm/complex/catan.c
+++ b/newlib/libm/complex/catan.c
@@ -105,8 +105,6 @@ catan(double complex z)
x2 = x * x;
a = 1.0 - x2 - (y * y);
- if (a == 0.0)
- goto ovrf;
t = 0.5 * atan2(2.0 * x, a);
w = _redupi(t);
--
2.34.1
Hi Joseph, Sorry for the delay. I did a check and the current NetBSD sources still have that check in them and that was where this code was taken from. However, I created a test case and tried it with glibc and also tested with newlib versions of catan/catanf minus the checks. They match without the check so I pushed the change to all 3 of the catan functions. -- Jeff J. On Mon, Oct 9, 2023 at 6:47 AM Joseph Faulls <Joseph.Faulls@imgtec.com> wrote: > Ping > > > > *From:* Joseph Faulls > *Sent:* Tuesday, September 26, 2023 12:07 PM > *To:* newlib@sourceware.org > *Subject:* [PATCH 1/1] newlib: libm: fix complex atan for +/- 1 + 0i > > > > Delete check which ensured atan2 was not called with x=0. This is not > > necessary as atan2 is defined for x=0 when y != 0. The check incorrectly > > resulted in catan returning nan + inf i for when real part is +/- 1 and > > imaginary part is 0. > > > > The check could also have implications when called with imaginary number > > x + yi where x^2 + y^2 == 1.0. Although this is unlikely due to floating > > point precision. > > --- > > newlib/libm/complex/catan.c | 2 -- > > 1 file changed, 2 deletions(-) > > > > diff --git a/newlib/libm/complex/catan.c b/newlib/libm/complex/catan.c > > index 77510ec2f..34d75b849 100644 > > --- a/newlib/libm/complex/catan.c > > +++ b/newlib/libm/complex/catan.c > > @@ -105,8 +105,6 @@ catan(double complex z) > > > > x2 = x * x; > > a = 1.0 - x2 - (y * y); > > - if (a == 0.0) > > - goto ovrf; > > > > t = 0.5 * atan2(2.0 * x, a); > > w = _redupi(t); > > -- > > 2.34.1 >
diff --git a/newlib/libm/complex/catan.c b/newlib/libm/complex/catan.c index 77510ec2f..34d75b849 100644 --- a/newlib/libm/complex/catan.c +++ b/newlib/libm/complex/catan.c @@ -105,8 +105,6 @@ catan(double complex z) x2 = x * x; a = 1.0 - x2 - (y * y); - if (a == 0.0) - goto ovrf; t = 0.5 * atan2(2.0 * x, a); w = _redupi(t);