Fixed an error while evaluating lazy elements
authorAntonio Jimenez Pastor <ajpastor@risc.uni-linz.ac.at>
Wed, 20 Feb 2019 14:20:02 +0000 (15:20 +0100)
committerAntonio Jimenez Pastor <ajpastor@risc.uni-linz.ac.at>
Wed, 20 Feb 2019 14:20:02 +0000 (15:20 +0100)
Error detected in the Hypergeometric function.

ajpastor/lazy/conversion.py
ajpastor/lazy/lazyRing.py
releases/diff_defined_functions__0.6.zip
releases/old/diff_defined_functions__0.6__19.02.20_15:20:01.zip [new file with mode: 0644]

index 4949906..2fdff3d 100644 (file)
@@ -267,21 +267,26 @@ class ConversionSystem(object):
             This method can be overwritten if needed.
         '''
         variables = polynomial.variables();
-        multi = (len(variables) > _sage_const_1 );
-        res = self.base().zero();
-        for (k,v) in polynomial.dict().items():
-            term = self.base().one();
-            ## We distinguish between several variables and just one
-            ## because the return of poly.dict() is different
-            if(multi):
-                for i in range(len(variables)):
-                    term *= (self.map_of_vars()[str(variables[i])]**k[i]);
-            else:
-                term *= self.map_of_vars()[str(variables[_sage_const_0 ])]**k;
-                
-            res += term*self.base()(v);
-            
-        return res;
+
+        if(len(variables) == 0):
+            return self.base()(polynomial);
+
+        return polynomial(**{str(v) : self.map_of_vars()[str(v)] for v in variables});
+#        multi = (len(variables) > _sage_const_1 );
+#        res = self.base().zero();
+#        for (k,v) in polynomial.dict().items():
+#            term = self.base().one();
+#            ## We distinguish between several variables and just one
+#            ## because the return of poly.dict() is different
+#            if(multi):
+#                for i in range(len(variables)):
+#                    term *= (self.map_of_vars()[str(variables[i])]**k[i]);
+#            else:
+#                term *= self.map_of_vars()[str(variables[_sage_const_0 ])]**k;
+#                
+#            res += term*self.base()(v);
+#            
+#        return res;
         
     def _mix_conversion(self, conversion):
         '''
index 6f2e32d..8b0683e 100644 (file)
@@ -2,7 +2,6 @@
 # This file was *autogenerated* from the file ./lazyRing.sage
 from sage.all_cmdline import *   # import sage library
 
-_sage_const_2 = Integer(2); _sage_const_1 = Integer(1); _sage_const_0 = Integer(0); _sage_const_20 = Integer(20)
 from sage.rings.ring import IntegralDomain;
 from sage.structure.element import IntegralDomainElement;
 from sage.categories.integral_domains import IntegralDomains;
@@ -167,7 +166,7 @@ class _LazyElement(IntegralDomainElement):
         '''
         Method that a common divisor of 'self' and the input
         '''
-        if(len(input) > _sage_const_1 ):
+        if(len(input) > 1 ):
             return self.gcd(input);
         
         return _LazyElement(self.parent(), gcd([self.poly()]+[self.parent()(el).poly() for el in input]));
@@ -176,7 +175,7 @@ class _LazyElement(IntegralDomainElement):
         '''
         Method that a common multiple of 'self' and the input
         '''
-        if(len(input) > _sage_const_1 ):
+        if(len(input) > 1 ):
             return self.gcd(input);
         
         return _LazyElement(self.parent(), lcm([self.poly()]+[self.parent()(el).poly() for el in input]));
@@ -209,10 +208,10 @@ class _LazyElement(IntegralDomainElement):
     #    return result;
         
     def is_zero(self):
-        result = (self.poly() == _sage_const_0 );
-        if((not result) and (self(**{repr(self.parent().base().variables()[_sage_const_0 ]):_sage_const_0 }) == _sage_const_0 )):
+        result = (self.poly() == 0 );
+        if((not result) and (self(**{repr(self.parent().base().variables()[0]):0}) == 0)):
             if(not (self.__raw is None)):
-                result = self.raw() == _sage_const_0 ;
+                result = self.raw() == 0 ;
             else:
                 pol = None;
                 if(self.poly() in self.parent().poly_ring()):
@@ -227,20 +226,20 @@ class _LazyElement(IntegralDomainElement):
                     except NotImplementedError:
                         factors = pol.factor(proof=False);
                 except:
-                    factors = [(pol,_sage_const_1 )];
+                    factors = [(pol,1 )];
                 for factor in factors:
-                    result = (self.parent().to_real(factor[_sage_const_0 ]) == _sage_const_0 );
+                    result = (self.parent().to_real(factor[0 ]) == 0 );
                     if(result):
-                        self.parent().add_relations(factor[_sage_const_0 ]);
+                        self.parent().add_relations(factor[0 ]);
                         break;
                         
         return result;
         
     def is_one(self):
         try:
-            result = (self.poly() == _sage_const_1 ) or (self.raw() == self.parent().one());
+            result = (self.poly() == 1 ) or (self.raw() == self.parent().one());
             if(result):
-                self.parent().add_relations(self.poly()-_sage_const_1 );
+                self.parent().add_relations(self.poly()-1 );
             return result;
         except TypeError:
             return False;
@@ -294,7 +293,7 @@ class LazyRing (UniqueRepresentation, ConversionSystem, IntegralDomain):
         
         ## Auxiliary data
         self.__var_name = "x";
-        self.__version = _sage_const_1 ;
+        self.__version = 1 ;
                  
     
     ################################################################################################
@@ -332,17 +331,17 @@ class LazyRing (UniqueRepresentation, ConversionSystem, IntegralDomain):
         try:
             built = element.built();
             if(not (built is None)):
-                if(built[_sage_const_0 ] == "derivative"):
-                    if(not(element in built[_sage_const_1 ])):
-                        integral = self(built[_sage_const_1 ][_sage_const_0 ]);
-                        if(not (integral.poly().is_monomial() and integral.poly().degree() == _sage_const_1 )):
-                            return self(built[_sage_const_1 ][_sage_const_0 ]).derivative().poly();
-                elif(built[_sage_const_0 ] == "polynomial"):
+                if(built[0 ] == "derivative"):
+                    if(not(element in built[1 ])):
+                        integral = self(built[1 ][0 ]);
+                        if(not (integral.poly().is_monomial() and integral.poly().degree() == 1 )):
+                            return self(built[1 ][0 ]).derivative().poly();
+                elif(built[0 ] == "polynomial"):
                     ## We check we do not have infinite recursion
-                    if(not element in built[_sage_const_1 ][_sage_const_1 ].values()):
+                    if(not element in built[1 ][1 ].values()):
                         ## We have some building information
-                        polys = {key : self.to_poly(built[_sage_const_1 ][_sage_const_1 ][key]) for key in built[_sage_const_1 ][_sage_const_1 ]};
-                        return built[_sage_const_1 ][_sage_const_0 ](**polys);
+                        polys = {key : self.to_poly(built[1 ][1 ][key]) for key in built[1 ][1 ]};
+                        return built[1 ][0 ](**polys);
         except AttributeError:
             pass;
             
@@ -371,14 +370,14 @@ class LazyRing (UniqueRepresentation, ConversionSystem, IntegralDomain):
             
         ## We try to keep the real representations small
         try:
-            new_elem = (element-rel[_sage_const_1 ])/rel[_sage_const_0 ];
+            new_elem = (element-rel[1 ])/rel[0 ];
             if(new_elem.size() < self.map_of_vars()[var_found].size()):
                 self.__map_of_vars[var_found] = new_elem;
         except:
             pass;
             
         ## Otherwise, we return the polynomial computed
-        return self.poly_ring()(rel[_sage_const_0 ]*self.poly_ring()(var_found) + rel[_sage_const_1 ]);
+        return self.poly_ring()(rel[0 ]*self.poly_ring()(var_found) + rel[1 ]);
         
     ################################################################################################
     ### Other Methods for LazyRing
@@ -402,7 +401,7 @@ class LazyRing (UniqueRepresentation, ConversionSystem, IntegralDomain):
         ## Deleting the map of derivatives
         self.__map_of_derivatives = {};
         
-        self.__version += _sage_const_1 ;
+        self.__version += 1 ;
         
     def change_variable_name(self, new_name):
         self.__var_name = str(new_name);
@@ -415,7 +414,7 @@ class LazyRing (UniqueRepresentation, ConversionSystem, IntegralDomain):
             return self.__map_of_derivatives[el];
             
         if(el in self.__constants):
-            return _sage_const_0 ;
+            return 0 ;
         else:
             try:
                 el = self.poly_ring()(el);
@@ -478,15 +477,15 @@ class LazyRing (UniqueRepresentation, ConversionSystem, IntegralDomain):
         return (not(coer is False) and not(coer is None));
         
     def _element_constructor_(self, *args, **kwds):
-        if(len(args) < _sage_const_1 ):
+        if(len(args) < 1 ):
             print args
             raise ValueError("Impossible to build an element without arguments");
         
-        i = _sage_const_0 ;
-        if(len(args) >= _sage_const_2 ):
-            if(not (args[_sage_const_0 ] is self)):
+        i = 0 ;
+        if(len(args) >= 2 ):
+            if(not (args[0 ] is self)):
                 raise ValueError("RIOKO: What the .... are you sending to this method?");
-            i = _sage_const_1 ;
+            i = 1 ;
         X = args[i];
         
         try:
@@ -547,17 +546,17 @@ class LazyRing (UniqueRepresentation, ConversionSystem, IntegralDomain):
             
     def __find_relation(self, a, b):
         ## TODO We assume a and b are not constants
-        i = _sage_const_1 ;
-        while(self.sequence(a,i) == _sage_const_0  and self.sequence(b,i) == _sage_const_0 ):
-            i = i + _sage_const_1 ;
+        i = 1 ;
+        while(self.sequence(a,i) == 0  and self.sequence(b,i) == 0 ):
+            i = i + 1 ;
             
         ai = self.sequence(a,i);
         bi = self.sequence(b,i);
-        if(bi == _sage_const_0  or ai == _sage_const_0 ):
+        if(bi == 0  or ai == 0 ):
             return None;
             
         c = ai/bi;
-        d = self.sequence(a,_sage_const_0 )-c*self.sequence(b,_sage_const_0 );
+        d = self.sequence(a,0 )-c*self.sequence(b,0 );
         
         if(a == c*b + d):
             return (c,d);
@@ -572,7 +571,7 @@ class LazyRing (UniqueRepresentation, ConversionSystem, IntegralDomain):
 class LazyRingFunctor (ConstructionFunctor):
     def __init__(self):
         ID = IntegralDomains();
-        self.rank = _sage_const_20 ;
+        self.rank = 20 ;
         super(LazyRingFunctor, self).__init__(ID,ID);
         
     ### Methods to implement
index 03648d0..6fde1bf 100644 (file)
Binary files a/releases/diff_defined_functions__0.6.zip and b/releases/diff_defined_functions__0.6.zip differ
diff --git a/releases/old/diff_defined_functions__0.6__19.02.20_15:20:01.zip b/releases/old/diff_defined_functions__0.6__19.02.20_15:20:01.zip
new file mode 100644 (file)
index 0000000..6fde1bf
Binary files /dev/null and b/releases/old/diff_defined_functions__0.6__19.02.20_15:20:01.zip differ