[Numpy-discussion] big picture? One proposal

Pearu Peterson peterson at math.utwente.nl
Fri Mar 8 05:05:06 EST 2002


On Fri, 8 Mar 2002, Konrad Hinsen wrote:

<snip>
> Unfortunately, I have the impression that there are two schools of
> thought in collision here (and not just when it comes to programming).
> There is the "mathematical" school that defines matrices and arrays
> as abstract entities with certain properties and associated operations.
> And there is the "engineering" school that sees arrays as a convenient
> data structure to express certain operations, of which "matrix operations"
> are a subset.

I see arrays as a convenient data structure (being implemented in
computer programs) to hold matrices (being members of a mathematical
concept).
I guess that my views are narrow-minded (but willing to widen it)
regarding to consider arrays as a mathematical concept too. Just in
mathematics I never (need to) use arrays in that way (my fields are
mathematical analysis, integrable systems, and not computer science nor
engineering). So, I also belong to the school of "mathematics", but may
be into a different one.

<snip>
> That's another point where I disagree. I use Python for many different
> uses, numerics is only one of them (though the most important one).
> Uniformity of style is an important value for me.

Me too. Just I am not too crazy about the constant style but more of if
something can be accomplished efficiently. To be honest, I don't like
programming  in Python because it has a nice style, but because I can
accomplish a lot with it in a very efficient way (and not only by using
efficient algorithms). Writing, for example, Numeric.transpose(a) instead
of a**T, a.T, a`, or whatever just reduces this efficiency.

I also realize and respect that for computer scientists (that I presume
the developers of Python are) it is crucial to have consistent style for
their reasons. Sometimes this style makes some site-specific simple tasks
too verbose to follow.

> Moreover, I claim that Python *does* provide a good solution, it is
> merely a very different one.

So, what is it?

<snip>
> Does that work? I'd expect that a**T would first call .__pow__(T)
> which quite probably crashes... (Not that it matters to me, I find
> this almost as abusive as the matrix attributes.)

Yes, it works:
>>> from Numeric import *
>>> class T: __rpow__ = lambda s,o: transpose(o)
...
>>> print array([[1,2],[3,4]]) ** T()
[[1 3]
 [2 4]]

And I don't understand why it is abusive (because it is a different
approach?). It's just an idea.

Pearu





More information about the NumPy-Discussion mailing list