[Numpy-discussion] design issues - octave 'incompatibilities'

Robert Kern rkern at ucsd.edu
Mon Jul 25 22:45:05 CDT 2005


Soeren Sonnenburg wrote:
> On Mon, 2005-07-25 at 08:59 -0700, Chris Barker wrote:

[snip]

>>such thing as a column vs. a row vector. A vector is a one-dimensional 
>>array: it has no orientation.
> 
> This makes life more difficult if one wants to convert 
> from octave/matlab -> numarray and automated systems close to
> impossible.

<shrug> That wasn't a design goal.

> If vectors had the same properties/functions as matrices one
> would not have such problems, i.e. v^{transpose} * u == dot(v,u) and v*u
> -> error

That would be a big problem for those of us who don't use Numeric just 
for linear algebra. These are general arrays, not matrices and vectors.

[snip]

> In my eyes 'array broadcasting' is confusing and should rather be in a
> function like meshgrid and instead a*b should return
> matrixmultiply(a,b) ...

Spend some time with it. It will probably grow on you. Numeric is not 
Matlab or Octave. It never will be, thank G-d.

[snip]

>>I hope that helps:
> 
> Indeed it does - Thanks!! Unfortunately I am not at all happy now that
> '*' != matrixmultiply (but outerproduct) for vectors/matrices...

Again, Numeric is a package for arrays, not just linear algebra. Please 
spend some more time with Python and Numeric before deciding that they 
must be changed to match your preconceptions.

> I realize that with lists it is ok to grow them via slicing.
> 
> x=[]
> x[0]=1
> IndexError: list assignment index out of range
> x[0:0]=[1]
> x
> [1]
> 
> that seems not to work with numarray ... or ?
> 
> y=array()
> y[0]=1
> TypeError: object does not support item assignment
> y[0:0]=array([1])
> TypeError: object does not support item assignment

Python lists are designed to grow dynamically. Their memory is 
preallocated so that growing them is on average pretty cheap. Numeric 
arrays are not, nor will they be.

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter




More information about the Numpy-discussion mailing list