hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
3192022d1b02e9e09ccfebd2c0d721fec3542c6c32d3ae39029c9c2e6a9898be | from sympy import (Symbol, Set, Union, Interval, oo, S, sympify, nan,
Max, Min, Float, DisjointUnion,
FiniteSet, Intersection, imageset, I, true, false, ProductSet,
sqrt, Complement, EmptySet, sin, cos, Lambda, ImageSet, pi,
Pow, Contains, Sum, rootof, SymmetricDifference, Piecewise,
Matrix, Range, ... |
82e776efa5c33a2b826416cb57aff5dbf56cdd2b677801b855a66703fcd40c6d | from sympy import Symbol, log, sqrt, sin, S
from sympy.plotting.textplot import textplot_str
def test_axes_alignment():
x = Symbol('x')
lines = [
' 1 | ..',
' | ... ',
' ... |
828e285b72b70a5ab774b313b0b02a10ebca9b881a0fcd5c8b475b072b59b966 | #!/usr/bin/env python
"""Distutils based setup script for SymPy.
This uses Distutils (https://python.org/sigs/distutils-sig/) the standard
python mechanism for installing packages. Optionally, you can use
Setuptools (https://setuptools.readthedocs.io/en/latest/)
to automatically handle dependencies. For the easiest in... |
b277ce5aba24985577c9938485d8f9cc6819d75a64a5f7ecd37e0e02b6703ba6 | __version__ = "1.7.dev"
|
5fd41120e4d6eead6cf8e76df1d7cfa0e423a3b46d3ab0ea37498d2e78d0813e | #!/usr/bin/env python
"""
Plotting Examples
Suggested Usage: python -i pyglet_plotting.py
"""
from sympy import symbols, sin, cos, pi, sqrt
from sympy.core.compatibility import clock
from sympy.plotting.pygletplot import PygletPlot
from time import sleep
def main():
x, y, z = symbols('x,y,z')
# toggl... |
d3c8b295ddbdb096652df33b83eda6a328caf62cc43a59f557ff8cf222393c92 | # -*- coding: utf-8 -*-
#
# SymPy documentation build configuration file, created by
# sphinx-quickstart.py on Sat Mar 22 19:34:32 2008.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# The contents of this file are pickled, so don't put values in the namespace
# that aren't pickle... |
bd1388ab9ca49d521f6b78ec9000b6e827db3e3afa7341d56cfc8b8f77ea7cd0 | """
sympylive
~~~~~~~~~
Allow `SymPy Live <https://live.sympy.org/>`_ to be used for interactive
evaluation of SymPy's code examples.
:copyright: Copyright 2014 by the SymPy Development Team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
def builder_inited(app):
if not app.con... |
95148d04e7f37d2b299671656718107cd14e27221e6e79220b1288cd8c019a3a | """
Continuous Random Variables - Prebuilt variables
Contains
========
Arcsin
Benini
Beta
BetaNoncentral
BetaPrime
BoundedPareto
Cauchy
Chi
ChiNoncentral
ChiSquared
Dagum
Erlang
ExGaussian
Exponential
ExponentialPower
FDistribution
FisherZ
Frechet
Gamma
GammaInverse
Gumbel
Gompertz
Kumaraswamy
Laplace
Levy
Logistic
Lo... |
b6bd494d2eef12039983b8351501acb6cb3685a5e3c3e00b79e34b238a85d195 | from __future__ import print_function, division
from sympy import (Matrix, MatrixSymbol, S, Indexed, Basic,
Set, And, Eq, FiniteSet, ImmutableMatrix,
Lambda, Mul, Dummy, IndexedBase, Add,
linsolve, eye, Or, Not, Intersection,
Union, Expr, Func... |
c576d9d31763e7a6ea0becca11d819106232cbcf789687eb2b4eb084b560f824 | """
SymPy statistics module
Introduces a random variable type into the SymPy language.
Random variables may be declared using prebuilt functions such as
Normal, Exponential, Coin, Die, etc... or built with functions like FiniteRV.
Queries on random expressions can be made using the functions
======================... |
454760d7c3929b205dccbb1b6c862e3343a72876c3b2de6744f073019e02c9c7 | """Tools for arithmetic error propagation."""
from __future__ import print_function, division
from itertools import repeat, combinations
from sympy import S, Symbol, Add, Mul, simplify, Pow, exp
from sympy.stats.symbolic_probability import RandomSymbol, Variance, Covariance
_arg0_or_var = lambda var: var.args[0] if ... |
d6f18fa56956b0b0e6ad3c505516f1c9dd97be5f8a5615e61b92bb08e498e89b | """
Contains
========
Geometric
Hermite
Logarithmic
NegativeBinomial
Poisson
Skellam
YuleSimon
Zeta
"""
from __future__ import print_function, division
from sympy import (Basic, factorial, exp, S, sympify, I, zeta, polylog, log, beta,
hyper, binomial, Piecewise, floor, besseli, sqrt, Sum, Dummy,
... |
e78c39128ad218099988af3bdbeaba2158f28df5803ca97ce9722b723257c0a0 | """
Main Random Variables Module
Defines abstract random variable type.
Contains interfaces for probability space object (PSpace) as well as standard
operators, P, E, sample, density, where, quantile
See Also
========
sympy.stats.crv
sympy.stats.frv
sympy.stats.rv_interface
"""
from __future__ import print_function... |
78104d2c54b8230d96a8cf0d4baef35ab2a7079b88d44130002fa9e5985f05da | from __future__ import print_function, division
from sympy import (Basic, sympify, symbols, Dummy, Lambda, summation,
Piecewise, S, cacheit, Sum, exp, I, Ne, Eq, poly,
series, factorial, And)
from sympy.polys.polyerrors import PolynomialError
from sympy.solvers.solveset import so... |
b246f15c9e2ba9f3481663f486b316b28a64dcee1b8ef9dafdf84bcb52652bcf | """
Continuous Random Variables Module
See Also
========
sympy.stats.crv_types
sympy.stats.rv
sympy.stats.frv
"""
from __future__ import print_function, division
from sympy import (Interval, Intersection, symbols, sympify, Dummy, nan,
Integral, And, Or, Piecewise, cacheit, integrate, oo, Lambda,
Basi... |
e6f08b51148337fa66a08907ef0691fcbb506aa65f5a8b0643c0e2a93df4ba75 | import itertools
from sympy import Expr, Add, Mul, S, Integral, Eq, Sum, Symbol
from sympy.core.compatibility import default_sort_key
from sympy.core.parameters import global_parameters
from sympy.core.sympify import _sympify
from sympy.stats import variance, covariance
from sympy.stats.rv import RandomSymbol, probabi... |
78001429d1a633ecbd76d6d49e1b560e0b0091a5c53ae93af7854849ffa4c965 | """
Finite Discrete Random Variables Module
See Also
========
sympy.stats.frv_types
sympy.stats.rv
sympy.stats.crv
"""
from __future__ import print_function, division
import random
from itertools import product
from sympy import (Basic, Symbol, cacheit, sympify, Mul,
And, Or, Tuple, Piecewise, Eq,... |
34e76052ceb21a731d86b8c1feff97a1984731179729c86e4be7096a78e12a54 | #!/usr/bin/env python
from random import random
from sympy import factor, I, Integer, pi, simplify, sin, sqrt, Symbol, sympify
from sympy.abc import x, y, z
from timeit import default_timer as clock
def bench_R1():
"real(f(f(f(f(f(f(f(f(f(f(i/2)))))))))))"
def f(z):
return sqrt(Integer(1)/3)*z**2 + I/... |
74df8f2768e90c04e43dbe60bc2a0e861d9275b41c42848d7d91c5c2eed8cc96 | # conceal the implicit import from the code quality tester
from sympy import (exp, gamma, integrate, oo, pi, sqrt, Symbol, symbols,
besseli, laplace_transform, fourier_transform, mellin_transform,
inverse_fourier_transform, inverse_laplace_transform,
inverse_mellin_transform)
LT = laplace_trans... |
08d721209e4714c3e9365559876bce5341a04376ec7ba86acaa0e8be90c794a1 | import sys
from time import time
from sympy.ntheory.residue_ntheory import (discrete_log,
_discrete_log_trial_mul, _discrete_log_shanks_steps,
_discrete_log_pollard_rho, _discrete_log_pohlig_hellman)
# Cyclic group (Z/pZ)* with p prime, order p - 1 and generator g
data_set_1 = [
# p, p - 1, g
... |
a1415ab3a631e73fc6dcdd22844fd0240bb91000e255e309f290f6cecbfc9706 | '''
This implementation is a heavily modified fixed point implementation of
BBP_formula for calculating the nth position of pi. The original hosted
at: http://en.literateprograms.org/Pi_with_the_BBP_formula_(Python)
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and a... |
563ad8374ce550c92902c6887e689f9b7a56101bf0c7b5efad9281e2fc4dfcbc | """
Generating and counting primes.
"""
import random
from bisect import bisect
from itertools import count
# Using arrays for sieving instead of lists greatly reduces
# memory consumption
from array import array as _array
from sympy import Function, S
from sympy.core.compatibility import as_int
from .primetest impo... |
7af99886bc92e95eb8598a799c2d6e7c2ae4871c2df3656172c46a1750d0919d | from sympy.core.compatibility import as_int
from sympy.core.function import Function
from sympy.utilities.iterables import cartes
from sympy.core.numbers import igcd, igcdex, mod_inverse
from sympy.core.power import isqrt
from sympy.core.singleton import S
from .primetest import isprime
from .factor_ import factorint, ... |
7ceb6be95a9b17f9d8dbd6442e387f1ec6d824cb91be8a6258b3c4fddc2c7ff8 | from collections import defaultdict
from sympy.core.compatibility import as_int
from sympy.utilities.iterables import multiset, is_palindromic as _palindromic
def digits(n, b=10, digits=None):
"""
Return a list of the digits of ``n`` in base ``b``. The first
element in the list is ``b`` (or ``-b`` if ``n... |
efa2facc27134eee26896b607060b83a9469f9aea2a46822475dc29f8f9bdc7a | from sympy.core.compatibility import as_int, reduce
from sympy.core.mul import prod
from sympy.core.numbers import igcdex, igcd
from sympy.ntheory.primetest import isprime
from sympy.polys.domains import ZZ
from sympy.polys.galoistools import gf_crt, gf_crt1, gf_crt2
def symmetric_residue(a, m):
"""Return the res... |
c6f152eb1ed0e2f439ef315b9bb3307a58818ccd7bca9194549ece70b9ce380e | from sympy.core.compatibility import as_int
def binomial_coefficients(n):
"""Return a dictionary containing pairs :math:`{(k1,k2) : C_kn}` where
:math:`C_kn` are binomial coefficients and :math:`n=k1+k2`.
Examples
========
>>> from sympy.ntheory import binomial_coefficients
>>> binomial_coef... |
2b6ca0d6fe7f7e1af94849397efbfbd5bf7cd0114ade0824ece900c5e27a02c9 | """
Primality testing
"""
from sympy.core.compatibility import as_int
from mpmath.libmp import bitcount as _bitlength
def _int_tuple(*i):
return tuple(int(_) for _ in i)
def is_euler_pseudoprime(n, b):
"""Returns True if n is prime or an Euler pseudoprime to base b, else False.
Euler Pseudoprime : I... |
8b755ca7004966b32d08aa209f0d69ad50bbf48a370c4fe4500802a5063f514a | from sympy import Integer
import sympy.polys
import sys
if sys.version_info < (3,5):
from fractions import gcd
else:
from math import gcd
def egyptian_fraction(r, algorithm="Greedy"):
"""
Return the list of denominators of an Egyptian fraction
expansion [1]_ of the said rational `r`.
Paramet... |
2fc78e6367f2d7a0d193cbc4aa15804931ac4ef6189ddd182fa877d5838d952f | """
Integer factorization
"""
from collections import defaultdict
import random
import math
from sympy.core import sympify
from sympy.core.compatibility import as_int, SYMPY_INTS
from sympy.core.containers import Dict
from sympy.core.evalf import bitcount
from sympy.core.expr import Expr
from sympy.core.function impo... |
46e91fbbe3a45bcd4de71d6f75787a66679bc0bcef50db87e11e9bebf2ea0359 | from mpmath.libmp import (fzero, from_int, from_rational,
fone, fhalf, bitcount, to_int, to_str, mpf_mul, mpf_div, mpf_sub,
mpf_add, mpf_sqrt, mpf_pi, mpf_cosh_sinh, mpf_cos, mpf_sin)
from sympy.core.numbers import igcd
from .residue_ntheory import (_sqrt_mod_prime_power,
legendre_symbol, jacobi_symbol, is_... |
356a7511bf675a56df56cff6c2c0efdad22b63b38542d526b0c8168b2e3fc584 | from random import randrange, choice
from math import log
from sympy.ntheory import primefactors
from sympy import multiplicity, factorint, Symbol
from sympy.combinatorics import Permutation
from sympy.combinatorics.permutations import (_af_commutes_with, _af_invert,
_af_rmul, _af_rmuln, _af_pow, Cycle)
from sympy... |
feab07ddad4a87474809e90f7f557c678cb888680fe5e2799d47287b84a30313 | from sympy.combinatorics.permutations import Permutation
from sympy.core.symbol import symbols
from sympy.matrices import Matrix
from sympy.utilities.iterables import variations, rotate_left
def symmetric(n):
"""
Generates the symmetric group of order n, Sn.
Examples
========
>>> from sympy.comb... |
bf79ae51d72d7e58603cef49d7c88040b6282b91f7454e07d3e222913d1b59ff | from sympy.core import Basic
import random
class GrayCode(Basic):
"""
A Gray code is essentially a Hamiltonian walk on
a n-dimensional cube with edge length of one.
The vertices of the cube are represented by vectors
whose values are binary. The Hamilton walk visits
each vertex exactly once. ... |
14ab0f8cd203bac22b5ca120ecbc43d4fe3312d6ab9dfb2ad4f4d140f8330863 | from sympy.combinatorics.rewritingsystem_fsm import StateMachine
class RewritingSystem:
'''
A class implementing rewriting systems for `FpGroup`s.
References
==========
.. [1] Epstein, D., Holt, D. and Rees, S. (1991).
The use of Knuth-Bendix methods to solve the word problem in automat... |
aa202d68104bd01395723e3b04861228f3adef41b546fb65c4b2737f262ae8f2 | import random
from collections import defaultdict
from sympy.core.parameters import global_parameters
from sympy.core.basic import Atom
from sympy.core.expr import Expr
from sympy.core.compatibility import \
is_sequence, reduce, as_int, Iterable
from sympy.core.numbers import Integer
from sympy.core.sympify import... |
11c5d9cc2494f860ed077358c6e7e47d33a29755f19ade6ae5ecdec4e5be7468 | from itertools import combinations
from sympy.combinatorics.graycode import GrayCode
from sympy.core import Basic
class Subset(Basic):
"""
Represents a basic subset object.
We generate subsets using essentially two techniques,
binary enumeration and lexicographic enumeration.
The Subset class ta... |
3b62373dc37ddd278ca7f730a643c03f4a99375c558682a5a6393ad9a5d30618 | from sympy.combinatorics.permutations import Permutation, Cycle
from sympy.combinatorics.prufer import Prufer
from sympy.combinatorics.generators import cyclic, alternating, symmetric, dihedral
from sympy.combinatorics.subsets import Subset
from sympy.combinatorics.partitions import (Partition, IntegerPartition,
RG... |
5a4ba35bc57017c573b2b658b0055d7fa4f5d7d51d0b1b5b2760d87712e0f72e | """
The Schur number S(k) is the largest integer n for which the interval [1,n]
can be partitioned into k sum-free sets.(http://mathworld.wolfram.com/SchurNumber.html)
"""
import math
from sympy.core import S
from sympy.core.basic import Basic
from sympy.core.function import Function
from sympy.core.numbers import Inte... |
c40abad21fc3c7cbdfbf6322f9d562c14e9850618414c4295063717961539838 | from sympy.combinatorics.perm_groups import PermutationGroup
from sympy.combinatorics.permutations import Permutation
from sympy.utilities.iterables import uniq
_af_new = Permutation._af_new
def DirectProduct(*groups):
"""
Returns the direct product of several groups as a permutation group.
This is impl... |
1650028e357213c4beb9ae2827ca78359b07f2451634c790b707f6abf88e4c92 | from typing import Dict, List
from sympy.core import S
from sympy.core.compatibility import is_sequence, as_int
from sympy.core.expr import Expr
from sympy.core.symbol import Symbol, symbols as _symbols
from sympy.core.sympify import CantSympify
from sympy.printing.defaults import DefaultPrinting
from sympy.utilities ... |
c9502ee6bae33db890c687711d766414a0c33fd41955a20d37760ea610fa6c09 | from sympy.combinatorics.permutations import Permutation, _af_rmul, \
_af_invert, _af_new
from sympy.combinatorics.perm_groups import PermutationGroup, _orbit, \
_orbit_transversal
from sympy.combinatorics.util import _distribute_gens_by_base, \
_orbits_transversals_from_bsgs
"""
References for tensor ... |
4b2a53b9164915b7fda3e785c565a5d55d2c3be4a166d6212e9f9c58e313998f | from sympy import isprime
from sympy.combinatorics.perm_groups import PermutationGroup
from sympy.printing.defaults import DefaultPrinting
from sympy.combinatorics.free_groups import free_group
class PolycyclicGroup(DefaultPrinting):
is_group = True
is_solvable = True
def __init__(self, pc_sequence, pc_... |
08a1a12eacafc58d26966cbcfc76f85b391275660f51a536c99621cfed22679c | class State:
'''
A representation of a state managed by a ``StateMachine``.
Attributes:
name (instance of FreeGroupElement or string) -- State name which is also assigned to the Machine.
transisitons (OrderedDict) -- Represents all the transitions of the state object.
state_type (st... |
ddc2af95466f47ccc2c7392a02427ccd504dbbad587789edf5338c4efdc97f3d | from sympy.combinatorics import Permutation as Perm
from sympy.combinatorics.perm_groups import PermutationGroup
from sympy.core import Basic, Tuple
from sympy.core.compatibility import as_int
from sympy.sets import FiniteSet
from sympy.utilities.iterables import (minlex, unflatten, flatten)
rmul = Perm.rmul
class P... |
c08f7c5b817d719e867b4e01fb5b753af85d43135d65738281f107b1fea1d7a6 | import itertools
from sympy.combinatorics.fp_groups import FpGroup, FpSubgroup, simplify_presentation
from sympy.combinatorics.free_groups import FreeGroup
from sympy.combinatorics.perm_groups import PermutationGroup
from sympy.core.numbers import igcd
from sympy.ntheory.factor_ import totient
from sympy import S
clas... |
7ab8104fa7324e56e22ee34c3f6c04a79eafeb07647d0c6cf933e720b994f6d6 | from sympy.core import Basic, Dict, sympify
from sympy.core.compatibility import as_int, default_sort_key
from sympy.core.sympify import _sympify
from sympy.functions.combinatorial.numbers import bell
from sympy.matrices import zeros
from sympy.sets.sets import FiniteSet, Union
from sympy.utilities.iterables import fla... |
659eb9b52156f1fee4bd29586300652fb527a906bc97655f929d83c9a018a1d1 | from sympy.combinatorics.permutations import Permutation, _af_invert, _af_rmul
from sympy.ntheory import isprime
rmul = Permutation.rmul
_af_new = Permutation._af_new
############################################
#
# Utilities for computational group theory
#
############################################
def _base_or... |
705b5592f3442d3341f4c45b2e02ac18087af0d97e429f6eca64422e28fb67c8 | from sympy.combinatorics.free_groups import free_group
from sympy.printing.defaults import DefaultPrinting
from itertools import chain, product
from bisect import bisect_left
###############################################################################
# COSET TABLE ... |
cbcf92f7b5d773b248be3fbdb689488ddfb674202408d1f493bf4f476e230c1c | from sympy.combinatorics.group_constructs import DirectProduct
from sympy.combinatorics.perm_groups import PermutationGroup
from sympy.combinatorics.permutations import Permutation
_af_new = Permutation._af_new
def AbelianGroup(*cyclic_orders):
"""
Returns the direct product of cyclic groups with the given o... |
4eee37b47c6acfff3c384c171811ae6c0eb0ba09398c935fe9f1e75a5d88885b | from sympy.core import Basic
from sympy.core.compatibility import iterable, as_int
from sympy.utilities.iterables import flatten
from collections import defaultdict
class Prufer(Basic):
"""
The Prufer correspondence is an algorithm that describes the
bijection between labeled trees and the Prufer code. A... |
c3c2b5bb5c6ca27413ffe32ab92a3418712dc4381f733636d2e20df8a2c0c0fa | """Finitely Presented Groups and its algorithms. """
from sympy import S
from sympy.combinatorics.free_groups import (FreeGroup, FreeGroupElement,
free_group)
from sympy.combinatorics.rewritingsystem import RewritingSystem
from sympy.combinatorics.coset_table import (Cos... |
96ea480f74d95a4ea50eb89e3fee8b0ede94eaa1004cd93fe1696787ae96b12f | from sympy.core.mul import Mul
from sympy.core.singleton import S
from sympy.concrete.expr_with_intlimits import ExprWithIntLimits
from sympy.core.exprtools import factor_terms
from sympy.functions.elementary.exponential import exp, log
from sympy.polys import quo, roots
from sympy.simplify import powsimp
class Produ... |
f75a1f43da51b99a2109bd292b1665b2c69cf23d4daf058655ffa1a23ad9a318 | from sympy.concrete.expr_with_limits import ExprWithLimits
from sympy.core.singleton import S
from sympy.core.relational import Eq
class ReorderError(NotImplementedError):
"""
Exception raised when trying to reorder dependent limits.
"""
def __init__(self, expr, msg):
super().__init__(
... |
650af6b2046a2efc4458017e6ba1b749f04c3a1ea458af020104a6ce0d9a64b2 | """
This module implements sums and products containing the Kronecker Delta function.
References
==========
- http://mathworld.wolfram.com/KroneckerDelta.html
"""
from sympy.core import Add, Mul, S, Dummy
from sympy.core.cache import cacheit
from sympy.core.compatibility import default_sort_key
from sympy.functions ... |
e1e0e8c5ae7a14c19fbc04916059241e5a914efaceb6ae1a83ab93fd43950dae | """Gosper's algorithm for hypergeometric summation. """
from sympy.core import S, Dummy, symbols
from sympy.core.compatibility import is_sequence
from sympy.polys import Poly, parallel_poly_from_expr, factor
from sympy.solvers import solve
from sympy.simplify import hypersimp
def gosper_normal(f, g, n, polys=True):
... |
9973bd7d41d7c3ae440bdb791b584f010706dc187b02facd2f2afd329b1a7569 | """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... |
8c2c9e0d7107f78369fdbaf41c25f4783a9f9b330d2ff5ed2ef5f49d93dcd6bd | from sympy.core.add import Add
from sympy.core.compatibility import is_sequence
from sympy.core.containers import Tuple
from sympy.core.expr import Expr
from sympy.core.mul import Mul
from sympy.core.relational import Equality, Relational
from sympy.core.singleton import S
from sympy.core.symbol import Symbol, Dummy
fr... |
879f4e31fb4e01eeed8e06a6023adb4ed8dad3c82fba4ab9b244dfa8b073bc5a | 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... |
1349996c184df8c102caae98a63deeb35dfc4066988d77b70baec2d4cac2521b | """Tools to assist importing optional external modules."""
import sys
from distutils.version import LooseVersion
# Override these in the module to change the default warning behavior.
# For example, you might set both to False before running the tests so that
# warnings are not printed to the console, or set both to ... |
7d5944e5d6cb0704dc4b0023c95249290fce70ad88148e32e447bf7248293ef2 | """
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... |
297b50e5c12767e4048be895f3d4baeb5bc4dc22d126942fb7323fbfe35ae0f6 | """Limits of sequences"""
from __future__ import print_function, division
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.combina... |
bd5ee6d93366766697631541dddaa7bbd5265c946b0859f63f07bb848fd0a07f | """ Optimizations of the expression tree representation for better CSE
opportunities.
"""
from __future__ import print_function, division
from sympy.core import Add, Basic, Mul
from sympy.core.basic import preorder_traversal
from sympy.core.singleton import S
from sympy.utilities.iterables import default_sort_key
de... |
46e3edc38fd820f39f56cc8dad5ed0a101d01295e9641a1e10125754a5692b5c | from __future__ import print_function, division
from collections import defaultdict
from sympy import SYMPY_DEBUG
from sympy.core import expand_power_base, sympify, Add, S, Mul, Derivative, Pow, symbols, expand_mul
from sympy.core.add import _unevaluated_Add
from sympy.core.compatibility import iterable, ordered, de... |
ebfb11eb229794513bcb63ac35aa0efceb3dd3ddc63e93cb8bf82ed4f6c9a3f5 | 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... |
cc10688fb2b9ea4411dc13dc705672a5b760f2077d06e19c7252d5b3b4f53f5f | from sympy.core import S, Basic, Dict, Symbol, Tuple, sympify
from sympy.core.compatibility import iterable
from sympy.sets import Set, FiniteSet, EmptySet
class Class(Set):
r"""
The base class for any kind of class in the set-theoretic sense.
In axiomatic set theories, everything is a class. A class wh... |
b7fdd052d1cb5ca8eabd814fe85b7ac22694c1b76127554cd1cea625ed8d8a12 | """Predefined R^n manifolds together with common coord. systems.
Coordinate systems are predefined as well as the transformation laws between
them.
Coordinate functions can be accessed as attributes of the manifold (eg `R2.x`),
as attributes of the coordinate systems (eg `R2_r.x` and `R2_p.theta`), or by
using the us... |
83829d8398d6904bc7bd2489b42998529880101451561d0afcd50c2b5fb9d58b | from typing import Any, Set
from itertools import permutations
from sympy.combinatorics import Permutation
from sympy.core import (
Basic, Expr, Dummy, Function, diff,
Pow, Mul, Add, Atom
)
from sympy.core.compatibility import reduce
from sympy.core.numbers import Zero
from sympy.core.sympify import _sympify... |
cfb0843088c82fc5cf245b5b9c6c563e93cade6992791cef2acac5bfbcae4073 | 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... |
f2c434b778698c70cf8dee8983281ae99f2d75192dfb83e74be4262c3ae3c8da | """
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... |
85ed7900776ec20bab7e2ad02bca35927ada18bf920d3e5417321d4c575fd885 | import bisect
import itertools
from functools import reduce
from collections import defaultdict
from sympy import Indexed, IndexedBase, Tuple, Sum, Add, S, Integer, diagonalize_vector, DiagMatrix
from sympy.combinatorics import Permutation
from sympy.core.basic import Basic
from sympy.core.compatibility import accumul... |
5ccb0adae92a6aabf005f31b134f8dbdc754c5dabf4094ebd786489f32c3966f | 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. "... |
d5955e21c3cef0f6bee531107caa26b95dd95e7d31dd2bd2726b286f17650606 | """
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... |
aeb0aa4fd09571a2d56f94fa687d617fafd87d1c325a6a5beb2ee98082b9a94e | """
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
| ... |
ab2285669f97aba8d724fbbf5ae1ad414bbc93135df7b1d49fcb2ff465eb87ed | """
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... |
47cf8d1b2027a7ffc98b13d74f28237ecb682285dcc33b075670025fd162c453 | """
This file contains some classical ciphers and routines
implementing a linear-feedback shift register (LFSR)
and the Diffie-Hellman key exchange.
.. warning::
This module is intended for educational purposes only. Do not use the
functions in this module for real cryptographic applications. If you wish
to ... |
72a9e98db98bd1840d6a5fda43e0057823645357870a90b5eee689f89a3c08e4 | """A module for solving all kinds of equations.
Examples
========
>>> from sympy.solvers import solve
>>> from sympy.abc import x
>>> solve(x**5+5*x**4+10*x**3+10*x**2+5*x+1,x)
[-1]
"""
from sympy.core.assumptions import check_assumptions, failing_assumptions
from .solvers import solve, solve... |
f37e32e0d1cc4d74f756445507609c190b3311bbac6822e03e69de2c0deeea56 | """
This module contains functions to:
- solve a single equation for a single variable, in any domain either real or complex.
- solve a single transcendental equation for a single variable in any domain either real or complex.
(currently supports solving in real domain only)
- solve a system of lin... |
2c3f8a0a8a051efc58d2d140af2a409888548510b5924cfaba6ee0733d38d08c | """
This module contain solvers for all kinds of equations:
- algebraic or transcendental, use solve()
- recurrence, use rsolve()
- differential, use dsolve()
- nonlinear (numerically), use nsolve()
(you will need a good starting point)
"""
from __future__ import print_function, division
fr... |
ecd6595e9be4db029b971183bf39e39292b7034f06941852a3a9979cd83cabfb | """
Discrete Fourier Transform, Number Theoretic Transform,
Walsh Hadamard Transform, Mobius Transform
"""
from sympy.core import S, Symbol, sympify
from sympy.core.compatibility import as_int, iterable
from sympy.core.function import expand_mul
from sympy.core.numbers import pi, I
from sympy.functions.elementary.trig... |
f8d9b6e167cefaa808ab1e974e92d6a537a6a038d0b702e11a13cf0f29937686 | """
Convolution (using **FFT**, **NTT**, **FWHT**), Subset Convolution,
Covering Product, Intersecting Product
"""
from sympy.core import S, sympify
from sympy.core.compatibility import as_int, iterable
from sympy.core.function import expand_mul
from sympy.discrete.transforms import (
fft, ifft, ntt, intt, fwht, i... |
6e6ead9d16a0ebbdfcfc54b5e91b878a3188afc4f6a59c1b4d477b6c361964ed | """
Recurrences
"""
from sympy.core import S, sympify
from sympy.core.compatibility import as_int, iterable
def linrec(coeffs, init, n):
r"""
Evaluation of univariate linear recurrences of homogeneous type
having coefficients independent of the recurrence variable.
Parameters
==========
coef... |
ea75d1bbbec2aed980095dd2037807684576efb221fcd3a10324828dcd1c69df | from sympy.core import Basic
class CartanType_generator(Basic):
"""
Constructor for actually creating things
"""
def __call__(self, *args):
c = args[0]
if type(c) == list:
letter, n = c[0], int(c[1])
elif type(c) == str:
letter, n = c[0], int(c[1:])
... |
1887938912941f4033b3f3994cf4e102e184c99f60a1bd50640a60e21244c6c1 | from .cartan_type import Standard_Cartan
from sympy.core.backend import eye
class TypeB(Standard_Cartan):
def __new__(cls, n):
if n < 2:
raise ValueError("n can not be less than 2")
return Standard_Cartan.__new__(cls, "B", n)
def dimension(self):
"""Dimension of the vector... |
c5dd6ca29c88f3505e3e9654958f6ae80d80354a3afe3cf082e699e32ee7aba6 | from sympy.liealgebras.cartan_type import Standard_Cartan
from sympy.core.backend import eye
class TypeA(Standard_Cartan):
"""
This class contains the information about
the A series of simple Lie algebras.
====
"""
def __new__(cls, n):
if n < 1:
raise ValueError("n can not... |
5d716e866c23fafbc4d4ae1d1f2dab6ed39e38e05d3929e15a304638fdae4147 | """
Singularities
=============
This module implements algorithms for finding singularities for a function
and identifying types of functions.
The differential calculus methods in this module include methods to identify
the following function types in the given ``Interval``:
- Increasing
- Strictly Increasing
- Decre... |
a99345988813a32e382248062f9b57d1196692c64d00763ce3d78e35e3cd57fa | from sympy import Order, S, log, limit, lcm_list, im, re, Dummy
from sympy.core import Add, Mul, Pow
from sympy.core.basic import Basic
from sympy.core.compatibility import iterable
from sympy.core.expr import AtomicExpr, Expr
from sympy.core.function import expand_mul
from sympy.core.numbers import _sympifyit, oo
from... |
3ea3ee58b24066533e85e3f640d1c26b48dfa63a25487c5881f63a6e3b62460f | """
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... |
f3e08c6e7b90aa0bb7509a3d8e1cdc8176de7e2aa925e52cb689b79ae4db2e32 | """Module for compiling codegen output, and wrap the binary for use in
python.
.. note:: To use the autowrap module it must first be imported
>>> from sympy.utilities.autowrap import autowrap
This module provides a common interface for different external backends, such
as f2py, fwrap, Cython, SWIG(?) etc. (Curren... |
75fc4cb6466b8886a744f8ed366ce89cbea4a59773a13333f5f05a09fe56220b | """
This module adds several functions for interactive source code inspection.
"""
from sympy.core.decorators import deprecated
import inspect
@deprecated(useinstead="?? in IPython/Jupyter or inspect.getsource", issue=14905, deprecated_since_version="1.3")
def source(object):
"""
Prints the source code of a ... |
0b1d847c12ac3c213d9db994fa7b4b124f574168c542ad254c3a2446266eb023 | """
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
import inspect
import keyword
import textwrap
import linecache
from sympy.core.compatibility import (exec_, is_sequence, iterabl... |
81a8f89897774f5e930983e5a89abb4d8da49012022a394ae6420928e7d8c3f4 | """
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... |
96fe933d27b6987cfa47d42cd2683558c07e2c25f104913008ecd18712923fbb | """
Algorithms and classes to support enumerative combinatorics.
Currently just multiset partitions, but more could be added.
Terminology (following Knuth, algorithm 7.1.2.5M TAOCP)
*multiset* aaabbcccc has a *partition* aaabc | bccc
The submultisets, aaabc and bccc of the partition are called
*parts*, or sometimes ... |
a0236d83ef41ef5491c13024e8f6d3175c6d65f7a5dc463622ce24a47140f36b | """
General SymPy exceptions and warnings.
"""
import warnings
from sympy.utilities.misc import filldedent
class SymPyDeprecationWarning(DeprecationWarning):
r"""A warning for deprecated features of SymPy.
This class is expected to be used with the warnings.warn function (note
that one has to explicitl... |
27b15985d0a5b98311d2246539787426bada1d2de2f23515fbd7bc58e9040cc7 | """Useful utility decorators. """
import sys
import types
import inspect
from sympy.core.decorators import wraps
from sympy.core.compatibility import get_function_globals, get_function_name, iterable
from sympy.testing.runtests import DependencyError, SymPyDocTests, PyTestReporter
def threaded_factory(func, use_add)... |
4321af644094a701f60bc8f48aef7970c60152b3c4f7ff26417213a3d2d4a65c | from sympy.core.decorators import wraps
def recurrence_memo(initial):
"""
Memo decorator for sequences defined by recurrence
See usage examples e.g. in the specfun/combinatorial module
"""
cache = initial
def decorator(f):
@wraps(f)
def g(n):
L = len(cache)
... |
e032a065d7e8d4313d76167db404460f2662ddce6132b0d6086549ca15b37e13 | """Simple tools for timing functions' execution, when IPython is not available. """
import timeit
import math
_scales = [1e0, 1e3, 1e6, 1e9]
_units = ['s', 'ms', '\N{GREEK SMALL LETTER MU}s', 'ns']
def timed(func, setup="pass", limit=None):
"""Adaptively measure execution time of a function. """
timer = t... |
a1faf08b5fb1c0c59be150903842307b8275400c313ac722803ab6eae4a7de26 | """Functions that involve magic. """
def pollute(names, objects):
"""Pollute the global namespace with symbols -> objects mapping. """
from inspect import currentframe
frame = currentframe().f_back.f_back
try:
for name, obj in zip(names, objects):
frame.f_globals[name] = obj
fi... |
7c3d0f4800bf24ff64fc37ecf719f1ceb84575588d990e3faaf7261817e67a5c | 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... |
5e5a9725fcd38f2c0281319dbb52bb17c0e0071747e42f585066fcaf8f369aa3 | """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 get_function_name, as_int
class Undecidable(ValueError):
# an error to be raised when a decision can... |
b86aaf5e16a91b4b5ebf5d04d77e7b0d8f7a2919ee892b4607fa7f5d6d793742 | """
Python code printers
This module contains python code printers for plain python as well as NumPy & SciPy enabled code.
"""
from collections import defaultdict
from itertools import chain
from sympy.core import S
from .precedence import precedence
from .codeprinter import CodePrinter
_kw_py2and3 = {
'and', 'as... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.