Solution (source code)

= Solution

Choose the <diagonal matrix> $W=\operatorname{diag}(w_1,\ldots,w_m)$. Multiplying a <vector> by $W$ scales its $i$th component by $w_i$. Therefore
$$
\boxed{\|Wb-WAx\|^2=\sum_{i=1}^mw_i^2\bigl(b_i-(Ax)_i\bigr)^2}.
$$
The <Euclidean norm> objective for ordinary <linear least squares> on $(WA,Wb)$ is exactly the <weighted least squares> objective, so the sets of minimizing <vectors> coincide. Zero weights simply discard the corresponding residuals.