Hierarchical Matrices: Algorithms and Analysis