[SciPy-dev] New in fastumath ~ (means conjugate on floats and complex numbers)

Pearu Peterson pearu at cens.ioc.ee
Sun Feb 24 02:50:07 CST 2002


On Sun, 24 Feb 2002, eric wrote:

> > I finally realized that with a simple change we can use the unary operator on
> > floats and complex numbers to mean complex conjugation.

Is it as easy for integers?

> > Is the added convenience worth the possible confusion?  The problem is that
> > complex conjugation happens all the time, but bitwise inversion rarely. 
> -1

Yes, I think so too. But see below.

> I like the idea of having a conjugate operator, but this introduces a dangerous
> ambiguity.  There are many times where arrays are passed around without regard
> for their numeric typecode.  If an integer array is passed into some function
> that does a conjugate, a bit inversion occurs instead and silently produces
> invalid results.  Are there any other symbols available?

No, I think there are not. This is one shortcomings in Python language
that one cannot define new operators.

However, note that all scipy functions should apply
  asarray()
to its arguments and if we assume that one never needs bitwise operations
within scipy, then scipy specific asarray() function could set some flag
to this array saying that ~ operator means complex conjugate also for
integer arrays, otherwise ~(integer array) is array(~integers). I am not
sure if Numeric then needs a patch for that.

Just an idea.. as I see already -4 for Travis patch.

Regards,
	Pearu





More information about the Scipy-dev mailing list