From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14706 invoked by alias); 22 Nov 2007 11:40:11 -0000 Received: (qmail 14697 invoked by uid 22791); 22 Nov 2007 11:40:11 -0000 X-Spam-Check-By: sourceware.org Received: from smtp3.smtp.bt.com (HELO smtp3.smtp.bt.com) (217.32.164.138) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 22 Nov 2007 11:38:17 +0000 Received: from E03MVB2-UKBR.domain1.systemhost.net ([193.113.197.108]) by smtp3.smtp.bt.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 22 Nov 2007 11:38:14 +0000 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: Not clear to understand :) Date: Thu, 22 Nov 2007 11:40:00 -0000 Message-ID: <6546343904687E41B19D8E5A26AB9F530175DA0C@E03MVB2-UKBR.domain1.systemhost.net> In-Reply-To: <1195731261.5477.14.camel@localhost.localdomain> From: To: Mailing-List: contact gsl-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gsl-discuss-owner@sourceware.org X-SW-Source: 2007-q4/txt/msg00036.txt.bz2 These are *not* equivalent in floating point, of course. The first is bett= er.=20=20=20 Even better: for (i =3D 1; i <=3D n; i++) { m_x +=3D (x[i * xstride] - m_x) / i; m_y +=3D (y[i * ystride] - m_y) / i; } Keith -----Original Message----- From: gsl-discuss-owner@sourceware.org [mailto:gsl-discuss-owner@sourceware.org]On Behalf Of Serhiy Lisovenko Sent: 22 November 2007 11:34 To: gsl-discuss@sourceware.org Subject: Not clear to understand :) in file fit/linear.c for (i =3D 0; i < n; i++) { m_x +=3D (x[i * xstride] - m_x) / (i + 1.0); m_y +=3D (y[i * ystride] - m_y) / (i + 1.0); } and other same... code equivalent to for (i =3D 0; i < n; i++) { m_x +=3Dx[i * xstride]; m_y +=3Dy[i * ystride]; } m_x/=3D(double)n; m_y/=3D(double)n; But the second code is more clear and some faster (no extra divisions).