@@ -5757,24 +5757,23 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
5757
5757
else :
5758
5758
return self * self .denominator()
5759
5759
5760
- def in_subalgebra (self , J , algorithm = None ):
5760
+ def in_subalgebra (self , J , algorithm = " algebra_containment " ):
5761
5761
"""
5762
5762
Return whether this polynomial is contained in the subalgebra
5763
5763
generated by ``J``
5764
5764
5765
5765
INPUT:
5766
5766
5767
- - ``J`` -- iterable of elements of the parent polynomial ring
5767
+ - ``J`` -- list of elements of the parent polynomial ring
5768
5768
5769
5769
- ``algorithm`` -- can be ``None`` (the default), "algebra_containment",
5770
5770
"inSubring", or "groebner".
5771
5771
5772
- - ``None`` (the default): use "algebra_containment".
5773
-
5774
- - "algebra_containment": use Singular's ``algebra_containment`` function,
5772
+ - "algebra_containment" (default): use Singular's
5773
+ ``algebra_containment`` function,
5775
5774
https://www.singular.uni-kl.de/Manual/4-2-1/sing_1247.htm#SEC1328. The
5776
- Singular documentation suggests that this is frequently faster than the
5777
- next option.
5775
+ Singular documentation suggests that this is frequently
5776
+ faster than the next option.
5778
5777
5779
5778
- "inSubring": use Singular's ``inSubring`` function,
5780
5779
https://www.singular.uni-kl.de/Manual/4-2-0/sing_1240.htm#SEC1321.
@@ -5789,31 +5788,37 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
5789
5788
and only if the remainder involves only the new variables
5790
5789
`z_i`.
5791
5790
5792
- Note: the default algorithm may print some intermediate information.
5793
-
5794
5791
EXAMPLES::
5795
5792
5796
5793
sage: P.<x,y,z> = QQ[]
5797
5794
sage: J = [x^2 + y^2, x^2 + z^2]
5798
5795
sage: (y^2).in_subalgebra(J)
5799
- ...
5800
5796
False
5801
5797
sage: a = (x^2 + y^2) * (x^2 + z^2)
5802
5798
sage: a.in_subalgebra(J, algorithm='inSubring')
5803
5799
True
5804
5800
sage: (a^2).in_subalgebra(J, algorithm='groebner')
5805
5801
True
5806
5802
sage: (a + a^2).in_subalgebra(J)
5807
- ...
5808
5803
True
5809
5804
"""
5810
5805
R = self .parent()
5811
- if algorithm is not None :
5812
- algorithm = algorithm.lower()
5806
+ algorithm = algorithm.lower()
5813
5807
from sage.libs.singular.function import singular_function, lib as singular_lib
5814
5808
singular_lib(' algebra.lib' )
5815
- if algorithm is None or algorithm == " algebra_containment" :
5816
- return singular_function(' algebra_containment' )(self , R.ideal(J)) == 1
5809
+ if algorithm == " algebra_containment" :
5810
+ execute = singular_function(' execute' )
5811
+ try :
5812
+ get_printlevel = singular_function(' get_printlevel' )
5813
+ except NameError :
5814
+ execute(' proc get_printlevel {return (printlevel);}' )
5815
+ get_printlevel = singular_function(' get_printlevel' )
5816
+ # It's fairly verbose unless printlevel is -1.
5817
+ saved_printlevel = get_printlevel()
5818
+ execute(' printlevel=-1' )
5819
+ contains = singular_function(' algebra_containment' )(self , R.ideal(J)) == 1
5820
+ execute(' printlevel={}' .format(saved_printlevel))
5821
+ return contains
5817
5822
elif algorithm == " insubring" :
5818
5823
return singular_function(' inSubring' )(self , R.ideal(J))[0 ] == 1
5819
5824
elif algorithm == " groebner" :
0 commit comments