Difference between convention for matrix multiplication of vector in algebra and computer science

267 Views Asked by At

In algebra, we typically write $Ax=b$ when we wish to multiply a $n$ dimensional $x$ vector by matrix $A$, requiring $A$ of course to have $n$ columns.

Yet, in computer science, I typically see $xA=b$, with $A$ having $n$ rows.

Of course, any "math" matrix can be transposed to give you its "computer science" matrix, so this is a matter of convention. Why? Is this for computational efficiency? For clarity? Tradition?

Similarly, the scalar product of two vectors is typically expressed $x \cdot y$ in math, but $x^Ty$ in computer science. Why?

1

There are 1 best solutions below

2
On

I don't associate the "row vector" convention to Computer Science more than to other fields and I believe that it is globally much less frequent. It probably arose just because the two conventions are possible.

Computational efficiency cannot be an explanation (or more precisely cache-friendliness), as there exist languages used in scientific applications that store matrices in row-major as well as column-major order.

$x^Ty$ is a kind of notational abuse, as it corresponds to a $1\times1$ matrix, and not exactly a scalar. The dot is more appropriate.