Discussion: new operators for numerical computation

Huaiyu Zhu hzhu at localhost.localdomain
Thu Jul 20 19:23:14 EDT 2000


On Thu, 20 Jul 2000 18:12:18 -0400, Paul Barrett <Barrett at STScI.Edu> wrote:
>
>The one issue that concerns me about this discussion is the continued narrow
>focus to emulate Matlab syntax to the exclusion of more general N-dimensional
>operations.  I can see the need for some more general operators, but I'm not
>for any of this, if all we're doing is defining 2-D Matlab syntax.   I
>suggest the Matlab people take a look at APL or J to get a broader
>perspective of array languages.

As far as I'm aware, multiarray necessarily involves indices.  So infix
operators are not so useful, until a class with index labels are defined.
This means

a.label(1,2,3,6) * b.label(1,4,2,5,7)

would do what's written on paper as

a_ijkl * b^imjcnp

and gives a tensor similar to c.label(3,6,4,5,7).  But once you are dealing
with such classes, you'd be implementing a lot of other methods and
redefining __mul__ anyway.  You might even need a way to distinguish
covariant and contravariant indices. The infix notation itself would
certainly not be the main issue.

The only default meaning for tensor inner product I would agree was what
Greg Lielens proposed, effectively,

a*b  == a.label(1,2,3,4)*b.label(4,5,6,7,8)

But this is the same as the matrix notation. 

OTOH, would you care to give a brief summary of how these other languages
deal with these issues?  It may indeed provide valuable insight.

Huaiyu



More information about the Python-list mailing list