Solution of low-frequency electromagnetics problems using hierarchical matrices