[MATRIX-SIG] -3**(-1/3.), sgn()
Jean-Bernard ADDOR
jbaddor@phy.ulaval.ca
Thu, 24 Jul 1997 13:42:01 -0400 (EDT)
What I meant was :
def sgn(a):
return 2*Numeric.greater_equal(a,0) - 1
I don't know which one is better (faster, without using too much memory).
Your give sgn(0)=0 what is better that sgn(0)=1 for mine, but for my
application it doesn't change anythink.
Jean-Bernard
On Thu, 24 Jul 1997, Timothy A. Hochberg wrote:
> On Thu, 24 Jul 1997, Jean-Bernard ADDOR wrote:
>
> > I would like to write sgn(a)*abs(a)**(-1/3.) but the sgn function seems
> > not to be defined in python (perhaps because it is not in c, but it is in
> > fortran). I can use greater_equal. Do you have a better solution ?
>
> For what it's worth, sgn(x) can be implemented as:
>
> def sgn(x):
> return greater_equal(x,0) - less_equal(x,0)
>
> (or is that what you meant by use greater equal?)
>
> ____
> /im
>
> +------------------------------------------------+
> |Tim Hochberg Research Assistant |
> |hochberg <at> wwa.com University of Illinois |
> | Electrical Engineering |
> +------------------------------------------------+
>
>
_______________
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________