Le lundi 05 septembre 2011 à 09:38 +0545, Chris Smith a écrit :
> > You often need unity matrices or empty matrices. Actually zeros() is
> > redundant to the Matrix() constructor IMHO, so maybe we should remove
> > it.
> 
> The question is why there are two methods of generating them:
> 
> eye(3) or Matrix().eye(3) or SparseMatrix().eye(3)
> zeros(3,4) or Matrix().zeros(3,4) or SparseMatrix().zeros(3,4)
> ones(3,4) BUT NEITHER Matrix().ones(3,4) nor SparseMatrix().ones(3,4)
> 
> Also, which version of zeros do you feel is redundant?
> 
These methods shouldn't be instance methods: this forces the creation of
an instance that is immediately discarded in order to access the method.
They should definitely be classmethods instead.

Concerning the initial question, I don't have a strong opinion between
functions and classmethods. If we choose functions, they need to gain
the option of specifying the class of the result (e.g. eye(3,
cls=Matrix) vs eye(3, cls=SparseMatrix).

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to