#NEWLINE# def dup_sign_variations( f , K ) : #NEWLINE# #INDENT# '\n    Compute the number of sign variations of ``f`` in ``K[x]``.\n\n    Examples\n    ========\n\n    >>> from sympy.polys import ring, ZZ\n    >>> R, x = ring("x", ZZ)\n\n    >>> R.dup_sign_variations(x**4 - x**2 - x + 1)\n    2\n\n    ' #NEWLINE# ( prev , k ) = ( K . zero , 0 ) #NEWLINE# for coeff in f : #NEWLINE# #INDENT# if K . is_negative ( ( coeff * prev ) ) : #NEWLINE# #INDENT# k += 1 #NEWLINE# #UNINDENT# if coeff : #NEWLINE# #INDENT# prev = coeff #NEWLINE# #UNINDENT# #UNINDENT# return k