# [Numpy-discussion] numpy release

Bruce Southey bsouthey@gmail....
Fri Apr 25 09:40:09 CDT 2008

```Christopher Barker wrote:
[cjop]
>
> Bruce Southey wrote:
>
>> Hi,
>> I would like to use the matrix functionality but I, like others, get by
>> without it.
>>
>
> What does it lack that keeps you from using it? That's the key question?
>
I mainly do matrix-matrix and matrix-vector multiplications like in
linear models and predictions.
The main reason I have already learnt how to do to what I want using
Numpy via mainly Numarray. So at the moment I am not interested in doing
something else.
>> +1 to Tim's and Nadav's comments. As Tim said, there should be seamless
>> integration between concepts of vectors and matrices - after all there
>> really no distinction between them in linear algebra.
>>
>
> This is all about being able to index a "vector" with a single index --
> that's it, I think. Matlab handles this by special casing matrices that
> have a single dimension of one. It also has an easy way to spell a
> literal for column vector, though I suppose:
>
> np.Matrix((1,2,3,4,5)).T
>
>
>
>> -2 for having rowvector and columnvector - both numpy and I should know
>> the orientation, if not, I deserve garbage or an error.
>>
>
> But HOW can you know the orientation? a 1-d array has no orientation --
>
I fully agree and which is why there is absolutely no sense in saying
row or column vector/array!  But vectors always have an orientation in
the context of a matrix (as you also indicate below) or 2-d array so in
that situation vectors are matrices. Numpy and other options have an
implicit orientation because they usually always check that an operation
is feasible first so errors are returned if the dimensions are not
appropriate. So, as I understand it, Numpy's array do have an implicit
orientation because Numpy's 1-d arrays act like 1 by n arrays when used
with m by n arrays:
import numpy
a=numpy.ones((4))
b=numpy.ones((4,3))
numpy.dot(a,b) # gives array([ 4.,  4.,  4.])
numpy.dot(b,a) # gives error
numpy.dot(b.T,a) #gives array([ 4.,  4.,  4.])

Thus, Numpy's 1-d arrays do have an orientation otherwise all three
multiplications should return an error!

> which is why the current version always returns a matrix when indexing.
>
As you point out, that is inconsistent with 1-d arrays having NO
orientation. But this is fully consistent with the view that a vector is
a special case of a matrix when we commonly refer to an n by 1 or 1 by n
vector (as you also indicate below).
>> 0 for vector - I don't see the need for it as a unique entity but
>> understand the simplicity of saying vector.
>>
>
> I don't think we can have vector without ColumnVector, though I suppose
> a "Vector" can be either a (n,1) or a (1,n) matrix that allows single
> indexing.
>
But didn't you say that '1-d array has no orientation'... :-)
This why I am -2 on row and column vector because one should just be the
transpose of the other.

> By the way, maybe a column vector could be handy for doing array
> broadcasting, as an cleaner way to do:
>
> x = np.arange(10)
> y = np.arange(20).reshape((-1,1))
>
> z = FunctionOfXandY(x,y)
>
>
> Final note:
>
> If no one has an linear algebra examples, then we're wasting out time
> with even this cheap talk.
>
> -Chris
>
>
>
Bruce
```