[Numpy-discussion] matrix indexing question

Bill Baxter wbaxter@gmail....
Fri Mar 30 00:46:32 CDT 2007


On 3/30/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 useful for many things.

You can use it in the computation of the least squares best fits
between sets of points.  The sum of   p_i p_^t  comes up in that
context.  (Which is also the covariance matrix of the points)

The derivative of a unit vector (useful for mass spring dynamics
calcs, among other things, I'm sure) is given by something like   c *
(I - x x^t).

Householder reflections are useful for a lot of things such as
implementing QR factorization.  They're given by :  H = I - 2 x x^t /
x^t x
http://www.cs.ut.ee/~toomas_l/linalg/lin2/node6.html

I'm positive I've seen col * row come up in other contexts too, though
I can't think of any other particulars right now.

--bb


More information about the Numpy-discussion mailing list