<commit_before>#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2016 <NAME> <<EMAIL>>
#
# Distributed under terms of the MIT license.

"""Operations of polynomial class"""

import numpy
from utils.errors import InfLoopError


def eval_poly(x, C):
    """evaluate the value of the polynomial at x using recursion

    Args:
        x: the point at where the value will be evaluated
        C: coefficient array

    Returns:
        value
    """
    assert isinstance(C, numpy.ndarray), \
        "The coefficient array is not a NumPy array"
    assert len(C.shape) == 1, "_coeffs is not a 1D array"

    if C.size == 2:
        return C[0] + C[1] * x
    else:
        return C[0] + x * eval_poly(x, C[1:])


def der_poly(C):
    """der_poly

    Args:
        C: coefficient array

    Returns:
        the coefficient array of the derived polynomial
    """
    assert isinstance(C, numpy.ndarray), \
        "The coefficient array is not a NumPy array"
    assert len(C.shape) == 1, "C is not a 1D array"

    if C.size == 1:
        return numpy.zeros(1)

    dC = numpy.zeros(C.size - 1)
    for i, c in enumerate(C[1:]):
        dC[i] = c * (i + 1)

    return dC


def find_roots(C, z=None):
    """find the roots of the polynomial, using Laguerre's method

    Args:
        C: coefficient array
        z: user-provided initial guesses for all roots

    Returns:
        roots
    """
    assert isinstance(C, numpy.ndarray), \
        "The coefficient array is not a NumPy array"
    assert len(C.shape) == 1, "C is not a 1D array"
    assert C.size > 1, \
        "The order of the polynomial is less than 1, no root exists"
<commit_msg>Correct the name of numerical root-finding scheme<commit_after>#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2016 <NAME> <<EMAIL>>
#
# Distributed under terms of the MIT license.

"""Operations of polynomial class"""

import numpy
from utils.errors import InfLoopError


def eval_poly(x, C):
    """evaluate the value of the polynomial at x using recursion

    Args:
        x: the point at where the value will be evaluated
        C: coefficient array

    Returns:
        value
    """
    assert isinstance(C, numpy.ndarray), \
        "The coefficient array is not a NumPy array"
    assert len(C.shape) == 1, "_coeffs is not a 1D array"

    if C.size == 2:
        return C[0] + C[1] * x
    else:
        return C[0] + x * eval_poly(x, C[1:])


def der_poly(C):
    """der_poly

    Args:
        C: coefficient array

    Returns:
        the coefficient array of the derived polynomial
    """
    assert isinstance(C, numpy.ndarray), \
        "The coefficient array is not a NumPy array"
    assert len(C.shape) == 1, "C is not a 1D array"

    if C.size == 1:
        return numpy.zeros(1)

    dC = numpy.zeros(C.size - 1)
    for i, c in enumerate(C[1:]):
        dC[i] = c * (i + 1)

    return dC


def find_roots(C, z=None):
    """find the roots of the polynomial, using Durand-Kerner method

    Args:
        C: coefficient array
        z: user-provided initial guesses for all roots

    Returns:
        roots
    """
    assert isinstance(C, numpy.ndarray), \
        "The coefficient array is not a NumPy array"
    assert len(C.shape) == 1, "C is not a 1D array"
    assert C.size > 1, \
        "The order of the polynomial is less than 1, no root exists"

{'fraction_non_alphanumeric': 0.11019688510138113, 'fraction_numerical': 0.014692918013517485, 'mean_word_length': 2.314508276533593, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '7124356', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1079, 'n_words': 414}