File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -537,6 +537,7 @@ cdef class Gen(Gen_base):
537
537
return new_gen(gmul(t0.g, t1.g))
538
538
539
539
def __div__ (left , right ):
540
+ # Python 2 old-style division: same implementation as __truediv__
540
541
cdef Gen t0, t1
541
542
try :
542
543
t0 = objtogen(left)
@@ -547,6 +548,15 @@ cdef class Gen(Gen_base):
547
548
return new_gen(gdiv(t0.g, t1.g))
548
549
549
550
def __truediv__ (left , right ):
551
+ """
552
+ Examples:
553
+
554
+ >>> from cypari2 import Pari; pari = Pari()
555
+ >>> pari(11) / pari(4)
556
+ 11/4
557
+ >>> pari("x^2 + 2*x + 3") / pari("x")
558
+ (x^2 + 2*x + 3)/x
559
+ """
550
560
cdef Gen t0, t1
551
561
try :
552
562
t0 = objtogen(left)
@@ -556,6 +566,25 @@ cdef class Gen(Gen_base):
556
566
sig_on()
557
567
return new_gen(gdiv(t0.g, t1.g))
558
568
569
+ def __floordiv__ (left , right ):
570
+ """
571
+ Examples:
572
+
573
+ >>> from cypari2 import Pari; pari = Pari()
574
+ >>> pari(11) // pari(4)
575
+ 2
576
+ >>> pari("x^2 + 2*x + 3") // pari("x")
577
+ x + 2
578
+ """
579
+ cdef Gen t0, t1
580
+ try :
581
+ t0 = objtogen(left)
582
+ t1 = objtogen(right)
583
+ except Exception :
584
+ return NotImplemented
585
+ sig_on()
586
+ return new_gen(gdivent(t0.g, t1.g))
587
+
559
588
def __mod__ (left , right ):
560
589
"""
561
590
Return ``left`` modulo ``right``.
You can’t perform that action at this time.
0 commit comments