# Projection onto subspace given set of LI vectors

I want a subroutine to find the Projection Matrix onto a subspace given a set of linearly independent vectors of that subspace. Suppose I have vectors $v_1, v_2, \dots v_n$ and the Vector space $\text{span}({v_i})$. How do I get the projection matrix onto that span?

This looks like a homework. I guess you mean

orthogonalprojection (othewise some information is missing). How would you construct such a matrix mathematically ?