ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 06 May 2016 15:58:41 -0500Force positive representation in GFhttp://ask.sagemath.org/question/33327/force-positive-representation-in-gf/ I work with arbitrary finite field `GF(q)`, for `q` power of prime. I've been looking around for some function, which would force, that any element is printed as a positive natural number. i.e. in `GF(5)`, `-2` is printed as `3` etc. Is that possible in an easy way? I need to achieve that for arbitraty `q`. I've been thinking about writing some own function, but it seems intractable for me at the moment.Fri, 06 May 2016 08:50:31 -0500http://ask.sagemath.org/question/33327/force-positive-representation-in-gf/Comment by B r u n o for <p>I work with arbitrary finite field <code>GF(q)</code>, for <code>q</code> power of prime. I've been looking around for some function, which would force, that any element is printed as a positive natural number. i.e. in <code>GF(5)</code>, <code>-2</code> is printed as <code>3</code> etc. Is that possible in an easy way? I need to achieve that for arbitraty <code>q</code>. I've been thinking about writing some own function, but it seems intractable for me at the moment.</p>
http://ask.sagemath.org/question/33327/force-positive-representation-in-gf/?comment=33332#post-id-33332Oh, I think I was able to reproduce the behavior: Are you working with multivariate polynomials over `GF(5)`? This due to the fact that Sage uses Singular's string representation for those polynomials, which itself uses negative integers to represent finite fields elements. As far as I know, there is no way to make Sage represent these polynomials using only positive integers. Note though that if you have a polynomial `p`, `p.coefficients()` gives you the coefficients as positive integers. You can use this to construct your own string representation of the polynomial.Fri, 06 May 2016 15:58:41 -0500http://ask.sagemath.org/question/33327/force-positive-representation-in-gf/?comment=33332#post-id-33332Comment by AJey for <p>I work with arbitrary finite field <code>GF(q)</code>, for <code>q</code> power of prime. I've been looking around for some function, which would force, that any element is printed as a positive natural number. i.e. in <code>GF(5)</code>, <code>-2</code> is printed as <code>3</code> etc. Is that possible in an easy way? I need to achieve that for arbitraty <code>q</code>. I've been thinking about writing some own function, but it seems intractable for me at the moment.</p>
http://ask.sagemath.org/question/33327/force-positive-representation-in-gf/?comment=33329#post-id-33329Yep, for polynomials with coefficients in `GF(q)` The sage naturally decides to print the lower number, i.e. `-2` instead of `3` in case of `GF(5)`.Fri, 06 May 2016 11:17:14 -0500http://ask.sagemath.org/question/33327/force-positive-representation-in-gf/?comment=33329#post-id-33329Comment by B r u n o for <p>I work with arbitrary finite field <code>GF(q)</code>, for <code>q</code> power of prime. I've been looking around for some function, which would force, that any element is printed as a positive natural number. i.e. in <code>GF(5)</code>, <code>-2</code> is printed as <code>3</code> etc. Is that possible in an easy way? I need to achieve that for arbitraty <code>q</code>. I've been thinking about writing some own function, but it seems intractable for me at the moment.</p>
http://ask.sagemath.org/question/33327/force-positive-representation-in-gf/?comment=33328#post-id-33328Do have an example where this is not the case? In `GF(5)` for instance, I get:
sage : [e for e in GF(5)]
[0, 1, 2, 3, 4]Fri, 06 May 2016 09:32:13 -0500http://ask.sagemath.org/question/33327/force-positive-representation-in-gf/?comment=33328#post-id-33328