def apply_poly(poly, x, y, z):
    """
    Evaluates a 3-variables polynom of degree 3 on a triplet of numbers.

    Args:
        poly: list of the 20 coefficients of the 3-variate degree 3 polynom,
            ordered following the RPC convention.
        x, y, z: triplet of floats. They may be numpy arrays of same length.

    Returns:
        the value(s) of the polynom on the input point(s).
    """
    out = 0
    out += poly[0]
    out += poly[1] * y + poly[2] * x + poly[3] * z
    out += poly[4] * y * x + poly[5] * y * z + poly[6] * x * z
    out += poly[7] * y * y + poly[8] * x * x + poly[9] * z * z
    out += poly[10] * x * y * z
    out += poly[11] * y * y * y
    out += poly[12] * y * x * x + poly[13] * y * z * z + poly[14] * y * y * x
    out += poly[15] * x * x * x
    out += poly[16] * x * z * z + poly[17] * y * y * z + poly[18] * x * x * z
    out += poly[19] * z * z * z
    return out
