diff -r 8661b9237ed5 -r 3a88e7a60b63 src/basics.h --- a/src/basics.h Fri Mar 03 00:35:43 2017 +0200 +++ b/src/basics.h Fri Mar 03 23:08:04 2017 +0200 @@ -315,3 +315,15 @@ { return ring.size(); } + +/* + * Extracts the sign of x. + */ +template +T sign(T x) +{ + if (isZero(x)) + return {}; + else + return x / qAbs(x); +}