Finite-difference calculation of demagnetizing factors for shapes with cylindrical symmetry