I'm wrote a method to get the symbolic coefficients of polynomial p \in
GF(2^pp)[X0,...,X_{nvars-1}] translate to GF(2). The method was wrotte
using companion matrix [1] of irreducible polynomial GF(2^pp). For example
for pp = 2. The polynomial p = X0*X1 = (x_00+x_01*t)*(x_10+x_11*t) =
(x_00*x_10+x_01*x_11) + (x_01*x_11+x_01*x_10 + x_00*x_11)*t  then the
method get [(x_00*x_10+x_01*x_11),(x_01*x_11+x_01*x_10 + x_00*x_11)]. The
method use the matrix of quadratic form p, n below code that variable is
p_matix. My problem is when I want extend the number pp and nvars to values
for example 8 and 8. Then my question is: How I will be able to accelerate
that code?

    p = 2
    n = 4 # num vars
    K.<t> = GF(2**p, name='t')
    VS = K.vector_space()
    vars_GF = [var("X%d"%i) for i in range(n)]

    #variable for formulas: addition and multiplication
    vars_gf_X_ = [var("fX_%d"%i) for i in range(p)]
    vars_gf_Y_ = [var("fY_%d"%i) for i in range(p)]
    vars_gf_Z_ = [var("fZ_%d"%i) for i in range(p)]

    #variables of components of variables vars_GF
    vars_gf_X = [[var("x_%d_%d"%(i,k)) for k in range(p)] for i in range(n)]

    P=PolynomialRing(K,names=vars_GF)
    A = companion_matrix(K.modulus())
    sum = 0
    sum1 = 0
    sum2= 0
    for i in range(p):
        sum = sum + (A^i)*vars_gf_X_[i]
        sum1 = sum1 + (A^i)*vars_gf_Y_[i]
        sum2 = sum2 + (A^i)*vars_gf_Z_[i]

    #calculate formula to adtion and multiplication with the components of
the vector space GF(2^p)
    Msum = sum + sum1
    Mmul = sum*sum1*sum2
    psum0 = (Msum)[0,0]
    psum1 = (Msum)[0,1]
    pmul0 = (Mmul)[0,0]
    pmul1 = (Mmul)[0,1]

    p_matrix = random_matrix(K,n,n)
    #saving the element 0,0 of matrix
    s0 =
pmul0(VS(p_matrix[0,0])[0],VS(p_matrix[0,0])[1],vars_gf_X[0][0],vars_gf_X[0][1],vars_gf_X[0][0],vars_gf_X[0][1])
    s1 =
pmul1(VS(p_matrix[0,0])[0],VS(p_matrix[0,0])[1],vars_gf_X[0][0],vars_gf_X[0][1],vars_gf_X[0][0],vars_gf_X[0][1])
    #sum of each monomial
    for i in range(n):
        for j in range(i+1):
            if i != 0 or j !=0:
                s0 =
psum0(s0,pmul0(VS(p_matrix[i,j])[0],VS(p_matrix[i,j])[1],vars_gf_X[i][0],vars_gf_X[i][1],vars_gf_X[j][0],vars_gf_X[j][1]))
                s1 =
psum1(s1,pmul1(VS(p_matrix[i,j])[0],VS(p_matrix[i,j])[1],vars_gf_X[i][0],vars_gf_X[i][1],vars_gf_X[j][0],vars_gf_X[j][1]))
    print s0
    print s1


  [1]: http://www.gregorybard.com/papers/extension_fields.pdf

-- 
---------------------------------------------------------------------
MSc. Juan del Carmen Grados Vásquez
Laboratório Nacional de Computação Científica
Tel: +55 21 97633 3228
(http://www.lncc.br/)
http://juaninf.blogspot.com
---------------------------------------------------------------------

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to