Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions msinvar/flow_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@
# Copyright (C) 2021 Sergey Mozgovoy <mozhov@gmail.com>
#
# Distributed under the terms of the GNU General Public License (GPL)
# http://www.gnu.org/licenses/
# https://www.gnu.org/licenses/
# *****************************************************************************

from sage.misc.misc_c import prod
from sage.functions.other import factorial
from sage.combinat.permutation import Permutations
from sage.misc.prandom import random
from sage.rings.rational_field import QQ

from msinvar.utils import vec
from msinvar.invariants import Transform, Invariant
from msinvar.iterators import UnorderedMultiPartitions_iterator
Expand Down Expand Up @@ -200,6 +201,10 @@ def simp(f):
if f == 0:
return f
try:
return f.parent(f.factor().expand())
except (TypeError, ValueError):
num, den = f.numerator(), f.denominator()
content = den.content()
num /= content
den /= content
return num / den
except (TypeError, ValueError, AttributeError):
return f
12 changes: 8 additions & 4 deletions msinvar/rings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# Copyright (C) 2021 Sergey Mozgovoy <mozhov@gmail.com>
#
# Distributed under the terms of the GNU General Public License (GPL)
# http://www.gnu.org/licenses/
# https://www.gnu.org/licenses/
# *****************************************************************************

from sage.rings.fraction_field import FractionField_generic
Expand Down Expand Up @@ -51,14 +51,14 @@ class RationalFunctionField(FractionField_generic):
(-1) * (-x + y) * (y + 1)^5
"""

def __init__(self, vars='y', base=QQ):
def __init__(self, vars='y', base=QQ) -> None:
vars = vars.split(',')
R = MPolynomialRing_libsingular(base, n=len(vars), names=vars)
# cat=Category.join([QuotientFields(),LambdaRings()])
super().__init__(R, element_class=RationalFunction) # , category=cat)
LambdaRings.add_ring(self)

def _repr_(self):
def _repr_(self) -> str:
vars = ', '.join(self.variable_names())
return 'Field of Rational Functions in ' + vars

Expand All @@ -76,7 +76,11 @@ def root_vars(self, k=2):
def simp(self):
if self == 0:
return self
return self.parent(self.factor().expand())
num, den = self.numerator(), self.denominator()
content = den.content()
num /= content
den /= content
return num / den


def root_vars(f, k=2):
Expand Down