Distance between points Suppose I have two matrices each containing coordinates of $m$ and $n$ points in 2 D. Is there an easy way using linear algebra to calculate the euclidean distance between all points (i.e., the results should be a $m$ by $n$ matrix)?

We start with
$$
M = (u_1, \ldots, u_m) \in \mathbb{R}^{3\times m} \\
N = (v_1, \ldots, v_n) \in \mathbb{R}^{3\times n}
$$
and want
$$
D = (d_{ij}) \in \mathbb{R}^{m\times n}
$$
with
\begin{align}
d_{ij}
&= \lVert u_i - v_j \rVert \\
&= \sqrt{(u_i - v_j)\cdot (u_i - v_j)} \\
&= \sqrt{u_i \cdot u_i + v_j \cdot v_j - 2(u_i \cdot v_j)} \\  
&= \sqrt{(M e_i - N e_j)\cdot (M e_i - N e_j)} \\
&= \sqrt{M e_i \cdot M e_i + N e_j \cdot N e_j - 2 (M e_i \cdot N e_j)} \\
&= \sqrt{(M^t M)_{ii} + (N^tN)_{jj}-2(M^tN)_{ij}} \\
\end{align}
I do not see an advantage of the matrix formulation here. Beside that one has to take the square roots anyway. 
