<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 15, 2014 at 11:11 AM, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div id=":1wt" class="" style="overflow:hidden">The only question is whether it is more common to write:<br>
<br>
Matrix @ Matrix @ Column_Vector<br>
<br>
or<br>
<br>
Row_Vector @ Matrix @ Matrix<br>
<br>
<br>
I'll leave it to those who do matrix maths to decide which they use more<br>
often, but personally I've never come across the second case except in<br>
schoolbook exercises.</div></blockquote></div><div class="gmail_extra"><br></div>Abstractly, 1-dimensional arrays are neither columns nor rows, but Python's horizontal notation makes them more row-like than column-like. In 2-dimensional case, [[1,2]] is a row-vector and [[1],[2]] is a column-vector. Which one is more "natural"?</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">When you have a matrix</div><div class="gmail_extra"><br></div><font face="courier new, monospace">A = [[1, 2],</font><div><font face="courier new, monospace"> [3, 4]]</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="arial, helvetica, sans-serif">A[1] is [3, 4], which is a row. To get a column, [2, 4], one has to write A[:,1] in numpy.</font></div><div><font face="arial, helvetica, sans-serif"><br>
</font></div><div><font face="arial, helvetica, sans-serif">When it comes to matrix - vector multiplication,</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="courier new, monospace">[1, 2] @ [[1, 2],</font></div>
<div><font face="courier new, monospace"> [3, 4]] -> [7, 10]</font></div><div><br></div><div><font face="arial, helvetica, sans-serif">has a text-book appearance, while</font></div><div><font face="arial, helvetica, sans-serif"><br>
</font></div><div><div><font face="courier new, monospace">[[1, 2],</font></div><div><font face="courier new, monospace"> [3, 4]] @ [1, 2] -> [5, 11]</font></div></div><div><font face="courier new, monospace"><br></font></div>
<div><font face="arial, helvetica, sans-serif">has to be mentally cast into</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><div><font face="courier new, monospace">([[1, 2],</font></div><div>
<font face="courier new, monospace"> [3, 4]] @ [[1],</font></div><div><font face="courier new, monospace"> [2]])[0] -> [5, 11]</font></div></div><div><br></div><div>While it is more common in math literature to see Mat @ vec than vec @ Mat, I don't think anyone who has completed an introductory linear algebra course would have trouble understanding what [1, 2, 3] @ Mat means. On the other hand, novice programmers may find it puzzling why Mat @ [Mat1, Mat2] is the same as [Mat @ Mat1, Mat @ Mat2], but [Mat @ [vec1, vec2]] is not [Mat @ vec1, Mat @ vec2].</div>
</div>