[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
moments optimization
From: |
Ben Pfaff |
Subject: |
moments optimization |
Date: |
Mon, 05 Feb 2007 13:33:48 -0800 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) |
When I looked at src/math/moments.c earlier, it seemed like we
were doing more multiplications than necessary. I'd like to
check in the following change. It passes "make check". Any
comments?
--- moments.c.~1.4.~ 2007-02-05 13:19:12.000000000 -0800
+++ moments.c 2007-02-05 13:25:17.000000000 -0800
@@ -166,23 +166,24 @@ moments_pass_two (struct moments *m, dou
{
m->w2 += weight;
- d = d_power = value - m->mean;
- m->d1 += d_power * weight;
+ d = value - m->mean;
+ d_power = d * weight;
+ m->d1 += d_power;
if (m->max_moment >= MOMENT_VARIANCE)
{
d_power *= d;
- m->d2 += d_power * weight;
+ m->d2 += d_power;
if (m->max_moment >= MOMENT_SKEWNESS)
{
d_power *= d;
- m->d3 += d_power * weight;
+ m->d3 += d_power;
if (m->max_moment >= MOMENT_KURTOSIS)
{
d_power *= d;
- m->d4 += d_power * weight;
+ m->d4 += d_power;
}
}
}
--
Ben Pfaff
address@hidden
http://benpfaff.org
- moments optimization,
Ben Pfaff <=