signum() not in math?
robin at jessikat.fsnet.co.uk
Sat Oct 13 11:09:18 CEST 2001
In article <3BC7FE9B.CD190C62 at darwin.in-berlin.de>, Dinu Gherman
<gherman at darwin.in-berlin.de> writes
>Tim Peters wrote:
>The reason for people not complaining about the absence of the
>sign() function need not necessarily be that they use something
>like tanh() more often (I doubt so), but simply because they
>can write sign() with far less difficulty than tanh().
that may be so, but while some write this
if x < 0: return -1
elif x > 0: return 1
else: return 0
others might use
if x<0: return -1
else: return x>0
only an insider could tell us if the latter is guaranteed always to work
now and forever. If truth gets redefined as -1 then the second would
Also there is controversy about what the sign function should actually
Indeed the matrix sign function is a true heaviside function
(http://rkb.home.cern.ch/rkb/AN16pp/node117.html) on each element x the
result is 2*h(x)-1 ie -1 for x<0 and 1 for x>=0.
Probably python should provide both the three value signum and the two
value one and perhaps the sign transfer operation. These are so common
in maths, physics and engineering it seems wrong to have sinh() without
h() et al.
More information about the Python-list