<commit_before>"""Basic tools for dense recursive polynomials in `K[x]` or `K[X]`. """

from sympy.utilities import any, all
from sympy.core import igcd, ilcm

from sympy.polys.monomialtools import (
    monomial_key, monomial_min, monomial_div
)

from sympy.polys.groebnertools import sdp_sort

from sympy.utilities import cythonized

import random

def poly_LC(f, K):
    """Returns leading coefficient of `f`. """
    if not f:
        return K.zero
    else:
        return f[0]

def poly_TC(f, K):
    """Returns trailing coefficient of `f`. """
    if not f:
        return K.zero
    else:
        return f[-1]

dup_LC = dmp_LC = poly_LC
dup_TC = dmp_TC = poly_TC

@cythonized("u")
def dmp_ground_LC(f, u, K):
    """Returns ground leading coefficient. """
    if not u:
        return dup_LC(f, K)
    else:
        return dmp_ground_LC(dmp_LC(f, K), u-1, K)

@cythonized("u")
def dmp_ground_TC(f, u, K):
    """Returns ground trailing coefficient. """
    if not u:
        return dup_TC(f, K)
    else:
        return dmp_ground_TC(dmp_TC(f, K), u-1, K)

@cythonized("u")
def dmp_true_LT(f, u, K):
    """Returns leading term `c * x_1**n_1 ... x_k**n_k`. """
    monom = []

    while u:
        monom.append(len(f) - 1)
        f, u = f[0], u - 1

    if not f:
        monom.append(0)
    else:
        monom.append(len(f) - 1)

    return tuple(monom), dup_LC(f, K)

def dup_degree(f):
    """Returns leading degree of `f` in `K[x]`. """
    return len(f) - 1

@cythonized("u")
def dmp_degree(f, u):
    """Returns leading degree of `f` in `x_0` in `K[X]`. """
    if dmp_zero_p(f, u):<commit_msg>Make dmp_ground_LC and dmp_ground_TC non-recursive<commit_after>"""Basic tools for dense recursive polynomials in `K[x]` or `K[X]`. """

from sympy.utilities import any, all
from sympy.core import igcd, ilcm

from sympy.polys.monomialtools import (
    monomial_key, monomial_min, monomial_div
)

from sympy.polys.groebnertools import sdp_sort

from sympy.utilities import cythonized

import random

def poly_LC(f, K):
    """Returns leading coefficient of `f`. """
    if not f:
        return K.zero
    else:
        return f[0]

def poly_TC(f, K):
    """Returns trailing coefficient of `f`. """
    if not f:
        return K.zero
    else:
        return f[-1]

dup_LC = dmp_LC = poly_LC
dup_TC = dmp_TC = poly_TC

@cythonized("u")
def dmp_ground_LC(f, u, K):
    """Returns ground leading coefficient. """
    while u:
        f = dmp_LC(f, K)
        u -= 1
    return dup_LC(f, K)

@cythonized("u")
def dmp_ground_TC(f, u, K):
    """Returns ground trailing coefficient. """
    while u:
        f = dmp_TC(f, K)
        u -= 1
    return dup_TC(f, K)

@cythonized("u")
def dmp_true_LT(f, u, K):
    """Returns leading term `c * x_1**n_1 ... x_k**n_k`. """
    monom = []

    while u:
        monom.append(len(f) - 1)
        f, u = f[0], u - 1

    if not f:
        monom.append(0)
    else:
        monom.append(len(f) - 1)

    return tuple(monom), dup_LC(f, K)

def dup_degree(f):
    """Returns leading degree of `f` in `K[x]`. """
    return len(f) - 1

@cythonized("u")
def dmp_degree(f, u):
    """Returns leading degree of `f` in `x_0` in `K[X]`. """
    if dmp_zero_p(f, u):
{'fraction_non_alphanumeric': 0.14758190327613105, 'fraction_numerical': 0.008112324492979718, 'mean_word_length': 2.685057471264368, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2328744', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1247, 'n_words': 351}