Ticket #991: trac_991.patch

File trac_991.patch, 4.6 KB (added by malb, 14 years ago)
  • sage/rings/polynomial/multi_polynomial_libsingular.pyx

    # HG changeset patch
    # User Martin Albrecht <malb@informatik.uni-bremen.de>
    # Date 1195319938 0
    # Node ID 0b49417bdbc793222688baf7ce4e5acbed9c6cfb
    # Parent  31a18043fb4d81a0fa10016d09fbf627a6f214bf
    fixing #991 (problem in interaction with Singular subprocesses)
    
    diff -r 31a18043fb4d -r 0b49417bdbc7 sage/rings/polynomial/multi_polynomial_libsingular.pyx
    a b cdef class MPolynomialRing_libsingular(M 
    792792                return R
    793793            if self.base_ring().is_finite():
    794794                R.set_ring() #sorry for that, but needed for minpoly
    795                 if  singular.eval('minpoly') != self.__minpoly:
     795                if  singular.eval('minpoly') != "(" + self.__minpoly + ")":
    796796                    singular.eval("minpoly=%s"%(self.__minpoly))
     797                    self.__minpoly = singular.eval('minpoly')[1:-1] # store in correct format
    797798            return R
    798799        except (AttributeError, ValueError):
    799800            return self._singular_init_(singular)
    cdef class MPolynomialRing_libsingular(M 
    859860        elif self.base_ring().is_finite(): #must be extension field
    860861            gen = str(self.base_ring().gen())
    861862            r = singular.ring( "(%s,%s)"%(self.characteristic(),gen), _vars, order=order)
    862             self.__minpoly = "("+(str(self.base_ring().modulus()).replace("x",gen)).replace(" ","")+")"
    863             singular.eval("minpoly=%s"%(self.__minpoly) )
    864 
     863            self.__minpoly = (str(self.base_ring().modulus()).replace("x",gen)).replace(" ","")
     864            if  singular.eval('minpoly') != "(" + self.__minpoly + ")":
     865                singular.eval("minpoly=%s"%(self.__minpoly) )
     866                self.__minpoly = singular.eval('minpoly')[1:-1]
    865867            self.__singular = r
    866868        else:   
    867869            raise TypeError, "no conversion to a Singular ring defined"
  • sage/rings/polynomial/polynomial_singular_interface.py

    diff -r 31a18043fb4d -r 0b49417bdbc7 sage/rings/polynomial/polynomial_singular_interface.py
    a b class PolynomialRing_singular_repr: 
    164164            if sage.rings.ring.is_FiniteField(self.base_ring()) or\
    165165                    number_field.all.is_NumberField(self.base_ring()):
    166166                R.set_ring() #sorry for that, but needed for minpoly
    167                 if  singular.eval('minpoly') != self.__minpoly:
     167                if  singular.eval('minpoly') != "(" + self.__minpoly + ")":
    168168                    singular.eval("minpoly=%s"%(self.__minpoly))
     169                    self.__minpoly = singular.eval('minpoly')[1:-1]
     170
    169171            return R
    170172        except (AttributeError, ValueError):
    171173            return self._singular_init_(singular, force)
    class PolynomialRing_singular_repr: 
    217219            # not the prime field!
    218220            gen = str(self.base_ring().gen())
    219221            r = singular.ring( "(%s,%s)"%(self.characteristic(),gen), _vars, order=order, check=False)
    220             self.__minpoly = "("+(str(self.base_ring().modulus()).replace("x",gen)).replace(" ","")+")"
    221             singular.eval("minpoly=%s"%(self.__minpoly) )
     222            self.__minpoly = (str(self.base_ring().modulus()).replace("x",gen)).replace(" ","")
     223            if  singular.eval('minpoly') != "(" + self.__minpoly + ")":
     224                singular.eval("minpoly=%s"%(self.__minpoly) )
     225                self.__minpoly = singular.eval('minpoly')[1:-1]
    222226
    223227            self.__singular = r
     228
    224229        elif number_field.all.is_NumberField(self.base_ring()):
    225230            # not the rationals!
    226231            gen = str(self.base_ring().gen())
    class PolynomialRing_singular_repr: 
    228233            poly_gen=str(poly.parent().gen())
    229234            poly_str=str(poly).replace(poly_gen,gen)
    230235            r = singular.ring( "(%s,%s)"%(self.characteristic(),gen), _vars, order=order, check=False)
    231             self.__minpoly = "("+(poly_str).replace(" ","")+")"
    232             singular.eval("minpoly=%s"%(self.__minpoly) )
     236            self.__minpoly = (poly_str).replace(" ","")
     237            if  singular.eval('minpoly') != "(" + self.__minpoly + ")":
     238                singular.eval("minpoly=%s"%(self.__minpoly) )
     239                self.__minpoly = singular.eval('minpoly')[1:-1]
    233240
    234241            self.__singular = r
    235                        
    236242       
    237243        else:   
    238244            raise TypeError, "no conversion to a Singular ring defined"