Theory and Application of Hierarchical Matrices in Multiscale Problems