def sum_dot(s, i, p):
    """
    Sum the items of a list multiplied by a factor from p.
    Used for calculation of affine functions
    :param s:
    :param i:
    :param p:
    :return:
    """
    sumd = 0

    for l in range(0, len(i)):
        sumd += s[i[l]] * float(p[l])

    return sumd