  We present an analytical solution for the magnetic field of a homogeneously
magnetized cylinder tile and by extension solutions for full cylinders, rings,
cylinder sectors and ring segments. The derivation is done by direct
integration in the magnetic surface charge picture. Results are closed-form
expressions and elliptic integrals. All special cases are treated individually,
which enables the field computation for all possible position arguments. An
implementation is provided in Python together with a performance analysis. The
implementation is tested against numerical solutions and applied to compute the
magnetic field in a discrete Halbach cylinder.
