Weak stability of switching dynamical systems and fast computation of the p-radius of matrices