I do not understand why you are using the symbolic ring and not a
polynomial ring (in several variables). The symbolic ring is very slow
for everything.

I did not fully understand your question, but here at least is an
example involving polynomial rings

sage: K = GF(2)
sage: n=4; R = PolynomialRing(K, ['x%d'%i for i in range(n)])
sage: R.gens()
(x0, x1, x2, x3)
sage: x0,x1,x2,x3 = R.gens()
sage: RR = PolynomialRing(R,'t')
sage: t = RR.gen()
sage: t
t
sage: (x0 + x1*t) * (x1*t^2 + x2)
x1^2*t^3 + x0*x1*t^2 + x1*x2*t + x0*x2
sage: p = (x0 + x1*t) * (x1*t^2 + x2)
sage: p.coefficients()
[x0*x2, x1*x2, x0*x1, x1^2]

Vincent
2014-08-23 3:53 UTC+02:00, Juan Grados <juan...@gmail.com>:
> I'm see that substitution is very slow in SAGE for many many. Is there any
> way to get best perfomance to substitution?
> thanks
>
>
> 2014-08-22 7:42 GMT-03:00 Juan Grados <juan...@gmail.com>:
>
>> 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
>> ---------------------------------------------------------------------
>>
>
>
>
> --
> ---------------------------------------------------------------------
> 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 sage-support+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
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