API for crt_cartesion

15 views
Skip to first unread message

Chris Smith

unread,
Jan 22, 2020, 4:19:41 PM1/22/20
to sympy
There are several APIs for crt-like functions as described in the `crt` docstring:

  • crt(mod, rem)
  • gf_crt(rem, mod)
  • solve_congruence(*rem_mod_pairs)

There is a new function, `crt_cartesian` being introduced by this PR. e.g.

    >>> from sympy.ntheory.modular import crt_cartesian
   
>>> from sympy.utilities.iterables import cartes
   
>>> rem = [[3, 5], [3, 7]]
   
>>> crt_cartesian(rem, [7, 11])
     
[3, 73, 47, 40]
   
>>> [(p%7, p%11) for p in _]
   
[(3, 3), (3, 7), (5, 3), (5, 7)]
   
>>> assert _ == list(cartes(*rem))


 
Does anyone use such a calculation? Should the API of the new function be the same as `crt`? reversed? a dictionary of `{modulus m: list of residuals wrt modulus m}`? Should the output include the product of `mod` like crt does?

Aaron Meurer

unread,
Jan 22, 2020, 5:00:39 PM1/22/20
to sympy
I don't use crt very often and I can't speak to the usefulness of this
function, but it does seem odd to me that crt() has mod as the first
argument. I would expect it to be the second argument.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/b1f77e73-1fd5-4338-9776-beaf99be4bde%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages