[Numpy-discussion] adding a .M attribute to the array.
Andrew P. Lentvorski
bsder at allcaps.org
Wed Mar 6 12:50:18 CST 2002
Well, I believe that it solves the wrong problem. What I really want are
Matrix objects that stay as Matrix objects even through their associated
functions. And Array objects that stay as array objects.
Why add any characters or casts at all when the objects can stay in their
Please correct me if I'm missing something here.
On Tue, 5 Mar 2002, Travis Oliphant wrote:
> Recently there has been discussion on the list about the awkwardness of
> matrix syntax when using Numeric Python.
> Matrix expressions can be awkard to express in Numeric which is a negative
> mark on an otherwise excellent computing environment.
> Currently part of the problem can be solved by working with Matrix objects
> a = Matrix.Matrix("[1 2 3; 4 5 6]") # Notice the strings.
> However, most operations return arrays which have to be recast to matrices
> using at best a character with parenthesis:
> M = Matrix.Matrix
> M(sin(a)) * M(cos(a)).T
> The suggestion was made to add ".M" as an attribute of arrays which returns a
> matrix. Thus, the code above can be written:
> sin(a).M * cos(a).M.T
> While some aesthestic simplicity is obtained, the big advantage is in
> consistency. Somebody else may decide that
> P = Matrix.Matrix is a better choice. But, if we establish that
> .M always returns a matrix for arrays < 2d, then we gain consistency.
> I've made this change and am ready to commit the change to the Numeric tree,
> unless there are strong objections. I know some people do not like the
> proliferation of attributes, but in this case the notational convenience it
> affords to otherwise overly burdened syntax and the consistency it allows
> Numeric to deal with Matrix equations may be worth it.
> What do you think?
> -Travis Oliphant
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
More information about the Numpy-discussion