On Fri, Oct 6, 2017 at 8:37 AM, Maarten Derickx <[email protected]
> wrote:

> I think the parent of the answer is not really the problem, but the actual
> code producing the answer:
>
> sage: R = GaussianIntegers()
>
> sage: R(*10*)//*7*
>
> 10/7
>
I would say that both are problems, but the current behavior is at least
somewhat sensible: just do normal division.

On the ticket, Jeroen proposed that the behavior should depend on whether
the order is norm-Euclidean.  If so, return the corresponding quotient; it
not, raise a TypeError.

Here's another suggestion.  In https://www.jstor.org/stable/2008732,
Kaltofen uses division chains with minimal remainder to compute gcds.  He
notes that using minimal remainder doesn't always terminate, but in some
sense it's the best you can do: if there is a division chain that
terminates, then a minimal remainder one does.  So, we could implement
quo_rem, _floordiv_, _mod_ and round (on the number field elements) to give
the result so that the remainder has the smallest possible norm.

Of course, there are still implementation details to be worked out.  :-)

On a related note:
sage: R = GaussianIntegers()
sage: R in EuclideanDomains()
False

David

>
> I agree with Jeroen his comment made on the trac ticket:
>
>> Well, the correct behaviour would be to do the right thing in the
>> imaginary quadratic orders which are naturally Euclidean and raise an
>> exception otherwise
>
>
>
> On Friday, 6 October 2017 04:41:20 UTC+2, David Roe wrote:
>>
>> As pointed out in #23971, the following is unexpected if you're used to
>> floor division in Z:
>>
>> sage: R = GaussianIntegers()
>> sage: (R(1)//1).parent()
>> Number Field in I with defining polynomial x^2 + 1
>>
>> For Gaussian integers, we can do better: there is a reasonable quo_rem
>> algorithm and R is norm-Euclidean.  But it's not clear to me what the right
>> thing to implement is, since most orders are not norm-Euclidean, and it
>> would be strange to have the meaning of floor division vary by number field.
>>
>> Any thoughts?  I do think that there is an expectation in Sage that the
>> parent of a//b is the same as the common parent of a and b, while a/b
>> changes the parent to the fraction field.
>> David
>>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-nt" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sage-nt.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-nt" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send an email to [email protected].
Visit this group at https://groups.google.com/group/sage-nt.
For more options, visit https://groups.google.com/d/optout.

Reply via email to