コード例 #1
0
ファイル: test_str.py プロジェクト: thorek1/sympy
def test_PolyElement():
    Ruv, u, v = ring("u,v", ZZ)
    Rxyz, x, y, z = ring("x,y,z", Ruv)
    Rx_zzi, xz = ring("x", ZZ_I)

    assert str(x - x) == "0"
    assert str(x - 1) == "x - 1"
    assert str(x + 1) == "x + 1"
    assert str(x**2) == "x**2"
    assert str(x**(-2)) == "x**(-2)"
    assert str(x**QQ(1, 2)) == "x**(1/2)"

    assert str((u**2 + 3 * u * v + 1) * x**2 * y + u +
               1) == "(u**2 + 3*u*v + 1)*x**2*y + u + 1"
    assert str((u**2 + 3 * u * v + 1) * x**2 * y +
               (u + 1) * x) == "(u**2 + 3*u*v + 1)*x**2*y + (u + 1)*x"
    assert str((u**2 + 3 * u * v + 1) * x**2 * y + (u + 1) * x +
               1) == "(u**2 + 3*u*v + 1)*x**2*y + (u + 1)*x + 1"
    assert str((-u**2 + 3 * u * v - 1) * x**2 * y - (u + 1) * x -
               1) == "-(u**2 - 3*u*v + 1)*x**2*y - (u + 1)*x - 1"

    assert str(-(v**2 + v + 1) * x + 3 * u * v +
               1) == "-(v**2 + v + 1)*x + 3*u*v + 1"
    assert str(-(v**2 + v + 1) * x - 3 * u * v +
               1) == "-(v**2 + v + 1)*x - 3*u*v + 1"

    assert str((1 + I) * xz + 2) == "(1 + 1*I)*x + (2 + 0*I)"
コード例 #2
0
def test_PolyRing():
    assert srepr(ring("x", ZZ, lex)[0]) == "PolyRing((Symbol('x'),), ZZ, lex)"
    assert srepr(
        ring("x,y", QQ,
             grlex)[0]) == "PolyRing((Symbol('x'), Symbol('y')), QQ, grlex)"
    assert srepr(
        ring("x,y,z", ZZ["t"], lex)
        [0]) == "PolyRing((Symbol('x'), Symbol('y'), Symbol('z')), ZZ[t], lex)"
コード例 #3
0
def test_PolyRing():
    assert str(ring("x", ZZ,
                    lex)[0]) == "Polynomial ring in x over ZZ with lex order"
    assert str(
        ring("x,y", QQ,
             grlex)[0]) == "Polynomial ring in x, y over QQ with grlex order"
    assert str(
        ring("x,y,z", ZZ["t"],
             lex)[0]) == "Polynomial ring in x, y, z over ZZ[t] with lex order"
コード例 #4
0
ファイル: test_str.py プロジェクト: Acebulf/sympy
def test_PolyElement():
    Ruv, u,v = ring("u,v", ZZ);
    Rxyz, x,y,z = ring("x,y,z", Ruv.to_domain())

    assert str(x - x) == "0"
    assert str(x - 1) == "x - 1"
    assert str(x + 1) == "x + 1"

    assert str((u**2 + 3*u*v + 1)*x**2*y + u + 1) == "(u**2 + 3*u*v + 1)*x**2*y + u + 1"
    assert str((u**2 + 3*u*v + 1)*x**2*y + (u + 1)*x) == "(u**2 + 3*u*v + 1)*x**2*y + (u + 1)*x"
    assert str((u**2 + 3*u*v + 1)*x**2*y + (u + 1)*x + 1) == "(u**2 + 3*u*v + 1)*x**2*y + (u + 1)*x + 1"
    assert str((-u**2 + 3*u*v - 1)*x**2*y - (u + 1)*x - 1) == "-(u**2 - 3*u*v + 1)*x**2*y - (u + 1)*x - 1"
コード例 #5
0
ファイル: test_str.py プロジェクト: waseem18/sympy
def test_PolyElement():
    Ruv, u,v = ring("u,v", ZZ);
    Rxyz, x,y,z = ring("x,y,z", Ruv)

    assert str(x - x) == "0"
    assert str(x - 1) == "x - 1"
    assert str(x + 1) == "x + 1"

    assert str((u**2 + 3*u*v + 1)*x**2*y + u + 1) == "(u**2 + 3*u*v + 1)*x**2*y + u + 1"
    assert str((u**2 + 3*u*v + 1)*x**2*y + (u + 1)*x) == "(u**2 + 3*u*v + 1)*x**2*y + (u + 1)*x"
    assert str((u**2 + 3*u*v + 1)*x**2*y + (u + 1)*x + 1) == "(u**2 + 3*u*v + 1)*x**2*y + (u + 1)*x + 1"
    assert str((-u**2 + 3*u*v - 1)*x**2*y - (u + 1)*x - 1) == "-(u**2 - 3*u*v + 1)*x**2*y - (u + 1)*x - 1"

    assert str(-(v**2 + v + 1)*x + 3*u*v + 1) == "-(v**2 + v + 1)*x + 3*u*v + 1"
    assert str(-(v**2 + v + 1)*x - 3*u*v + 1) == "-(v**2 + v + 1)*x - 3*u*v + 1"
コード例 #6
0
ファイル: test_str.py プロジェクト: Lenqth/sympy
def test_PolyElement():
    Ruv, u,v = ring("u,v", ZZ)
    Rxyz, x,y,z = ring("x,y,z", Ruv)

    assert str(x - x) == "0"
    assert str(x - 1) == "x - 1"
    assert str(x + 1) == "x + 1"
    assert str(x**2) == "x**2"
    assert str(x**(-2)) == "x**(-2)"
    assert str(x**QQ(1, 2)) == "x**(1/2)"

    assert str((u**2 + 3*u*v + 1)*x**2*y + u + 1) == "(u**2 + 3*u*v + 1)*x**2*y + u + 1"
    assert str((u**2 + 3*u*v + 1)*x**2*y + (u + 1)*x) == "(u**2 + 3*u*v + 1)*x**2*y + (u + 1)*x"
    assert str((u**2 + 3*u*v + 1)*x**2*y + (u + 1)*x + 1) == "(u**2 + 3*u*v + 1)*x**2*y + (u + 1)*x + 1"
    assert str((-u**2 + 3*u*v - 1)*x**2*y - (u + 1)*x - 1) == "-(u**2 - 3*u*v + 1)*x**2*y - (u + 1)*x - 1"

    assert str(-(v**2 + v + 1)*x + 3*u*v + 1) == "-(v**2 + v + 1)*x + 3*u*v + 1"
    assert str(-(v**2 + v + 1)*x - 3*u*v + 1) == "-(v**2 + v + 1)*x - 3*u*v + 1"
コード例 #7
0
def test_PolyElement():
    Ruv, u, v = ring("u,v", ZZ)
    Rxyz, x, y, z = ring("x,y,z", Ruv)

    assert str(x - x) == "0"
    assert str(x - 1) == "x - 1"
    assert str(x + 1) == "x + 1"
    assert str(x**2) == "x**2"
    assert str(x**(-2)) == "x**(-2)"
    assert str(x**QQ(1, 2)) == "x**(1/2)"

    assert (str((u**2 + 3 * u * v + 1) * x**2 * y + u +
                1) == "(u**2 + 3*u*v + 1)*x**2*y + u + 1")
    assert (str((u**2 + 3 * u * v + 1) * x**2 * y +
                (u + 1) * x) == "(u**2 + 3*u*v + 1)*x**2*y + (u + 1)*x")
    assert (str((u**2 + 3 * u * v + 1) * x**2 * y + (u + 1) * x +
                1) == "(u**2 + 3*u*v + 1)*x**2*y + (u + 1)*x + 1")
    assert (str((-(u**2) + 3 * u * v - 1) * x**2 * y - (u + 1) * x -
                1) == "-(u**2 - 3*u*v + 1)*x**2*y - (u + 1)*x - 1")

    assert str(-(v**2 + v + 1) * x + 3 * u * v +
               1) == "-(v**2 + v + 1)*x + 3*u*v + 1"
    assert str(-(v**2 + v + 1) * x - 3 * u * v +
               1) == "-(v**2 + v + 1)*x - 3*u*v + 1"
コード例 #8
0
ファイル: test_str.py プロジェクト: Lenqth/sympy
def test_PolyRing():
    assert str(ring("x", ZZ, lex)[0]) == "Polynomial ring in x over ZZ with lex order"
    assert str(ring("x,y", QQ, grlex)[0]) == "Polynomial ring in x, y over QQ with grlex order"
    assert str(ring("x,y,z", ZZ["t"], lex)[0]) == "Polynomial ring in x, y, z over ZZ[t] with lex order"
コード例 #9
0
import numpy as np
import numpy.linalg as la
from math import log, ceil, floor
from scipy import linalg as scila
from sympy import Poly
from sympy.polys import ring, QQ

RR, x = ring("x", QQ)


# setup code
def randomvec(n, seedNumber=0):
    np.random.seed(seedNumber)
    return np.random.rand(n)


def vectorToToeplitz(v, N=-1):
    band_width = len(v)
    if (N <= 0):
        N = band_width

    assert (band_width <= N)

    H = np.zeros((N * 2 - 1, N))
    for col in range(N):
        H[col:col + band_width, col] = v
    return H


def toeplitzToHankle(M):
    return M[:, ::-1]
コード例 #10
0
ファイル: test_repr.py プロジェクト: KonstantinTogoi/sympy
def test_PolyElement():
    R, x, y = ring("x,y", ZZ)
    assert srepr(3*x**2*y + 1) == "PolyElement(PolyRing((Symbol('x'), Symbol('y')), ZZ, lex), [((2, 1), 3), ((0, 0), 1)])"
コード例 #11
0
ファイル: test_repr.py プロジェクト: KonstantinTogoi/sympy
def test_PolyRing():
    assert srepr(ring("x", ZZ, lex)[0]) == "PolyRing((Symbol('x'),), ZZ, lex)"
    assert srepr(ring("x,y", QQ, grlex)[0]) == "PolyRing((Symbol('x'), Symbol('y')), QQ, grlex)"
    assert srepr(ring("x,y,z", ZZ["t"], lex)[0]) == "PolyRing((Symbol('x'), Symbol('y'), Symbol('z')), ZZ[t], lex)"
コード例 #12
0
def test_PolyElement():
    R, x, y = ring("x,y", ZZ)
    assert srepr(3*x**2*y + 1) == "PolyElement(PolyRing((Symbol('x'), Symbol('y')), ZZ, lex), [((2, 1), 3), ((0, 0), 1)])"