public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
* Not clear to understand :)
@ 2007-11-22 11:33 Serhiy Lisovenko
  2007-11-22 11:40 ` keith.briggs
  2007-11-22 16:13 ` Patrick Alken
  0 siblings, 2 replies; 3+ messages in thread
From: Serhiy Lisovenko @ 2007-11-22 11:33 UTC (permalink / raw)
  To: gsl-discuss

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).




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-11-22 16:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-22 11:33 Not clear to understand :) Serhiy Lisovenko
2007-11-22 11:40 ` keith.briggs
2007-11-22 16:13 ` Patrick Alken

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).