hmatrix implementation (partial)