[sage-devel] Re: hyperelliptic curve constructor question
What the code does is to assign PP to a suitable projective space. I imagine that the intention was for the user to provide the ambient space if they had it handy, so that assignment should be wrapped in if PP is None:. John 2009/3/16 dmharvey dmhar...@cims.nyu.edu: Hi, The constructor for hyperelliptic curves has the following signature: def HyperellipticCurve(f,h=None,names=None,PP=None) but the code doesn't seem to use the PP parameter anywhere, and there are no examples of its use in the docstring. In fact the first thing the code does with PP is overwrite it. Does anyone know what its purpose is? Should it be removed? david --~--~-~--~~~---~--~~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-devel] Re: hyperelliptic curve constructor question
I'm worried when you say that the whole schemes directory is being scrubbed, since this could either mean thoroughly cleaned up to it is sparklingly clean and beautiful or deleted, erased completely as in a well-used blackboard. I assume the former ;) but would appreciate it if some of the planning for this was done in the open, e.g. on sage-nt, since I had no idea that it was happening. John 2009/3/16 Alex Ghitza aghi...@gmail.com: Hi David, On Mon, Mar 16, 2009 at 1:12 PM, David Harvey dmhar...@cims.nyu.edu wrote: Ah. The reason I asked is that various people have requested that I write a better wrapper for my hypellfrob library in Sage, and I was about to try doing that. I thought it should be some kind of method frobenius_charpoly or something attached to a hyperelliptic curve object, and I was trying to find out what already existed. The count_points and zeta_series interfaces don't seem quite right for this. But if you guys are working heavily on that code now, perhaps you can tell me where the code should go, and I can put up a patch, which you might need to merge if things change too much in the meantime. I'm very happy you're wrapping hypellfrob in Sage. I agree with Justin's suggestion that you should just attach it to the existing hyperelliptic code in whatever way is most convenient to you. If in the course of refactoring that code we need to make some changes to what you did, we'll deal with that there and then. And please open tickets if you run into stupid stuff along the way. We'll try to get issues fixes as we go along. Best, Alex david -- Alex Ghitza -- Lecturer in Mathematics -- The University of Melbourne -- Australia -- http://www.ms.unimelb.edu.au/~aghitza/ --~--~-~--~~~---~--~~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-devel] Re: hyperelliptic curve constructor question
Awesome! Looks like your patch is a little more comprehensive than what I was planning, I might pick and choose a bit :-) david On Mar 15, 11:09 pm, Nick Alexander ncalexan...@gmail.com wrote: My wrapper that I never got around to submitting... Nick frobenius.py 10KViewDownload On 15-Mar-09, at 7:59 PM, Alex Ghitza wrote: Hi David, On Mon, Mar 16, 2009 at 1:12 PM, David Harvey dmhar...@cims.nyu.edu wrote: Ah. The reason I asked is that various people have requested that I write a better wrapper for my hypellfrob library in Sage, and I was about to try doing that. I thought it should be some kind of method frobenius_charpoly or something attached to a hyperelliptic curve object, and I was trying to find out what already existed. The count_points and zeta_series interfaces don't seem quite right for this. But if you guys are working heavily on that code now, perhaps you can tell me where the code should go, and I can put up a patch, which you might need to merge if things change too much in the meantime. I'm very happy you're wrapping hypellfrob in Sage. I agree with Justin's suggestion that you should just attach it to the existing hyperelliptic code in whatever way is most convenient to you. If in the course of refactoring that code we need to make some changes to what you did, we'll deal with that there and then. And please open tickets if you run into stupid stuff along the way. We'll try to get issues fixes as we go along. Best, Alex david --~--~-~--~~~---~--~~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-devel] Re: hyperelliptic curve constructor question
On Mar 16, 2009, at 3:04 AM, John Cremona wrote: I'm worried when you say that the whole schemes directory is being scrubbed, since this could either mean thoroughly cleaned up to it is sparklingly clean and beautiful or deleted, erased completely as in a well-used blackboard. I assume the former ;) but would appreciate it if some of the planning for this was done in the open, e.g. on sage-nt, since I had no idea that it was happening. You assumption is correct. It will be sparkly clean, with chewy, choclatey goodness in every bite. When the job's complete, of course :-} The topic was broached on the SD14 wiki (see http://wiki.sagemath.org/days14/projects ). The first steps involve understanding what's there, since the code tends to be skeletal and lacking docstrings/tests. This isn't a secret exercise, but right now, we're in the exploratory phase. The planning phase is for later. Alex may have more to add. Justin -- Justin C. Walker, Curmudgeon at Large Institute for the Absorption of Federal Funds --- Like the ski resort full of girls hunting for husbands and husbands hunting for girls, the situation is not as symmetrical as it might seem. - Alan MacKay -- --~--~-~--~~~---~--~~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-devel] Re: hyperelliptic curve constructor question
Thanks, Justin. I wish I could have been there! John 2009/3/16 Justin Walker jus...@mac.com: On Mar 16, 2009, at 3:04 AM, John Cremona wrote: I'm worried when you say that the whole schemes directory is being scrubbed, since this could either mean thoroughly cleaned up to it is sparklingly clean and beautiful or deleted, erased completely as in a well-used blackboard. I assume the former ;) but would appreciate it if some of the planning for this was done in the open, e.g. on sage-nt, since I had no idea that it was happening. You assumption is correct. It will be sparkly clean, with chewy, choclatey goodness in every bite. When the job's complete, of course :-} The topic was broached on the SD14 wiki (see http://wiki.sagemath.org/days14/projects ). The first steps involve understanding what's there, since the code tends to be skeletal and lacking docstrings/tests. This isn't a secret exercise, but right now, we're in the exploratory phase. The planning phase is for later. Alex may have more to add. Justin -- Justin C. Walker, Curmudgeon at Large Institute for the Absorption of Federal Funds --- Like the ski resort full of girls hunting for husbands and husbands hunting for girls, the situation is not as symmetrical as it might seem. - Alan MacKay -- --~--~-~--~~~---~--~~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-devel] Re: hyperelliptic curve constructor question
On Mar 16, 2009, at 3:04 AM, John Cremona wrote: I'm worried when you say that the whole schemes directory is being scrubbed, since this could either mean thoroughly cleaned up to it is sparklingly clean and beautiful or deleted, erased completely as in a well-used blackboard. I assume the former ;) but would appreciate it if some of the planning for this was done in the open, e.g. on sage-nt, since I had no idea that it was happening. You assumption is correct. It will be sparkly clean, with chewy, choclatey goodness in every bite. When the job's complete, of course :-} The topic was broached on the SD14 wiki (see http://wiki.sagemath.org/days14/projects ). The first steps involve understanding what's there, since the code tends to be skeletal and lacking docstrings/tests. This isn't a secret exercise, but right now, we're in the exploratory phase. The planning phase is for later. Alex may have more to add. Justin -- Justin C. Walker, Curmudgeon at Large Institute for the Absorption of Federal Funds --- Like the ski resort full of girls hunting for husbands and husbands hunting for girls, the situation is not as symmetrical as it might seem. - Alan MacKay -- --~--~-~--~~~---~--~~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-devel] Re: hyperelliptic curve constructor question
Hi, David, On Mar 15, 2009, at 6:54 PM, dmharvey wrote: The constructor for hyperelliptic curves has the following signature: def HyperellipticCurve(f,h=None,names=None,PP=None) but the code doesn't seem to use the PP parameter anywhere, and there are no examples of its use in the docstring. In fact the first thing the code does with PP is overwrite it. Does anyone know what its purpose is? Should it be removed? The short answer is: we're working on it (as a part of an SD14 project). The whole schemes directory is being scrubbed (and of course, it takes time to figure out what is intended, before cleaning it up). Trac items will appear in due course, but if you find something, feel free to create a Trac report for it. Add any information you feel is useful (including patches :-}). There isn't much of a long answer right now -} Justin -- Justin C. Walker, Curmudgeon-At-Large Institute for the Enhancement of the Director's Income Experience is what you get when you don't get what you want. --~--~-~--~~~---~--~~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-devel] Re: hyperelliptic curve constructor question
On Mar 15, 10:00 pm, Justin Walker jus...@mac.com wrote: The short answer is: we're working on it (as a part of an SD14 project). The whole schemes directory is being scrubbed (and of course, it takes time to figure out what is intended, before cleaning it up). Trac items will appear in due course, but if you find something, feel free to create a Trac report for it. Add any information you feel is useful (including patches :-}). There isn't much of a long answer right now -} Justin Ah. The reason I asked is that various people have requested that I write a better wrapper for my hypellfrob library in Sage, and I was about to try doing that. I thought it should be some kind of method frobenius_charpoly or something attached to a hyperelliptic curve object, and I was trying to find out what already existed. The count_points and zeta_series interfaces don't seem quite right for this. But if you guys are working heavily on that code now, perhaps you can tell me where the code should go, and I can put up a patch, which you might need to merge if things change too much in the meantime. (This is also related to my unanswered question on sage-devel a few days ago about characteristic polynomials of p-adic matrices, but I know how to work around that bug.) david --~--~-~--~~~---~--~~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-devel] Re: hyperelliptic curve constructor question
Alex Ghitza might have some comments to add to this. On Mar 15, 2009, at 7:12 PM, David Harvey wrote: On Mar 15, 10:00 pm, Justin Walker jus...@mac.com wrote: The short answer is: we're working on it (as a part of an SD14 project). The whole schemes directory is being scrubbed (and of course, it takes time to figure out what is intended, before cleaning it up). Trac items will appear in due course, but if you find something, feel free to create a Trac report for it. Add any information you feel is useful (including patches :-}). There isn't much of a long answer right now -} Justin Ah. The reason I asked is that various people have requested that I write a better wrapper for my hypellfrob library in Sage, and I was about to try doing that. No reason to stop. As you observe, much work is needed there. The generic directory has the sparsest content, and for those of us arriving late to the party, the intended structure is only dimly perceived. I thought it should be some kind of method frobenius_charpoly or something attached to a hyperelliptic curve object, and I was trying to find out what already existed. The count_points and zeta_series interfaces don't seem quite right for this. But if you guys are working heavily on that code now, perhaps you can tell me where the code should go, and I can put up a patch, which you might need to merge if things change too much in the meantime. Working heavily is overstating it. There were several people looking at the schemes directory during SD14, but there was not much progress. Most of the work was in the scratching of heads... Feel free to add your patch. (This is also related to my unanswered question on sage-devel a few days ago about characteristic polynomials of p-adic matrices, but I know how to work around that bug.) :-} Justin -- Justin C. Walker, Curmudgeon at Large Institute for the Absorption of Federal Funds --- Like the ski resort full of girls hunting for husbands and husbands hunting for girls, the situation is not as symmetrical as it might seem. - Alan MacKay -- --~--~-~--~~~---~--~~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-devel] Re: hyperelliptic curve constructor question
Hi David, On Mon, Mar 16, 2009 at 1:12 PM, David Harvey dmhar...@cims.nyu.edu wrote: Ah. The reason I asked is that various people have requested that I write a better wrapper for my hypellfrob library in Sage, and I was about to try doing that. I thought it should be some kind of method frobenius_charpoly or something attached to a hyperelliptic curve object, and I was trying to find out what already existed. The count_points and zeta_series interfaces don't seem quite right for this. But if you guys are working heavily on that code now, perhaps you can tell me where the code should go, and I can put up a patch, which you might need to merge if things change too much in the meantime. I'm very happy you're wrapping hypellfrob in Sage. I agree with Justin's suggestion that you should just attach it to the existing hyperelliptic code in whatever way is most convenient to you. If in the course of refactoring that code we need to make some changes to what you did, we'll deal with that there and then. And please open tickets if you run into stupid stuff along the way. We'll try to get issues fixes as we go along. Best, Alex david -- Alex Ghitza -- Lecturer in Mathematics -- The University of Melbourne -- Australia -- http://www.ms.unimelb.edu.au/~aghitza/ --~--~-~--~~~---~--~~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~--~~~~--~~--~--~---
[sage-devel] Re: hyperelliptic curve constructor question
My wrapper that I never got around to submitting... Nick --~--~-~--~~~---~--~~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~--~~~~--~~--~--~--- # -*- sage -*- def _frobenius_coefficient_bounds(self): # Bound from Weil conjectures, via Kedlaya's paper: # | a_i | = (2g choose i) * q**(i/2) p = self.base_ring().characteristic() # XXX higher degree sqrtp = RR(p).sqrt() g = self.genus() Bs = [] for i in range(2*g + 1): B = 2 * binomial(2*g, i) * sqrtp**i Bs.append(ZZ(ceil(B))) Bs.reverse() return Bs def _frobenius_coefficient_bound(self): assert self.base_ring().is_finite() p = self.base_ring().characteristic() # XXX higher degree Bs = self._frobenius_coefficient_bounds() M = ZZ(max(Bs)) B = M.exact_log(p) if p**B M: B += 1 assert p**B = M # B += 2*self.genus() return B # XXX def frobenius_matrix(self, N=None): from sage.schemes.hyperelliptic_curves.hypellfrob import hypellfrob p = self.base_ring().characteristic() f, h = self.hyperelliptic_polynomials() if h != 0: # need y^2 = f(x) raise NotImplementedError sign = 1 if not f.is_monic(): # at this time we need a monic f c = f.leading_coefficient() f = f / c if c.is_square(): # solutions of $y^2 = c * f(x)$ correspond naturally to solutions of # $(sqrt(c) y)^2 = f(x)$ pass else: # we'll count points on a twist and then correct by untwisting... sign = -1 if not f.is_monic(): raise NotImplementedError if N is None: N = self._frobenius_coefficient_bound() matrix_of_frobenius = hypellfrob(p, N, f) matrix_of_frobenius = sign * matrix_of_frobenius return matrix_of_frobenius def cnt(Hbar, kbar=None): if kbar is None: kbar = Hbar.base_ring() f = Hbar.hyperelliptic_polynomials()[0] cnt = 1 # pt at \infty for x in kbar: c = f(x) if c == 0: cnt += 1 elif c.is_square(): cnt += 2 return cnt def frobenius_polynomial_r(Hbar): g = Hbar.genus() kbar = Hbar.base_ring() q = kbar.order() e = SFAElementary(QQ) p = SFAPower(QQ) P = [0] * (g+1) P[1] = q + 1 - cnt(Hbar) for i in range(2, g+1): # N_k = q^k + 1 - \sum_{i=1}^{2 g} \alpha_i^k . kbar2 = GF(ZZ(kbar.order())**i, 'a') P[i] = q**i + 1 - cnt(Hbar, kbar2) A = [0] * (2*g+1) A[0] = 1 for i in range(1, g+1): f = p(e([i])) # express coefficient of frob poly in terms of power basis A[i] = sum( coeff*prod(P[mon] for mon in mons) for mons, coeff in f.monomial_coefficients().items()) for i in range(0, g+1): # a_{2 g - i} = q^{g - i} a_i for i = 0, \ldots, g. A[2*g - i] = q**(g - i) * A[i] return QQ['x'](ZZ['x'](A).reverse()(-ZZ['x'].gen())) def frobenius_polynomial(self, N=None): if N is None: N = self._frobenius_coefficient_bound() try: p = self.frobenius_matrix(N=N).charpoly() except ValueError: return frobenius_polynomial_r(self) try: Bs = self._frobenius_coefficient_bounds() cs = [] for c, B in zip(p.coeffs(), Bs): d = ZZ(c) if d B: d = -ZZ(-c) assert abs(d) = B cs.append(d) return ZZ['x'](cs) except: return self.frobenius_polynomial(2*N) # otherwise increase precision def frobenius_order(self): f = self.frobenius_polynomial().factor()[0][0] return ZZ.extension(f, names='phi') def frobenius(self): return self.frobenius_order().fraction_field().gen() def _reduce(self, P): return self.change_ring(self.base_ring().residue_field(P)) sage.schemes.hyperelliptic_curves.hyperelliptic_generic.HyperellipticCurve_generic._frobenius_coefficient_bounds = _frobenius_coefficient_bounds sage.schemes.hyperelliptic_curves.hyperelliptic_generic.HyperellipticCurve_generic._frobenius_coefficient_bound = _frobenius_coefficient_bound sage.schemes.hyperelliptic_curves.hyperelliptic_generic.HyperellipticCurve_generic.frobenius_matrix = frobenius_matrix sage.schemes.hyperelliptic_curves.hyperelliptic_generic.HyperellipticCurve_generic.frobenius_polynomial = frobenius_polynomial sage.schemes.hyperelliptic_curves.hyperelliptic_generic.HyperellipticCurve_generic.frobenius_order = frobenius_order sage.schemes.hyperelliptic_curves.hyperelliptic_generic.HyperellipticCurve_generic.frobenius = frobenius sage.schemes.hyperelliptic_curves.hyperelliptic_generic.HyperellipticCurve_generic.mod = _reduce # sage: x = QQ['x'].0 # sage: f = x^7 + 143*x^6 + 41*x^5