[Numpy-discussion] array vs. matrix for matlab-compatible stuff
Sven Schreiber
svetosch at gmx.net
Wed Jan 18 07:47:08 CST 2006
Hi,
I've spent a couple of weeks with scipy/numpy and the old-to-new transition; now that the transition
is over (?) but some confusion is remaining (on my side) I feel the need to ask a basic question
about matlab compatibility in terms of matrix (linear algebra) programming.
Take "eye" and "identity" for example; given that "eye" supposedly exists to facilitate transiton
from matlab to numpy/scipy (correct?), I expected eye to be/return a matrix.
However (as you guys know better than I do), it's not a matrix:
>>> import numpy
>>> type(numpy.eye(2))
<type 'numpy.ndarray'>
>>> type(numpy.identity(2))
<type 'numpy.ndarray'>
>>> type(numpy.mat(numpy.eye(2)))
<class 'numpy.core.defmatrix.matrix'>
Why is that so? There doesn't seem to be any value added of eye over identity, and the downside is
inconvenience of having to explicitly convert those arrays to matrices (to use them in
multiplication, inverting them, avoid unexpected broadcasting behavior if I mistakenly write down a
non-defined matrix product etc.).
Surely I'm missing something here, but what?
Thanks for your help,
Sven
More information about the Numpy-discussion
mailing list