[Numpy-discussion] defmatrix.py

Colin J. Williams cjw@sympatico...
Tue Mar 27 13:08:12 CDT 2007


Charles R Harris wrote:
> 
> 
> On 3/26/07, *Travis Oliphant* <oliphant@ee.byu.edu 
> <mailto:oliphant@ee.byu.edu>> wrote:
> 
> 
>      > I think that might be the simplest thing, dot overrides subtypes.
>     BTW,
>      > here is another ambiguity
>      >
>      > In [6]: dot(array([[1]]),ones(2))
>      >
>     ---------------------------------------------------------------------------
> 
>      > exceptions.ValueError                                Traceback (most
>      > recent call last)
>      >
>      > /home/charris/<ipython console>
>      >
>      > ValueError: matrices are not aligned
>      >
>      > Note that in this case dot acts like the rhs is always a column
>     vector
>      > although it returns a 1-d vector. I don't know that this is a bad
>      > thing, but perhaps we should extend this behaviour to matrices,
>     which
>      > would be different from the now current 1-d is always a *row*
>     vector, i.e.
> 
> 
>     The rule 1-d is always a *row* vector only applies when converting to a
>     matrix.
> 
>     In this case, the dot operator does not "convert to a matrix" but uses
>     rules for operating with mixed 2-d and 1-d arrays inherited from
>     Numeric.
> 
>     I'm very hesitant to change those rules.
> 
> 
> I wasn't suggesting that, just noticing that the rule was 1-d vector on 
> right is treated as a column vector by dot, which is why an exception 
> was raised in the posted case. If it is traditional for matrix routines 
> always treat is as a row vector, so be it.

My recollection is that text books treat the column vector, represented 
by a lower case letter, bold or underlined, as the default.  If b 
(dressed as described before) is a column vector, then b' represents a 
row vector.

For numpy, it makes sense to consider b as a row vector, since the 
underlying array uses the C convention where each row is stored 
contiguously.

Colin W.

> 
> Chuck
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion



More information about the Numpy-discussion mailing list