[sage-support] Re: Quotient ring over Finite Field 2^n

2014-08-12 Thread Oleksandr Kazymyrov
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 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.


[sage-support] Quotient ring over Finite Field 2^n

2014-08-11 Thread Oleksandr Kazymyrov
Hello everyone, 

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. 

Kind regards,
Oleksandr

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


[sage-support] Re: Overflow creating finite field element

2014-08-11 Thread Oleksandr Kazymyrov
Hi Samuel,

I guess t_INT is the 64-bit sign integer in the pari library, which is 
written in C. It means the positive size is 63 bits. The number 2^63 
corresponds to -1 and pari raises an error. The following code works fine.

sage: p = previous_prime(2^64)
sage: F.x = GF(p^2)
sage: x * (2**63 - 1)


Kind regards,
Oleksandr

On Saturday, July 26, 2014 5:39:42 AM UTC+2, Samuel Neves wrote:

 I seem to have run across a potential bug on Sage:

 p = previous_prime(2^64)
 F.x = GF(p^2)
 x * 2**63


 throws a overflow in t_INT--long assignment exception creating the 
 element x * 2**63. Reproduced here:


 https://sagecell.sagemath.org/?z=eJwrULBVKChKLcvMLy2OLyjKzE3VMIozM9Hk5XLTs6mwA8q6u2kUxBkBBSq0jLS0zIwBihANsg==lang=sage


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


[sage-support] Re: Symmetric polynomials over a ring of polynomials

2014-08-11 Thread Oleksandr Kazymyrov
Hi Tom,

Your code works perfectly in Sage 6.2 on Mac

R.x1,x2,x3 = PolynomialRing(ZZ,3)
C.c1,c2 = PolynomialRing(R,2)

Sym = SymmetricFunctions(R)
e = Sym.elementary()

def ElemSym(p):
# checks whether a polynomial is symmetric (coefficients in ZZ[l1,l2,l3])
f = Sym.from_polynomial(p)
return e(f)

p = ((x1^3 - 2*x1*x2 + x3)*c1^2 - (x1*x2 - x3)*c1 + x3)*c2^2 + x1^3 + 
c1^2*x3 - (x1*x2 - x3)*c1 - ((x1*x2 - x3)*c1^2 - (x1^3 - x1*x2 + x3)*c1 + 
x1*x2 - x3)*c2 - 2*x1*x2 + x3
ElemSym(p) == ElemSym(((x1^3 - 2*x1*x2 + x3)*c1^2 - (x1*x2 - x3)*c1 + 
x3)*c2^2 + x1^3 + c1^2*x3 - (x1*x2 - x3)*c1 - ((x1*x2 - x3)*c1^2 - (x1^3 - 
x1*x2 + x3)*c1 + x1*x2 - x3)*c2 - 2*x1*x2 + x3)
True

Best regards,
Oleksandr

On Saturday, May 24, 2014 4:29:38 PM UTC+2, Tom Harris wrote:

 Hi all,

 I am new to sage, so please forgive me if this is a trivial question.

 I am trying to express certain polynomials, which are symmetric in a 
 subset of the variables, in terms of elementary symmetric polynomials on 
 the symmetric subset (with coefficients that are polynomials in the other 
 variables.

 Here is my setup:
 _

 R.x1,x2,x3 = PolynomialRing(ZZ,3)
 C.c1,c2 = PolynomialRing(R,2)

 Sym = SymmetricFunctions(R)
 e = Sym.elementary()

 def ElemSym(p):
 # checks whether a polynomial is symmetric (coefficients in ZZ[l1,l2,l3])
 f = Sym.from_polynomial(p)
 return e(f)
 _

 If one enters some polynomials of the desired form by hand, e.g., 

 g = (x1^2 - 2*x2^2)*c1 +c1*c2 + (x1^2 -2*x2^2)*c2

 and calls ElemSym(g)

 then sage returns

 (x1^2-2*x2^2)*e[1] + e[2]

 as expected.

 Now I have some code to generate the polynomial which I am interested in, 
 I store it as p:

 p = (output of some functions)

 ( p is ((x1^3 - 2*x1*x2 + x3)*c1^2 - (x1*x2 - x3)*c1 + x3)*c2^2 + x1^3 + 
 c1^2*x3 - (x1*x2 - x3)*c1 - ((x1*x2 - x3)*c1^2 - (x1^3 - x1*x2 + x3)*c1 + 
 x1*x2 - x3)*c2 - 2*x1*x2 + x3) 

 Now the curious thing: p is (naively at least) symmetric in c1 and c2, but 
 calling ElemSym(p) returns an error:

 ValueError: x0 + 2*x1 + x2 is not a symmetric polynomial

 but if I copy the polynomial itself and call

 ElemSym(((x1^3 - 2*x1*x2 + x3)*c1^2 - (x1*x2 - x3)*c1 + x3)*c2^2 + x1^3 + 
 c1^2*x3 - (x1*x2 - x3)*c1 - ((x1*x2 - x3)*c1^2 - (x1^3 - x1*x2 + x3)*c1 + 
 x1*x2 - x3)*c2 - 2*x1*x2 + x3)),

 then it works and I get

 (x1^3-2*x1*x2+x3)*e[] + (-x1*x2+x3)*e[1] + x3*e[1, 1] + 
 (x1^3-x1*x2-x3)*e[2] + (-x1*x2+x3)*e[2, 1] + (x1^3-2*x1*x2+x3)*e[2, 2] + 
 (3*x1*x2-3*x3)*e[3] + (-2*x1^3+4*x1*x2-2*x3)*e[3, 1] + 
 (2*x1^3-4*x1*x2+2*x3)*e[4]

 as expected.

 Can somebody help me understand what is going on here?



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


Re: [sage-support] Re: Possible bug in algebraic_immunity( ) function in crypto toolbox

2013-08-21 Thread Oleksandr Kazymyrov
Yes, I agree with this statement. However, this is not useful. Suppose I 
(as an user) want to find an annihilator of f (only f). I alway must 
write a cycle to find degree and corresponding function.

I propose to add an option to annihilator which will allow return the 
function with smallest degree. And one more option, which returns all 
annihilators instead of one function.

On Wednesday, August 21, 2013 7:57:17 AM UTC+2, Yann wrote:

 From the doc of .algebraic_immunity :

Returns the algebraic immunity of the Boolean function. This is the
smallest integer i such that there exists a non trivial annihilator
for self or ~self.

 The annihilator you get is for ~f1 (or if you prefer 1+f1)

 You can check that: (1+f1)*annihilator_f1 == 0

 Best regards

 Le mardi 20 août 2013 20:01:03 UTC+2, Martin Albrecht a écrit :

 Hi Yann, 

 I believe you are the original author of this code? 

 Cheers, 
 Martin 

 --  Forwarded Message  -- 

 Subject: [sage-support] Re: Possible bug in algebraic_immunity( ) 
 function in 
 crypto toolbox 
 Date: Tuesday 20 August 2013, 08:54:18 
 From: Oleksandr Kazymyrov vrona.ak...@gmail.com 
 To: sage-s...@googlegroups.com 

 I have the same problem. 

 My output (Mac OS 10.8.4 with sage 5.11) for 
 #!/usr/bin/env sage 

 from sage.crypto.boolean_function import BooleanFunction 

 P = BooleanPolynomialRing(4,'x') 
 P.inject_variables() 
 f = BooleanFunction(x0*x2 + x2*x3 + 1) 

 print f.algebraic_immunity() = {0}.format(f.algebraic_immunity()) 
 print f.annihilator(f.algebraic_immunity()) = 
 {0}.format(f.annihilator(f.algebraic_immunity())) 
 print f.algebraic_immunity(annihilator=True) = 
 {0}.format(f.algebraic_immunity(annihilator=True)) 

 g = BooleanFunction(f.algebraic_immunity(annihilator=True)[1]) 

 print f = {0}.format(f.algebraic_normal_form()) 
 print g = {0}.format(g.algebraic_normal_form()) 
 print g*f = 
 {0}.format(g.algebraic_normal_form()*f.algebraic_normal_form()) 

 is 
 Defining x0, x1, x2, x3 
 f.algebraic_immunity() = 1 
 f.annihilator(f.algebraic_immunity()) = None 
 f.algebraic_immunity(annihilator=True) = (1, x2 + 1) 
 f = x0*x2 + x2*x3 + 1 
 g = x2 + 1 
 g*f = x2 + 1 

 Therefore algebraic_immunity returns wrong degree. g*f = 0 for degree 2, 
 which is the correct answer. 

 On Tuesday, February 12, 2013 6:35:05 PM UTC+1, akhil wrote: 
  
  Hello, 
  
  SAGE returns an incorrect annihilator when 
 algebraic_immunity(annihilator 
  = True) is used in the following code: 
  
  from  sage.crypto.boolean_function import BooleanFunction 
  R = BooleanPolynomialRing(4,'x') 
  f1 = R.gen(0)*R.gen(1)*R.gen(2) + R.gen(0)*R.gen(1)*R.gen(3) + 
  R.gen(0)*R.gen(2)*R.gen(3) + R.gen(1)*R.gen(2)*R.gen(3) + 1 
  annihilator_f1 = BooleanFunction(f1).algebraic_immunity(annihilator = 
  True)[1] 
  print (annihilator_f1 * f1) 
  
  annihilator_f1 is incorrect, because the response comes as: 
  
  x0 + x1 + x2 + x3 + 1 
  
  
  and not 0 as expected. 
  
  The annihilator( ) function however, returns the correct answer, as 
  checked with the following code: 
  
  for i in range(1,f1.total_degree() + 1): 
  if BooleanFunction(f1).annihilator(i) == None: 
  continue 
  else: 
  p =  BooleanFunction(f1).annihilator(i) 
  print p 
  print (p*f1 == 0) 
  break 
  
  Output: 
  
  x0*x1*x2 + x1*x2*x3 
  True 
  
  
  The above code was written in online notebook version of SAGE. 
  
  Thanks, 
  AKHIL. 
  
  
  
  
  

 -- 
 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...@googlegroups.com. 
 To post to this group, send email to sage-s...@googlegroups.com. 
 Visit this group at http://groups.google.com/group/sage-support. 
 For more options, visit https://groups.google.com/groups/opt_out. 
 - 

 -- 
 name: Martin Albrecht 
 _pgp: http://pgp.mit.edu:11371/pks/lookup?op=getsearch=0x6532AFB4 
 _otr: 47F43D1A 5D68C36F 468BAEBA 640E8856 D7951CCF 
 _www: http://martinralbrecht.wordpress.com/ 
 _jab: martinr...@jabber.ccc.de



-- 
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/groups/opt_out.


[sage-support] Label of vertices

2013-08-21 Thread Oleksandr Kazymyrov
How can I get a graph with two vertices and one label? I want to create 
something like thishttp://upload.wikimedia.org/wikipedia/commons/9/91/BDD.png
.

-- 
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/groups/opt_out.


[sage-support] Re: Possible bug in algebraic_immunity( ) function in crypto toolbox

2013-08-20 Thread Oleksandr Kazymyrov
I have the same problem.

My output (Mac OS 10.8.4 with sage 5.11) for
#!/usr/bin/env sage

from sage.crypto.boolean_function import BooleanFunction

P = BooleanPolynomialRing(4,'x')
P.inject_variables()
f = BooleanFunction(x0*x2 + x2*x3 + 1)

print f.algebraic_immunity() = {0}.format(f.algebraic_immunity())
print f.annihilator(f.algebraic_immunity()) = 
{0}.format(f.annihilator(f.algebraic_immunity()))
print f.algebraic_immunity(annihilator=True) = 
{0}.format(f.algebraic_immunity(annihilator=True))

g = BooleanFunction(f.algebraic_immunity(annihilator=True)[1])

print f = {0}.format(f.algebraic_normal_form())
print g = {0}.format(g.algebraic_normal_form())
print g*f = 
{0}.format(g.algebraic_normal_form()*f.algebraic_normal_form())

is
Defining x0, x1, x2, x3
f.algebraic_immunity() = 1
f.annihilator(f.algebraic_immunity()) = None
f.algebraic_immunity(annihilator=True) = (1, x2 + 1)
f = x0*x2 + x2*x3 + 1
g = x2 + 1
g*f = x2 + 1

Therefore algebraic_immunity returns wrong degree. g*f = 0 for degree 2, 
which is the correct answer.

On Tuesday, February 12, 2013 6:35:05 PM UTC+1, akhil wrote:

 Hello,

 SAGE returns an incorrect annihilator when algebraic_immunity(annihilator 
 = True) is used in the following code:

 from  sage.crypto.boolean_function import BooleanFunction
 R = BooleanPolynomialRing(4,'x')
 f1 = R.gen(0)*R.gen(1)*R.gen(2) + R.gen(0)*R.gen(1)*R.gen(3) + 
 R.gen(0)*R.gen(2)*R.gen(3) + R.gen(1)*R.gen(2)*R.gen(3) + 1
 annihilator_f1 = BooleanFunction(f1).algebraic_immunity(annihilator = 
 True)[1]
 print (annihilator_f1 * f1)

 annihilator_f1 is incorrect, because the response comes as:

 x0 + x1 + x2 + x3 + 1


 and not 0 as expected.

 The annihilator( ) function however, returns the correct answer, as 
 checked with the following code:

 for i in range(1,f1.total_degree() + 1):
 if BooleanFunction(f1).annihilator(i) == None:
 continue
 else:
 p =  BooleanFunction(f1).annihilator(i)
 print p
 print (p*f1 == 0)
 break

 Output:

 x0*x1*x2 + x1*x2*x3
 True


 The above code was written in online notebook version of SAGE.

 Thanks,
 AKHIL.






-- 
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/groups/opt_out.


Main.sage
Description: Binary data


[sage-support] Binary decision diagrams

2013-08-20 Thread Oleksandr Kazymyrov
Hi all, 

Could I receive a binary decision diagrams for a boolean function?

I saw some information here http://planet.sagemath.org/, but I'm not sure 
that she (they) do the same what I need.

-- 
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/groups/opt_out.


[sage-support] How to build documentation for separate files?

2013-08-14 Thread Oleksandr Kazymyrov
I have a class and want to generate html page with the description of 
functions (like 
thathttp://www.sagemath.org/doc/reference/cryptography/sage/crypto/mq/sbox.html)).
 
How to do this?

P.S. I know that examples inside the description (for separate files) can 
be tested by sage -t filename. Is it possible to produce the output in 
html or pdf in the same way?

-- 
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/groups/opt_out.




[sage-support] Re: How to build documentation for separate files?

2013-08-14 Thread Oleksandr Kazymyrov
Thanks, it should work. 

However, it would be great to add such functionality to sage.

On Wednesday, August 14, 2013 5:31:28 PM UTC+2, Volker Braun wrote:

 Afaik there is no simple one-command solution. But its relatively easy to 
 take the Sage docbuilder minus the parallelism stuff and just process your 
 own rst. I did this here:

 https://github.com/sagemath/git-developer-guide


 On Wednesday, August 14, 2013 4:10:29 PM UTC+1, Oleksandr Kazymyrov wrote:

 I have a class and want to generate html page with the description of 
 functions (like 
 thathttp://www.sagemath.org/doc/reference/cryptography/sage/crypto/mq/sbox.html)).
  
 How to do this?

 P.S. I know that examples inside the description (for separate files) can 
 be tested by sage -t filename. Is it possible to produce the output in 
 html or pdf in the same way?



-- 
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/groups/opt_out.




[sage-support] Re: power representation of finite field elements

2012-09-17 Thread Oleksandr Kazymyrov
Today is easiest way and *secure* to use multiplicative_generator function:

sage: K=GF(2^4,'a')
sage: K
Finite Field in a of size 2^4
sage: b=K.random_element()
sage: b.log(K.multiplicative_generator())
14
sage: K.multiplib.log(K.multiplicative_generator())
K.multiplication_table  K.multiplicative_generator
sage: K.multiplicative_generator()^b.log(K.multiplicative_generator()) == b
True

Because the function log_repr() works only in some special cases. 
sage: K=GF(2^4,'a',modulus=ZZ['x']('x^4 + x^3 + x^2 + x + 1'));
sage: K.list()
[0, a + 1, a^2 + 1, a^3 + a^2 + a + 1, a^3 + a^2 + a, a^3 + a^2 + 1, a^3, 
a^2 + a + 1, a^3 + 1, a^2, a^3 + a^2, a^3 + a + 1, a, a^2 + a, a^3 + a, 1]
sage: b=K.random_element()
sage: b
a^3 + a
sage: b.log_repr() 
'14'
sage: b^ZZ(b.log_repr()) == b
False
sage: K.multiplicative_generator() 

a^2 + a + 1
sage: K.multiplicative_generator()^ZZ(b.log(K.multiplicative_generator())) 
== b
True

On Monday, September 17, 2012 11:07:58 PM UTC+2, Mike OS wrote:

 HI

 I was asking myself this question and couldn't find an answer in the 
 documentation, not
 in past posts (which is how I found this email).

 So I re-ask the question  is there a way to have finite field elements
 printed as powers of the primitive element?

 Thanks

 Mike

 On Saturday, October 31, 2009 2:34:38 AM UTC-7, Kwankyu wrote:

 Hi, 

 Is it possible to get elements of a finite field printed as powers of 
 a primitive element if the modulus is a primitive polynomial? That 
 will save a lot of screen space. 


 Kwankyu



-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




[sage-support] Re: Modulus operation in PolynomialRing with many variables

2012-08-02 Thread Oleksandr Kazymyrov
I have found the way how to fix it. If I use order 'deglex'
P=PolynomialRing(GF(2^8,'a'),['x','c','b'],order='deglex')
the result looks like correct
sage: f.mod(x^2+1)
(a^7 + a^6 + a^5 + 1)*x*c^3*b + (a^7 + a^4 + a^3 + a^2 + a + 1)*x*c*b^6 + (a
^7 + a^5 + a)*c^5*b + (a^7 + a^6 + a^5 + a^4 + a^3 + a^2 + 1)*c*b^2 + (a^6 +a
^4 + a + 1)*b

But in general case I think that it is bug. 

On Wednesday, August 1, 2012 10:13:22 PM UTC+2, Oleksandr Kazymyrov wrote:


 How to get polynomial by modulus in PolynomialRing with many variables?

 sage: P=PolynomialRing(GF(2^8,'a'),['x','b','c'])
 sage: f=P.random_element(8)
 sage: f
 (a^7 + a^4 + a^3 + a^2 + a + 1)*x*b^6*c + (a^6 + a^4 + a + 1)*x^6*b + (a^7 
 + a^5 + a)*b*c^5 + (a^7 + a^6 + a^5 + a^4 + a^3 + a^2 + 1)*x^2*b^2*c + (a^7 
 + a^6 + a^5 + 1)*x*b*c^3
 sage: f.mod(P(x^2+1))
 (a^7 + a^4 + a^3 + a^2 + a + 1)*x*b^6*c + (a^6 + a^4 + a + 1)*x^6*b + (a^7 
 + a^5 + a)*b*c^5 + (a^7 + a^6 + a^5 + a^4 + a^3 + a^2 + 1)*x^2*b^2*c + (a^7 
 + a^6 + a^5 + 1)*x*b*c^3

 I expect that all monomials have degree at most 1.



-- 
-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org





[sage-support] Modulus operation in PolynomialRing with many variables

2012-08-01 Thread Oleksandr Kazymyrov

How to get polynomial by modulus in PolynomialRing with many variables?

sage: P=PolynomialRing(GF(2^8,'a'),['x','b','c'])
sage: f=P.random_element(8)
sage: f
(a^7 + a^4 + a^3 + a^2 + a + 1)*x*b^6*c + (a^6 + a^4 + a + 1)*x^6*b + (a^7 
+ a^5 + a)*b*c^5 + (a^7 + a^6 + a^5 + a^4 + a^3 + a^2 + 1)*x^2*b^2*c + (a^7 
+ a^6 + a^5 + 1)*x*b*c^3
sage: f.mod(P(x^2+1))
(a^7 + a^4 + a^3 + a^2 + a + 1)*x*b^6*c + (a^6 + a^4 + a + 1)*x^6*b + (a^7 
+ a^5 + a)*b*c^5 + (a^7 + a^6 + a^5 + a^4 + a^3 + a^2 + 1)*x^2*b^2*c + (a^7 
+ a^6 + a^5 + 1)*x*b*c^3

I expect that all monomials have degree at most 1.

-- 
-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org





[sage-support] Re: slow symbolic computation

2012-06-22 Thread Oleksandr Kazymyrov
Hi,

I have the same problem:
sage: time floor(log(4)/log(2))
2
Time: CPU 7.04 s, Wall: 7.05 s

But you can use n() before floor:
sage: time floor(log(4).n()/log(2).n())
2
Time: CPU 0.00 s, Wall: 0.00 s

It should help you.

Regards,
Oleksandr

On Friday, June 22, 2012 1:19:55 PM UTC+2, dmharvey wrote:

 -- 
 | Sage Version 5.0, Release Date: 2012-05-14 | 
 | Type notebook() for the GUI, and license() for information.| 
 -- 
 sage: time floor(log(4)/log(2)) 
 2 
 Time: CPU 1.07 s, Wall: 1.07 s 
 sage: time floor(log(4)/log(2)) 
 2 
 Time: CPU 1.07 s, Wall: 1.07 s 

 This seems very slow to me. Am I doing something wrong? 

 david 



-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Error message when use vectors in Sage 5 with Ubuntu 12.04...

2012-06-18 Thread Oleksandr Kazymyrov
Hi,

I haven't the problem on Ubuntu 12.04:
sage: vector( [-1,2] ) 
(-1, 2)
sage: version()
'Sage Version 5.0, Release Date: 2012-05-14'
sage: exit
Exiting Sage (CPU time 0m1.48s, Wall time 0m18.12s).
hamsin@hamsin:~$ uname -a
Linux hamsin 3.2.0-25-generic #40-Ubuntu SMP Wed May 23 20:33:05 UTC 2012 
i686 i686 i386 GNU/Linux

and
sage: vector( [-1,2] )
(-1, 2)
sage: version()
'Sage Version 5.0.1, Release Date: 2012-06-10'
hamsin@hamsin-PC:~$ uname -a
Linux hamsin-PC 3.2.0-25-generic #40-Ubuntu SMP Wed May 23 20:30:51 UTC 
2012 x86_64 x86_64 x86_64 GNU/Linux

Regards,
Oleksandr

On Sunday, June 17, 2012 4:13:05 AM UTC+2, Chris Seberino wrote:

 I installed Ubuntu 12.04 about 2 weeks ago along with Sage 5.
 I just now tried using vectors for the first time and got this error...

 sage: vector( [-1,2] ) 
 ---
 AttributeErrorTraceback (most recent call last)

 /home/cs/Ws/Lone_Star/1401/Exams/ipython console in module()

 /usr/local/sage-5.0-linux-32bit-ubuntu_12.04_lts-i686-Linux/local/lib/python2.7/site-packages/sage/modules/free_module_element.so
  
 in sage.modules.free_module_element.vector 
 (sage/modules/free_module_element.c:3789)()

 /usr/local/sage-5.0-linux-32bit-ubuntu_12.04_lts-i686-Linux/local/lib/python2.7/site-packages/numpy/__init__.py
  
 in module()
 134 return loader(*packages, **options)
 135 
 -- 136 import add_newdocs
 137 __all__ = ['add_newdocs']
 138 

 /usr/local/sage-5.0-linux-32bit-ubuntu_12.04_lts-i686-Linux/local/lib/python2.7/site-packages/numpy/add_newdocs.py
  
 in module()
   7 #   core/fromnumeric.py, core/defmatrix.py up-to-date.
   8 
  9 from numpy.lib import add_newdoc
  10 
  11 
 ###

 /usr/local/sage-5.0-linux-32bit-ubuntu_12.04_lts-i686-Linux/local/lib/python2.7/site-packages/numpy/lib/__init__.py
  
 in module()
  11 
  12 import scimath as emath
 --- 13 from polynomial import *
  14 #import convertcode
  15 from utils import *

 /usr/local/sage-5.0-linux-32bit-ubuntu_12.04_lts-i686-Linux/local/lib/python2.7/site-packages/numpy/lib/polynomial.py
  
 in module()
   9 import re
  10 import warnings
 --- 11 import numpy.core.numeric as NX
  12 
  13 from numpy.core import isscalar, abs, finfo, atleast_1d, hstack

 AttributeError: 'module' object has no attribute 'core'
 sage: 


-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Polynomial representation over GF(2^n)

2012-06-13 Thread Oleksandr Kazymyrov
Hi all,

Continuing the 
questionhttps://groups.google.com/forum/?fromgroups#!topic/sage-support/cvtz4Zh-WYQ
...

Input data:
sage: K=GF(2^8,'a',modulus=ZZ['x'](x^8 + x^7 + x^6 + x^4 + x^3 + x^2 + 1))
sage: K.multiplicative_generator()
a^4 + a^3 + a
sage: P=PolynomialRing(K,'x')
sage: pol=P.random_element(5)
sage: pol
(a^7 + a^5 + a^3 + 1)*x^5 + (a^5 + a^4 + a^3 + a^2 + a + 1)*x^4 + (a^7 + 
a^3 + a^2 + a)*x^3 + (a^5 + a^2)*x^2 + (a^6 + a^5 + a^4 + 1)*x + a^3

1. How to represent *pol *using multiplicative generator? The output must 
be b^(i1)*x^5 + b^(i2)*x^4 + b^(i3)*x^3 + b^(i4)*x^2 + b^(i5)*x + a^3, 
where b = K.multiplicative_generator(), i1-i5 logarithmic representation of 
(a^7 
+ a^5 + a^3 + 1), (a^5 + a^4 + a^3 + a^2 + a + 1)...

I have a correct function:
sage: b=K.multiplicative_generator()
sage: P([({0})^{1}.format(b,i.log(b)) for i in pol.coeffs()]) == pol
True
sage: [({0})^{1}.format(b,i.log(b)) for i in pol.coeffs()]
['(a^4 + a^3 + a)^27', '(a^4 + a^3 + a)^234', '(a^4 + a^3 + a)^195', '(a^4 
+ a^3 + a)^134', '(a^4 + a^3 + a)^79', '(a^4 + a^3 + a)^101']

If I have one program then the above method suits me. But if two, i.e. one 
program represents polynomial in the form b^(i1)*x^5 ... and returns b and 
another program tries to restore it, then I worry about the phrase
The docs for multiplicative_generator() say: return a generator of 
the multiplicative group, then add Warning: This generator might 
change from one version of Sage to another. 

2. So the question is how to uniquely reconstruct the original *pol*, if I 
have *modulus*, *multiplicative generator *and* representation of pol as *
b^(i1)*x^5...?

Regards,
Oleksandr

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Polynomial representation over GF(2^n)

2012-06-13 Thread Oleksandr Kazymyrov
And one more.

The following is quite strange:
sage: K=GF(2^8,'a',modulus=ZZ['x'](x^8 + x^7 + x^6 + x^4 + x^3 + x^2 + 1))
sage: b=K.multiplicative_generator()
sage: c=K(0)
sage: c.log(b)
0
sage: c=K(1)
sage: c.log(b)
0

How to determine when c is 0 and when 1? Perhaps log should return 
-1 for finite fields when c=0?

Kind regards,
Oleksandr

On Wednesday, June 13, 2012 3:02:46 PM UTC+2, Oleksandr Kazymyrov wrote:

 Hi all,

 Continuing the 
 questionhttps://groups.google.com/forum/?fromgroups#!topic/sage-support/cvtz4Zh-WYQ
 ...

 Input data:
 sage: K=GF(2^8,'a',modulus=ZZ['x'](x^8 + x^7 + x^6 + x^4 + x^3 + x^2 + 
 1))
 sage: K.multiplicative_generator()
 a^4 + a^3 + a
 sage: P=PolynomialRing(K,'x')
 sage: pol=P.random_element(5)
 sage: pol
 (a^7 + a^5 + a^3 + 1)*x^5 + (a^5 + a^4 + a^3 + a^2 + a + 1)*x^4 + (a^7 + 
 a^3 + a^2 + a)*x^3 + (a^5 + a^2)*x^2 + (a^6 + a^5 + a^4 + 1)*x + a^3

 1. How to represent *pol *using multiplicative generator? The output must 
 be b^(i1)*x^5 + b^(i2)*x^4 + b^(i3)*x^3 + b^(i4)*x^2 + b^(i5)*x + a^3, 
 where b = K.multiplicative_generator(), i1-i5 logarithmic representation of 
 (a^7 
 + a^5 + a^3 + 1), (a^5 + a^4 + a^3 + a^2 + a + 1)...

 I have a correct function:
 sage: b=K.multiplicative_generator()
 sage: P([({0})^{1}.format(b,i.log(b)) for i in pol.coeffs()]) == pol
 True
 sage: [({0})^{1}.format(b,i.log(b)) for i in pol.coeffs()]
 ['(a^4 + a^3 + a)^27', '(a^4 + a^3 + a)^234', '(a^4 + a^3 + a)^195', '(a^4 
 + a^3 + a)^134', '(a^4 + a^3 + a)^79', '(a^4 + a^3 + a)^101']

 If I have one program then the above method suits me. But if two, i.e. one 
 program represents polynomial in the form b^(i1)*x^5 ... and returns b and 
 another program tries to restore it, then I worry about the phrase
 The docs for multiplicative_generator() say: return a generator of 
 the multiplicative group, then add Warning: This generator might 
 change from one version of Sage to another. 

 2. So the question is how to uniquely reconstruct the original *pol*, if 
 I have *modulus*, *multiplicative generator *and* representation of pol 
 as *b^(i1)*x^5...?

 Regards,
 Oleksandr


-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Isomorphism of Linear Codes

2012-06-07 Thread Oleksandr Kazymyrov
Hi all,

I have next code for checking CCZ-equivalence of two vectorial Boolean 
functions in magma:
n:=7;
GF:= FiniteField(2,n);
a:=PrimitiveElement(GF);

// returns the linear Code with columns (1,x,f(x))
function CF(f)
M:=Matrix( 2*n+1, 2^n, [1: x in GF] cat [Trace(a^i * x): x in GF, i in [1..n
]] cat [Trace(a^i * f(x)): x in GF, i in [1..n]]);
return LinearCode( M );
end function;

f:=funcx | x^3 ;

g:=funcx | x^5 ;

if IsIsomorphic(CF(f),CF(g)) eq false 
then f and g are NOT equivalent;
else f and g are equivalent ;
end if;


I can't find analogue of IsIsomorphic in sage.It is the main problem of 
converting code to sage. Is sage has similar function? Or how to implement 
it?
Best regards,
Oleksandr

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Isomorphism of Linear Codes

2012-06-07 Thread Oleksandr Kazymyrov
It seems to be true. But are your sure that functions are equivalent?

On Thursday, June 7, 2012 5:05:11 PM UTC+2, David Joyner wrote:

 On Thu, Jun 7, 2012 at 10:13 AM, Oleksandr Kazymyrov 
  Hi all, 
  
  I have next code for checking CCZ-equivalence of two vectorial Boolean 
  functions in magma: 
  n:=7; 
  GF:= FiniteField(2,n); 
  a:=PrimitiveElement(GF); 
  
  // returns the linear Code with columns (1,x,f(x)) 
  function CF(f) 
  M:=Matrix( 2*n+1, 2^n, [1: x in GF] cat [Trace(a^i * x): x in GF, i in 
  [1..n]] cat [Trace(a^i * f(x)): x in GF, i in [1..n]]); 
  return LinearCode( M ); 
  end function; 
  
  f:=funcx | x^3 ; 
  
  g:=funcx | x^5 ; 
  
  if IsIsomorphic(CF(f),CF(g)) eq false 
  then f and g are NOT equivalent; 
  else f and g are equivalent ; 
  end if; 
  
  
  I can't find analogue of IsIsomorphic in sage.It is the main problem of 
  converting code to sage. Is sage has similar function? Or how to 
 implement 
  it? 

 Do you want something like the LinearCode method 
 is_permutation_equivalent? 

  
  Best regards, 
  Oleksandr 
  
  -- 
  To post to this group, send email to sage-support@googlegroups.com 
  To unsubscribe from this group, send email to 
  sage-support+unsubscr...@googlegroups.com 
  For more options, visit this group at 
  http://groups.google.com/group/sage-support 
  URL: http://www.sagemath.org 


-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Crash report: integral of ln(1+4/5*sin(x)) crashes Maxima and Sage

2012-06-07 Thread Oleksandr Kazymyrov
I have the same problem on:
sage: version()
'Sage Version 5.0, Release Date: 2012-05-14'
hamsin@hamsin-PC:~$ uname -a
Linux hamsin-PC 3.2.0-24-generic #39-Ubuntu SMP Mon May 21 16:52:17 UTC 
2012 x86_64 x86_64 x86_64 GNU/Linux



On Thursday, June 7, 2012 11:13:44 PM UTC+2, Benjamin Jones wrote:

 On Mac OS X 10.6.8 intel core i7 and sage-5.0 (also sage-5.1.beta2) I can 
 crash sage (and Maxima) by evaluating:

 sage: integrate(ln(1+4/5*sin(x)), x, -3.1415, 3.1415)


 ;;;
 ;;; Binding stack overflow.
 ;;; Jumping to the outermost toplevel prompt
 ;;;

 ...

 ;;;
 ;;; Binding stack overflow.
 ;;; Jumping to the outermost toplevel prompt
 ;;;


 /Users/jonesbe/sage/sage-5.1.beta2/spkg/bin/sage: line 335: 86594 
 Illegalinstruction sage
 -ipython $@ -i

 The same happens with the indefinite integral and the exact definite 
 integral from -pi to pi. 

 Has anyone seen similar crashes using sage-5.0 or earlier?



-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Generator of Finite Field

2012-06-03 Thread Oleksandr Kazymyrov
I have used log_repr() and expect that it return y of equation x^y = z. I 
also believed  hat k.gen() return generator of the field.

Now I must use following construction for solving my problem
sage: R.x=ZZ[]
sage: k=GF(2^8,name='a',modulus=x^8+x^4+x^3+x+1)
sage: a = k.multiplicative_generator()
sage: a^ZZ(k(ZZ(3).digits(2)).log(a)) == k(ZZ(3).digits(2))

By the way, any of next functions don't return the value y of equation x^y=z
sage: b=K(ZZ(3).digits(2))
sage: b
a + 1
sage: b.log_repr()
'1'
sage: b.log_to_int()
3

I think that log_repr() should has the same logic as int_repr() or 
integer_representation(), 
i.e.
sage: a=K.multiplicative_generator()
sage: ZZ(K(ZZ(3).digits(2)).log(a))
164

What do you think?

Kind regards,
Oleksandr

On Tuesday, May 29, 2012 12:52:16 PM UTC+3, AlexGhitza wrote:

 Hi, 

 On Mon, May 21, 2012 at 9:29 AM, Oleksandr Kazymyrov 
 vrona.aka.ham...@gmail.com wrote: 
  I have encountered the following problem In Sage 5.0: 
  sage: R.x=ZZ[] 
  sage: k=GF(2^8,name='a',modulus=x^8+x^4+x^3+x+1) 
  sage: k(ZZ(3).digits(2)) 
  a + 1 
  sage: k.gen()^ZZ(k(ZZ(3).digits(2)).log_repr()) 
  a 
  sage:  k.gen()^ZZ(k(ZZ(3).digits(2)).log_repr()) == k(ZZ(3).digits(2)) 
  False 
  sage: k(a+1)^ZZ(k(ZZ(3).digits(2)).log_repr()) == k(ZZ(3).digits(2)) 
  True 
  
  It easy see that k.gen() or k.multiplicative_generator() is not a 
 generator 
  of the finite field: 
  sage: k.multiplicative_generator() 
  a^4 + a + 1 

 Why is it clear that a^4+a+1 is not a multiplicative generator?  I think 
 it is: 

 sage: k.a = GF(2^8, names='a', name='a', modulus=x^8+x^4+x^3+x+1) 
 sage: (a^4+a+1).multiplicative_order() 
 255 

 Indeed, so is a+1: 
 sage: (a+1).multiplicative_order() 
 255 

 The docs for multiplicative_generator() say: return a generator of 
 the multiplicative group, then add Warning: This generator might 
 change from one version of Sage to another. 


 -- 
 Best, 
 Alex 

 -- 
 Alex Ghitza -- Lecturer in Mathematics -- The University of Melbourne 
 http://aghitza.org 


-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Methods in GF

2012-06-03 Thread Oleksandr Kazymyrov
Hi,

I agree with Martin, especially about private methods.

 sage: k.some_elements ? 
  ... 
 Returns a collection of elements of this finite field *for use 
  in unit testing.* 
 The function is indeed used in unitests as confirmed by 
 search_src(some_elements).  Perhaps it should start with an underscore?

In my opinion it must start with an underscore. The method 
k.random_element() return a random element and it is enough for users. 

 2. Also a few misunderstanding functions 
  
 - sage: *k.cardinality* ? 
 Type: builtin_function_or_method 
 Base Class: type 'builtin_function_or_method' 
 String Form: built-in method cardinality of 
 FiniteField_givaro_with_category object at 0xbb0eaac 
 Namespace: Interactive 
 Definition: k.cardinality(self) 
 Docstring: 
Return the order of this finite field (*same as 
 self.order()*). 
  
  Why is this confusing? 
 I can't understand the confusion either. Some people say order and 
 some people say cardinality when they refer to the number of elements 
 of a group or field. Personally, I'd tend to say cardinality in the 
 case of a set (but a field *is* as set!), and order in the case of a 
 field or group. But why shouldn't one offer both, if both is used by 
 people? 

In most of books Finite Fields you can find definition order (imho). 
But if some use it, then it's no problem.

In general I can't understand why it is important to have two (or more) 
functions with the same functionality in user space. If some of them are 
used for compatibility, then maybe they should be private?

- sage: *k.ngens* *?* 
 Docstring: 
The number of generators of the finite field. * Always 1.* 
  
  This is a generic function provided for compatibility with other parents 
 in 
  Sage. 
 At that point one should mention duck typing, I guess. Sometimes one 
 writes generic code, that is supposed to work with various kinds of 
 objects, and the type of these objects does not (and should not) matter. 
 In some cases, all what one wants to know is whether the object 
 is defined in terms of generators (e.g., a polynomial ring is, but a set 
 is not), and how many generators there are. ngens() answers both 
 questions. 

Ok, but the finite field has a set of generators. I'm a bit confused.
sage: R.x=ZZ[]
sage: K=GF(2^8,name='a',modulus=x^8+x^4+x^3+x+1)
sage: m=[i.multiplicative_order() for i in K if i != 0]
sage: m.count(255)
128

Anyway, do you want to provide (documentation) patches for the issues you 
 discovered?

My English is not so good for documentation, but I can provide some code 
(logic and programming) patches after my registration at trac.sagemath.org.

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Generator of Finite Field

2012-05-28 Thread Oleksandr Kazymyrov
Hi again,

A try to use *log* function and got error:
sage: R.x=ZZ[]
sage: k.a=GF(2^8,modulus=x^8+x^4+x^3+x+1)
sage: b=k.random_element() 
sage: b.log(a) 
---
ValueErrorTraceback (most recent call last)

/home/hamsin/ipython console in module()

/home/hamsin/bin/sage/local/lib/python2.7/site-packages/sage/rings/finite_rings/element_givaro.so
 
in sage.rings.finite_rings.element_givaro.FiniteField_givaroElement.log 
(sage/rings/finite_rings/element_givaro.cpp:11248)()

/home/hamsin/bin/sage/local/lib/python2.7/site-packages/sage/groups/generic.pyc 
in discrete_log(a, base, ord, bounds, operation, identity, inverse, op)
814 return  CRT_list(l,[pi**ri for pi,ri in f])
815 except ValueError:
-- 816 raise ValueError, No discrete log of %s found to base 
%s%(a,base)
817 
818 def discrete_log_generic(a, base, ord=None, bounds=None, 
operation='*', identity=None, inverse=None, op=None):

ValueError: No discrete log of a^7 + a^6 + a^5 + a^4 + a^2 + 1 found to 
base a

I also found some strangeness:
sage: m=[a^i for i in xrange(255)]
sage: m.append(0)
sage: len(set(m))
52

But last value must be 256, if *a *is a generator. So *k.gens() *returns 
wrong value.

P.S.
sage: version()
'Sage Version 5.0, Release Date: 2012-05-14'


On Monday, May 21, 2012 1:29:29 AM UTC+2, Oleksandr Kazymyrov wrote:

 Hello all.

 I have encountered the following problem In Sage 5.0:
 sage: R.x=ZZ[] 
 sage: k=GF(2^8,name='a',modulus=x^8+x^4+x^3+x+1)
 sage: k(ZZ(3).digits(2))
 a + 1
 sage: k.gen()^ZZ(k(ZZ(3).digits(2)).log_repr())
 a
 sage:  k.gen()^ZZ(k(ZZ(3).digits(2)).log_repr()) == k(ZZ(3).digits(2))
 False
 sage: *k(a+1)*^ZZ(k(ZZ(3).digits(2)).log_repr()) == k(ZZ(3).digits(2))
 True

 It easy see that k.gen() or k.multiplicative_generator() is not a 
 generator of the finite field:
 sage: k.multiplicative_generator()
 a^4 + a + 1
 sage: k.gen()
 a
 sage: k.list()
 [0, a + 1, a^2 + 1, a^3 + a^2 + a + 1, a^4 + 1, a^5 + a^4 + a + 1, a^6 + 
 a^4 + a^2 + 1, ... ]

 Generator is a+1!

 How to get generator of Finite Field? It was fine in Sage 4.8.

 Ubuntu 12.04
 Linux hamsin 3.2.0-24-generic #37-Ubuntu SMP Wed Apr 25 08:43:52 UTC 2012 
 i686 i686 i386 GNU/Linux

 Best regards,
 Oleksandr


-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Generator of Finite Field

2012-05-20 Thread Oleksandr Kazymyrov
Hello all.

I have encountered the following problem In Sage 5.0:
sage: R.x=ZZ[] 
sage: k=GF(2^8,name='a',modulus=x^8+x^4+x^3+x+1)
sage: k(ZZ(3).digits(2))
a + 1
sage: k.gen()^ZZ(k(ZZ(3).digits(2)).log_repr())
a
sage:  k.gen()^ZZ(k(ZZ(3).digits(2)).log_repr()) == k(ZZ(3).digits(2))
False
sage: *k(a+1)*^ZZ(k(ZZ(3).digits(2)).log_repr()) == k(ZZ(3).digits(2))
True

It easy see that k.gen() or k.multiplicative_generator() is not a generator 
of the finite field:
sage: k.multiplicative_generator()
a^4 + a + 1
sage: k.gen()
a
sage: k.list()
[0, a + 1, a^2 + 1, a^3 + a^2 + a + 1, a^4 + 1, a^5 + a^4 + a + 1, a^6 + 
a^4 + a^2 + 1, ... ]

Generator is a+1!

How to get generator of Finite Field? It was fine in Sage 4.8.

Ubuntu 12.04
Linux hamsin 3.2.0-24-generic #37-Ubuntu SMP Wed Apr 25 08:43:52 UTC 2012 
i686 i686 i386 GNU/Linux

Best regards,
Oleksandr

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Methods in GF

2012-05-20 Thread Oleksandr Kazymyrov
Dear all,

1. Why important next functions?
k.a_times_b_minus_c
k.a_times_b_plus_c
k.c_minus_a_times_b
sage: k.some_elements ?  
...
   Returns a collection of elements of this finite field *for use 
in unit testing.*

Why this function are defined as public?

2. Also a few misunderstanding functions

   - sage: *k.cardinality* ? 
   Type: builtin_function_or_method
   Base Class: type 'builtin_function_or_method'
   String Form: built-in method cardinality of 
   FiniteField_givaro_with_category object at 0xbb0eaac
   Namespace: Interactive
   Definition: k.cardinality(self)
   Docstring:
  Return the order of this finite field (*same as self.order()*).
   
   - sage: *k.cayley_graph() *
   
   ---
   AttributeErrorTraceback (most recent call 
   last)
   
   /home/hamsin/ipython console in module()
   
   
/home/hamsin/bin/sage/local/lib/python2.7/site-packages/sage/categories/semigroups.pyc
 
   in cayley_graph(self, side, simple, elements, generators, connecting_set)
   284 generators = connecting_set
   285 if generators is None:
   -- 286 generators = self.semigroup_generators()
   287 if isinstance(generators, (list, tuple)):
   288 generators = dict((self(g), self(g)) for g in 
   generators)
   
   
/home/hamsin/bin/sage/local/lib/python2.7/site-packages/sage/structure/parent.so
 
   in sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:6805)()
   
   
/home/hamsin/bin/sage/local/lib/python2.7/site-packages/sage/structure/parent.so
 
   in sage.structure.parent.getattr_from_other_class 
   (sage/structure/parent.c:3248)()
   
   AttributeError: 'FiniteField_givaro_with_category' object has no 
   attribute 'semigroup_generators'
   
   - sage: *k.has_base()*
   *True*
   sage: *k.has_base* ? 
   Type: builtin_function_or_method
   Base Class: type 'builtin_function_or_method'
   String Form: built-in method has_base of 
   FiniteField_givaro_with_category object at 0xbb0eaac
   Namespace: Interactive
   Definition: k.has_base(self, category=None)
   *??*
   *
   *
   - sage: *k.ngens* *?*
   Type: builtin_function_or_method
   Base Class: type 'builtin_function_or_method'
   String Form: built-in method ngens of FiniteField_givaro_with_category 
   object at 0xbb0eaac
   Namespace: Interactive
   Definition: k.ngens(self)
   Docstring:
  The number of generators of the finite field. * Always 1.*
   *
   *
   - sage: *k.normalize_names ?* 
   Type: builtin_function_or_method
   Base Class: type 'builtin_function_or_method'
   String Form: built-in method normalize_names of 
   FiniteField_givaro_with_category object at 0xbb0eaac
   Namespace: Interactive
   Definition: k.normalize_names(self, ngens, names=None)
   
   sage: k.normalize_names()
   
   ---
   TypeError Traceback (most recent call 
   last)
   
   /home/hamsin/ipython console in module()
   
   
/home/hamsin/bin/sage/local/lib/python2.7/site-packages/sage/structure/category_object.so
 
   in sage.structure.category_object.CategoryObject.normalize_names 
   (sage/structure/category_object.c:3939)()
   
   TypeError: normalize_names() takes at least 1 positional argument (0 
   given)
   sage: k.normalize_names(1)
   *??*
   *
   *
   - sage: *k.on*
   k.one  k.one_element  
   sage: k.one ? 
   Type: builtin_function_or_method
   Base Class: type 'builtin_function_or_method'
   String Form: built-in method one_element of 
   FiniteField_givaro_with_category object at 0xbb0eaac
   Namespace: Interactive
   Definition: k.one(self)
   Docstring:
  Return the one element of this ring (cached), if it exists.
   
  EXAMPLES:
   
 sage: ZZ.*one_element()*
 1
 sage: QQ.*one_element()*
 1
 sage: QQ['x'].*one_element()*
 1
   
  The result is cached:
   
 sage: ZZ.*one_element() *is *ZZ.one_element()*
 True
   
   

   - sage: *k.zero ? *
   Type: builtin_function_or_method
   Base Class: type 'builtin_function_or_method'
   String Form: built-in method zero_element of 
   FiniteField_givaro_with_category object at 0xbb0eaac
   Namespace: Interactive
   Definition: k.zero(self)
   Docstring:
  Return the zero element of this ring (cached).
   
  EXAMPLES:
   
 sage: *ZZ.zero_element()*
 0
 sage: *QQ.zero_element()*
 0
 sage: QQ['x'].*zero_element()*
 0
   
  The result is cached:
   
 sage: ZZ.*zero_element()* is ZZ.*zero_element()*
 True
   
   

Definition of the field:
sage: R.x=ZZ[]
sage: k=GF(2^8,name='a',modulus=x^8+x^4+x^3+x+1)

-- 

[sage-support] Re: Reserved words (Sage + Cython)

2012-02-18 Thread Oleksandr Kazymyrov
Hi Simon,

 Rename it, if that solves the problem. 

I have done it. But I wonder why has that happened after upgrade from 4.7.2 
to 4.8 (5.0beta4)?

Best regards,
Oleksandr

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Modular operation in multivariate polynomials

2012-02-17 Thread Oleksandr Kazymyrov
Hi Simon,

 Do you have a trac account, or shall I open a trac ticket myself? 
No, I havn't. If this is not a problem for you then open.

At the moment I use the following code:

pol=sum([g.mod(P(y^{0}+y.format(1bits)))  for g in pol.monomials()])

Maybe it will help.

Best regards,
Oleksandr

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Modular operation in multivariate polynomials

2012-02-17 Thread Oleksandr Kazymyrov
Hi Simon,

I agree with you. My previous message is true only for GF(2^n).

Best regards,
Oleksandr

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Reserved words (Sage + Cython)

2012-02-17 Thread Oleksandr Kazymyrov
Hi All,

After upgrading from version 4.7.2 to 4.8, one function of dozen is stopped 
working. I use a combination of Sage + Cython. You can find examples in the 
attachments.

The main problem is: when you use PC as the function name in *.c file 
sage gives an error

/home/hamsin/bin/sage/local/lib/libcsage.so(print_backtrace+0x31)[0x7f3c8b89e3a3]
/home/hamsin/bin/sage/local/lib/libcsage.so(sigdie+0x14)[0x7f3c8b89e3d5]
/home/hamsin/bin/sage/local/lib/libcsage.so(sage_signal_handler+0x20e)[0x7f3c8b89e000]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x10060)[0x7f3c8dc93060]
/home/hamsin/bin/sage/local/lib/libreadline.so.6(PC+0x0)[0x7f3c861f83cc]


Unhandled SIGSEGV: A segmentation fault occurred in Sage.
This probably occurred because a *compiled* component of Sage has a bug
in it and is not properly wrapped with sig_on(), sig_off(). You might
want to run Sage under gdb with 'sage -gdb' to debug this.
Sage will now terminate.

local/bin/sage-sage: line 460: 10163 Segmentation fault  python $@

If I use PCc or PC_1, then there are no problems. So this is a bug, 
feature or Cython has limitations on function names. If the last point, 
then where I can see this limitations.

Best regards,
Oleksandr

Machine:
linux: Linux pcen 3.0.0-16-generic #28-Ubuntu SMP Fri Jan 27 17:44:39 UTC 
2012 x86_64 x86_64 x86_64 GNU/Linux
sage: 'Sage Version 4.8, Release Date: 2012-01-20'

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Cython_bad.tar.gz
Description: Binary data


Cython_good.tar.gz
Description: Binary data


[sage-support] Re: Reserved words (Sage + Cython)

2012-02-17 Thread Oleksandr Kazymyrov
Dear Simon,

 But the only difference between the good and the bad version is that some 
function is called PC in the bad file and PCc in the good file
Yes, exactly.

 However, Oleksandr: What is one supposed to do in order to reproduce the 
error? When I start a sage session and attach Main.sage, then it fails with 
both the bad and the good version.
You should replace:

if __name__ == __main__:
sys.exit(main())
by

main()

Or just run Main.sage from a shell (in this case, variable PATH should 
has a path to the sage directory, like this one 
PATH=/home/user/bin/sage/:$PATH). 

Best regards,
Oleksandr

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Modular operation in multivariate polynomials

2012-02-16 Thread Oleksandr Kazymyrov
Dear Simon,

 There is a difference between a polynomial (i.e., an element of a 
polynomial ring) and a polynomial function. Polynomials can be of arbitrary 
degree, over any coefficient field.

Yes I know this. But I think there is no difference between defining of 
PolynomialRing and PolynomialQuotientRing, assuming that you independently 
perform the operation by modulus. I am forcing the call of a function 
pol.mod(P(y^8+y)) to obtain the remainder by modulus. And I expect that 
monomial y^10*a2*b1^10*p5^2 will has degree 3 (y^3*a2*b1^10*p5^2) after 
operation pol.mod(P(y^8+y)) in the polynomial.

KInd regards,
Oleksandr

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org