[Numpy-discussion] Matlab -> NumPy translation and indexing
Mon Mar 5 07:13:02 CST 2007
I am trying to translate some Matlab code to NumPy. I started reading the
NumPy book and, yeah it's a very long read :-/ One thing I am completely
confused about are the concpets of "basic" vs. "advanced" indexing. Are
there some good examples out there where for the same piece of code - Matlab
and NumPy are compared? I feel looking at those maybe more helpful to get me
started than an in-depth study of the book. I already read "Numpy for Matlab
users" and at a glance it doesn't seem to contain equivalents to all the
common indexing operations you'd do in Matlab.
Some concrete problems/questions I have right now:
- Am I correct in assuming that all arrays have to be initialized to their
final number of elements in NumPy (using empty/zero for instance)?
- Given a matrix R, is there an equvialent to the Matlab operation R(:,j) =
 (which removes column j and "shrinks" the matrix?
- For (basic ?) indexing of an ndarray - is there any reason to prefer
A[i,j] over A[i][j]?
- Is it "pythonic" to initialize vectors to 2 dimensions so that
vec.shape== (len(vec), 1) instead of
vec.shape == (len(vec),)?
Thanks for now,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion