Efficient algorithms for compressed sensing and matrix completion