diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-01-25 16:56:05 +0100 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-01-25 16:56:05 +0100 |
| commit | 2debbbe6e70b66357fa510850b57c47406a87249 (patch) | |
| tree | ffd945e7d9d88d265ae97ea0da8932f541180014 | |
| parent | Update todo (diff) | |
| download | blind-2debbbe6e70b66357fa510850b57c47406a87249.tar.gz blind-2debbbe6e70b66357fa510850b57c47406a87249.tar.bz2 blind-2debbbe6e70b66357fa510850b57c47406a87249.tar.xz | |
blind-arithm: add abs
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
| -rw-r--r-- | man/blind-arithm.1 | 7 | ||||
| -rw-r--r-- | src/blind-arithm.c | 3 |
2 files changed, 8 insertions, 2 deletions
diff --git a/man/blind-arithm.1 b/man/blind-arithm.1 index 048fa0a..df5887f 100644 --- a/man/blind-arithm.1 +++ b/man/blind-arithm.1 @@ -50,13 +50,18 @@ is the value of the right-hand operand. .TP .B log Calculate the logarithm of the left-hand operand -and divid it by the logarithm of the rigth-hand operand. +and divide it by the logarithm of the rigth-hand operand. .TP .B min Select the lowest operand. .TP .B max Select the highest operand. +.TP +.B abs +Calculate the the sum of absolute value of the left-hand +operand subtracted by the right-hand operand, and the +right-hand operand .SH OPTIONS .TP .B -a diff --git a/src/blind-arithm.c b/src/blind-arithm.c index 2ac1652..bc30bee 100644 --- a/src/blind-arithm.c +++ b/src/blind-arithm.c @@ -26,7 +26,8 @@ typedef void (*process_func)(struct stream *left, struct stream *right, size_t n X(exp, *lh = pow(*lh, rh))\ X(log, *lh = log(*lh) / log(rh))\ X(min, *lh = *lh < rh ? *lh : rh)\ - X(max, *lh = *lh > rh ? *lh : rh) + X(max, *lh = *lh > rh ? *lh : rh)\ + X(abs, *lh = fabs(*lh - rh) + rh) #define X(NAME, ALGO)\ static void\ |
