I took that very seriously when you said that matrices were important to you. Far from me the idea of forbidding numpy users to use matrices.<div><br></div><div>My point was the fact that newcomers are confused by the presence of both matrices and arrays. I think that there should be only one matrix/vector/tensor object in numpy. Therefore I would advocate the removal of matrices from numpy.</div>
<div><br></div><div>*But* why not have matrices in a different component? Maybe as a part of scipy? or somewhere else? You would be more than welcome to use them anywhere. Note that I use components outside numpy for my teaching (scipy, sympy, mayavi, nosetest) and I don't have any problems with that.</div>
<div><br></div><div>With my "argument" I endeavoured to explain the potential complications of using matrices instead of arrays when teaching. Perhaps the strongest argument against matrices is that you cannot use vectors. I've taught enough matlab courses to realise the pain that this represents for students. But I realise also that somebody else would have a different experience.</div>
<div><br></div><div>Of course x.T*y should be a 1x1 matrix, this is not an anomaly, but it is confusing for students, because they expect a scalar. That is why I prefer to teach with dot. Then the relation matrix/vector/scalar is crystal clear.</div>
<div><br></div><div>== Olivier<br><br><div class="gmail_quote">2009/6/5 Alan G Isaac <span dir="ltr"><<a href="mailto:aisaac@american.edu">aisaac@american.edu</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 6/5/2009 11:38 AM Olivier Verdier apparently wrote:<br>
> I think matrices can be pretty tricky when used for<br>
> teaching.  For instance, you have to explain that all the<br>
> operators work component-wise, except the multiplication!<br>
> Another caveat is that since matrices are always 2x2, the<br>
> "scalar product" of two column vectors computed as " x.T<br>
> * y" will not be a scalar, but a 2x2 matrix. There is also<br>
> the fact that you must cast all your vectors to column/raw<br>
> matrices (as in matlab). For all these reasons, I prefer<br>
> to use arrays and dot for teaching, and I have never had<br>
> any complaints.<br>
<br>
<br>
</div>I do not understand this "argument".<br>
You should take it very seriously when someone<br>
reports to you that the matrix object is a crucial to them,<br>
e.g., as a teaching tool.  Even if you do not find<br>
personally persuasive an example like<br>
<a href="http://mail.scipy.org/pipermail/numpy-discussion/2009-June/043001.html" target="_blank">http://mail.scipy.org/pipermail/numpy-discussion/2009-June/043001.html</a><br>
I have told you: this is important for my students.<br>
Reporting that your students do not complain about using<br>
arrays instead of matrices does not change this one bit.<br>
<br>
Student backgrounds differ by domain of application.  In<br>
economics, matrices are in *very* wide use, and<br>
multidimensional arrays get almost no use.  Textbooks in<br>
econometrics (a huge and important field, even outside of<br>
economics) are full of proofs using matrix algebra.<br>
A close match to what the students see is crucial.<br>
When working with multiplication or exponentiation,<br>
matrices do what they expect, and 2d arrays do not.<br>
<br>
One more point. As Python users we get used to installing<br>
a package here and a package there to add functionality.<br>
But this is not how most people looking for a matrix<br>
language see the world.  Removing the matrix object from<br>
NumPy will raise the barrier to adoption by social<br>
scientists, and there should be a strongly persuasive reason<br>
before taking such a step.<br>
<br>
Separately from all that, does anyone doubt that there is<br>
code that depends on the matrix object?  The core objection<br>
to a past proposal for useful change was that it could break<br>
extant code.  I would hope that nobody who took that<br>
position would subsequently propose removing the matrix<br>
object altogether.<br>
<br>
Cheers,<br>
Alan Isaac<br>
<br>
PS If x and y are "column vectors" (i.e., matrices), then<br>
x.T * y *should* be a 1×1 matrix.<br>
Since the * operator is doing matrix multiplication,<br>
this is the correct result, not an anomaly.<br>
<div><div></div><div class="h5"><br>
<br>
_______________________________________________<br>
Numpy-discussion mailing list<br>
<a href="mailto:Numpy-discussion@scipy.org">Numpy-discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</div></div></blockquote></div><br></div>