@@ -510,52 +510,74 @@ cdef class fmpz_mod_poly(flint_poly):
510510 res.val, self .val, e_ulong, self .ctx.mod.val
511511 )
512512 return res
513-
514- def shift (self , slong n ):
513+
514+ def left_shift (self , slong n ):
515515 """
516- Returns ``self`` shifted by ``n`` coefficients. If ``n`` is positive,
517- zero coefficients are inserted, when ``n`` is negative, if ``n`` is
518- greater than or equal to the length of ``self``, the zero polynomial
519- is returned.
516+ Returns ``self`` shifted left by ``n`` coefficients by inserting
517+ zero coefficients. This is equivalent to multiplying the polynomial
518+ by x^n
520519
521520 >>> R = fmpz_mod_poly_ctx(163)
522521 >>> f = R([1,2,3])
523- >>> f.shift (0)
522+ >>> f.left_shift (0)
524523 3*x^2 + 2*x + 1
525- >>> f.shift (1)
524+ >>> f.left_shift (1)
526525 3*x^3 + 2*x^2 + x
527- >>> f.shift (4)
526+ >>> f.left_shift (4)
528527 3*x^6 + 2*x^5 + x^4
529- >>> f.shift(-1)
530- 3*x + 2
531- >>> f.shift(-4)
532- 0
533528
534529 """
535530 cdef fmpz_mod_poly res
536531 res = fmpz_mod_poly.__new__ (fmpz_mod_poly)
537532 res.ctx = self .ctx
538533
534+ if n < 0 :
535+ raise ValueError (" Value must be shifted by a non-negative integer" )
536+
539537 if n > 0 :
540538 fmpz_mod_poly_shift_left(
541539 res.val, self .val, n, self .ctx.mod.val
542540 )
543- elif n < 0 :
544- fmpz_mod_poly_shift_right(
545- res.val, self .val, - n, self .ctx.mod.val
546- )
547541 else : # do nothing, just copy self
548542 fmpz_mod_poly_set(
549543 res.val, self .val, self .ctx.mod.val
550544 )
551545
552- return res
546+ return res
553547
554- def __lshift__ (self , n ):
555- return self .shift(n)
548+ def right_shift (self , slong n ):
549+ """
550+ Returns ``self`` shifted right by ``n`` coefficients.
551+ This is equivalent to the floor division of the polynomial
552+ by x^n
556553
557- def __rshift__ (self , n ):
558- return self .shift(- n)
554+ >>> R = fmpz_mod_poly_ctx(163)
555+ >>> f = R([1,2,3])
556+ >>> f.right_shift(0)
557+ 3*x^2 + 2*x + 1
558+ >>> f.right_shift(1)
559+ 3*x + 2
560+ >>> f.right_shift(4)
561+ 0
562+ """
563+ cdef fmpz_mod_poly res
564+
565+ if n < 0 :
566+ raise ValueError (" Value must be shifted by a non-negative integer" )
567+
568+ res = fmpz_mod_poly.__new__ (fmpz_mod_poly)
569+ res.ctx = self .ctx
570+
571+ if n > 0 :
572+ fmpz_mod_poly_shift_right(
573+ res.val, self .val, n, self .ctx.mod.val
574+ )
575+ else : # do nothing, just copy self
576+ fmpz_mod_poly_set(
577+ res.val, self .val, self .ctx.mod.val
578+ )
579+
580+ return res
559581
560582 @staticmethod
561583 def _mod_ (left , right ):
@@ -1344,14 +1366,14 @@ cdef class fmpz_mod_poly(flint_poly):
13441366 )
13451367 return res
13461368
1347- def inflate (self , ulong n ):
1369+ def inflation (self , ulong n ):
13481370 r """
13491371 Returns the result of the polynomial `f = \t extrm{self}` to
13501372 `f( x^ n) `
13511373
13521374 >>> R = fmpz_mod_poly_ctx( 163)
13531375 >>> f = R( [1,2,3 ])
1354- >>> f. inflate ( 10)
1376+ >>> f. inflation ( 10)
13551377 3* x^ 20 + 2* x^ 10 + 1
13561378
13571379 """
@@ -1364,7 +1386,7 @@ cdef class fmpz_mod_poly(flint_poly):
13641386 )
13651387 return res
13661388
1367- def deflate (self , ulong n ):
1389+ def deflation (self , ulong n ):
13681390 r """
13691391 Returns the result of the polynomial `f = \t extrm{self}` to
13701392 `f( x^ {1/n}) `
@@ -1373,7 +1395,7 @@ cdef class fmpz_mod_poly(flint_poly):
13731395 >>> f = R( [1,0,2,0,3 ])
13741396 >>> f
13751397 3* x^ 4 + 2* x^ 2 + 1
1376- >>> f. deflate ( 2)
1398+ >>> f. deflation ( 2)
13771399 3* x^ 2 + 2* x + 1
13781400
13791401 """
0 commit comments