This is the mail archive of the
gsl-discuss@sourceware.org
mailing list for the GSL project.
Not clear to understand :)
- From: Serhiy Lisovenko <lisovenko dot s at gmail dot com>
- To: gsl-discuss at sourceware dot org
- Date: Thu, 22 Nov 2007 13:34:21 +0200
- Subject: Not clear to understand :)
- Reply-to: lisovenko dot s at gmail dot com
in file fit/linear.c
for (i = 0; i < n; i++)
{
m_x += (x[i * xstride] - m_x) / (i + 1.0);
m_y += (y[i * ystride] - m_y) / (i + 1.0);
}
and other same...
code equivalent to
for (i = 0; i < n; i++)
{
m_x +=x[i * xstride];
m_y +=y[i * ystride];
}
m_x/=(double)n;
m_y/=(double)n;
But the second code is more clear and some faster (no extra divisions).