Sorry for the leftovers I copied and pasted...
With the following I manage to create polynomials whose coefficients are in 
Z_32 and they are modulo x^N-1. 
N=100
q=32
PR.<xx> = Zmod(q)[]
Q.<x> = PR.quotient(xx^N - 1)
pp=Q.random_element()

The problem is that  pp.inverse_mod(x^N-1) does not work 
(NotImplementedError). Similarly, for pp^(-1) I get the error 
NotImplementedError: The base ring (=Ring of integers modulo 32) is not a 
field
I'm working on sage-6.3-x86_64-Linux
Justin proposed to use GF(), however, if I use the following (fixed the 
garbages of the previous code):
q=32
FFQ.<t> = GF(q)
PR.<x> = PolynomialRing(FFQ)
Q.<xx> = PR.quotient(x^N - 1)

My coefficients belong to a finite field of size 32 I can invert etc, but 
the coeffs are not in Z_32 as I would like to.
Thanks for your help


On Sunday, April 5, 2015 at 5:09:40 PM UTC+3, Dima Pasechnik wrote:
>
>
>
> On Sunday, 5 April 2015 13:20:49 UTC+1, absinthe wrote:
>>
>> Justin thanks for your reply. When I realised that I have posted to dev I 
>> deleted the message and I posted to support. It looks like that you had 
>> already answered there. Since it might help others which will look at 
>> support and not dev, I copy and paste your dev reply here.
>> 2. Yes no problem :)
>> 1. The reason I resulted to Integers(p) was that I couldn't have the 
>> proper cooefficients when using GF.
>> For the same "configuration" I tried the following
>> Trying with the following 
>> p=32
>> N=100
>> FFQ.<t> = GF(q)#FiniteField(q)
>> PR.<x> = PolynomialRing(K)
>> Q.<xx> = PR.quotient(x^N - 1)
>> pp=Q.random_element()
>> while True:
>>     try:
>>         ppInv=pp.inverse_mod(xx^N-1)
>>         break
>>     except:
>>         pp=Q.random_element()
>> print (pp*ppInv).mod(x^N-1)
>>
>> I get to a dead end as inverse_mod returns me a not implemented error 
>> (sage-6.3-x86_64-Linux)
>>
>
> What is K there? And what is q?
> They are not defined in your code above.
>
> As well, 
> it's not clear why you try to call inverse_mod(), as pp is already an 
> element
> of the quotient ring modulo (x^N-1).
>
> But pp^{-1} need not exist, still, as Q is not a field for each N>1.
>
>
>
> On Sunday, April 5, 2015 at 3:59:42 AM UTC+3, Justin C. Walker wrote:
>>
>>
>> On Apr 4, 2015, at 17:25 , absinthe wrote: 
>>
>> > Dear all, 
>> > 
>> > I'm trying to work with polynomials modulo x^N-1 whose coefficients 
>> belong 
>> > to Z_p (If it helps p is a power of a prime). I know that I'm doing 
>> > something wrong, but I cannot figure out what so any help is welcome. 
>>
>> I'm not sure how familiar you are with this stuff, so forgive me if this 
>> is already clear to you. 
>>
>> 1. When "p" is a prime power, Z/pZ is not a field (it's a ring, but not a 
>> domain).  If you want to deal with coefficients in a field, then you will 
>> want to use "GF(p)", not "Integers(p)".  And a minor syntactic wrinkle to 
>> beware of is that when "p" (as above) is a prime power, and not a prime, 
>> you need a second argument, to be used as the name of the "generator" of 
>> F_p (as an extension of F_q, q being the prime in p). 
>>
>> 2. Also, in computer algebra systems, you have to be careful about 
>> parentheses, to get what you want.  In particular, "X^N-1" and X^(N-1)" are 
>> not the same. 
>>
>> If this isn't helpful, we can look at this some more. 
>>
>> HTH 
>>
>> Justin 
>>
>> -- 
>> Justin C. Walker 
>> Curmudgeon at Large 
>> Director 
>> Institute for the Enhancement of the Director's Income 
>> -- 
>> Build a man a fire and he'll be warm 
>>  for a night. 
>> Set a man on fire and he'll be warm 
>>  for the rest of his life. 
>>
>>
>>
>> On Sunday, April 5, 2015 at 4:00:47 AM UTC+3, Justin C. Walker wrote:
>>>
>>>
>>> On Apr 4, 2015, at 17:29 , absinthe wrote: 
>>>
>>> > Dear all, 
>>> > 
>>> > I'm trying to work with polynomials modulo x^N-1 whose coefficients 
>>> belong 
>>> > to Z_p (If it helps p is a power of a prime). I know that I'm doing 
>>> > something wrong, but I cannot figure out what so any help is welcome. 
>>>
>>> Answered, possibly, on sage-devel... 
>>>
>>> -- 
>>> Justin C. Walker, Curmudgeon at Large 
>>> Institute for the Absorption of Federal Funds 
>>> ----------- 
>>> My wife 'n kids 'n dogs are gone, 
>>> I can't get Jesus on the phone, 
>>> But Ol' Milwaukee's Best is my best friend. 
>>> ----------- 
>>>
>>>
>>>

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