Algorithm Architecture Co-design for Dense and Sparse Matrix Computations