I want to compute the L2 distance between a set of points X and M using matrices, for that I proceed as follows:
1) I substract both matrices, X-M
2) I square each matrice member (X-M)^2
3) I collapse the matrice into a column vector by summing the column values of each row.
I lack some formalization knowledge of matrices, so my questions are, is T^2 the correct way to represent the squaring of each matrice member? And what's the correct way to represent the operation I'm doing at 3) ?
Thanks
In general, if $T$ is a matrix, then $T^2 = T \cdot T$ (matrix multiplication).
What you are doing is the Hadamard Product.
Also, summing the rows of a matrix is equivalant to multiplying the matrix by a column vector of all $1$'s.