def num_fixed_points(permutation):
    """
    Compute the number of fixed points (elements mapping to themselves) of a permutation.

    :param permutation: Permutation in one-line notation (length n tuple of the numbers 0, 1, ..., n-1).
    :return: Number of fixed points in the permutation.

    .. rubric:: Examples

    >>> num_fixed_points((0, 2, 1))
    1
    """
    n = 0
    for i in range(len(permutation)):
        if permutation[i] == i:
            n += 1
    return n