[Numpy-discussion] Automatic matrices
Paulo Jose da Silva e Silva
pjssilva at ime.usp.br
Fri Dec 15 18:21:37 CST 2006
Em Sex, 2006-12-15 às 23:37 +0100, Sven Schreiber escreveu:
> Paulo Jose da Silva e Silva schrieb:
>
> >
> > However, after trying to use the matrix class I have came across a major
> > roadblock: many numpy/scipy functions return an array by default and not
> > matrices. Then, we need then to add many conversion calls to the 'mat'
> > function in our code. This is also unconvenient.
> >
>
> scipy I don't know, but in numpy as a matrix user I'm glad that such
> behavior has been treated as bugs on the way to 1.0 -- so could you
> please send a list with the affected numpy functions?
> -sven
Ops...
I did not try to imply that there are some functions in numpy that
return array when receiving matrices. What I meant is that there are
functions in numpy that always return arrays. Hence they ask for an
explicit conversion to matrices. Good examples is the whole numpy.random
sub-module. So if you want a random matrix you need to type:
A = mat(numpy.random.rand(4,4))
Hence, a matrix user of numpy module still have to be aware of such
conversions.
Note that in my code, after importing numpy using the special module, I
can write
A = num.random.rand(4,4)
There is no special case.
best,
Paulo
Obs: I remember reading somewhere in the list that we can change the
behavior of numpy to make it return matrices as default, even in calls
for functions like zeros or ones. I don't have the reference now. Anyhow
I wanted a solution that can make any module play nice with matrices.
More information about the Numpy-discussion
mailing list