QuickPol: Fast calculation of effective beam matrices for CMB polarization