signum() not in math?

Robin Becker robin at jessikat.fsnet.co.uk
Sat Oct 13 09:20:45 EDT 2001


In article <3BC812DE.8C6C260 at darwin.in-berlin.de>, Dinu Gherman
<gherman at darwin.in-berlin.de> writes
>> 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.
>
>One free pint! ;-) Well, yes a general step() function could 
>be useful, too, maybe like this, even if you don't find it 
>usually in entry-level math textbooks:
>
>  def step(x, x0=0):
>      "Generalised Heaviside step function."
>
>      if x < x0: 
>          return 0
>      else:
>          return 1
well as a Heaviside award winner I presumably should be expected to know
about such arcana ;)
-- 
Robin Becker



More information about the Python-list mailing list