[Numpy-discussion] matrix default to column vector?

Charles R Harris charlesr.harris at gmail.com
Sat Jun 6 16:32:46 EDT 2009


On Sat, Jun 6, 2009 at 1:59 PM, Alan G Isaac <aisaac at american.edu> wrote:

> On 6/6/2009 2:58 PM Charles R Harris apparently wrote:
> > How about the common expression
> > exp((v.t*A*v)/2)
> > do you expect a matrix exponential here?
>
>
> I take your point that there are conveniences
> to treating a 1 by 1 matrix as a scalar.
> Most matrix programming languages do this, I think.
> For sure GAUSS does.  The result of   x' * A * x
> is a "matrix" (it has one row and one column) but
> it functions like a scalar (and even more,
> since right multiplication by it is also allowed).
>

It's actually an inner product and the notation <x, A*x> would be
technically correct. More generally, it is a bilinear function of two
vectors. But the correct notation is a bit cumbersome for a student
struggling with plain old matrices ;)

Ndarrays are actually closer to the tensor ideal in that M*v would be a
contraction removing two indices from a three index tensor product. The
"dot" function, aka *, then functions as a contraction. In this case x.T*A*x
works just fine because A*x is 1D and x.T=x, so the final result is a scalar
(0D array). So making vectors 1D arrays would solve some problems. There
remains the construction v*v.T, which should really be treated as a tensor
product, or bivector.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090606/c8b815ff/attachment.html>


More information about the NumPy-Discussion mailing list