Hi Peter, 

Your solution can be used in some applications. However, I guess the "call" 
is more natural and understandable. It can be also used in the following:

K = GF(2^8, 'a')
P.<x> = PolynomialRing(K)
Q.<y> = P.quotient_ring(x^256 - x)
f = Q.random_element()
f.subs(Q.random_element())

Albeit...

K = GF(2^8, 'a')
P.<x> = PolynomialRing(K)
Q.<y> = P.quotient_ring(x^256 - x)
f = Q.random_element()
ev_a = Q.hom([Q.random_element()])  # homomorphism: Q -> Q
f = Q.random_element()
b = ev_a(f)

The code above works fine!

Regards,
Oleksandr 

On Tuesday, August 12, 2014 10:40:34 PM UTC+2, Peter Bruin wrote:
>
> Hello,
>
> It seems like quotient_ring doesn't have '__call__'. Does it a bug or a 
>> feature?
>>
>> sage: K = GF(2^8,'a')
>> sage: P = PolynomialRing(K,'x')
>> sage: Q = P.quotient_ring(P("x^256+x"),'y')
>> sage: f = Q.random_element()
>> sage: f.subs(y=K.random_element()) # random
>> (a^7 + a^6 + a^3 + a)*y^255 + (a^7 + a^4)*y^254 ...
>> sage: Q
>> Univariate Quotient Polynomial Ring in y over Finite Field in a of size 2
>> ^8 with modulus x^256 + x
>>
>> I expect that the output will be in K. 
>>
>
> It would in principle not be hard to implement the functionality you are 
> asking for, but I would recommend a solution like the following:
>
> sage: K = GF(2^8, 'a')
> sage: P.<x> = PolynomialRing(K)
> sage: Q.<y> = P.quotient_ring(x^256 - x)
> sage: a = K.random_element()
> sage: ev_a = Q.hom([a])  # homomorphism "evaluation in a": Q -> K
> sage: f = Q.random_element()
> sage: b = ev_a(f)
> sage: b  # random
> a^7 + a^5 + a^3 + a^2 + a + 1
> sage: b.parent() is K
> True
>
> In this way, the fact that ev_a is well-defined is checked during its 
> construction, so it doesn't have to be checked when doing the actual 
> evaluation.
>
> Peter
>

-- 
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