# [Numpy-discussion] matrix indexing question

Charles R Harris charlesr.harris@gmail....
Fri Mar 30 00:16:26 CDT 2007

```On 3/29/07, Timothy Hochberg <tim.hochberg@ieee.org> wrote:
>
>
>
> On 3/29/07, Bill Baxter <wbaxter@gmail.com> wrote:
> >
> > On 3/30/07, Timothy Hochberg <tim.hochberg@ieee.org> wrote:
> > > Note, however that you can't (for instance) multiply column vector
> > with
> > > a row vector:
> > >
> > > >>> (c)(r)
> > > Traceback (most recent call last):
> > >   ...
> > > TypeError: Cannot matrix multiply columns with anything
> > >
> >
> > That should be allowed.  (N,1)*(1,M) is just an (N,M) matrix with
> > entries C[i,j] = A[i,0]*B[0,]
>
>
> I thought about that a little, and while I agree that it could be allowed,
> I'm not sure that it should be allowed. It's a trade off between a bit of
> what I would guess is little used functionality with some enhanced error
> checking (I would guess that usually row*column signals a mistake). However,
> I don't care much one way or the other; it's not hard to allow.
>

It's really a sort of tensor product, so use outer(.,.). In my mind, row and
column vectors are *not* matrices, they only have a single dimension. On the
other hand (r)(c) is really the application of the dual vector r (a
functional) to the vector c, i.e., r is a map from vectors into the reals
reasonable.

I kind of like the idea of using call for multiply, though.  If it
> > doesn't turn out to have any major down sides it could be a good way
> > to give ndarray a concise syntax for "dot".
>
>
Hmmm, have to try it a bit to see how it looks. Overall, I like this
approach.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070329/a8fbacc7/attachment.html
```