Data-sparse algorithms for structured matrices