Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 0fa7a24

Browse files
committed
MPolynomialIdeal.random_element bugfix
Return linear combination of generators if requested degree of random element equals degree of generators.
1 parent ae4110c commit 0fa7a24

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/sage/rings/polynomial/multi_polynomial_ideal.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -4151,6 +4151,14 @@ def random_element(self, degree, compute_gb=False, *args, **kwds):
41514151
sage: all(I.random_element(degree=1) == 0 for _ in range(100))
41524152
True
41534153
4154+
If degree equals the degree of the generators a random linear
4155+
combination of the generators is returned::
4156+
4157+
sage: P.<x,y> = QQ[]
4158+
sage: I = P.ideal([x^2,y^2])
4159+
sage: I.random_element(degree=2)
4160+
52*x^2 - 8/3*y^2
4161+
41544162
"""
41554163
if compute_gb:
41564164
gens = self.groebner_basis()
@@ -4163,7 +4171,7 @@ def random_element(self, degree, compute_gb=False, *args, **kwds):
41634171

41644172
for f in gens:
41654173
d = degree - f.degree()
4166-
if d > 0:
4174+
if d >= 0:
41674175
h = R.random_element(degree=d, *args, **kwds)
41684176
r += h*f
41694177
return r

0 commit comments

Comments
 (0)