top | item 45568594

(no title)

knappa | 4 months ago

I'm a mathematician. It's kind of a strange statement since, if we are talking about a matrix, it has two indices not one. Even if we do flatten the matrix to a vector, rows then columns are an almost universal ordering of those two indices and the natural lexicographic ordering would stride down the rows.

discuss

order

FabHK|4 months ago

Yes. I think what all mathematicians can agree on is that the layout (and the starting index! :-) is like this:

  A[1,1] … A[1,n]
   …        …
  A[m,1] … A[m,n]

nerdponx|4 months ago

I assume they're talking about how when multiplying by a matrix by a vector, it's more natural to think of the matrix as a collection of columns than as a collection of rows, and to think of the vector as a column vector.

That layout is a nearly universal convention in applied practice such as statistics. Readers would be very very confused if you flipped it the other way.

The irony is that "programmers" are much more divided on this than statisticians are.

knappa|4 months ago

It depends which side you are doing the multiplication on? Most linear algebra textbooks work matrix-vector, where the vector is a column vector. In that arrangement, the resulting vector is formed by dot products of the rows of the matrix with the vector.

On the other hand, you see vector-matrix multiplication a lot in other places, for example, the Markov chain literature. There, the vector is a row vector and the resulting vector is formed by dot products of the columns of the matrix with the original vector.