[Numpy-discussion] dot function or dot notation, matrices, arrays?

Alan G Isaac aisaac@american....
Sat Dec 19 11:17:17 CST 2009

On 12/19/2009 11:45 AM, Wayne Watson wrote:
> A 4x1, 1x7, and 1x5 would be examples of a 1D array or matrix, right?
> Are you saying that instead of using a rotational matrix  ...
> that I should use a 2-D array for rotCW? So why does numpy have a matrix
> class?  Is the class only used when working with matplotlib?
> To get the scalar value (sum of squares) I had to use a transpose, T, on
> one argument.

At this point, you have raised some long standing issues.
There are a couple standard replies people give to some of them.

1. don't use matrices, OR
2. don't mix the use of matrices and arrays

Matrices are *always* 2d (e.g., a "row vector" or a "column vector" is 2d).
So in fact you should find it quite natural that that transpose was needed.
Matrices change * to matrix multiplication and ** to matrix exponentiation.
I find this very convenient, especially in a teaching setting, so I use
NumPy matrices all the time.   Many on this list avoid them completely.

Again, if you want a *scalar* as the product of vectors for which you
created matrix objects (e.g., a and b), you can just use flat:

Alan Isaac

More information about the NumPy-Discussion mailing list