At the expense of having to write the algorithm twice (once for additive groups, once for multiplicative groups, though one could wrap one in the other via a wrapper, or maybe being even more clever by swapping the tp_add and tp_mul function pointer slots in the type) I can't help but mention that Python/Cython already has a much more natural way of handling abstract groups than manually passing function pointers around. Specifically, a*b (or a+b) gives the group law, and ~a (or -a) the inverse, and the "one" which need only be computed once (then cached) should be available via G(1). Of course, this is really passing function pointers around in the background, but would be easier to follow.
I'll concede that if the group operations are *extremely* cheap the the overhead of two (rather than one) C function call might impact performance. I think a additive group -> multiplicative group wrapper could be written as to be very thin too. - Robert On Feb 13, 2008, at 2:22 PM, David Harvey wrote: > On Feb 13, 2008, at 5:09 PM, Nick Alexander wrote: > >> John also needs identity and inverses, which requires passing in >> three or functions. Or, more likely a struct, which in an OO >> language, I call an object. >> >> To me, that means you're writing a special purpose "abstract group" >> wrapper for discrete logs, which is fine. But I believe the heavier > > This would be great to have in sage. I wanted to work on something > like this in collaboration with Andrew Sutherland a few months back, > but that whole annoying thesis thing got in the way. Our idea was to > have the underlying abstract group algorithms (like computing > discrete logs, exponents of groups, orders of groups, group > structures etc) written in C++ with templates. Andrew has had a lot > of experience with this. One instantiation would be a black box using > C function pointers, which we could then plug into a cython class to > perform the arithmetic. > > david > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---