hash
stringlengths
64
64
content
stringlengths
0
1.51M
1e26747b136c86087279b841157a002bbdf59157b1f4ea1c42d82abede8811c4
""" This is a shim file to provide backwards compatibility (ccode.py was renamed to c.py in SymPy 1.7). """ from sympy.utilities.exceptions import SymPyDeprecationWarning SymPyDeprecationWarning( feature="importing from sympy.printing.ccode", useinstead="Import from sympy.printing.c", issue=20256, dep...
0a6f58d30d400d3fe5f40d9c4c4ae1f07c90fe0572355102e58ac18305d789f3
""" A MathML printer. """ from typing import Any, Dict from sympy import sympify, S, Mul from sympy.core.compatibility import default_sort_key from sympy.core.function import _coeff_isneg from sympy.printing.conventions import split_super_sub, requires_partial from sympy.printing.precedence import \ precedence_tr...
0e6e70033972a7899bddcc0d503b351d57dd25dc791f1044679ffb423e32b3b0
""" R code printer The RCodePrinter converts single sympy expressions into single R expressions, using the functions defined in math.h where possible. """ from typing import Any, Dict from sympy.printing.codeprinter import CodePrinter from sympy.printing.precedence import precedence, PRECEDENCE from sympy.sets.fa...
4bb580cbda07667946185148f7cfc8ba0ae8e4d6c8ae74dc9b2bbcfb50236034
""" Octave (and Matlab) code printer The `OctaveCodePrinter` converts SymPy expressions into Octave expressions. It uses a subset of the Octave language for Matlab compatibility. A complete code generator, which uses `octave_code` extensively, can be found in `sympy.utilities.codegen`. The `codegen` module can be us...
edcd917453f98c1e2ae9c66b21893906516d8a8147e9393bf0bc1672da7b82dc
""" This is a shim file to provide backwards compatibility (fcode.py was renamed to fortran.py in SymPy 1.7). """ from sympy.utilities.exceptions import SymPyDeprecationWarning SymPyDeprecationWarning( feature="importing from sympy.printing.fcode", useinstead="Import from sympy.printing.fortran", issue=20...
0901172461697b28c8d780a4b41e896644ff211495ca4344d52fa64b7abaa1a9
from typing import Any, Dict, Set, Tuple from functools import wraps from sympy.core import Add, Expr, Mul, Pow, S, sympify, Float from sympy.core.basic import Basic from sympy.core.compatibility import default_sort_key from sympy.core.function import Lambda from sympy.core.mul import _keep_coeff from sympy.core.symb...
10e2c0c6e85ea0d87b744a74c77f37ebaa55107852f2bff44e9df7b916cc9a0f
import keyword as kw import sympy from .repr import ReprPrinter from .str import StrPrinter # A list of classes that should be printed using StrPrinter STRPRINT = ("Add", "Infinity", "Integer", "Mul", "NegativeInfinity", "Pow", "Zero") class PythonPrinter(ReprPrinter, StrPrinter): """A printer which ...
086157bd4f4714a92ec721072e920d88691fe2ae03105768dbc04e1fc4477c77
""" Maple code printer The MapleCodePrinter converts single sympy expressions into single Maple expressions, using the functions defined in the Maple objects where possible. FIXME: This module is still under actively developed. Some functions may be not completed. """ from sympy.core import S from sympy.core.number...
6423ef542699a534043d4a362cee6e65d28793fd4cc9d2f7005bf924efe72f2c
from distutils.version import LooseVersion as V from sympy import Mul, S from sympy.codegen.cfunctions import Sqrt from sympy.core.compatibility import Iterable from sympy.external import import_module from sympy.printing.precedence import PRECEDENCE from sympy.printing.pycode import AbstractPythonCodePrinter import s...
b9e46bcab372897445e7f3d63d96feb2add9c15f31ba4bd45590be31d6f24d63
from sympy.core.basic import Basic from sympy.core.expr import Expr from sympy.core.symbol import Symbol from sympy.core.numbers import Integer, Rational, Float from sympy.printing.repr import srepr __all__ = ['dotprint'] default_styles = ( (Basic, {'color': 'blue', 'shape': 'ellipse'}), (Expr, {'color': 'bl...
fa56866e432bfc868c08d5cbb684a7574d3c583f163be8eaeb807a6dce636496
import os from os.path import join import shutil import tempfile try: from subprocess import STDOUT, CalledProcessError, check_output except ImportError: pass from sympy.utilities.decorator import doctest_depends_on from .latex import latex __doctest_requires__ = {('preview',): ['pyglet']} def _check_outpu...
bbc08e3e1f9bff1710174065bd562a0b7dbe293509dcfa02e67d15bf2fc8ba96
""" Javascript code printer The JavascriptCodePrinter converts single sympy expressions into single Javascript expressions, using the functions defined in the Javascript Math object where possible. """ from typing import Any, Dict from sympy.core import S from sympy.printing.codeprinter import CodePrinter from symp...
622b4b7c845f147f25b4d775f18e98b4182ae47dad7b4c052a51ee20ee1cbe8f
from sympy.core._print_helpers import Printable # alias for compatibility Printable.__module__ = __name__ DefaultPrinting = Printable
0252fb94f490ff17caa893ac69c988ba11e843ba5ec2531621beebda8a376cf0
""" Julia code printer The `JuliaCodePrinter` converts SymPy expressions into Julia expressions. A complete code generator, which uses `julia_code` extensively, can be found in `sympy.utilities.codegen`. The `codegen` module can be used to generate complete source code files. """ from typing import Any, Dict from...
54cd693095a6b7fd30d720db88d9bf892c38a5dff8f4d0c64849e0f5847518fc
from typing import Set from sympy.core import Basic, S from sympy.core.function import _coeff_isneg, Lambda from sympy.printing.codeprinter import CodePrinter from sympy.printing.precedence import precedence from functools import reduce known_functions = { 'Abs': 'abs', 'sin': 'sin', 'cos': 'cos', 'ta...
e58cf4de9be93e85405d11e5fe2d768651b1d1a3a79fdd246fc93ffe31d6e54e
from typing import Any, Dict from sympy.core.compatibility import is_sequence from sympy.external import import_module from sympy.printing.printer import Printer import sympy from functools import partial theano = import_module('theano') if theano: ts = theano.scalar tt = theano.tensor from theano.sandb...
889e040c00c266f699a093bb715f89678b508666a8b67de666f08fdec2ec668d
"""Integration method that emulates by-hand techniques. This module also provides functionality to get the steps used to evaluate a particular integral, in the ``integral_steps`` function. This will return nested namedtuples representing the integration rules used. The ``manualintegrate`` function computes the integra...
ea1db3425cc086498b93b9944beeefb448b8809498a5d5cd50a5101851ac627d
from sympy.functions import SingularityFunction, DiracDelta from sympy.core import sympify from sympy.integrals import integrate def singularityintegrate(f, x): """ This function handles the indefinite integrations of Singularity functions. The ``integrate`` function calls this function internally wheneve...
1e47956b57f4c8f373b224dbaa3b62a418afd1a73d23ef15b300ca1b7b5b4689
""" Integral Transforms """ from sympy.core import S from sympy.core.compatibility import reduce, iterable from sympy.core.function import Function from sympy.core.relational import _canonical, Ge, Gt from sympy.core.numbers import oo from sympy.core.symbol import Dummy from sympy.integrals import integrate, Integral ...
35745b8be8949859fc93d18480bc44bd9898f9d9535d7d8abad8e5978de7f5d7
from sympy.core import S, Dummy, pi from sympy.functions.combinatorial.factorials import factorial from sympy.functions.elementary.trigonometric import sin, cos from sympy.functions.elementary.miscellaneous import sqrt from sympy.functions.special.gamma_functions import gamma from sympy.polys.orthopolys import (legendr...
696db6b6b017255fbc1bc08c43ee546d4baedf56667a4159621f6227835bfed0
""" Module to implement integration of uni/bivariate polynomials over 2D Polytopes and uni/bi/trivariate polynomials over 3D Polytopes. Uses evaluation techniques as described in Chin et al. (2015) [1]. References =========== .. [1] Chin, Eric B., Jean B. Lasserre, and N. Sukumar. "Numerical integration of homogene...
4fb3ffe781598da07cf636e830d8d419458ef7bc7d05a876117359f5f73e5a6e
from sympy.concrete.expr_with_limits import AddWithLimits from sympy.core.add import Add from sympy.core.basic import Basic from sympy.core.compatibility import is_sequence from sympy.core.containers import Tuple from sympy.core.expr import Expr from sympy.core.function import diff from sympy.core.logic import fuzzy_bo...
8b3c8be3a3c695794b42ec6cfb593b8eede174e4f4ddd2e7b6f25ba3ebeb26bb
from typing import Dict, List from itertools import permutations from sympy.core.add import Add from sympy.core.basic import Basic from sympy.core.mul import Mul from sympy.core.symbol import Wild, Dummy from sympy.core.basic import sympify from sympy.core.numbers import Rational, pi, I from sympy.core.relational imp...
c6f185468b176acece711db7e0d4a7c7d0eed99dbc767743fbb0d1c9e5a10841
""" Algorithms for solving the Risch differential equation. Given a differential field K of characteristic 0 that is a simple monomial extension of a base field k and f, g in K, the Risch Differential Equation problem is to decide if there exist y in K such that Dy + f*y == g and to find one if there are some. If t i...
c07653a8ffab2efbb7bf1c3f2988ab6cb872d6c9fca907b4d9455fb50c51df57
""" The Risch Algorithm for transcendental function integration. The core algorithms for the Risch algorithm are here. The subproblem algorithms are in the rde.py and prde.py files for the Risch Differential Equation solver and the parametric problems solvers, respectively. All important information concerning the d...
0b2c852a298b9590d382cc491b1d1ae29785c9bc294d3048e34b4170066fe877
"""This module implements tools for integrating rational functions. """ from sympy import S, Symbol, symbols, I, log, atan, \ roots, RootSum, Lambda, cancel, Dummy from sympy.polys import Poly, resultant, ZZ def ratint(f, x, **flags): """ Performs indefinite integration of rational functions. Explan...
54d17634486ef93d8cf7374c343ac0625cb71b256b49e1c39ca8de3083ce6645
from sympy.core import Mul from sympy.functions import DiracDelta, Heaviside from sympy.core.compatibility import default_sort_key from sympy.core.singleton import S def change_mul(node, x): """change_mul(node, x) Rearranges the operands of a product, bringing to front any simple DiracDelta express...
c9508fc95b61b529cdc32577c82e5be2bfa728f6e6f62cae486cafd67a3036df
""" Algorithms for solving Parametric Risch Differential Equations. The methods used for solving Parametric Risch Differential Equations parallel those for solving Risch Differential Equations. See the outline in the docstring of rde.py for more information. The Parametric Risch Differential Equation problem is, giv...
74361de19f6a29952f10389225a12b972b615302c92cbdfbcca7ba3d601d0a8c
from sympy.core import cacheit, Dummy, Ne, Integer, Rational, S, Wild from sympy.functions import binomial, sin, cos, Piecewise # TODO sin(a*x)*cos(b*x) -> sin((a+b)x) + sin((a-b)x) ? # creating, each time, Wild's and sin/cos/Mul is expensive. Also, our match & # subs are very slow when not cached, and if we create W...
a3b3e253920a50a8a9a7b8f11d6161e67fece52181c5355bd7319c8f3c31bbe8
""" Integrate functions by rewriting them as Meijer G-functions. There are three user-visible functions that can be used by other parts of the sympy library to solve various integration problems: - meijerint_indefinite - meijerint_definite - meijerint_inversion They can be used to compute, respectively, indefinite i...
3d1e65958beb399e2237be3191c70ac8df3f84ee001cf03472689fde84cc1ada
""" SymPy core decorators. The purpose of this module is to expose decorators without any other dependencies, so that they can be easily imported anywhere in sympy/core. """ from functools import wraps from .sympify import SympifyError, sympify from sympy.core.compatibility import get_function_code def deprecated(*...
64a5020f0a72b5970ffd271ac6fbdf497415e3cec8cedb2343593f43901c622e
from math import log as _log from .sympify import _sympify from .cache import cacheit from .singleton import S from .expr import Expr from .evalf import PrecisionExhausted from .function import (_coeff_isneg, expand_complex, expand_multinomial, expand_mul) from .logic import fuzzy_bool, fuzzy_not, fuzzy_and from ....
55bba8aa9d194051f74deda63e84e21b17e44ecd7e3298cb8b4ce208a47f38d1
"""Thread-safe global parameters""" from .cache import clear_cache from contextlib import contextmanager from threading import local class _global_parameters(local): """ Thread-local global parameters. Explanation =========== This class generates thread-local container for SymPy's global paramet...
1439299d856bc66e580fcc2c24998910a93c111d7471b8bdd79ef0444b359e51
"""Tools for manipulating of large commutative expressions. """ from sympy.core.add import Add from sympy.core.compatibility import iterable, is_sequence, SYMPY_INTS from sympy.core.mul import Mul, _keep_coeff from sympy.core.power import Pow from sympy.core.basic import Basic, preorder_traversal from sympy.core.expr ...
0db8b0facd7480a59df421c1900e262ebaccaf533008e16bcd80f2b39565d180
"""Singleton mechanism""" from typing import Any, Dict, Type from .core import Registry from .assumptions import ManagedProperties from .sympify import sympify class SingletonRegistry(Registry): """ The registry for the singleton classes (accessible as ``S``). Explanation =========== This cla...
59f95bab3e4fa782ea132e85187b7ffb3307c851fd69321fec51123d98cec9ae
""" There are three types of functions implemented in SymPy: 1) defined functions (in the sense that they can be evaluated) like exp or sin; they have a name and a body: f = exp 2) undefined function which have a name but no body. Undefined functions can be defined using a Function cla...
009b99ced998299ff25084cb641eab8598c3cba44e042b5a8dc62a3dae74b237
""" Replacement rules. """ class Transform: """ Immutable mapping that can be used as a generic transformation rule. Parameters ========== transform : callable Computes the value corresponding to any key. filter : callable, optional If supplied, specifies which objects are in...
adbdb15511d692dc09bcfdb5739f0ea524d7a19af465ae5f2d0282f8cd38888a
from collections import defaultdict from functools import cmp_to_key from .basic import Basic from .compatibility import reduce, is_sequence from .parameters import global_parameters from .logic import _fuzzy_group, fuzzy_or, fuzzy_not from .singleton import S from .operations import AssocOp, AssocOpDispatcher from .ca...
7b5ff63da0e9cc8a438863d5cb9b9826f3f7ca2517d4a15e3bead25da8a839b4
""" Provides functionality for multidimensional usage of scalar-functions. Read the vectorize docstring for more details. """ from sympy.core.decorators import wraps def apply_on_element(f, args, kwargs, n): """ Returns a structure with the same dimension as the specified argument, where each basic elem...
c54ab533b02fef87f8ff03d8215548ac8279de62407c2f973f1cd2b9cf873d20
from typing import Tuple as tTuple from .sympify import sympify, _sympify, SympifyError from .basic import Basic, Atom from .singleton import S from .evalf import EvalfMixin, pure_complex from .decorators import call_highest_priority, sympify_method_args, sympify_return from .cache import cacheit from .compatibility i...
6ca916fb6dfd3f859a1ba9ce016e9a43bed469d03a8c97efa4a04d9a787e2c54
from typing import Dict, Union, Type from sympy.utilities.exceptions import SymPyDeprecationWarning from .basic import S, Atom from .compatibility import ordered from .basic import Basic from .evalf import EvalfMixin from .function import AppliedUndef from .sympify import _sympify, SympifyError from .parameters import...
660de38c82f84706f0ded11714b86fe4e9ce71822153ee5c441e0d9afa01c097
import numbers import decimal import fractions import math import re as regex from .containers import Tuple from .sympify import (SympifyError, converter, sympify, _convert_numpy_types, _sympify, _is_numpy_instance) from .singleton import S, Singleton from .expr import Expr, AtomicExpr from .eval...
11358109ea8e14556ccb640cb53591f7bc4e05414471e255d18dc10bd698dff4
from operator import attrgetter from typing import Tuple, Type from collections import defaultdict from sympy.utilities.exceptions import SymPyDeprecationWarning from sympy.core.sympify import _sympify as _sympify_, sympify from sympy.core.basic import Basic from sympy.core.cache import cacheit from sympy.core.compat...
3e6e15503b7bf6decad6b20dfeaa361fd749c221a6e2d0633a14bdf1ebe6338e
from sympy.core.numbers import nan from .function import Function class Mod(Function): """Represents a modulo operation on symbolic expressions. Parameters ========== p : Expr Dividend. q : Expr Divisor. Notes ===== The convention used is the same as Python's: the ...
da20ccf1235a3a9c490484ae34b02bafbbaad7c79b00287331e270e3244ec35e
from sympy.core.assumptions import StdFactKB, _assume_defined from sympy.core.compatibility import is_sequence, ordered from .basic import Basic, Atom from .sympify import sympify from .singleton import S from .expr import Expr, AtomicExpr from .cache import cacheit from .function import FunctionClass from sympy.core.l...
b7b0409ccb826a29ac08c1d4d72e7c900af0c93d13273586bcd312cde4ab4b5e
"""sympify -- convert objects SymPy internal format""" import typing if typing.TYPE_CHECKING: from typing import Any, Callable, Dict, Type from inspect import getmro from .compatibility import iterable from .parameters import global_parameters class SympifyError(ValueError): def __init__(self, expr, base_e...
78f63d0454689878af6e86e2bbf6db4e958bde19934f80d16b04ff72dac56d27
from sympy import Expr, Add, Mul, Pow, sympify, Matrix, Tuple from sympy.utilities import default_sort_key def _is_scalar(e): """ Helper method used in Tr""" # sympify to set proper attributes e = sympify(e) if isinstance(e, Expr): if (e.is_Integer or e.is_Float or e.is_Rational o...
9e2dc4b5a400843f5ee8f8542650f591a9b0fb48e723d46160757e8ac56d6e3c
""" Adaptive numerical evaluation of SymPy expressions, using mpmath for mathematical functions. """ from typing import Tuple import math import mpmath.libmp as libmp from mpmath import ( make_mpc, make_mpf, mp, mpc, mpf, nsum, quadts, quadosc, workprec) from mpmath import inf as mpmath_inf from mpmath.libmp imp...
a1a144fb7022f19405cf304bd4eca82dbda3d043872f75bf07529ed7bb10ca8d
"""Module for SymPy containers (SymPy objects that store other SymPy objects) The containers implemented in this module are subclassed to Basic. They are supposed to work seamlessly within the SymPy framework. """ from collections import OrderedDict from sympy.core.basic import Basic from sympy.core.com...
76ee7589112d5d9ff9e8bbdb9aada1e88d85cfdbb3c3f3c912fd5ebf5dee65b8
from collections import defaultdict from functools import cmp_to_key import operator from .sympify import sympify from .basic import Basic from .singleton import S from .operations import AssocOp, AssocOpDispatcher from .cache import cacheit from .logic import fuzzy_not, _fuzzy_group, fuzzy_and from .compatibility imp...
9a07c5a69f52535e7db40fcf336a34e16672ccca167ceb5666e8117079cfe367
"""Configuration utilities for polynomial manipulation algorithms. """ from contextlib import contextmanager _default_config = { 'USE_COLLINS_RESULTANT': False, 'USE_SIMPLIFY_GCD': True, 'USE_HEU_GCD': True, 'USE_IRREDUCIBLE_IN_FACTOR': False, 'USE_CYCLOTOMIC_FACTO...
3f39dfc54487672cc5fe769ae1780ab0d6702c9ce433bfb62a899a845a61a326
from sympy.matrices.dense import MutableDenseMatrix from sympy.polys.polytools import Poly from sympy.polys.domains import EX class MutablePolyDenseMatrix(MutableDenseMatrix): """ A mutable matrix of objects from poly module or to operate with them. Examples ======== >>> from sympy.polys.polyma...
a947c5b77e6aebb0ab797e54f18d0f6fbfd07d931d356a934bbfa20651d74291
"""Definitions of monomial orderings. """ from typing import Optional __all__ = ["lex", "grlex", "grevlex", "ilex", "igrlex", "igrevlex"] from sympy.core import Symbol from sympy.core.compatibility import iterable class MonomialOrder: """Base class for monomial orderings. """ alias = None # type: Optiona...
ee1cb206a22e6f650bbfe0482b59c0766d1807679cc074509bf09dd6cb3dea4f
"""OO layer for several polynomial representations. """ from sympy import oo from sympy.core.sympify import CantSympify from sympy.polys.polyerrors import CoercionFailed, NotReversible, NotInvertible from sympy.polys.polyutils import PicklableWithSlots class GenericPoly(PicklableWithSlots): """Base class for lo...
10f80f4702d72ba8123d0d581f18d730e1e21ba9c79a588556aad90d2efc2f88
""" Solving solvable quintics - An implementation of DS Dummit's paper Paper : http://www.ams.org/journals/mcom/1991-57-195/S0025-5718-1991-1079014-X/S0025-5718-1991-1079014-X.pdf Mathematica notebook: http://www.emba.uvm.edu/~ddummit/quintics/quintics.nb """ from sympy.core import Symbol from sympy.core.evalf imp...
b33258c0f63c0c21ce03928f6d03006e55744fa71584cbfccbd8b0e0bad25b10
"""Implementation of RootOf class and related tools. """ from sympy import Basic from sympy.core import (S, Expr, Integer, Float, I, oo, Add, Lambda, symbols, sympify, Rational, Dummy) from sympy.core.cache import cacheit from sympy.core.compatibility import ordered from sympy.core.relational import is_le from sy...
d8676ff6df5336075b9dcfbb5eba448606097d2bda707532b84d5a396a3d0d75
"""Square-free decomposition algorithms and related tools. """ from sympy.polys.densearith import ( dup_neg, dmp_neg, dup_sub, dmp_sub, dup_mul, dup_quo, dmp_quo, dup_mul_ground, dmp_mul_ground) from sympy.polys.densebasic import ( dup_strip, dup_LC, dmp_ground_LC, dmp_zero_p, dmp_...
d9a3ad18b8f453c29016497a73972110b21bc0de2728c6cf7cd6e053f5a0c8a2
"""Advanced tools for dense recursive polynomials in ``K[x]`` or ``K[X]``. """ from sympy.polys.densearith import ( dup_add_term, dmp_add_term, dup_lshift, dup_add, dmp_add, dup_sub, dmp_sub, dup_mul, dmp_mul, dup_sqr, dup_div, dup_rem, dmp_rem, dmp_expand, dup_mul_ground, dmp_...
8b75b4ea99832884fcd53c252bf7d0a200ddc483e65151000a4ce5e063c74bdf
"""User-friendly public interface to polynomial functions. """ from functools import wraps, reduce from operator import mul from sympy.core import ( S, Basic, Expr, I, Integer, Add, Mul, Dummy, Tuple ) from sympy.core.basic import preorder_traversal from sympy.core.compatibility import iterable, ordered from sym...
b1577e4e12364dc3fccbe2214d1245a5477920e573abc266bfefd3e38f130b5b
"""Functions for generating interesting polynomials, e.g. for benchmarking. """ from sympy.core import Add, Mul, Symbol, sympify, Dummy, symbols from sympy.core.containers import Tuple from sympy.core.singleton import S from sympy.functions.elementary.miscellaneous import sqrt from sympy.ntheory import nextprime from...
8a4766efd977d27c95acdfd70050e4000cd545eb35bb62cb1927ca79dfbd88dd
"""Implementation of matrix FGLM Groebner basis conversion algorithm. """ from sympy.polys.monomials import monomial_mul, monomial_div def matrix_fglm(F, ring, O_to): """ Converts the reduced Groebner basis ``F`` of a zero-dimensional ideal w.r.t. ``O_from`` to a reduced Groebner basis w.r.t. ``O_to`...
d93c4a290e0f849234b26d0318741e9e0646c03279c25e8b26c08c5c7046e395
"""Basic tools for dense recursive polynomials in ``K[x]`` or ``K[X]``. """ from sympy import oo from sympy.core import igcd from sympy.polys.monomials import monomial_min, monomial_div from sympy.polys.orderings import monomial_key import random def poly_LC(f, K): """ Return leading coefficient of ``f``. ...
eaf72ccfd2170c842e7584950695de763f4a40272a04c60682fc40df0dd33a4a
"""Algorithms for computing symbolic roots of polynomials. """ import math from sympy.core import S, I, pi from sympy.core.compatibility import ordered, reduce from sympy.core.exprtools import factor_terms from sympy.core.function import _mexpand from sympy.core.logic import fuzzy_not from sympy.core.mul import expa...
44eba916e598f9302e1370474391f6ed72992d6b66f2c90246e1c8a373464b17
from operator import mul from sympy.core.sympify import _sympify from sympy.matrices.common import (NonInvertibleMatrixError, NonSquareMatrixError, ShapeError) from sympy.polys.constructor import construct_domain class DDMError(Exception): """Base class for errors raised by DDM""" pass class DDMBadInpu...
d07a82e76e01b4d0a2ae00bb2494b7fc64ed8f8625c9aec94056cedf3c308bc9
"""Arithmetics for dense recursive polynomials in ``K[x]`` or ``K[X]``. """ from sympy.polys.densebasic import ( dup_slice, dup_LC, dmp_LC, dup_degree, dmp_degree, dup_strip, dmp_strip, dmp_zero_p, dmp_zero, dmp_one_p, dmp_one, dmp_ground, dmp_zeros) from sympy.polys.polyerrors import (Exa...
5e0f9804cbfeaa8664c5d036d7c8d7a09df40a3ea8accba947257d8251dfd9b3
"""Dense univariate polynomials with coefficients in Galois fields. """ from random import uniform from math import ceil as _ceil, sqrt as _sqrt from sympy.core.compatibility import SYMPY_INTS from sympy.core.mul import prod from sympy.ntheory import factorint from sympy.polys.polyconfig import query from sympy.poly...
feee9db132f2d32fe355d15e3463e1645a78dae1327f7e003422d5ca9ac271d2
""" This module contains functions for the computation of Euclidean, (generalized) Sturmian, (modified) subresultant polynomial remainder sequences (prs's) of two polynomials; included are also three functions for the computation of the resultant of two polynomials. Except for the function res_z(), which computes the ...
260822771c45153ac75f3e6544c0f6a3667f766255193925959e977834c4160e
"""Sparse polynomial rings. """ from typing import Any, Dict from operator import add, mul, lt, le, gt, ge from types import GeneratorType from sympy.core.compatibility import is_sequence, reduce from sympy.core.expr import Expr from sympy.core.numbers import igcd, oo from sympy.core.symbol import Symbol, symbols a...
5ea59549abc5f698900f4b29ab9c1e8ca8dd607b5f5e37c6dddd1591db8b7bea
"""Options manager for :class:`~.Poly` and public API functions. """ __all__ = ["Options"] from typing import Dict, Type from typing import List, Optional from sympy.core import Basic, sympify from sympy.polys.polyerrors import GeneratorsError, OptionError, FlagError from sympy.utilities import numbered_symbols, to...
d2183c7be5c0e0c7d30287e562ab99b7b2ff56f0e61d49552f67519340bf4442
"""Groebner bases algorithms. """ from sympy.core.symbol import Dummy from sympy.polys.monomials import monomial_mul, monomial_lcm, monomial_divides, term_div from sympy.polys.orderings import lex from sympy.polys.polyerrors import DomainError from sympy.polys.polyconfig import query def groebner(seq, ring, method=N...
dfdbd8db7055aff76a0f2540da6b68e01d58b5f57ad4f2a1924dac8644518a85
"""Definitions of common exceptions for `polys` module. """ from sympy.utilities import public @public class BasePolynomialError(Exception): """Base class for polynomial related exceptions. """ def new(self, *args): raise NotImplementedError("abstract base class") @public class ExactQuotientFailed(...
32b86a883b044adceb954008aca1f658ec999440e923f25eb2f7776d6e1d6905
"""High-level polynomials manipulation functions. """ from sympy.core import S, Basic, Add, Mul, symbols, Dummy from sympy.polys.polyerrors import ( PolificationFailed, ComputationFailed, MultivariatePolynomialError, OptionError) from sympy.polys.polyoptions import allowed_flags from sympy.polys.polytools imp...
ac3de29ed80a0ad000307decaa582a6c92f55d2abd4237de1bf318cf008e7a4d
"""Heuristic polynomial GCD algorithm (HEUGCD). """ from .polyerrors import HeuristicGCDFailed HEU_GCD_MAX = 6 def heugcd(f, g): """ Heuristic polynomial GCD in ``Z[X]``. Given univariate polynomials ``f`` and ``g`` in ``Z[X]``, returns their GCD and cofactors, i.e. polynomials ``h``, ``cff`` and ``...
c0e0e9d87794f85087372030da24f1e9fecef7e33a2a0a91abbe8b7a6e0c2253
"""Tools and arithmetics for monomials of distributed polynomials. """ from itertools import combinations_with_replacement, product from textwrap import dedent from sympy.core import Mul, S, Tuple, sympify from sympy.core.compatibility import exec_, iterable from sympy.polys.polyerrors import ExactQuotientFailed fro...
a6c9f256fc34593a2422fe25741cc431ebabc3e35b5db9d4bc9e8a23595c77ee
"""Sparse rational function fields. """ from typing import Any, Dict from operator import add, mul, lt, le, gt, ge from sympy.core.compatibility import is_sequence, reduce from sympy.core.expr import Expr from sympy.core.mod import Mod from sympy.core.numbers import Exp1 from sympy.core.singleton import S from symp...
b28cbbae4c1a8928e5d37de7d41842f5b0553006461380e450dd5e1fe5260535
"""Low-level linear systems solver. """ from sympy.utilities.iterables import connected_components from sympy.matrices import MutableDenseMatrix from sympy.polys.domains import EX from sympy.polys.rings import sring from sympy.polys.polyerrors import NotInvertible from sympy.polys.domainmatrix import DomainMatrix ...
607fcb93ed4bf7cb3e60d4792d44b66933d96b9ffd52f6a6d01f4fcf2837d5d2
"""Algorithms for partial fraction decomposition of rational functions. """ from sympy.core import S, Add, sympify, Function, Lambda, Dummy from sympy.core.basic import preorder_traversal from sympy.polys import Poly, RootSum, cancel, factor from sympy.polys.polyerrors import PolynomialError from sympy.polys.polyopti...
4186d17fd2a96ca2659447ed35a260c7b83e5784da69fab29dd3d1c47307d7b3
"""Real and complex root isolation and refinement algorithms. """ from sympy.polys.densearith import ( dup_neg, dup_rshift, dup_rem) from sympy.polys.densebasic import ( dup_LC, dup_TC, dup_degree, dup_strip, dup_reverse, dup_convert, dup_terms_gcd) from sympy.polys.densetools import ( dup_cle...
88c5467946f0a3d6d61056a59460da65523314224d69514beda5ccd796bc73b8
"""Compatibility interface between dense and sparse polys. """ from sympy.polys.densearith import dup_add_term from sympy.polys.densearith import dmp_add_term from sympy.polys.densearith import dup_sub_term from sympy.polys.densearith import dmp_sub_term from sympy.polys.densearith import dup_mul_term from sympy.poly...
fc2aa3d37a04d03de6328643cebea47cf3f5eaeb0ea9c60a39fb578e7ba829a2
"""Efficient functions for generating orthogonal polynomials. """ from sympy import Dummy from sympy.polys.constructor import construct_domain from sympy.polys.densearith import ( dup_mul, dup_mul_ground, dup_lshift, dup_sub, dup_add ) from sympy.polys.domains import ZZ, QQ from sympy.polys.polyclasses import DMP...
15eed70c48771548d40c920daa82f9cd8c3f560e661cd5d5526c423f3f21019f
"""Useful utilities for higher level polynomial classes. """ from sympy.core import (S, Add, Mul, Pow, Eq, Expr, expand_mul, expand_multinomial) from sympy.core.exprtools import decompose_power, decompose_power_rat from sympy.polys.polyerrors import PolynomialError, GeneratorsError from sympy.polys.polyoptions im...
40e7ba4160bec8c488766017613fb2f1faa2d099e9e369b994cd7c1a0520ddac
"""Tools for manipulation of rational expressions. """ from sympy.core import Basic, Add, sympify from sympy.core.compatibility import iterable from sympy.core.exprtools import gcd_terms from sympy.utilities import public @public def together(expr, deep=False, fraction=True): """ Denest and combine rational ...
c20581eb09a7295d11c6ed89153b990aa4efa0605e879daa5a25afd519f15acd
"""Computational algebraic field theory. """ from sympy import ( S, Rational, AlgebraicNumber, GoldenRatio, TribonacciConstant, Add, Mul, sympify, Dummy, expand_mul, I, pi ) from sympy.functions import sqrt, cbrt from sympy.core.compatibility import reduce from sympy.core.exprtools import Factors from sympy.c...
b3a188627180e94f638463fb6174104bc1b76f21b8fa43dbaf9e4147aa7e8b3e
from sympy.core import S from sympy.polys import Poly def dispersionset(p, q=None, *gens, **args): r"""Compute the *dispersion set* of two polynomials. For two polynomials `f(x)` and `g(x)` with `\deg f > 0` and `\deg g > 0` the dispersion set `\operatorname{J}(f, g)` is defined as: .. math:: ...
81686d2425ad63ec5fae03db7a64dff15283eac9a3821d8e73d234f71fa6699a
"""Euclidean algorithms, GCDs, LCMs and polynomial remainder sequences. """ from sympy.ntheory import nextprime from sympy.polys.densearith import ( dup_sub_mul, dup_neg, dmp_neg, dmp_add, dmp_sub, dup_mul, dmp_mul, dmp_pow, dup_div, dmp_div, dup_rem, dup_quo, dmp_quo, dup_prem...
90a79c179eef6e23f6dbe8413076f991914f311898d264808fef9d4b5539e447
"""Tools for constructing domains for expressions. """ from sympy.core import sympify from sympy.core.evalf import pure_complex from sympy.polys.domains import ZZ, QQ, ZZ_I, QQ_I, EX from sympy.polys.domains.complexfield import ComplexField from sympy.polys.domains.realfield import RealField from sympy.polys.polyopti...
b6c81cba0e60620a9270de6c01a71e7a9329f1ea9f9fe9dfd80cd4eeefcc7634
"""Polynomial factorization routines in characteristic zero. """ from sympy.polys.galoistools import ( gf_from_int_poly, gf_to_int_poly, gf_lshift, gf_add_mul, gf_mul, gf_div, gf_rem, gf_gcdex, gf_sqf_p, gf_factor_sqf, gf_factor) from sympy.polys.densebasic import ( dup_LC, dmp_LC, dmp_gr...
0619409f35c1ec98572770f7e9802ad7b1336984753025bf1e9feb4953f6cd3a
r""" Sparse distributed elements of free modules over multivariate (generalized) polynomial rings. This code and its data structures are very much like the distributed polynomials, except that the first "exponent" of the monomial is a module generator index. That is, the multi-exponent ``(i, e_1, ..., e_n)`` represent...
8ab15e366d70fc7bc9d6db3bfb7e6fbdcb876d6ecc2a19efcd970400f4c837cd
""" Generic Unification algorithm for expression trees with lists of children This implementation is a direct translation of Artificial Intelligence: A Modern Approach by Stuart Russel and Peter Norvig Second edition, section 9.2, page 276 It is modified in the following ways: 1. We allow associative and commutati...
ccef755d57617b77ed0d394755fd5c2e1e1340c1ef13f2059ea2b125eea3ac42
""" SymPy interface to Unification engine See sympy.unify for module level docstring See sympy.unify.core for algorithmic docstring """ from sympy.core import Basic, Add, Mul, Pow from sympy.core.operations import AssocOp, LatticeOp from sympy.matrices import MatAdd, MatMul, MatrixExpr from sympy.sets.sets import Uni...
9fd129ceeadbd60fb3ef32048498ea4ead18378acc2d94b50ea703020d3edbc2
""" Functions to support rewriting of SymPy expressions """ from sympy import Expr from sympy.assumptions import ask from sympy.strategies.tools import subs from sympy.unify.usympy import rebuild, unify def rewriterule(source, target, variables=(), condition=None, assume=None): """ Rewrite rule Transform exp...
5b70f0308b54213de082bfb422b967b61357167769bed26e5383ce5737cc8d51
"""py.test hacks to support XFAIL/XPASS""" import sys import functools import os import contextlib import warnings from sympy.core.compatibility import get_function_name from sympy.utilities.exceptions import SymPyDeprecationWarning ON_TRAVIS = os.getenv('TRAVIS_BUILD_NUMBER', None) try: import pytest USE_P...
b6001dd9f5529863bebaa13052639d4faf5fceabc4846e3699ba5dbdf6734528
"""benchmarking through py.test""" import py from py.__.test.item import Item from py.__.test.terminal.terminal import TerminalSession from math import ceil as _ceil, floor as _floor, log10 import timeit from inspect import getsource from sympy.core.compatibility import exec_ # from IPython.Magic.magic_timeit uni...
b15e02c0ecae9d9e101dc0aa63ef8fa7503d9201082100037f7fb392d41440e6
""" This is our testing framework. Goals: * it should be compatible with py.test and operate very similarly (or identically) * doesn't require any external dependencies * preferably all the functionality should be in this file only * no magic, just import the test file and execute the test functions, that's it * po...
bdc1324386af359dbbe4ff6b4e623f74eb6c028f8309dd3d0cc5dc9533c93e35
""" Helpers for randomized testing """ from random import uniform, Random, randrange, randint from sympy.core.compatibility import is_sequence, as_int from sympy.core.containers import Tuple from sympy.core.numbers import comp, I from sympy.core.symbol import Symbol from sympy.simplify.simplify import nsimplify def...
6c5f24b4a0bd943852eb981a841f6139ec2c677efc52484b82add01e2a966175
""" This module adds context manager for temporary files generated by the tests. """ import shutil import os class TmpFileManager: """ A class to track record of every temporary files created by the tests. """ tmp_files = set('') tmp_folders = set('') @classmethod def tmp_file(cls, name=...
45ead2e335568d421758fcad26831db19331a301a09e758ad90a82f807210a29
from sympy import S, simplify from sympy.core import Basic, diff from sympy.matrices import Matrix from sympy.vector import (CoordSys3D, Vector, ParametricRegion, parametric_region_list, ImplicitRegion) from sympy.vector.operators import _get_coord_sys_from_expr from sympy.integrals import Integ...
a0f901321d56a81dd8326bd3574f263041ee8bd28c5380bdf3248bd30094e5fe
from functools import singledispatch from sympy import pi, tan from sympy.simplify import trigsimp from sympy.core import Basic, Tuple from sympy.core.symbol import _symbol from sympy.solvers import solve from sympy.geometry import Point, Segment, Curve, Ellipse, Polygon from sympy.vector import ImplicitRegion class ...
a0e1ea6649a5d05352810ad3addb46b941f79f9fec28af814c6e7ad6419b1611
"""Curves in 2-dimensional Euclidean space. Contains ======== Curve """ from sympy import sqrt from sympy.core import sympify, diff from sympy.core.compatibility import is_sequence from sympy.core.containers import Tuple from sympy.core.symbol import _symbol from sympy.geometry.entity import GeometryEntity, Geometry...
1d66c71f1b9864623b8ecd5e6570eb45fe060b0603fdbb4387ac776b736ee39d
"""Recurrence Operators""" from sympy import symbols, Symbol, S from sympy.printing import sstr from sympy.core.sympify import sympify def RecurrenceOperators(base, generator): """ Returns an Algebra of Recurrence Operators and the operator for shifting i.e. the `Sn` operator. The first argument need...