Re: [PATCH 24/25]: Macro for moving average

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/22/07, Gerrit Renker <gerrit@xxxxxxxxxxxxxx> wrote:
[CCID 3]: Macro for moving average

The moving average computation occurs so frequently in the CCID 3 code that
it merits a macro of its own.

Signed-off-by: Gerrit Renker <gerrit@xxxxxxxxxxxxxx>
---
 net/dccp/ccids/ccid3.c    |    8 +++-----
 net/dccp/ccids/lib/tfrc.h |    8 ++++++++
 2 files changed, 11 insertions(+), 5 deletions(-)

--- a/net/dccp/ccids/lib/tfrc.h
+++ b/net/dccp/ccids/lib/tfrc.h
@@ -37,6 +37,14 @@ static inline u32 scaled_div32(u64 a, u3
        return result;
 }

+/**
+ * Macro for exponentially weighted moving average
+ * @weight: Weight to be used as damping factor, in units of 1/10
+ * Beware that @val is evaluated multiple times.
+ */
+#define TFRC_EWMA(val, newval, weight) \
+       val = val? ((weight) * val + (10 - (weight)) * (newval)) / 10 : (newval)
+
Just wondering why you pass weight when you only use 9 anyway and it
just adds a step. Is it used in following patches with a different
weight?

Ian
--
Web: http://wand.net.nz/~iam4
Blog: http://iansblog.jandi.co.nz
WAND Network Research Group
-
To unsubscribe from this list: send the line "unsubscribe dccp" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [IETF DCCP]     [Linux Networking]     [Git]     [Security]     [Linux Assembly]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux