hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
68051618ff9212670df8223a333b8639bf41fd9ca331c486c86f4e78f5d6ea16 | """Implementation of :class:`AlgebraicField` class. """
from sympy.polys.domains.characteristiczero import CharacteristicZero
from sympy.polys.domains.field import Field
from sympy.polys.domains.simpledomain import SimpleDomain
from sympy.polys.polyclasses import ANP
from sympy.polys.polyerrors import CoercionFailed,... |
6e63152f72a3cf351ae0cdda4cebb494c228e541b649e800974d8957e26d27c8 | """Implementation of :class:`Ring` class. """
from sympy.polys.domains.domain import Domain
from sympy.polys.polyerrors import ExactQuotientFailed, NotInvertible, NotReversible
from sympy.utilities import public
@public
class Ring(Domain):
"""Represents a ring domain. """
is_Ring = True
def get_ring(s... |
09f8d8e165090577062e9246c2f6f8a989c5d0b1c3c37d43d9284773e27d0a50 | """Trait for implementing domain elements. """
from sympy.utilities import public
@public
class DomainElement:
"""
Represents an element of a domain.
Mix in this trait into a class which instances should be recognized as
elements of a domain. Method ``parent()`` gives that domain.
"""
def ... |
984cf91e7317f80b62d09fc30d28ac5b462cb9a06ac97ba3e56f08924eae7bb4 | """Rational number type based on Python integers. """
import operator
from sympy.core.numbers import Rational, Integer
from sympy.core.sympify import converter
from sympy.polys.polyutils import PicklableWithSlots
from sympy.polys.domains.domainelement import DomainElement
from sympy.printing.defaults import DefaultP... |
fcaf99cfc3a97f9d39af77874ab6cf0259c68864a363f3b80b06b839378e4a86 | """Implementation of :class:`SimpleDomain` class. """
from sympy.polys.domains.domain import Domain
from sympy.utilities import public
@public
class SimpleDomain(Domain):
"""Base class for simple domains, e.g. ZZ, QQ. """
is_Simple = True
def inject(self, *gens):
"""Inject generators into this ... |
fe36a7f5a2e95964ef411a44f2571c674234b7b88b2a1ade76a3c34fda44a7f1 | """Implementation of mathematical domains. """
__all__ = [
'Domain', 'FiniteField', 'IntegerRing', 'RationalField', 'RealField',
'ComplexField', 'PythonFiniteField', 'GMPYFiniteField',
'PythonIntegerRing', 'GMPYIntegerRing', 'PythonRational',
'GMPYRationalField', 'AlgebraicField', 'PolynomialRing', 'Fr... |
70a801411df528c59ec9a78621dbc6e69b4cbecc71c97715519e7e08b7bdbdf4 | """Implementation of :class:`FiniteField` class. """
from sympy.polys.domains.field import Field
from sympy.polys.domains.modularinteger import ModularIntegerFactory
from sympy.polys.domains.simpledomain import SimpleDomain
from sympy.polys.polyerrors import CoercionFailed
from sympy.utilities import public
from sym... |
f875179e1a507164ae6a663eb39335ec5fb9a16e89f9acc4b2671d10fffbea26 | """Implementation of :class:`PythonIntegerRing` class. """
from sympy.polys.domains.groundtypes import (
PythonInteger, SymPyInteger, python_sqrt,
python_factorial, python_gcdex, python_gcd, python_lcm,
)
from sympy.polys.domains.integerring import IntegerRing
from sympy.polys.polyerrors import CoercionFailed... |
3d5f604811f8c540cea2271409661fdb732c06bdc02b1e2fec7fdb2c4fdebbf9 | """Implementation of :class:`GMPYRationalField` class. """
from sympy.polys.domains.groundtypes import (
GMPYRational, SymPyRational,
gmpy_numer, gmpy_denom, gmpy_factorial,
)
from sympy.polys.domains.rationalfield import RationalField
from sympy.polys.polyerrors import CoercionFailed
from sympy.utilities imp... |
5ba3a13c3ed7db4ede4c51d6462455b7bce07c327caf7a978246bcfce3c8938e | """Implementation of :class:`QuotientRing` class."""
from sympy.polys.agca.modules import FreeModuleQuotientRing
from sympy.polys.domains.ring import Ring
from sympy.polys.polyerrors import NotReversible, CoercionFailed
from sympy.utilities import public
# TODO
# - successive quotients (when quotient ideals are impl... |
fba72ce21b3df6ba525e485fa7bcc94362c06fc9c4c31b2a9feab03e12191c3e | """Implementation of :class:`RealField` class. """
from sympy.core.numbers import Float
from sympy.polys.domains.field import Field
from sympy.polys.domains.simpledomain import SimpleDomain
from sympy.polys.domains.characteristiczero import CharacteristicZero
from sympy.polys.domains.mpelements import MPContext
from ... |
45c2060bdc0aa07e5289a3aca02d93e3d310280c1628273f6392a456753aee57 | """Implementation of :class:`Field` class. """
from sympy.polys.domains.ring import Ring
from sympy.polys.polyerrors import NotReversible, DomainError
from sympy.utilities import public
@public
class Field(Ring):
"""Represents a field domain. """
is_Field = True
is_PID = True
def get_ring(self):
... |
d33512b6b888be2ded904c8322db83fd31eedd40db58a3f47e2c536a3d86f2a8 | """Implementation of :class:`PythonRationalField` class. """
from sympy.polys.domains.groundtypes import PythonInteger, PythonRational, SymPyRational
from sympy.polys.domains.rationalfield import RationalField
from sympy.polys.polyerrors import CoercionFailed
from sympy.utilities import public
@public
class PythonRa... |
0c094cd4d589262f014cf6f4cdaf230941bae5947e7cd6b867a85c2328d455cc | """Implementation of :class:`PolynomialRing` class. """
from sympy.core.compatibility import iterable
from sympy.polys.agca.modules import FreeModulePolyRing
from sympy.polys.domains.characteristiczero import CharacteristicZero
from sympy.polys.domains.compositedomain import CompositeDomain
from sympy.polys.domains.o... |
138feb76cb72f63d07254ae2cf532f42ae155ffe4da718f886a00934157aff58 | """Implementation of :class:`PolynomialRing` class. """
from sympy.polys.domains.ring import Ring
from sympy.polys.domains.compositedomain import CompositeDomain
from sympy.polys.polyerrors import CoercionFailed, GeneratorsError
from sympy.utilities import public
@public
class PolynomialRing(Ring, CompositeDomain):... |
fa1064f2e81f0598478fcd39387b7ed7d93597e4e0cce4b5cb3c9eca3a54662b | """Implementation of :class:`IntegerRing` class. """
from sympy.polys.domains.characteristiczero import CharacteristicZero
from sympy.polys.domains.ring import Ring
from sympy.polys.domains.simpledomain import SimpleDomain
from sympy.utilities import public
import math
@public
class IntegerRing(Ring, Characteristic... |
14b7e60a2f7380f66b197286e968ac28147f61f27ba12e8603b091ec2846a6d2 | """Implementation of :class:`ComplexField` class. """
from sympy.core.numbers import Float, I
from sympy.polys.domains.characteristiczero import CharacteristicZero
from sympy.polys.domains.field import Field
from sympy.polys.domains.mpelements import MPContext
from sympy.polys.domains.simpledomain import SimpleDomain... |
824a104bcdba933e852161ea339eb83eadcac4f248713ed7f9c9816e4ee75ad6 | """Implementation of :class:`FractionField` class. """
from sympy.polys.domains.compositedomain import CompositeDomain
from sympy.polys.domains.field import Field
from sympy.polys.polyerrors import CoercionFailed, GeneratorsError
from sympy.utilities import public
@public
class FractionField(Field, CompositeDomain):... |
696a765fc274c2c00cc0f21176ddf5b47bbb22112144aab82ab926b250d3c052 | """Implementation of :class:`ExpressionDomain` class. """
from sympy.core import sympify, SympifyError
from sympy.polys.domains.characteristiczero import CharacteristicZero
from sympy.polys.domains.field import Field
from sympy.polys.domains.simpledomain import SimpleDomain
from sympy.polys.polyutils import Picklable... |
f566fb1d7c7cc0f2491ba2cfbee04ce4711ca520c4dda4fe50b9b575fca22325 | """Implementation of :class:`ModularInteger` class. """
from typing import Any, Dict, Tuple, Type
import operator
from sympy.polys.polyutils import PicklableWithSlots
from sympy.polys.polyerrors import CoercionFailed
from sympy.polys.domains.domainelement import DomainElement
from sympy.utilities import public
@p... |
7a4e06288ebef0ca29df4d3a8c95068a1672226f940d6c2a2b22fd5790f34740 | """Implementation of :class:`FractionField` class. """
from sympy.polys.domains.field import Field
from sympy.polys.domains.compositedomain import CompositeDomain
from sympy.polys.domains.characteristiczero import CharacteristicZero
from sympy.polys.polyclasses import DMF
from sympy.polys.polyerrors import Generators... |
f57773b86981db43543e9e7618ad45b03a6202607edc1f6db7b25d8ef420e1b7 | """Domains of Gaussian type."""
from sympy.core.numbers import I
from sympy.polys.polyerrors import CoercionFailed
from sympy.polys.domains import ZZ, QQ
from sympy.polys.domains.algebraicfield import AlgebraicField
from sympy.polys.domains.domain import Domain
from sympy.polys.domains.domainelement import DomainEleme... |
3fe4098fdf53c09d7d1ae530303325af4fe4c8f48bde91ee03cf6ae0a4fa16da | """Ground types for various mathematical domains in SymPy. """
from sympy.core.compatibility import builtins, HAS_GMPY
PythonInteger = builtins.int
PythonReal = builtins.float
PythonComplex = builtins.complex
from .pythonrational import PythonRational
from sympy.core.numbers import (
igcdex as python_gcdex,
... |
458c03460d7354b2c6b49bd55ef5a1c146630bdd60f295d3c008ee42859ece4b | """Implementation of :class:`PythonFiniteField` class. """
from sympy.polys.domains.finitefield import FiniteField
from sympy.polys.domains.pythonintegerring import PythonIntegerRing
from sympy.utilities import public
@public
class PythonFiniteField(FiniteField):
"""Finite field based on Python's integers. """
... |
40567e396fdcc316d07e4ee666bcb697157e02b385c72a8de7c756471be241b0 | """Implementation of :class:`GMPYIntegerRing` class. """
from sympy.polys.domains.groundtypes import (
GMPYInteger, SymPyInteger,
gmpy_factorial,
gmpy_gcdex, gmpy_gcd, gmpy_lcm, gmpy_sqrt,
)
from sympy.polys.domains.integerring import IntegerRing
from sympy.polys.polyerrors import CoercionFailed
from symp... |
2d225e1c6557307c591960a6b5cc0131d5ed6d2d797e24e29af9db4d33fc7988 | """Implementation of :class:`Domain` class. """
from typing import Any, Optional, Type
from sympy.core import Basic, sympify
from sympy.core.compatibility import HAS_GMPY, is_sequence
from sympy.core.decorators import deprecated
from sympy.polys.domains.domainelement import DomainElement
from sympy.polys.orderings i... |
0bf35df46b9b48c0499887b9becfc2d88b814fc60614be3180ae288b13423ab9 | """Implementation of :class:`GMPYFiniteField` class. """
from sympy.polys.domains.finitefield import FiniteField
from sympy.polys.domains.gmpyintegerring import GMPYIntegerRing
from sympy.utilities import public
@public
class GMPYFiniteField(FiniteField):
"""Finite field based on GMPY integers. """
alias =... |
331ca6c70946040dcfc76145cb321212d027915a317aaf9b24cd5f9368e412db | """Real and complex elements. """
from sympy.polys.domains.domainelement import DomainElement
from sympy.utilities import public
from mpmath.ctx_mp_python import PythonMPContext, _mpf, _mpc, _constant
from mpmath.libmp import (MPZ_ONE, fzero, fone, finf, fninf, fnan,
round_nearest, mpf_mul, repr_dps, int_types,
... |
b3952a01dddc7a1573c23db4273bef1b99c9be3777fa69f57690f35d3d5039ca | """Tests for tools for constructing domains for expressions. """
from sympy.polys.constructor import construct_domain
from sympy.polys.domains import ZZ, QQ, ZZ_I, QQ_I, RR, CC, EX
from sympy.polys.domains.realfield import RealField
from sympy.polys.domains.complexfield import ComplexField
from sympy import S, sqrt, ... |
dd8905ad606e0673d10238b737710a7496563499e1ff600b8b8fc0b529587291 | """Tests for algorithms for partial fraction decomposition of rational
functions. """
from sympy.polys.partfrac import (
apart_undetermined_coeffs,
apart,
apart_list, assemble_partfrac_list
)
from sympy import (S, Poly, E, pi, I, Matrix, Eq, RootSum, Lambda,
Symbol, Dummy, factor, toget... |
63aa8f155e884ff6e805e989a43bb40018ecbfb85fed5418f173577d9d4028f3 | """Tests for user-friendly public interface to polynomial functions. """
import pickle
from sympy.polys.polytools import (
Poly, PurePoly, poly,
parallel_poly_from_expr,
degree, degree_list,
total_degree,
LC, LM, LT,
pdiv, prem, pquo, pexquo,
div, rem, quo, exquo,
half_gcdex, gcdex, in... |
2e85622ad2bc20d3c9e04b8089a8945273e55038c382c768402b3015f1952ae8 | from sympy.polys.galoistools import (
gf_crt, gf_crt1, gf_crt2, gf_int,
gf_degree, gf_strip, gf_trunc, gf_normal,
gf_from_dict, gf_to_dict,
gf_from_int_poly, gf_to_int_poly,
gf_neg, gf_add_ground, gf_sub_ground, gf_mul_ground,
gf_add, gf_sub, gf_add_mul, gf_sub_mul, gf_mul, gf_sqr,
gf_div, g... |
eb2180490b2f923e4f33c52b6343adbe5efb009eea1f9909f0912af340706062 | """Tests for algorithms for computing symbolic roots of polynomials. """
from sympy import (S, symbols, Symbol, Wild, Rational, sqrt,
powsimp, sin, cos, pi, I, Interval, re, im, exp, ZZ, Piecewise,
acos, root, conjugate)
from sympy.polys import Poly, cyclotomic_poly, intervals, nroots, rootof
from sympy.poly... |
f877336bdb1c855a14d1e292a9766e63b51e7b564659d4012fffdcf38b26d282 | """Computations with ideals of polynomial rings."""
from sympy.core.compatibility import reduce
from sympy.polys.polyerrors import CoercionFailed
class Ideal:
"""
Abstract base class for ideals.
Do not instantiate - use explicit constructors in the ring class instead:
>>> from sympy import QQ
... |
7496f883fb3a6bce17a868c073bce56392f0b6ea5436647bc9bbc9c949d779f6 | """
Computations with modules over polynomial rings.
This module implements various classes that encapsulate groebner basis
computations for modules. Most of them should not be instantiated by hand.
Instead, use the constructing routines on objects you already have.
For example, to construct a free module over ``QQ[x... |
ca21d2ad1069387db78c9f344249b743919f8b6b491d39e908b8d3760c999b3d | """
Computations with homomorphisms of modules and rings.
This module implements classes for representing homomorphisms of rings and
their modules. Instead of instantiating the classes directly, you should use
the function ``homomorphism(from, to, matrix)`` to create homomorphism objects.
"""
from sympy.polys.agca.m... |
b646a3ff6b6f4184ef14633d69864823604b4d5a198a79515cc0209da3b2b66d | """Finite extensions of ring domains."""
from sympy.polys.polyerrors import CoercionFailed, NotInvertible
from sympy.polys.polytools import Poly
from sympy.printing.defaults import DefaultPrinting
class ExtensionElement(DefaultPrinting):
"""
Element of a finite extension.
A class of univariate polynomia... |
eadd9d965f8ac935b91d38447ffee60001701bab3eb47dd6baf0ea4787be2b57 | """Tests for homomorphisms."""
from sympy import QQ, S
from sympy.abc import x, y
from sympy.polys.agca import homomorphism
from sympy.testing.pytest import raises
def test_printing():
R = QQ.old_poly_ring(x)
assert str(homomorphism(R.free_module(1), R.free_module(1), [0])) == \
'Matrix([[0]]) : QQ[... |
8cc214f9b1d94766218ebcde416ca33bddb147f05fbce3043d8059de59a2e117 | from sympy.unify.core import Compound, Variable, CondVariable, allcombinations
from sympy.unify import core
a,b,c = 'abc'
w,x,y,z = map(Variable, 'wxyz')
C = Compound
def is_associative(x):
return isinstance(x, Compound) and (x.op in ('Add', 'Mul', 'CAdd', 'CMul'))
def is_commutative(x):
return isinstance(x,... |
e70e85e895ba2bb960a5b0785fd4e3d15c3c01c35595f692baf6f029724a0fa7 | """
Checks that SymPy does not contain indirect imports.
An indirect import is importing a symbol from a module that itself imported the
symbol from elsewhere. Such a constellation makes it harder to diagnose
inter-module dependencies and import order problems, and is therefore strongly
discouraged.
(Indirect imports... |
89f0fa0c948ef54f1839c4836c6f8ec6a5080ef0a1987d0db6748d5ae7dfeb5d | #!/usr/bin/env python
"""
Import diagnostics. Run bin/diagnose_imports.py --help for details.
"""
from typing import Dict
if __name__ == "__main__":
import sys
import inspect
from sympy.core.compatibility import builtins
import optparse
from os.path import abspath, dirname, join, normpath
... |
1f47fa7a5b911d6da374756d248e90d30d42048cdce8e486db1e434cf9b56531 | # coding=utf-8
from os import walk, sep, pardir
from os.path import split, join, abspath, exists, isfile
from glob import glob
import re
import random
import ast
from sympy.testing.pytest import raises
from sympy.testing.quality_unicode import _test_this_file_encoding
# System path separator (usually slash or backsla... |
d59ab33af4d70b2312dd870b6a7c4a31d784e434a89490c7d4f84206571ffc0f | from sympy.core.function import Derivative
from sympy.vector.vector import Vector
from sympy.vector.coordsysrect import CoordSys3D
from sympy.simplify import simplify
from sympy.core.symbol import symbols
from sympy.core import S
from sympy import sin, cos
from sympy.vector.vector import Dot
from sympy.vector.operators... |
bdf6317484a2955aca35bc0b73d49b75e0c3392e0ec286539a07c4acf8bbf4cd | from sympy import Dummy, S, symbols, pi, sqrt, asin, sin, cos, Rational
from sympy.geometry import Line, Point, Ray, Segment, Point3D, Line3D, Ray3D, Segment3D, Plane, Circle
from sympy.geometry.util import are_coplanar
from sympy.testing.pytest import raises
def test_plane():
x, y, z, u, v = symbols('x y z u v',... |
e628323b80b5e42eaacf038a8eb21cc5b37dc64df798ec958b5a56a3b6597f74 | from sympy import Eq, Rational, S, Symbol, symbols, pi, sqrt, oo, Point2D, Segment2D, Abs, sec
from sympy.geometry import (Circle, Ellipse, GeometryError, Line, Point,
Polygon, Ray, RegularPolygon, Segment,
Triangle, intersection)
from sympy.testing.pytest import ... |
5a742d91c2bd85980fbf3b12d1bad1687cdf384b03fc534a66ea6081e5534b56 | from sympy import I, Rational, Symbol, pi, sqrt, sympify, S, Basic
from sympy.geometry import Line, Point, Point2D, Point3D, Line3D, Plane
from sympy.geometry.entity import rotate, scale, translate, GeometryEntity
from sympy.matrices import Matrix
from sympy.utilities.iterables import subsets, permutations, cartes
from... |
63e973d9d7f03f2269161da2904cb379654c41abab68ae8e755954dfa63e9fde | from sympy import Symbol, Rational
from sympy.geometry import Circle, Ellipse, Line, Point, Polygon, Ray, RegularPolygon, Segment, Triangle
from sympy.geometry.entity import scale, GeometryEntity
from sympy.testing.pytest import raises
from random import random
def test_entity():
x = Symbol('x', real=True)
y... |
bd6131abd35f7b430a624b50a31f8c511eaf148dc79887a58f684acaaf28a56a | from sympy import (Abs, Rational, Float, S, Symbol, symbols, cos, sin, pi, sqrt, \
oo, acos)
from sympy.functions.elementary.trigonometric import tan
from sympy.geometry import (Circle, Ellipse, GeometryError, Point, Point2D, \
Polygon, Ray, RegularPolygon, Segment, Trian... |
423980a9e7fb9c48212ae332f1722294ed04c5c4f1718cfc4ef18a23aa312373 | from sympy import Rational, oo, sqrt, S
from sympy import Line, Point, Point2D, Parabola, Segment2D, Ray2D
from sympy import Circle, Ellipse, symbols, sign
from sympy.testing.pytest import raises
def test_parabola_geom():
a, b = symbols('a b')
p1 = Point(0, 0)
p2 = Point(3, 7)
p3 = Point(0, 4)
p4 ... |
b46bc18c522288a3724e028e369c852febde89cf71c3af1e50bb58a4d4f05b69 | from sympy import Symbol, pi, symbols, Tuple, S, sqrt, asinh, Rational
from sympy.geometry import Curve, Line, Point, Ellipse, Ray, Segment, Circle, Polygon, RegularPolygon
from sympy.testing.pytest import raises, slow
def test_curve():
x = Symbol('x', real=True)
s = Symbol('s')
z = Symbol('z')
# thi... |
2ab6a2570daac4881878c453163b35be4322fa1aaa0e4c5406ff117368309022 | """Used for translating Fortran source code into a SymPy expression. """
|
9738706fa85a0f369f9b76423098e6b955f8bbd9373512e83a088f6186b77851 | from sympy.external import import_module
import os
cin = import_module('clang.cindex', import_kwargs = {'fromlist': ['cindex']})
"""
This module contains all the necessary Classes and Function used to Parse C and
C++ code into SymPy expression
The module serves as a backend for SymPyExpression to parse C code
It is a... |
50fb4843e29f73b2457f25651daeb330ff2c28e577245f94969a3bfda1cbdd51 | from sympy.testing.pytest import raises, XFAIL
from sympy.external import import_module
from sympy import (
Symbol, Mul, Add, Abs, sin, asin, cos, Pow,
csc, sec, Limit, oo, Derivative, Integral, factorial,
sqrt, root, StrictLessThan, LessThan, StrictGreaterThan,
GreaterThan, Sum, Product, E, log, tan, ... |
4b0a0337d829f8984ffd4a8dd500cb9ba1302d9b5eb817342681a5dc506d162b | from sympy.parsing.sym_expr import SymPyExpression
from sympy.testing.pytest import raises, XFAIL
from sympy.external import import_module
cin = import_module('clang.cindex', import_kwargs = {'fromlist': ['cindex']})
if cin:
from sympy.codegen.ast import (Variable, String, Return,
FunctionDefinition, Inte... |
5cce0cb536e936ac0517aa832f60966f0d442e70255dd793ee8c761c173cbfc7 | # Ported from latex2sympy by @augustt198
# https://github.com/augustt198/latex2sympy
# See license in LICENSE.txt
import sympy
from sympy.external import import_module
from sympy.printing.str import StrPrinter
from sympy.physics.quantum.state import Bra, Ket
from .errors import LaTeXParsingError
LaTeXParser = LaTeX... |
59fec92619b2211ef4bbd207378014627276603733ad318dd08cad7fb488a594 |
# encoding: utf-8
# *** GENERATED BY `setup.py antlr`, DO NOT EDIT BY HAND ***
#
# Generated from ../LaTeX.g4, derived from latex2sympy
# latex2sympy is licensed under the MIT license
# https://github.com/augustt198/latex2sympy/blob/master/LICENSE.txt
#
# Generated with antlr4
# antlr4 is licensed under th... |
4a6afde9d8f23e6415916a809d72b7ee4c2cd9bc5dad1b7bda84a0c1f41e9d17 |
# encoding: utf-8
# *** GENERATED BY `setup.py antlr`, DO NOT EDIT BY HAND ***
#
# Generated from ../LaTeX.g4, derived from latex2sympy
# latex2sympy is licensed under the MIT license
# https://github.com/augustt198/latex2sympy/blob/master/LICENSE.txt
#
# Generated with antlr4
# antlr4 is licensed under th... |
05886da6b971b7df8883edf498320d81022aad5f76617894960ab15efb0f7227 | from sympy import Basic, Mul, Pow, degree, Symbol, expand, cancel, Expr, exp, roots
from sympy.core.evalf import EvalfMixin
from sympy.core.logic import fuzzy_and
from sympy.core.numbers import Integer
from sympy.core.sympify import sympify, _sympify
from sympy.polys import Poly, rootof
from sympy.series import limit
... |
e72412b374b53665566a4f0918c48fe1f13fcbbedc013c7206c67b1a6d374116 | """A cache for storing small matrices in multiple formats."""
from sympy import Matrix, I, Pow, Rational, exp, pi
from sympy.physics.quantum.matrixutils import (
to_sympy, to_numpy, to_scipy_sparse
)
class MatrixCache:
"""A cache for small matrices in different formats.
This class takes small matrices ... |
8e0f41fc7eb5e3fb91a45c3f782328eb37f2df862de569a1ee350b7c92016030 | """An implementation of qubits and gates acting on them.
Todo:
* Update docstrings.
* Update tests.
* Implement apply using decompose.
* Implement represent using decompose or something smarter. For this to
work we first have to implement represent for SWAP.
* Decide if we want upper index to be inclusive in the co... |
4ff43b30be1e85463bfaca0bb1314007c2e6fda544acce777277066369cdfa4c | from collections import deque
from random import randint
from sympy.external import import_module
from sympy import Mul, Basic, Number, Pow, Integer
from sympy.physics.quantum.represent import represent
from sympy.physics.quantum.dagger import Dagger
__all__ = [
# Public interfaces
'generate_gate_rules',
... |
5bcad852b875ebb9e465ca1709316c719d59bc14fa59790c7e62b3464b3779d1 | """ A module for mapping operators to their corresponding eigenstates
and vice versa
It contains a global dictionary with eigenstate-operator pairings.
If a new state-operator pair is created, this dictionary should be
updated as well.
It also contains functions operators_to_state and state_to_operators
for mapping b... |
fef54326295f7076269662e5acb298f0b4df3756aaa3414c58a534cca6096644 | """Abstract tensor product."""
from sympy import Expr, Add, Mul, Matrix, Pow, sympify
from sympy.core.trace import Tr
from sympy.printing.pretty.stringpict import prettyForm
from sympy.physics.quantum.qexpr import QuantumError
from sympy.physics.quantum.dagger import Dagger
from sympy.physics.quantum.commutator impor... |
3e8bf3d5f13d4395e34fcf2c97f8b88201f1c7c8689d60fea102b83331a95aed | """The anti-commutator: ``{A,B} = A*B + B*A``."""
from sympy import S, Expr, Mul, Integer
from sympy.printing.pretty.stringpict import prettyForm
from sympy.physics.quantum.operator import Operator
from sympy.physics.quantum.dagger import Dagger
__all__ = [
'AntiCommutator'
]
#----------------------------------... |
55b5bb505c06556e26168bf63629121c042a5b450c939f861ea698ebaf2015fa | """Dirac notation for states."""
from sympy import (cacheit, conjugate, Expr, Function, integrate, oo, sqrt,
Tuple)
from sympy.printing.pretty.stringpict import stringPict
from sympy.physics.quantum.qexpr import QExpr, dispatch_method
__all__ = [
'KetBase',
'BraBase',
'StateBase',
'... |
60c92c111e3d64bb6adb5e0d3d4dae0318b0e4f6b9fffdbf208c14f51692423a | """Operators and states for 1D cartesian position and momentum.
TODO:
* Add 3D classes to mappings in operatorset.py
"""
from sympy import DiracDelta, exp, I, Interval, pi, S, sqrt
from sympy.physics.quantum.constants import hbar
from sympy.physics.quantum.hilbert import L2
from sympy.physics.quantum.operator impo... |
80af97569d065fd3e587bb289970d8d4ac1d7224811dce0aaf8a0b436708539d | """Utilities to deal with sympy.Matrix, numpy and scipy.sparse."""
from sympy import MatrixBase, I, Expr, Integer
from sympy.matrices import eye, zeros
from sympy.external import import_module
__all__ = [
'numpy_ndarray',
'scipy_sparse_matrix',
'sympy_to_numpy',
'sympy_to_scipy_sparse',
'numpy_to_... |
04ea7d00b589ffe43b08ce35ef9e11aba9a96f4a66b75140b5bdf46da92ecf80 | """An implementation of gates that act on qubits.
Gates are unitary operators that act on the space of qubits.
Medium Term Todo:
* Optimize Gate._apply_operators_Qubit to remove the creation of many
intermediate Qubit objects.
* Add commutation relationships to all operators and use this in gate_sort.
* Fix gate_s... |
e7ad5774274b1bc8be126ad1af847659becd05d29f9671f1c476ef46e18a920c | """Logic for representing operators in state in various bases.
TODO:
* Get represent working with continuous hilbert spaces.
* Document default basis functionality.
"""
from sympy import Add, Expr, I, integrate, Mul, Pow
from sympy.physics.quantum.dagger import Dagger
from sympy.physics.quantum.commutator import Com... |
2a4d62b36519ccb44c91b9f150416ae8c6d57411d9b0fef3743db89121b918a3 | """Quantum mechanical operators.
TODO:
* Fix early 0 in apply_operators.
* Debug and test apply_operators.
* Get cse working with classes in this file.
* Doctests and documentation of special methods for InnerProduct, Commutator,
AntiCommutator, represent, apply_operators.
"""
from sympy import Derivative, Expr, I... |
11a397f1564938e14c4c08312b5df34f5fd54b7b83e380ff058af2c658d878a3 | """Qubits for quantum computing.
Todo:
* Finish implementing measurement logic. This should include POVM.
* Update docstrings.
* Update tests.
"""
import math
from sympy import Integer, log, Mul, Add, Pow, conjugate
from sympy.core.basic import sympify
from sympy.core.compatibility import SYMPY_INTS
from sympy.matr... |
132eb6497382dac59e72695b08bc2d72343e02a06f8a10891505ec54a90c814a | """Symbolic inner product."""
from sympy import Expr, conjugate
from sympy.printing.pretty.stringpict import prettyForm
from sympy.physics.quantum.dagger import Dagger
from sympy.physics.quantum.state import KetBase, BraBase
__all__ = [
'InnerProduct'
]
# InnerProduct is not an QExpr because it is really just a... |
315068cf8b80f369ee275201a0d7785cdc5fb91a21e0428772af5e848f1931ae | from sympy import Expr, sympify, Symbol, Matrix
from sympy.printing.pretty.stringpict import prettyForm
from sympy.core.containers import Tuple
from sympy.core.compatibility import is_sequence
from sympy.physics.quantum.dagger import Dagger
from sympy.physics.quantum.matrixutils import (
numpy_ndarray, scipy_spars... |
fd47c1cf3fda746edf8e6ce5d8410342a9874aa2eb4aa20a623b8f84938945b3 | """Grover's algorithm and helper functions.
Todo:
* W gate construction (or perhaps -W gate based on Mermin's book)
* Generalize the algorithm for an unknown function that returns 1 on multiple
qubit states, not just one.
* Implement _represent_ZGate in OracleGate
"""
from sympy import floor, pi, sqrt, sympify, ey... |
d4859204d2d253ce3d6a6a9baeedde4e76b06c5a6bd44498f14c32de597954ee | from itertools import product
from sympy import Tuple, Add, Mul, Matrix, log, expand, S
from sympy.core.trace import Tr
from sympy.printing.pretty.stringpict import prettyForm
from sympy.physics.quantum.dagger import Dagger
from sympy.physics.quantum.operator import HermitianOperator
from sympy.physics.quantum.represe... |
db7c2f26f4f45d723842df7fbcdca01f61419eb6dfc56f3165db5e3b2f4a943c | """
qasm.py - Functions to parse a set of qasm commands into a Sympy Circuit.
Examples taken from Chuang's page: http://www.media.mit.edu/quanta/qasm2circ/
The code returns a circuit and an associated list of labels.
>>> from sympy.physics.quantum.qasm import Qasm
>>> q = Qasm('qubit q0', 'qubit q1', 'h q0', 'cnot ... |
76923ee69cdc8bb8e5794cfbfdfa1eae88cfa870ef2020289e82982992f787a7 | """1D quantum particle in a box."""
from sympy import Symbol, pi, sqrt, sin, Interval, S
from sympy.physics.quantum.operator import HermitianOperator
from sympy.physics.quantum.state import Ket, Bra
from sympy.physics.quantum.constants import hbar
from sympy.functions.special.tensor_functions import KroneckerDelta
fr... |
7ac2a14b8a6682a4590ba13cde301c24369f92876c3375aa33edcacd2b87c2e5 | """The commutator: [A,B] = A*B - B*A."""
from sympy import S, Expr, Mul, Add, Pow
from sympy.printing.pretty.stringpict import prettyForm
from sympy.physics.quantum.dagger import Dagger
from sympy.physics.quantum.operator import Operator
__all__ = [
'Commutator'
]
#---------------------------------------------... |
756b227868e5f1da4f2685d35684f5531ff3628bec3c86e58be104abcffe6da8 | """Quantum mechanical angular momemtum."""
from sympy import (Add, binomial, cos, exp, Expr, factorial, I, Integer, Mul,
pi, Rational, S, sin, simplify, sqrt, Sum, symbols, sympify,
Tuple, Dummy)
from sympy.matrices import zeros
from sympy.printing.pretty.stringpict import prettyF... |
db45510130a44a9ad29c6151e5e8ef3046255b011cbf507e744dd13ea3d343d9 | """Constants (like hbar) related to quantum mechanics."""
from sympy.core.numbers import NumberSymbol
from sympy.core.singleton import Singleton
from sympy.printing.pretty.stringpict import prettyForm
import mpmath.libmp as mlib
#-----------------------------------------------------------------------------
# Constant... |
84b08f16c888394718551bd239385a14db509f49509850d6539b8c612bc11b55 | """Matplotlib based plotting of quantum circuits.
Todo:
* Optimize printing of large circuits.
* Get this to work with single gates.
* Do a better job checking the form of circuits to make sure it is a Mul of
Gates.
* Get multi-target gates plotting.
* Get initial and final states to plot.
* Get measurements to plo... |
953794d0b9d6364cd3868d4ab9d0cde59036ed5c7f266ad03583d52bee5d413c | #TODO:
# -Implement Clebsch-Gordan symmetries
# -Improve simplification method
# -Implement new simpifications
"""Clebsch-Gordon Coefficients."""
from sympy import (Add, expand, Eq, Expr, Mul, Piecewise, Pow, sqrt, Sum,
symbols, sympify, Wild)
from sympy.printing.pretty.stringpict import prettyForm,... |
9a13af2bc999ab4594c0f6e7f7795e0e943f594ed42bc0a7f310edcaee6f93f8 | """Primitive circuit operations on quantum circuits."""
from sympy import Symbol, Tuple, Mul, sympify, default_sort_key
from sympy.utilities import numbered_symbols
from sympy.core.compatibility import reduce
from sympy.physics.quantum.gate import Gate
__all__ = [
'kmp_table',
'find_subcircuit',
'replace_... |
4b9353dfb211c9bf904b95f22145f9761d786207f26852ba903a18b507cd4d73 | """Hilbert spaces for quantum mechanics.
Authors:
* Brian Granger
* Matt Curry
"""
from sympy import Basic, Interval, oo, sympify
from sympy.printing.pretty.stringpict import prettyForm
from sympy.physics.quantum.qexpr import QuantumError
from sympy.core.compatibility import reduce
__all__ = [
'HilbertSpaceErr... |
5d57d9465fc00c87d6e1c38dd5c7c9a37431cae918628cf1602880e0c1707037 | """Simple Harmonic Oscillator 1-Dimension"""
from sympy import sqrt, I, Symbol, Integer, S
from sympy.physics.quantum.constants import hbar
from sympy.physics.quantum.operator import Operator
from sympy.physics.quantum.state import Bra, Ket, State
from sympy.physics.quantum.qexpr import QExpr
from sympy.physics.quantu... |
2fe4191b4be82bd8456a2f4c03953dc63b14a6e12ba549c2f9fd5908159ccd0d | """Logic for applying operators to states.
Todo:
* Sometimes the final result needs to be expanded, we should do this by hand.
"""
from sympy import Add, Mul, Pow, sympify, S
from sympy.physics.quantum.anticommutator import AntiCommutator
from sympy.physics.quantum.commutator import Commutator
from sympy.physics.qua... |
b2544e08699d88aea0f793e9506f165994523ca4c6fd6b066cc71b327347ecd0 | from sympy.core.backend import Symbol
from sympy.physics.vector import Point, Vector, ReferenceFrame
from sympy.physics.mechanics import RigidBody, Particle, inertia
__all__ = ['Body']
# XXX: We use type:ignore because the classes RigidBody and Particle have
# inconsistent parallel axis methods that take different n... |
cae079341362056d83b9e4c335b22f4bdb63240a35d4ed58df801c8dcf7564d2 | from sympy.core.backend import eye, Matrix, zeros
from sympy.physics.mechanics import dynamicsymbols
from sympy.physics.mechanics.functions import find_dynamicsymbols
__all__ = ['SymbolicSystem']
class SymbolicSystem:
"""SymbolicSystem is a class that contains all the information about a
system in a symbolic... |
f6ad60dc8db1629b93322faff607acc04ab12564cfdd18dc3aab917f33211f33 | #!/usr/bin/env python
"""This module contains some sample symbolic models used for testing and
examples."""
# Internal imports
from sympy.core import backend as sm
import sympy.physics.mechanics as me
def multi_mass_spring_damper(n=1, apply_gravity=False,
apply_external_forces=False):
... |
bec0a9456bed33eed4c0a623fd11e048d68490070ee1f63fd3d66e10ca0bd15d | from sympy.core.backend import zeros, Matrix, diff, eye
from sympy import solve_linear_system_LU
from sympy.utilities import default_sort_key
from sympy.physics.vector import (ReferenceFrame, dynamicsymbols,
partial_velocity)
from sympy.physics.mechanics.particle import Particle
from s... |
f22b3a96f11a2e8c5c8a41642b3dce5516d56b92cdb5cc372972acb1638eaa8f | from sympy.core.backend import sympify
from sympy.physics.vector import Point, ReferenceFrame, Dyadic
from sympy.utilities.exceptions import SymPyDeprecationWarning
__all__ = ['RigidBody']
class RigidBody:
"""An idealized rigid body.
Explanation
===========
This is essentially a container which h... |
4e392d5a0d9b76b4e98058caf92b0beaa46cf0c48e85f4eeb6a042c9945ff16b | from sympy.utilities import dict_merge
from sympy.utilities.iterables import iterable
from sympy.physics.vector import (Dyadic, Vector, ReferenceFrame,
Point, dynamicsymbols)
from sympy.physics.vector.printing import (vprint, vsprint, vpprint, vlatex,
... |
08b5f8a8cbe7792fe326a9c87dc838c60d3af9d80fab7e192d7843947668165e | __all__ = ['Linearizer']
from sympy.core.backend import Matrix, eye, zeros
from sympy.core.compatibility import Iterable
from sympy import Dummy
from sympy.utilities.iterables import flatten
from sympy.physics.vector import dynamicsymbols
from sympy.physics.mechanics.functions import msubs
from collections import nam... |
77ffc9629c2bd9a0709641ec25d2a098263dd73e1d2ee6abc482bdb1be4b81f5 | from sympy.core.backend import diff, zeros, Matrix, eye, sympify
from sympy.physics.vector import dynamicsymbols, ReferenceFrame
from sympy.physics.mechanics.functions import (find_dynamicsymbols, msubs,
_f_list_parser)
from sympy.physics.mechanics.linearize import Lineari... |
040ece4e773a70f5724c69a7b0cb09315ded0400f9d7a620e12c0b592cad741c | from sympy.core.backend import sympify
from sympy.physics.vector import Point
from sympy.utilities.exceptions import SymPyDeprecationWarning
__all__ = ['Particle']
class Particle:
"""A particle.
Explanation
===========
Particles have a non-zero mass and lack spatial extension; they take up no
... |
fc0498bdb44735cccb09a67a475261893390b8ed210cf15b6db0ed40d4308f2e | """
Unit system for physical quantities; include definition of constants.
"""
from typing import Dict
from sympy import S, Mul, Pow, Add, Function, Derivative
from sympy.physics.units.dimensions import _QuantityMapper
from sympy.utilities.exceptions import SymPyDeprecationWarning
from .dimensions import Dimension
... |
4d2be6d122780b3ccbed096b0ac610be84d5c57d040077a27a0e2d728ca7c20a | """
Definition of physical dimensions.
Unit systems will be constructed on top of these dimensions.
Most of the examples in the doc use MKS system and are presented from the
computer point of view: from a human point, adding length to time is not legal
in MKS but it is in natural system; for a computer in natural sys... |
287128e164e0a22cef8eb42e352843f284e859acd89a843ccc15201e3b550d4d | """
Module defining unit prefixe class and some constants.
Constant dict for SI and binary prefixes are defined as PREFIXES and
BIN_PREFIXES.
"""
from sympy import Expr, sympify
class Prefix(Expr):
"""
This class represent prefixes, with their name, symbol and factor.
Prefixes are used to create derived... |
f2a7beaf2dc2ee31fb966697a23df266623cdc518098bca429ca3e680e9238b5 | """
Several methods to simplify expressions involving unit objects.
"""
from sympy import Add, Mul, Pow, Tuple, sympify
from sympy.core.compatibility import reduce, Iterable, ordered
from sympy.physics.units.dimensions import Dimension
from sympy.physics.units.prefixes import Prefix
from sympy.physics.units.quantities... |
e9dbd92defd8c98e5e01dba04847330b5ccc43c5d393020c49f1cbc51db5cf65 | """
Physical quantities.
"""
from sympy import AtomicExpr, Symbol, sympify
from sympy.physics.units.dimensions import _QuantityMapper
from sympy.physics.units.prefixes import Prefix
from sympy.utilities.exceptions import SymPyDeprecationWarning
class Quantity(AtomicExpr):
"""
Physical quantity: can be a unit... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.