[MATRIX-SIG] umath.logical_blah vs normal python functions.

Chase, Christopher J (Chris), NNAD chase@att.com
Thu, 20 Nov 1997 16:36:06 -0500


I use these kinds of selection games all the time in other languages.
But with the NumPy choose() function this type of idiom is probably not
needed.

Chris

>----------
>From: 	Moore, Paul[SMTP:Paul.Moore@uk.origin-it.com]
>Sent: 	Wednesday, November 19, 1997 4:54 AM
>To: 	'David J. C. Beach'
>Cc: 	'Matrix SIG'
>Subject: 	RE: [MATRIX-SIG] umath.logical_blah vs normal python functions.
>
>One advantage of an and/or which returns 1 or 0 is that you can play
>games with it, like multiply it by a constant. Consider
>
>   a * logical_and(a,b)
>
>which gives the same values as a where b is nonzero, but zero where b is
>zero. This is the sort of game that gets played in APL all the time....
>(OK, this isn't a very good example, but I can't make up a realistic
>case offhand).
>
>Paul.
>_______________________________________________________
>Paul Moore
>Oracle Development Team,
>Business Application Management, Origin UK (Runcorn).
>Tel :  +44 (0)1928  511065
>Fax : +44 (0)1928  515020
>e-mail : paul.moore@uk.origin-it.com
>
>
>>----------
>>From: 	David J. C. Beach[SMTP:beach@verinet.com]
>>Sent: 	19 November 1997 07:36
>>To: 	richard.jones@bom.gov.au; Matrix SIG
>>Subject: 	Re: [MATRIX-SIG] umath.logical_blah vs normal python functions.
>>
>>Richard Jones wrote:
>>
>>>     Yes, but they're different to what Python does. Well, the && case is
>>> different. Do we need a further umath.python_and that does what Python
>>> programmers expect???
>>
>>A good point.  Perhaps what we really want, then, is this:
>>
>>umath.bitwise_and = the C (or Python) operator, &
>>umath.logical_and = the Python 'and' operator
>>
>>etc.
>>
>>After reconsidering it, it seems that a logical_and that returns only a 0 or
>>1
>>doesn't have any significant advantages over Python's 'and', which can be
>>used
>>to selectively evaluate a construct, return the truth value of the logical
>>and, or to selectively give a return value for the last true argument.
>>
>>Dave
>>
>>--
>>David J. C. Beach
>>Colorado State University
>>mailto:beach@verinet.com
>>http://www.verinet.com/~beach
>>
>>
>>
>>
>>_______________
>>MATRIX-SIG  - SIG on Matrix Math for Python
>>
>>send messages to: matrix-sig@python.org
>>administrivia to: matrix-sig-request@python.org
>>_______________
>>
>
>_______________
>MATRIX-SIG  - SIG on Matrix Math for Python
>
>send messages to: matrix-sig@python.org
>administrivia to: matrix-sig-request@python.org
>_______________
>
>

_______________
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________