Could you add more comments about the exact problem you are solving? It can help understand the code.

~~~
minimize 1/2 * x^T (AtA) x - (Atb)^T x
subject to x >= 0.
~~~