The reason for the output of 1 is just a pedantic one: 1+i and 2+i
are elements of a field: their parent is
sage: (1+i).parent()
Number Field in i with defining polynomial T^2 + 1
One can force the computation to take place in the ring of integers:
sage: R = K.ring_of_integers()
sage: a=R(1+i)
sage: b=R(2+2*i)
sage: gcd(a,b)
...
TypeError: unable to find gcd of i + 1 and 2*i + 2
since there's no gcd method for a:
sage: type(a)
<type 'sage.rings.number_field.number_field_element_quadratic.OrderElement_quadratic'>
sage: a.parent()
Maximal Order in Number Field in i with defining polynomial T^2 + 1
Possible fix: define a gcd function for elements of an order which
coerces into the field, constructs the ideal (as in David's solution),
tests if it is principal, returns a generator if it is and raises an
error only if it is not principal (which would be never for fields of
class number 1). Is that worth doing? In which case a trac ticket
could be opened. It seems an easy enough thing to implement, except
possibly for non-maximal orders.
John
>
> --
> You received this message because you are subscribed to the Google Groups "sage-nt" group.
> To post to this group, send an email to
sag...@googlegroups.com.
> To unsubscribe from this group, send email to
sage-nt+u...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/sage-nt?hl=en-GB.
>