def make_rhs(matrix, multiply_fast_component):
    """Return a function suitable for use as an RHS that does matrix
    multiplication. If multiply_fast_component is True, then the fast component
    is multiplied, otherwise the slow component is multiplied.
    """
    def f(t, f, s):
        return matrix.dot(f if multiply_fast_component else s)
    return f