#NEWLINE# def __pow__( self , n ) : #NEWLINE# #INDENT# "raise polynomial to power `n`\n\n        Examples\n        ========\n\n        >>> from sympy.polys.domains import ZZ\n        >>> from sympy.polys.rings import ring\n\n        >>> _, x, y = ring('x, y', ZZ)\n        >>> p = x + y**2\n        >>> p**3\n        x**3 + 3*x**2*y**2 + 3*x*y**4 + y**6\n\n        " #NEWLINE# ring = self . ring #NEWLINE# if ( not n ) : #NEWLINE# #INDENT# if self : #NEWLINE# #INDENT# return ring . one #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( '0**0' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( self ) == 1 ) : #NEWLINE# #INDENT# ( monom , coeff ) = list ( self . items ( ) ) [ 0 ] #NEWLINE# p = ring . zero #NEWLINE# if ( coeff == 1 ) : #NEWLINE# #INDENT# p [ ring . monomial_pow ( monom , n ) ] = coeff #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# p [ ring . monomial_pow ( monom , n ) ] = ( coeff ** n ) #NEWLINE# #UNINDENT# return p #NEWLINE# #UNINDENT# #UNINDENT# n = int ( n ) #NEWLINE# if ( n < 0 ) : #NEWLINE# #INDENT# raise ValueError ( 'Negative exponent' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( n == 1 ) : #NEWLINE# #INDENT# return self . copy ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( n == 2 ) : #NEWLINE# #INDENT# return self . square ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( n == 3 ) : #NEWLINE# #INDENT# return ( self * self . square ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( self ) <= 5 ) : #NEWLINE# #INDENT# return self . _pow_multinomial ( n ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return self . _pow_generic ( n )