Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation)

David M. Cooke cookedm at physics.mcmaster.ca
Mon Jul 17 17:39:33 EDT 2000


At some point, hzhu at localhost.localdomain (Huaiyu Zhu) wrote:

> On Mon, 17 Jul 2000 14:12:02 -0500, Paul Prescod <paul at prescod.net> wrote:
> 
> >Maybe you should consider how to scale back your syntactic request.
> >Perhaps a single keyword or symbol at the beginning of an expression
> >could make it element-wise or matrix-wise.
> 
> Well, that would be fine if it is workable, ie, when they don't appear in
> the same expression.  
> 
> Consider the proposal of having two classes, Matrixwise and Elementwise,
> with methods to cast to each other.  I don't know why
> 
> (a.E()*b.E()).M()*(c.E()*d.E()).M()
> 
> would be more preferable to 
> 
> (a.*b)*(c.*d)

Well, it doesn't have to be as complicated as your first example. Assume
the default is Matrixwise, and we get rid of some ()'s by overriding
__getattr__, so that we can right

(a.E*b.E)*(c.E*d.E)

Better? It's not great, you have to remember to put .E on both. Ahh!
But what if we assume that if one operand has .E, the other does also!
Then we can write

(a.E*b)*(c.E*d)

which is two characters more than your second example.

-- 
|>|\/|<
----------------------------------------------------------------------------
David M. Cooke
cookedm at mcmaster.ca



More information about the Python-list mailing list