hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
b391f72d7398f1471f07e9b065be742da7d652562b45f8c923e53fe1da41f64d | """Various algorithms for helping identifying numbers and sequences."""
from sympy.utilities import public
from sympy.core import Function, Symbol
from sympy.core.numbers import Zero
from sympy import (sympify, floor, lcm, denom, Integer, Rational,
exp, integrate, symbols, Product, product)
from sy... |
6cf8d0beb52de1285045c245a0871256d05bc01669017af2341752fe35697819 | from sympy.calculus.singularities import is_decreasing
from sympy.calculus.util import AccumulationBounds
from sympy.concrete.expr_with_limits import AddWithLimits
from sympy.concrete.expr_with_intlimits import ExprWithIntLimits
from sympy.concrete.gosper import gosper_sum
from sympy.core.add import Add
from sympy.core... |
c7bfc7bf74f8573cf3d92ee200c6a18e04f31654e71b06c22123d2255e15ce5d | from sympy import Integer
from sympy.core import Symbol
from sympy.utilities import public
@public
def approximants(l, X=Symbol('x'), simplify=False):
"""
Return a generator for consecutive Pade approximants for a series.
It can also be used for computing the rational generating function of a
series wh... |
e92731488c137f53c21a3766bac10a80d22a3b17219256e876b3852d815c6e16 | """
Convergence acceleration / extrapolation methods for series and
sequences.
References:
Carl M. Bender & Steven A. Orszag, "Advanced Mathematical Methods for
Scientists and Engineers: Asymptotic Methods and Perturbation Theory",
Springer 1999. (Shanks transformation: pp. 368-375, Richardson
extrapolation: pp. 375-3... |
c7ee40cf75828b2d1b45b8e39ff5403c54e2d991f1f823abbd18e2398d549e63 | """
Limits
======
Implemented according to the PhD thesis
http://www.cybertester.com/data/gruntz.pdf, which contains very thorough
descriptions of the algorithm including many examples. We summarize here
the gist of it.
All functions are sorted according to how rapidly varying they are at
infinity using the followin... |
b2b4ff5b0446f19ada9c3a75154d98dbde1f8e0f8d7219128ef2e308f587e82c | from sympy.core.basic import Basic
from sympy.core.cache import cacheit
from sympy.core.compatibility import is_sequence, iterable, ordered
from sympy.core.containers import Tuple
from sympy.core.decorators import call_highest_priority
from sympy.core.parameters import global_parameters
from sympy.core.function import ... |
155f8dca55b30fa9d3ada8333a838fcf2a574be92e8f02adab33ca76f5b8dca4 | """Limits of sequences"""
from sympy.core.add import Add
from sympy.core.function import PoleError
from sympy.core.power import Pow
from sympy.core.singleton import S
from sympy.core.symbol import Dummy
from sympy.core.sympify import sympify
from sympy.functions.combinatorial.numbers import fibonacci
from sympy.functi... |
ce69e8fbac10d5cc9e3f83a40f9980f8c8096ed7a1402e1eef6bec847459eec7 | """Fourier Series"""
from sympy import pi, oo, Wild
from sympy.core.expr import Expr
from sympy.core.add import Add
from sympy.core.compatibility import is_sequence
from sympy.core.containers import Tuple
from sympy.core.singleton import S
from sympy.core.symbol import Dummy, Symbol
from sympy.core.sympify import symp... |
599dd819eb44315f69768e80b5bd8468b03b2508e7241e50eae45c869572da23 | """
This module implements the Residue function and related tools for working
with residues.
"""
from sympy import sympify
from sympy.utilities.timeutils import timethis
@timethis('residue')
def residue(expr, x, x0):
"""
Finds the residue of ``expr`` at the point x=x0.
The residue is defined as the coef... |
1782a267b5b0344397fead091ee6ee71aca404dae013f1acdfad2393116e0622 | """Formal Power Series"""
from collections import defaultdict
from sympy import oo, zoo, nan
from sympy.core.add import Add
from sympy.core.compatibility import iterable
from sympy.core.expr import Expr
from sympy.core.function import Derivative, Function, expand
from sympy.core.mul import Mul
from sympy.core.numbers... |
0f456f20dfc036e0227a6e1a78690a8878f42ae9d5db9638300934066d3cf0a9 | from sympy.core import S, sympify, Expr, Rational, Dummy
from sympy.core import Add, Mul, expand_power_base, expand_log
from sympy.core.cache import cacheit
from sympy.core.compatibility import default_sort_key, is_sequence
from sympy.core.containers import Tuple
from sympy.sets.sets import Complement
from sympy.utilit... |
e0e507ba7e8bb078fb58623d24d4999021bf310beca7ba15c93585904dcdfd0d | from collections import defaultdict
from functools import reduce
from sympy.core import (sympify, Basic, S, Expr, expand_mul, factor_terms,
Mul, Dummy, igcd, FunctionClass, Add, symbols, Wild, expand)
from sympy.core.cache import cacheit
from sympy.core.compatibility import iterable, SYMPY_INTS
from sympy.core.fun... |
ae2ab378e57f7e275aa6fc57802234060d0b68f572386b66773247aceea65e62 | from collections import defaultdict
from sympy.core.add import Add
from sympy.core.basic import S
from sympy.core.compatibility import ordered
from sympy.core.expr import Expr
from sympy.core.exprtools import Factors, gcd_terms, factor_terms
from sympy.core.function import expand_mul
from sympy.core.mul import Mul
fro... |
c69f6180e361d5de0fc6b46da8c69261676b0ea3f0643354f51b01cd7f781c0a | r"""
This module contains the functionality to arrange the nodes of a
diagram on an abstract grid, and then to produce a graphical
representation of the grid.
The currently supported back-ends are Xy-pic [Xypic].
Layout Algorithm
================
This section provides an overview of the algorithms implemented in
:cl... |
147eafcf174e45cf174ce7dfa2e0c5dda33aa5198c523b9a097d1d0d2c805950 | from sympy.core import S, Basic, Dict, Symbol, Tuple, sympify
from sympy.core.compatibility import iterable
from sympy.core.symbol import Str
from sympy.sets import Set, FiniteSet, EmptySet
class Class(Set):
r"""
The base class for any kind of class in the set-theoretic sense.
Explanation
===========... |
f69ed1b4ee5861fdccbcf5193a5358f2f0376e336599cb0b99c3f0497c3475c0 | from typing import Any, Set
from functools import reduce
from itertools import permutations
from sympy.combinatorics import Permutation
from sympy.core import (
Basic, Expr, Function, diff,
Pow, Mul, Add, Atom, Lambda, S, Tuple, Dict
)
from sympy.core.cache import cacheit
from sympy.core.symbol import Symbol... |
e53f7369ef27e3d71876029c0aa7e998298b1245c343b932e895e5369ad0c2a2 | from sympy.printing.pycode import PythonCodePrinter
""" This module collects utilities for rendering Python code. """
def render_as_module(content, standard='python3'):
"""Renders python code as a module (with the required imports).
Parameters
==========
standard :
See the parameter ``stand... |
eace8ede3cbd305dffa63f7669c16eb3ddbfa2baf5639f4cf398849a2699fb4f | import math
from sympy import Interval
from sympy.calculus.singularities import is_increasing, is_decreasing
from sympy.codegen.rewriting import Optimization
from sympy.core.function import UndefinedFunction
"""
This module collects classes useful for approimate rewriting of expressions.
This can be beneficial when ge... |
1b726e7f0a6fc5b98b52b5cdffd136227438dc73fede2e1a5028956ea9017d50 | """
AST nodes specific to Fortran.
The functions defined in this module allows the user to express functions such as ``dsign``
as a SymPy function for symbolic manipulation.
"""
from sympy.codegen.ast import (
Attribute, CodeBlock, FunctionCall, Node, none, String,
Token, _mk_Tuple, Variable
)
from sympy.core... |
926dd53369227fbbfcccda12b9f07fcf1f23366bd91e0849bd189d1056aeb90d | from sympy.core.function import Add, ArgumentIndexError, Function
from sympy.core.power import Pow
from sympy.core.singleton import S
from sympy.functions.elementary.exponential import exp, log
from sympy.utilities import default_sort_key
def _logaddexp(x1, x2, *, evaluate=True):
return log(Add(exp(x1, evaluate=e... |
7852fe3c5e082e054762c3f7705af267aa51a60f023477d8809516a778e1a4cc | import bisect
import itertools
from functools import reduce
from itertools import accumulate
from collections import defaultdict
from sympy import Indexed, IndexedBase, Tuple, Sum, Add, S, Integer, diagonalize_vector, DiagMatrix
from sympy.combinatorics import Permutation
from sympy.combinatorics.permutations import _... |
291c7582d4a3853cfbafb8b8f990dc3068a8580d6237bdd71e0417abe05a772e | from sympy import And, Gt, Lt, Abs, Dummy, oo, Tuple, Symbol
from sympy.codegen.ast import (
Assignment, AddAugmentedAssignment, CodeBlock, Declaration, FunctionDefinition,
Print, Return, Scope, While, Variable, Pointer, real
)
""" This module collects functions for constructing ASTs representing algorithms. "... |
a963461015ada52cd02429a95ca62ed35916f688f1569e3aa32dc4bd29ba43f2 | """
Classes and functions useful for rewriting expressions for optimized code
generation. Some languages (or standards thereof), e.g. C99, offer specialized
math functions for better performance and/or precision.
Using the ``optimize`` function in this module, together with a collection of
rules (represented as instan... |
ab283f48ec13e73775266d719ab82476953969ecef5dcf4d942eee05d4b00937 | """
Types used to represent a full function/module as an Abstract Syntax Tree.
Most types are small, and are merely used as tokens in the AST. A tree diagram
has been included below to illustrate the relationships between the AST types.
AST Type Tree
-------------
::
*Basic*
|--->AssignmentBase
| ... |
cc016acaad95cb31737721caa8a7884e0111fb48434940827a293bdc13d11049 | """
This module contains SymPy functions mathcin corresponding to special math functions in the
C standard library (since C99, also available in C++11).
The functions defined in this module allows the user to express functions such as ``expm1``
as a SymPy function for symbolic manipulation.
"""
from sympy.core.functi... |
0a688065f84fdab595e7ac45d3dcfd0a255603bc2014d9d6a1693b03edc7f2ce | from typing import Dict, Callable
from sympy.core import S, Add, Expr, Basic, Mul
from sympy.logic.boolalg import Boolean
from sympy.assumptions import Q, ask # type: ignore
def refine(expr, assumptions=True):
"""
Simplify an expression using assumptions.
Explanation
===========
Gives the form... |
f47123de8daecc862b0e7706ba831391489aaf8027ca6bc1c4840120f382cee1 | """Module for querying SymPy objects about assumptions."""
from sympy.assumptions.assume import (global_assumptions, Predicate,
AppliedPredicate)
from sympy.core import sympify
from sympy.core.cache import cacheit
from sympy.core.relational import Relational
from sympy.logic.boolalg import (to_cnf, And, Not, O... |
d42021f2821b7464954b05d996e2c6399323e6701256787cedf5e063979bc88c | import inspect
from sympy.core.cache import cacheit
from sympy.core.singleton import S
from sympy.core.sympify import _sympify
from sympy.logic.boolalg import Boolean
from sympy.utilities.source import get_class
from contextlib import contextmanager
class AssumptionsContext(set):
"""
Set representing assumpti... |
3206f9148277f32d3fb525e043c106956a23d82a7feb6e1f992c4ce95ef2e972 | """
The classes used here are for the internal use of assumptions system
only and should not be used anywhere else as these don't possess the
signatures common to SymPy objects. For general use of logic constructs
please refer to sympy.logic classes And, Or, Not, etc.
"""
from itertools import combinations, product
fro... |
558b0126eab82ba81e22cb03985a6c86bf8716f985c2a1acde3f40af6effc1c0 | from collections import defaultdict
from collections.abc import MutableMapping
from sympy.assumptions.ask import Q
from sympy.assumptions.assume import Predicate, AppliedPredicate
from sympy.assumptions.cnf import AND, OR, to_NNF
from sympy.core import (Add, Mul, Pow, Integer, Number, NumberSymbol,)
from sympy.core.nu... |
96e93a797a17fd310ac3ba60104c0f41de149ae09eaa76b1b578dd5cfc37e0b4 | r"""
This module is intended for solving recurrences or, in other words,
difference equations. Currently supported are linear, inhomogeneous
equations with polynomial or rational coefficients.
The solutions are obtained among polynomials, rational functions,
hypergeometric terms, or combinations of hypergeometric term... |
f0557306dbb9d87791cfa30950c42ddd3b846e854a9e7d03a2de9355590ed4fe | """
This module contains pdsolve() and different helper functions that it
uses. It is heavily inspired by the ode module and hence the basic
infrastructure remains the same.
**Functions in this module**
These are the user functions in this module:
- pdsolve() - Solves PDE's
- classify_pde() - Classif... |
679553655358778cb529802487bb2ba9f7606bccc3c68438ad3cd43636862059 | """ Generic SymPy-Independent Strategies """
identity = lambda x: x
def exhaust(rule):
""" Apply a rule repeatedly until it has no effect """
def exhaustive_rl(expr):
new, old = rule(expr), expr
while new != old:
new, old = rule(new), new
return new
return exhaustive_rl... |
1f1998c508e081405b1c15ee8f3a8765fb2be859d106d0ef71c841848d397346 | """
module for generating C, C++, Fortran77, Fortran90, Julia, Rust
and Octave/Matlab routines that evaluate sympy expressions.
This module is work in progress.
Only the milestones with a '+' character in the list below have been completed.
--- How is sympy.utilities.codegen different from sympy.printing.ccode? ---
W... |
2af1088ed311bbf81b367591c1f87f16be982c5b0b07686b8222de719ac88b85 | """
This module provides convenient functions to transform sympy expressions to
lambda functions which can be used to calculate numerical values very fast.
"""
from typing import Any, Dict, Iterable
import builtins
import inspect
import keyword
import textwrap
import linecache
from sympy.utilities.exceptions import ... |
aed5dfbc865112986e7a3d2d50f70a57c1bf84b8bed13a056bf0d37c81b5b19d | """
pkgdata is a simple, extensible way for a package to acquire data file
resources.
The getResource function is equivalent to the standard idioms, such as
the following minimal implementation::
import sys, os
def getResource(identifier, pkgname=__name__):
pkgpath = os.path.dirname(sys.modules[pkgna... |
bf47ffbd53e4f3315826778c336664a173ba05e698c0b894379cc7f04c6fd061 | """Useful utility decorators. """
import sys
import types
import inspect
from sympy.core.decorators import wraps
from sympy.core.compatibility import iterable
from sympy.testing.runtests import DependencyError, SymPyDocTests, PyTestReporter
def threaded_factory(func, use_add):
"""A factory for ``threaded`` decor... |
845dc59754a6fd112390507caff141e8ec60cff4f5724c3214cfc35f49a22394 | """
The objects in this module allow the usage of the MatchPy pattern matching
library on SymPy expressions.
"""
from sympy.external import import_module
from sympy.functions import (log, sin, cos, tan, cot, csc, sec, erf, gamma, uppergamma)
from sympy.functions.elementary.hyperbolic import acosh, asinh, atanh, acoth, ... |
670f2775419b2073105d220482d496e9d7d21888cb8310ba410fdfc9c5468b15 | from collections import defaultdict, OrderedDict
from itertools import (
combinations, combinations_with_replacement, permutations,
product, product as cartes
)
import random
from operator import gt
from sympy.core import Basic
# this is the logical location of these functions
from sympy.core.compatibility im... |
36573c44d5a6db0a0c5739e7657690fc70da0dbfeec8ae99c479964c5c590a7e | """Miscellaneous stuff that doesn't really fit anywhere else."""
from typing import List
import sys
import os
import re as _re
import struct
from textwrap import fill, dedent
from sympy.core.compatibility import as_int
from sympy.core.decorators import deprecated
class Undecidable(ValueError):
# an error to be ... |
a698d0c6e887f10b933440ef27555ec13f7e242c9b11b959aefd248468a45225 | """
A Printer for generating readable representation of most sympy classes.
"""
from typing import Any, Dict
from sympy.core import S, Rational, Pow, Basic, Mul, Number
from sympy.core.mul import _keep_coeff
from .printer import Printer, print_function
from sympy.printing.precedence import precedence, PRECEDENCE
fro... |
b1084d60885fdbeb4b570f5dbcae36fe3ce67f648d1ac1a77ce253ebfc9df98a | """
C++ code printer
"""
from itertools import chain
from sympy.codegen.ast import Type, none
from .c import C89CodePrinter, C99CodePrinter
# These are defined in the other file so we can avoid importing sympy.codegen
# from the top-level 'import sympy'. Export them here as well.
from sympy.printing.codeprinter impor... |
1e1de66c2b92053bfd1adecaa55b718aacf497d94cf2f4056b2510b4b36fd63d | """
A few practical conventions common to all printers.
"""
import re
from collections.abc import Iterable
from sympy import Derivative
_name_with_digits_p = re.compile(r'^([a-zA-Z]+)([0-9]+)$')
def split_super_sub(text):
"""Split a symbol name into a name, superscripts and subscripts
The first part of th... |
afe809a38c09935e55e5bee72b05227a46487b928b340aec0f9e5ef8bf1fa128 | """Printing subsystem driver
SymPy's printing system works the following way: Any expression can be
passed to a designated Printer who then is responsible to return an
adequate representation of that expression.
**The basic concept is the following:**
1. Let the object print itself if it knows how.
2. Take the bes... |
ea732e9df28c4cfc417f2ce1983297bfcd9c61e41cc4bee5937cd83194d08b3f | from distutils.version import LooseVersion as V
from collections.abc import Iterable
from sympy import Mul, S
from sympy.codegen.cfunctions import Sqrt
from sympy.external import import_module
from sympy.printing.precedence import PRECEDENCE
from sympy.printing.pycode import AbstractPythonCodePrinter
import sympy
ten... |
ab638879025e89189aacd1e20ddb19c997e1ec0d219354c290b217da1bc39b4a | """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... |
5e95b574d802bb100d49db2ed7bab966f2cd99e44a26e786978cbe56a9d94136 | """ Integral Transforms """
from functools import reduce
from sympy.core import S
from sympy.core.compatibility import 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... |
56c62ebd05c8a967a2fcbdabd6411c6cdc47b16084e67d131f6a06aa099985fa | from typing import Dict, List
from itertools import permutations
from functools import reduce
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
f... |
bb85b94bcf2aa4d0ce6b53a777cfbb76817ad23d8bf1a982d7a31fe9404e9345 | """
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... |
a336a51ae04e7d1cd7c6067778cc85f5fe03d2c94691be673db47f30537bc601 | """
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... |
a9919c76611bfc335038dba50ae446b542966779bc5a120d12ee13017723fcf2 | """
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... |
4af190ccddad523a23519fa5d420bbde2b936996a51832f467a693570893dc00 | """
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
def deprecated(**decorator_kwargs):
"""This is a decorator which ca... |
34379a09ceda2f68225ad6ee1ddd4d8c56a242f1ce2d34d5137e8e766379b593 | """Base class for all the objects in SymPy"""
from collections import defaultdict
from collections.abc import Mapping
from itertools import chain, zip_longest
from .assumptions import BasicMeta, ManagedProperties
from .cache import cacheit
from .sympify import _sympify, sympify, SympifyError
from .compatibility import... |
aaccb7404eaf04de498204d56867f240ab42177d2ecfaeffa92973070bd1dff4 | from collections import defaultdict
from functools import cmp_to_key, reduce
from .basic import Basic
from .compatibility import 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... |
750d89b4699d21b439b893d82d329760331e9e572010c5174fee3fd6eda3b300 | from typing import Tuple as tTuple
from collections.abc import Iterable
from functools import reduce
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_arg... |
45f93df161cc965b636d3698533e8879c76e159d1c4bf90cdbda6ac300449298 | import numbers
import decimal
import fractions
import math
import re as regex
import sys
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... |
240444070238f03da6dad0fdb8d3f34d0e71c19df34158218d49dbf74fc88851 | """
Reimplementations of constructs introduced in later versions of Python than
we support. Also some functions that are needed SymPy-wide and are located
here for easy import.
"""
from typing import Tuple, Type
import operator
from collections import defaultdict
from sympy.external import import_module
"""
Python 2... |
fab8245e18f919c63401981307821a1d078c88fc99f825f6b5a8f0cfddaff043 | """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... |
fc6f62ba73371ce8fa74ce95ae0ed4c8f200cf1097999d76bc8e975cae4dc536 | """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 collections.abc import MutableSet
from sympy.core... |
190a3d748fc1bc026d60754515f9aba0daf42fc77bd54788fad53b48626072d9 | """
Base class to provide str and repr hooks that `init_printing` can overwrite.
This is exposed publicly in the `printing.defaults` module,
but cannot be defined there without causing circular imports.
"""
class Printable:
"""
The default implementation of printing for SymPy classes.
This implements a h... |
825787984b0254baad77f56866689af391e6a094947502168c1f4bc81a3a7887 | from collections import defaultdict
from functools import cmp_to_key, reduce
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
from .expr import Expr
fro... |
0b366c286967077118c60afc704a2a75703eafb7873d95c430ea1a7e343966a4 | """Tools for setting up printing in interactive sessions. """
import sys
from distutils.version import LooseVersion as V
from io import BytesIO
from sympy import latex as default_latex
from sympy import preview
from sympy.utilities.misc import debug
from sympy.printing.defaults import Printable
def _init_python_pri... |
c2772ee66346ccfc9de85e281127f8f2f0dad871386199726148e7573c360227 | """Tools for setting up interactive sessions. """
from distutils.version import LooseVersion as V
from sympy.interactive.printing import init_printing
preexec_source = """\
from __future__ import division
from sympy import *
x, y, z, t = symbols('x y z t')
k, m, n = symbols('k m n', integer=True)
f, g, h = symbols('... |
a2b04d5c57bb477fcd5866936cd2bfd5496a348f4f304a3f1655a1de2efa7107 | """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... |
a5e95f2722ba5efe6302846a5aea3d30e4b8cce28f9b85db322d4b438b8e2936 | """Algorithms for computing symbolic roots of polynomials. """
import math
from functools import reduce
from sympy.core import S, I, pi
from sympy.core.compatibility import ordered
from sympy.core.exprtools import factor_terms
from sympy.core.function import _mexpand
from sympy.core.logic import fuzzy_not
from sympy... |
4bc5cd168a2b5e1c4830e2503e330ee8d6d36dd84d72881d344c2a85a2fea0e0 | from operator import mul
from sympy.core.symbol import Dummy
from sympy.core.sympify import _sympify
from sympy.matrices.common import (NonInvertibleMatrixError,
NonSquareMatrixError, ShapeError)
from sympy.polys import Poly
from sympy.polys.agca.extensions import FiniteExtension
from sympy.polys.constructor impo... |
dbdc5ece91bb2c420040754960314876b097ed5808d2fd1f0076b917d42afc1f | """Sparse polynomial rings. """
from typing import Any, Dict
from operator import add, mul, lt, le, gt, ge
from functools import reduce
from types import GeneratorType
from sympy.core.compatibility import is_sequence
from sympy.core.expr import Expr
from sympy.core.numbers import igcd, oo
from sympy.core.symbol imp... |
34f8c08c33533a5b08e3605cf0cf1d9d0c892722b02fef436dd0015d7b12b4c0 | """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... |
7fc1877a09fc56276180ac90bcfe82e62b642812603a479ec39c53f07fbe97d4 | """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 iterable
from sympy.polys.polyerrors import ExactQuotientFailed
from sympy... |
3f9984c24e53d0829ad80ce60ec1ec94891e3159a6bc15896462908411f1e223 | """Sparse rational function fields. """
from typing import Any, Dict
from functools import reduce
from operator import add, mul, lt, le, gt, ge
from sympy.core.compatibility import is_sequence
from sympy.core.expr import Expr
from sympy.core.mod import Mod
from sympy.core.numbers import Exp1
from sympy.core.singlet... |
1245dd284c0b796606eb28bca3c3b80b6c14efeaa8b08984f41f369863593efd | """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
... |
41fcb53a856364874e519abf9d6e39348299de92c32ee9516e36aa79e24e691b | """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... |
2d5b0104ed41e074eb503c4a5878c0739cf77d13a24086874da1742d9d30fa36 | """Computational algebraic field theory. """
from functools import reduce
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.exprtools import Factors
from sympy.core.function i... |
c7f475a279bb82f36ec44e1d1be37bb6275f2e12cad0a6bcfc505de63e5fdcf0 | """Tools for constructing domains for expressions. """
from sympy.core import sympify
from sympy.core.compatibility import ordered
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.realfie... |
69bd0c3119b64b042c678798e37b25b9c5076e696620cf7cdc1b62ac66571af3 | """py.test hacks to support XFAIL/XPASS"""
import sys
import functools
import os
import contextlib
import warnings
from sympy.utilities.exceptions import SymPyDeprecationWarning
ON_TRAVIS = os.getenv('TRAVIS_BUILD_NUMBER', None)
try:
import pytest
USE_PYTEST = getattr(sys, '_running_pytest', False)
except I... |
a7dcf592b9a5cf37114c5c1eebf4f444c22060753e736ac023ffca5e195941d9 | """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 IPython.Magic.magic_timeit
units = ["s", "ms", "us", "ns"]
scaling = [1, 1... |
964ce56591524bc2f111102476ceaf783851228bda498707eef1f78932958d0e | """
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... |
6c563008504dc5ee564eddcf0a0d9accb26f469fc9803f7cb6e51fb3e465472b | from collections.abc import Callable
from sympy.utilities.exceptions import SymPyDeprecationWarning
from sympy.core.basic import Basic
from sympy.core.cache import cacheit
from sympy.core import S, Dummy, Lambda
from sympy.core.symbol import Str
from sympy import symbols, MatrixBase, ImmutableDenseMatrix
from sympy.so... |
54c7095261d22800e18dfd2940bfdfb335cdf9b28f2f50b179af0cbf1bef048a | """The definition of the base geometrical entity with attributes common to
all derived geometrical entities.
Contains
========
GeometryEntity
GeometricSet
Notes
=====
A GeometryEntity is any object that has special geometric properties.
A GeometrySet is a superclass of any GeometryEntity that can also
be viewed as ... |
e38650ffaec8d4b3d4cffa7cc9680e0fcf3c9c4a4cda712d9008c5fce971ca8f | """Transform a string with Python-like source code into SymPy expression. """
from tokenize import (generate_tokens, untokenize, TokenError,
NUMBER, STRING, NAME, OP, ENDMARKER, ERRORTOKEN, NEWLINE)
from keyword import iskeyword
import ast
import unicodedata
from io import StringIO
from sympy.core.compatibility... |
f64c9dac47764d767c8068c39bc0bdfd4dbdfcc1d64886736495334f9a537f5f | """
This module implements the functionality to take any Python expression as a
string and fix all numbers and other things before evaluating it,
thus
1/2
returns
Integer(1)/Integer(2)
We use the ast module for this. It is well documented at docs.python.org.
Some tips to understand how this works: use dump() to ge... |
36575564c68b4b4b066b42188ab9afb4d41e028a7d6217fec3c572fe556f90a8 | # -*- coding: utf-8 -*-
r"""
Wigner, Clebsch-Gordan, Racah, and Gaunt coefficients
Collection of functions for calculating Wigner 3j, 6j, 9j,
Clebsch-Gordan, Racah as well as Gaunt coefficients exactly, all
evaluating to a rational number times the square root of a rational
number [Rasch03]_.
Please see the descripti... |
e0223631b5be3e0aa37f47cb73f4703f2dfc5f498dce0bb67a1d9d6f81b83056 | """
This module implements Pauli algebra by subclassing Symbol. Only algebraic
properties of Pauli matrices are used (we don't use the Matrix class).
See the documentation to the class Pauli for examples.
References
==========
.. [1] https://en.wikipedia.org/wiki/Pauli_matrices
"""
from sympy import Symbol, I, Mul,... |
f3742654b1bf99b0a501edc851c9c9622796b08fbb45603bc4da282663a3ca14 | from sympy.core import S, pi, Rational
from sympy.functions import assoc_laguerre, sqrt, exp, factorial, factorial2
def R_nl(n, l, nu, r):
"""
Returns the radial wavefunction R_{nl} for a 3d isotropic harmonic
oscillator.
Parameters
==========
``n`` :
The "nodal" quantum number. Cor... |
c3596d3b160bf46a464d8cbb872993a02546ebe9ef9bc925b65ad0d5455eb33b | from sympy.core import S, pi, Rational
from sympy.functions import hermite, sqrt, exp, factorial, Abs
from sympy.physics.quantum.constants import hbar
def psi_n(n, x, m, omega):
"""
Returns the wavefunction psi_{n} for the One-dimensional harmonic oscillator.
Parameters
==========
``n`` :
... |
6cd63b7b3dfe899c93de5d0ac751c2a12eed7a30b9cf25f41a51af85e5dfaf4a | from sympy import factorial, sqrt, exp, S, assoc_laguerre, Float
from sympy.functions.special.spherical_harmonics import Ynm
def R_nl(n, l, r, Z=1):
"""
Returns the Hydrogen radial wavefunction R_{nl}.
Parameters
==========
n : integer
Principal Quantum Number which is
an integer... |
cc4b2e755677f0d6ae1cde1031fc8f93d60ce005d1661748c8ba599f36878f4c | """Known matrices related to physics"""
from sympy import Matrix, I, pi, sqrt
from sympy.functions import exp
def msigma(i):
r"""Returns a Pauli matrix `\sigma_i` with ``i=1,2,3``.
References
==========
.. [1] https://en.wikipedia.org/wiki/Pauli_matrices
Examples
========
>>> from sym... |
fdd3d1c0c0c9420e513669abb956ef86a6fa85ed550d388e199e3b8286b64957 | """
Second quantization operators and states for bosons.
This follow the formulation of Fetter and Welecka, "Quantum Theory
of Many-Particle Systems."
"""
from collections import defaultdict
from sympy import (Add, Basic, cacheit, Dummy, Expr, Function, I,
KroneckerDelta, Mul, Pow, S, sqrt, Symbol,... |
17db0c1067f412b52c9461f3847d005040e84771dc3e10e1a2777a15db15ad49 | from sympy import sqrt, exp, S, pi, I
from sympy.physics.quantum.constants import hbar
def wavefunction(n, x):
"""
Returns the wavefunction for particle on ring.
Parameters
==========
n : The quantum number.
Here ``n`` can be positive as well as negative
which can be used to desc... |
352194aebb36a72a55b5f1de3ba03e5a869f29d9f12f3d0b6b9d96849e6b84c6 | """A module to manipulate symbolic objects with indices including tensors
"""
from .indexed import IndexedBase, Idx, Indexed
from .index_methods import get_contraction_structure, get_indices
from .array import (MutableDenseNDimArray, ImmutableDenseNDimArray,
MutableSparseNDimArray, ImmutableSparseNDimArray, NDimAr... |
611317aa8f615a79562cf8a1772ee7fc0c66e9eefc3844f3362eaad5e31c6798 | """
This module defines tensors with abstract index notation.
The abstract index notation has been first formalized by Penrose.
Tensor indices are formal objects, with a tensor type; there is no
notion of index range, it is only possible to assign the dimension,
used to trace the Kronecker delta; the dimension can be... |
a86ea1a13e38a4def8ca0abae449be1ba37b29a8443d568daafbde9aede6e4bc | """Module with functions operating on IndexedBase, Indexed and Idx objects
- Check shape conformance
- Determine indices in resulting expression
etc.
Methods in this module could be implemented by calling methods on Expr
objects instead. When things stabilize this could be a useful
refactori... |
f74a8a652f74148d265569d2048fded22d7ba9ef4fa95e4e6648b065c9920a58 | from collections.abc import Iterable
from sympy import Expr, S, Mul, sympify
from sympy.core.parameters import global_parameters
class TensorProduct(Expr):
"""
Generic class for tensor products.
"""
is_number = False
def __new__(cls, *args, **kwargs):
from sympy.tensor.array import NDimA... |
9d2af4af741ea6b0ea383674ed424d08e497e1f70eeca6f83757c4579c5cb284 | r"""Module that defines indexed objects
The classes ``IndexedBase``, ``Indexed``, and ``Idx`` represent a
matrix element ``M[i, j]`` as in the following diagram::
1) The Indexed class represents the entire indexed object.
|
___|___
' '
M[i, j]... |
5aeb3753936a852bfe830229217bd5fa68dc95b85fc762f90efdf9f795efb24b | import copy
from sympy.core.function import expand_mul
from sympy.functions.elementary.miscellaneous import Min, sqrt
from .common import NonSquareMatrixError, NonPositiveDefiniteMatrixError
from .utilities import _get_intermediate_simp, _iszero
from .determinant import _find_reasonable_pivot_naive
def _rank_decomp... |
82d5459a7f8297ad0509671dac0a0bae04c2ce01e289ac19a078f9840b7872bf | """
Basic methods common to all matrices to be used
when creating more advanced matrices (e.g., matrices over rings,
etc.).
"""
from collections import defaultdict
from collections.abc import Iterable
from inspect import isfunction
from functools import reduce
from sympy.core.logic import FuzzyBool
from sympy.assumpt... |
c7d3e329b630cdfb8399ab57add3e704089ed8323a047ef94ff97efa4f646674 | import random
from functools import reduce
from sympy.core import SympifyError, Add
from sympy.core.basic import Basic
from sympy.core.compatibility import is_sequence
from sympy.core.expr import Expr
from sympy.core.singleton import S
from sympy.core.symbol import Symbol
from sympy.core.sympify import sympify, _sympi... |
23233607f1ae1c0a57ac8e177832c3262413fc7e32414e46e6202d72aed1048b | from collections import defaultdict
from collections.abc import Callable
from functools import reduce
from sympy.core import SympifyError, Add
from sympy.core.compatibility import as_int, is_sequence
from sympy.core.containers import Dict
from sympy.core.expr import Expr
from sympy.core.singleton import S
from sympy.c... |
61837da4de7c0485af9210306913d121cd0e77cf71c2f7233be3e1078dd9ada2 | from types import FunctionType
from collections import Counter
from mpmath import mp, workprec
from mpmath.libmp.libmpf import prec_to_dps
from sympy.core.compatibility import default_sort_key
from sympy.core.evalf import DEFAULT_MAXPREC, PrecisionExhausted
from sympy.core.logic import fuzzy_and, fuzzy_or
from sympy.... |
b800a1c9ee9b41c91c9c4e4ee03cc8840cf8ffb9c7ce7d27d68909dc9e9fd2bc | from .utilities import _iszero
def _columnspace(M, simplify=False):
"""Returns a list of vectors (Matrix objects) that span columnspace of ``M``
Examples
========
>>> from sympy.matrices import Matrix
>>> M = Matrix(3, 3, [1, 3, 0, -2, -6, 0, 3, 9, 6])
>>> M
Matrix([
[ 1, 3, 0],
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.