Discussion: new operators for numerical computation

Konrad Hinsen hinsen at cnrs-orleans.fr
Mon Jul 24 11:07:52 EDT 2000


Robin Becker <robin at jessikat.fsnet.co.uk> writes:

> outer products (of vectors at least) are inner products with the second
> vector being transposed. There is of course a general tensor notation,

I think I understand what you mean, but then this statement is only
true if you make a number of assumptions about vector representations
and array matching rules, some of which are not true in NumPy.

There are two schools of vector/matrix representations:

1) Vectors are rank-1 arrays, matrices are rank-2 arrays.
   Consequence: the transpose of a vector is the same vector.
   This is the approach used in NumPy as well as in APL and some
   other array languages.

2) Vectors exist in two varieties, "row" and "column" vectors.
   Row vectors are matrices with one row, and column vectors are
   matrices with one column. The transpose of a row vector is a
   column vector and vice versa.
   This is the approach used in MatLab, but not in NumPy.
   Of course any NumPy user is free to use Nx1 and 1xN-matrices
   to represent vectors, but this requires a lot of effort, because
   all vector-generating functions return rank-1 arrays.

Your statement only makes sense in the second framework.

> One thing I personally find very strange is that very few in this thread
> seem to want to make the default multiplication operation * into the
> default matrix multiply. I suppose early language designers have decided
> this for all time so all choose the unusual element wise operation.

The point is simply that NumPy uses this definition. Changing this would
mean facing the opposition of all those who have significant amounts
of NumPy code, and then there is probably no one left in favor of
the operator proposition.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
-------------------------------------------------------------------------------



More information about the Python-list mailing list