[Numpy-discussion] creating column vectors
luszczek at cs.utk.edu
Wed Feb 8 07:03:03 CST 2006
On Wednesday 08 February 2006 09:33, Sven Schreiber wrote:
> Stefan van der Walt schrieb:
> > This is probably a silly question, but what is the best way of
> > creating column vectors? 'arange' always returns a row vector, on
> > which you cannot perform 'transpose' since it has only one
> > dimension.
> > mat(arange(1,10)).transpose()
> mat(range(1,10)).T is a bit shorter, but I would agree that doing
> matrix algebra in numpy is not as natural as with explicitly
> matrix-oriented languages; my understanding is that this is due to
> numpy's broader (n-dimensional) scope.
> Numpy-masters: Is there a way to set a user- or project-specific
> config switch or something like that to always get matrix results
> when dealing with 1d and 2d arrays? I think that would make numpy
> much more attractive for people like Stefan and me coming from the 2d
I'm not a master by far but I heard that question before.
Isn't the mlab module just for that purpose?
I was explained that the problem with a "switch" is that the same code
will behave differently depending on which installation you run. If you
run on my n-D installation it will do one thing and if you run it on
your 2-D installation (with the 2D world "switch" enabled) you get
subtly different result. It might become a bug hunting nighmare.
I think this is when Python's explicit vs. implicit rule kicks in:
python -c 'import this'
More information about the Numpy-discussion