From: Antonio Jimenez Pastor Date: Wed, 29 Aug 2018 17:31:35 +0000 (+0200) Subject: First test with D3Finite functions. X-Git-Url: http://git.risc.jku.at/gitweb/?a=commitdiff_plain;h=8f3788fcc4b3e2f020514d5e48a713fd6eff4e62;p=ajpastor%2Fdiff_defined_functions.git First test with D3Finite functions. --- diff --git a/ajpastor/dd_functions/ddFunction.py b/ajpastor/dd_functions/ddFunction.py index d268678..04d7398 100644 --- a/ajpastor/dd_functions/ddFunction.py +++ b/ajpastor/dd_functions/ddFunction.py @@ -2137,6 +2137,10 @@ class DDRingFunctor (ConstructionFunctor): def _repr_(self): return "DDRing(*,%d,%s)" %(self.__depth, self.__base_field); + def __eq__(self, other): + if(other.__class__ == self.__class__): + return ((other.__depth == self.__depth) and (other.__base_field == self.__base_field)) + def depth(self): return self.__depth; diff --git a/ajpastor/dd_functions/toDiffAlgebraic.py b/ajpastor/dd_functions/toDiffAlgebraic.py index 7767bce..ab62169 100644 --- a/ajpastor/dd_functions/toDiffAlgebraic.py +++ b/ajpastor/dd_functions/toDiffAlgebraic.py @@ -47,19 +47,24 @@ def infinite_derivative(element, times=1): except AttributeError: return parent.zero(); if(element.is_monomial()): - if(len(element.variables()) == 1): + if(len(element.variables()) == 1 and element.degree() == 1): return parent(repr(parent.gen()).replace("*", str(int(str(element).split("_")[-1])+1))); else: degrees = element.degrees(); variables = [parent("y_%d" %i) for i in range(len(degrees))]; variables.reverse(); - print degrees; - print variables; - part = prod(variables[i]**(degrees[i]-1) for i in range(len(degrees))); - return sum([degrees[i]*infinite_derivative(variables[i])*prod(variables[j] for j in range(len(variables)) if i != j) for i in range(len(variables))]); + ## Computing the common factor + com_factor = prod([variables[i]**(degrees[i]-1) for i in range(len(degrees)) if degrees[i] > 0]); + ## Computing the derivative for each variable + each_sum = [ + degrees[i]*infinite_derivative(variables[i])*prod( + variables[j] for j in range(len(variables)) if ((i != j) and (degrees[j] > 0))) + for i in range(len(variables)) if degrees[i] > 0]; + + return com_factor*sum(each_sum); else: coefficients = element.coefficients(); monomials = element.monomials(); - return sum([coefficients[i].derivative()*monomials[i] + coefficients[i]*infinite_derivative(parent(monomials[i])) for i in range(len(monomials))]); + return sum([infinite_derivative(coefficients[i])*monomials[i] + coefficients[i]*infinite_derivative(parent(monomials[i])) for i in range(len(monomials))]); def fromInfinityPolynomial_toFinitePolynomial(poly): if(not is_InfinitePolynomialRing(poly.parent())): @@ -151,12 +156,12 @@ def toDifferentiallyAlgebraic_Below(poly): row += [infinite_derivative(row[-1])]; rows += [row]; else: - rows += [row for row in matrix_of_dMovement(el.equation.companion(), vector(goal_ring, dict_to_vectors[el]), infinite_derivative, S)]; + C = el.equation.companion(); + C = Matrix(goal_ring.base(),[[goal_ring.base()(row_el) for row_el in row] for row in C]); + rows += [row for row in matrix_of_dMovement(C, vector(goal_ring, dict_to_vectors[el]), infinite_derivative, S)]; - M = Matrix(goal_ring, rows); - print M; - - return M.determinant(); + M = Matrix(rows); + return M.determinant().numerator(); def diff_to_diffalg(func): try: @@ -169,6 +174,7 @@ def diff_to_diffalg(func): p = sum(func[i]*R("y_%d" %i) for i in range(func.getOrder()+1)); for i in range(parent.depth()-1): p = toDifferentiallyAlgebraic_Below(p); + return p; else: R = PolynomialRing(PolynomialRing(QQ,x).fraction_field, "y_0"); return R.gens()[0] - func; diff --git a/releases/diff_defined_functions__0.5.zip b/releases/diff_defined_functions__0.5.zip index aa554ee..44dd984 100644 Binary files a/releases/diff_defined_functions__0.5.zip and b/releases/diff_defined_functions__0.5.zip differ diff --git a/releases/old/diff_defined_functions__0.5__18.08.29_19:31:34.zip b/releases/old/diff_defined_functions__0.5__18.08.29_19:31:34.zip new file mode 100644 index 0000000..44dd984 Binary files /dev/null and b/releases/old/diff_defined_functions__0.5__18.08.29_19:31:34.zip differ