On Sat, Mar 15, 2014 at 11:11 AM, Steven D'Aprano <steve@pearwood.info>wrote:
The only question is whether it is more common to write:
Matrix @ Matrix @ Column_Vector
or
Row_Vector @ Matrix @ Matrix
I'll leave it to those who do matrix maths to decide which they use more often, but personally I've never come across the second case except in schoolbook exercises.
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"? When you have a matrix A = [[1, 2], [3, 4]] A[1] is [3, 4], which is a row. To get a column, [2, 4], one has to write A[:,1] in numpy. When it comes to matrix - vector multiplication, [1, 2] @ [[1, 2], [3, 4]] -> [7, 10] has a text-book appearance, while [[1, 2], [3, 4]] @ [1, 2] -> [5, 11] has to be mentally cast into ([[1, 2], [3, 4]] @ [[1], [2]])[0] -> [5, 11] 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].