You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/sage/rings/finite_rings/integer_mod.pyx
+16-30Lines changed: 16 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -1507,19 +1507,16 @@ cdef class IntegerMod_abstract(FiniteRingElement):
1507
1507
ifself==1:
1508
1508
ifall:
1509
1509
return [K(a) for a inrange(1, K.order())]
1510
-
else:
1511
-
returnself
1510
+
returnself
1512
1511
else:
1513
1512
ifall:
1514
1513
return []
1515
-
else:
1516
-
raiseValueError
1514
+
raiseValueError
1517
1515
F = K.factored_order()
1518
1516
iflen(F) ==0:
1519
1517
ifall:
1520
1518
return [self]
1521
-
else:
1522
-
returnself
1519
+
returnself
1523
1520
iflen(F) !=1:
1524
1521
ifall:
1525
1522
# we should probably do a first pass to see if there are any solutions so that we don't get giant intermediate lists and waste time...
@@ -1539,24 +1536,20 @@ cdef class IntegerMod_abstract(FiniteRingElement):
1539
1536
if n <0:
1540
1537
ifall:
1541
1538
return []
1542
-
else:
1543
-
raiseValueError
1539
+
raiseValueError
1544
1540
ifall:
1545
1541
if k ==1:
1546
1542
return [self]
1547
-
else:
1548
-
minval =max(1, (k/n).ceil())
1549
-
return [K(a*p**minval) for a inrange(p**(k-minval))]
1550
-
else:
1551
-
returnself
1543
+
minval =max(1, (k/n).ceil())
1544
+
return [K(a*p**minval) for a inrange(p**(k-minval))]
1545
+
returnself
1552
1546
if n <0:
1553
1547
try:
1554
1548
self=~self
1555
1549
exceptZeroDivisionError:
1556
1550
ifall:
1557
1551
return []
1558
-
else:
1559
-
raiseValueError
1552
+
raiseValueError
1560
1553
n =-n
1561
1554
if p ==2and k ==1:
1562
1555
return [self] ifallelseself
@@ -1565,8 +1558,7 @@ cdef class IntegerMod_abstract(FiniteRingElement):
1565
1558
ifnot n.divides(pval):
1566
1559
ifall:
1567
1560
return []
1568
-
else:
1569
-
raiseValueError("no nth root")
1561
+
raiseValueError("no nth root")
1570
1562
if pval >0:
1571
1563
ifall:
1572
1564
return [K(a.lift()*p**(pval // n) + p**(k - (pval - pval//n)) * b) for a in mod(upart, p**(k-pval)).nth_root(n, all=True, algorithm=algorithm) for b inrange(p**(pval - pval//n))]
@@ -1580,27 +1572,23 @@ cdef class IntegerMod_abstract(FiniteRingElement):
1580
1572
if n %2==0:
1581
1573
ifall:
1582
1574
return []
1583
-
else:
1584
-
raiseValueError("no nth root")
1575
+
raiseValueError("no nth root")
1585
1576
else:
1586
1577
sign = [-1]
1587
1578
self=-self
1588
1579
elif n %2==0:
1589
1580
if k >2andself%8==5:
1590
1581
ifall:
1591
1582
return []
1592
-
else:
1593
-
raiseValueError("no nth root")
1583
+
raiseValueError("no nth root")
1594
1584
sign = [1, -1]
1595
1585
if k ==2:
1596
1586
ifall:
1597
1587
return [K(s) for s in sign[:2]]
1598
-
else:
1599
-
return K(sign[0])
1588
+
return K(sign[0])
1600
1589
ifall:
1601
-
modp = [mod(self,8)]
1602
-
else:
1603
-
modp = mod(self,8)
1590
+
modp = [mod(self, 8)]
1591
+
modp = mod(self, 8)
1604
1592
else:
1605
1593
sign = [1]
1606
1594
modp =self% p
@@ -1614,13 +1602,11 @@ cdef class IntegerMod_abstract(FiniteRingElement):
1614
1602
ifself==1:
1615
1603
ifall:
1616
1604
return [s*K(p*a+m.lift()) for a inrange(p**(k-(2if p==2else1))) for m in modp for s in sign]
1617
-
else:
1618
-
return K(modp.lift())
1605
+
return K(modp.lift())
1619
1606
else:
1620
1607
ifall:
1621
1608
return []
1622
-
else:
1623
-
raiseValueError("no nth root")
1609
+
raiseValueError("no nth root")
1624
1610
ifall:
1625
1611
ans = [plog // n + p**(k - nval) * i for i inrange(p**nval)]
1626
1612
ans = [s*K(R.teichmuller(m) * a.exp()) for a in ans for m in modp for s in sign]
0 commit comments