A direct integral-equation solver of linear complexity for large-scale 3D capacitance and impedance extraction