This is the mail archive of the gsl-discuss@sourceware.org mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Not clear to understand :)


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





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]