On 23 October 2016 at 15:28, vdelecroix <
20100.d...@gmail.com> wrote:
> Le dimanche 23 octobre 2016 16:20:25 UTC+2, John Cremona a écrit :
>>
>> I see that despite the title of that ticket, this is (at present)
>> about r%n when r =p/q is rational.
>
>
> The ticket also cares about the case where n is rational. Moreover my
> proposed branch makes % part of the coercion system (when one of the
> argument is rational). So standard coercion rules apply.
OK
>
> However, concerning this thread, my question is about r%n with r=p/q being
> rational.
>
>> Questions:
>>
>> 1. What is the proposed behaviour when q is not invertible modulo n?
>> Or more generally, if q*x=p (mod n) has no solutions, or more than
>> one solution (mod n)?
>
>
> The very same behavior as with the two implementation I proposed. In other
> words, raise the same errors as inverse_mod does when it complains.
OK and this should be documented somehow, though I'm not sure how to
document the behaviour of operators.
>
> Concerning the non-uniqueness, it is just a matter of having an extra
> argument to inverse_mod on integers and using it here. Do you think it might
> be useful?
No, anyone wanting all solutions would be able to get them a different way.
>
>>
>> 2. Is the output going to be an element of Z/nZ, or of Z (as your
>> sample code suggests)?
>
>
> I was thinking about Z since for Z/nZ the direct conversion just works
> Zmod(n)(r).
That's reasonable, and what people would expect with an operator such as %.
thanks for the answers. As for you question, do we need a name to
shadow the operator %? If we do, then "mod"?