示例#1
0
def test_dup_zz_cyclotomic_poly():
    assert dup_zz_cyclotomic_poly(1, ZZ) == [1,-1]
    assert dup_zz_cyclotomic_poly(2, ZZ) == [1,1]
    assert dup_zz_cyclotomic_poly(3, ZZ) == [1,1,1]
    assert dup_zz_cyclotomic_poly(4, ZZ) == [1,0,1]
    assert dup_zz_cyclotomic_poly(5, ZZ) == [1,1,1,1,1]
    assert dup_zz_cyclotomic_poly(6, ZZ) == [1,-1,1]
    assert dup_zz_cyclotomic_poly(7, ZZ) == [1,1,1,1,1,1,1]
    assert dup_zz_cyclotomic_poly(8, ZZ) == [1,0,0,0,1]
    assert dup_zz_cyclotomic_poly(9, ZZ) == [1,0,0,1,0,0,1]
示例#2
0
def test_dup_zz_cyclotomic_poly():
    assert dup_zz_cyclotomic_poly(1, ZZ) == [1, -1]
    assert dup_zz_cyclotomic_poly(2, ZZ) == [1, 1]
    assert dup_zz_cyclotomic_poly(3, ZZ) == [1, 1, 1]
    assert dup_zz_cyclotomic_poly(4, ZZ) == [1, 0, 1]
    assert dup_zz_cyclotomic_poly(5, ZZ) == [1, 1, 1, 1, 1]
    assert dup_zz_cyclotomic_poly(6, ZZ) == [1, -1, 1]
    assert dup_zz_cyclotomic_poly(7, ZZ) == [1, 1, 1, 1, 1, 1, 1]
    assert dup_zz_cyclotomic_poly(8, ZZ) == [1, 0, 0, 0, 1]
    assert dup_zz_cyclotomic_poly(9, ZZ) == [1, 0, 0, 1, 0, 0, 1]
示例#3
0
def cyclotomic_poly(n, x=None, **args):
    """Generates cyclotomic polynomial of order `n` in `x`. """
    if n <= 0:
        raise ValueError("can't generate cyclotomic polynomial of order %s" % n)

    if x is not None:
        x = sympify(x)
    else:
        x = Dummy('x')

    poly = Poly.new(DMP(dup_zz_cyclotomic_poly(int(n), ZZ), ZZ), x)

    if not args.get('polys', False):
        return poly.as_expr()
    else:
        return poly
示例#4
0
def cyclotomic_poly(n, x=None, **args):
    """Generates cyclotomic polynomial of order `n` in `x`. """
    if n <= 0:
        raise ValueError("can't generate cyclotomic polynomial of order %s" % n)

    poly = DMP(dup_zz_cyclotomic_poly(int(n), ZZ), ZZ)

    if x is not None:
        poly = Poly.new(poly, x)
    else:
        poly = PurePoly.new(poly, Dummy("x"))

    if not args.get("polys", False):
        return poly.as_expr()
    else:
        return poly
示例#5
0
def cyclotomic_poly(n, x=None, **args):
    """Generates cyclotomic polynomial of order `n` in `x`. """
    if n <= 0:
        raise ValueError("can't generate cyclotomic polynomial of order %s" % n)

    if x is not None:
        x = sympify(x)
    else:
        x = Dummy('x')

    poly = Poly(DMP(dup_zz_cyclotomic_poly(int(n), ZZ), ZZ), x)

    if not args.get('polys', False):
        return poly.as_basic()
    else:
        return poly
示例#6
0
def cyclotomic_poly(n, x=None, **args):
    """Generates cyclotomic polynomial of order `n` in `x`. """
    if n <= 0:
        raise ValueError("can't generate cyclotomic polynomial of order %s" %
                         n)

    poly = DMP(dup_zz_cyclotomic_poly(int(n), ZZ), ZZ)

    if x is not None:
        poly = Poly.new(poly, x)
    else:
        poly = PurePoly.new(poly, Dummy('x'))

    if not args.get('polys', False):
        return poly.as_expr()
    else:
        return poly
示例#7
0
def cyclotomic_poly(n, x=None, polys=False):
    """Generates cyclotomic polynomial of order `n` in `x`.

    Parameters
    ----------
    n : int
        `n` decides the order of polynomial
    x : optional
    polys : bool, optional
        ``polys=True`` returns an expression, otherwise
        (default) returns an expression.
    """
    if n <= 0:
        raise ValueError("can't generate cyclotomic polynomial of order %s" % n)

    poly = DMP(dup_zz_cyclotomic_poly(int(n), ZZ), ZZ)

    if x is not None:
        poly = Poly.new(poly, x)
    else:
        poly = PurePoly.new(poly, Dummy("x"))

    return poly if polys else poly.as_expr()
示例#8
0
def cyclotomic_poly(n, x=None, polys=False):
    """Generates cyclotomic polynomial of order `n` in `x`.

    Parameters
    ----------
    n : int
        `n` decides the order of polynomial
    x : optional
    polys : bool, optional
        ``polys=True`` returns an expression, otherwise
        (default) returns an expression.
    """
    if n <= 0:
        raise ValueError(
            "can't generate cyclotomic polynomial of order %s" % n)

    poly = DMP(dup_zz_cyclotomic_poly(int(n), ZZ), ZZ)

    if x is not None:
        poly = Poly.new(poly, x)
    else:
        poly = PurePoly.new(poly, Dummy('x'))

    return poly if polys else poly.as_expr()