当前位置: 首页>>代码示例>>Python>>正文


Python PolynomialRing.irreductible_element方法代码示例

本文整理汇总了Python中sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing.irreductible_element方法的典型用法代码示例。如果您正苦于以下问题:Python PolynomialRing.irreductible_element方法的具体用法?Python PolynomialRing.irreductible_element怎么用?Python PolynomialRing.irreductible_element使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing的用法示例。


在下文中一共展示了PolynomialRing.irreductible_element方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: pinch_method

# 需要导入模块: from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing [as 别名]
# 或者: from sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing import irreductible_element [as 别名]
def pinch_method(p, n, m, f = None, g = None):
    '''
    Function that given three integers p, n and m such as :

    - p is prime,
    - m is dividing n and there exists a primitive mth root that spans F_{p^n} 
    and none of its subfields,

    returns the image, in a finite field G, of the polynomial generator of a 
    finite field F with the same cardinality as G.
    '''
    c, w = cputime(), walltime()
    R = PolynomialRing(GF(p), 'X')

    # If no polynomials are given, we compute both of them randomly.
    if f is None:
        f = R.irreducible_element(n, algorithm='random')
    if g is None:
        g = R.irreducible_element(n, algorithm='random')
    while f == g:
        g = R.irreductible_element(n, algorithm='random')

    # We compute two fields of cardinality p^n and two primitive m-rooth
    rootmf, rootmg, F, G = find_mroots_and_fields(p, n, m, f, g)

    # The matrixes will contain the coefficients of rootmf and rootmg in the 
    # basis x^i and y^i respectively
    A = matrix(GF(p), n, n)
    B = matrix(GF(p), n, n)

    for i in range(n):
    	A[i,:] = (rootmf**i).vector()

    # Failsafe, but probably outdated
    try:
    	Ainv = A.inverse()
    except ZeroDivisionError:
    	print 'erreur'
        return A

    # We will try to find the power s such as phi(rootmf) = rootmg^s, since 
    # rootmg and rootmf are both primitive mrooth it is bound to happen 
    # since the multiplicative group is cyclic.
    s = 1	


    while s <= m :	
    	for i in range(n):
		B[i,:] = ((rootmg**s)**i).vector()


        # This will be the isomorphism's matrix
    	C = Ainv*B	

    	v = C[1,:]	  # The second line correponds to the image of x
        res = G(v[0])

	# I realized that you could try to find if the image of 
	# rootmf is also a zero of the minimal polynomial of rootmf 
	# but it would force us to compute yet another minimal polynomials.
	# Instead, if you find that the image of x is a root of f, 
	# then you win!
        if f(res) == 0:
	    	print 'CPU %s, Wall %s' % (cputime(c), walltime(w))
	    	# Some of what is returned is probably useless and only here 
	    	# for testing purposes.
	    	return (res, C, rootmf, rootmg, s, f, F, G)

    	s = s + 1
	
    print 'No isomorphism found, check your m.'
    return 1
开发者ID:brieulle,项目名称:Rains-pinch,代码行数:74,代码来源:pinchimpl.py


注:本文中的sage.rings.polynomial.polynomial_ring_constructor.PolynomialRing.irreductible_element方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。