8000 trying a faster and simpler simp by fchapoton · Pull Request #11 · smzg/msinvar · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

trying a faster and simpler simp #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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 @@ -73,10 +73,14 @@ def root_vars(self, k=2):
"""See :meth:`root_vars`."""
return root_vars(self, k)

def simp(self):
if self == 0:
return self
return self.parent(self.factor().expand())
def simp(f):
if f == 0:
return f
num, den = f.numerator(), f.denominator()
content = den.content()
num /= content
den /= content
return num / den


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