Function: chinese
Section: number_theoretical
C-Name: chinese
Prototype: GDG
Help: chinese(x,{y}): x,y being both intmods (or polmods) computes z in the
 same residue classes as x and y.
Description:
 (gen):gen      chinese1($1)
 (gen, gen):gen chinese($1, $2)
Doc: if $x$ and $y$ are both intmods or both polmods, creates (with the same
 type) a $z$ in the same residue class as $x$ and in the same residue class as
 $y$, if it is possible.
 \bprog
 ? chinese(Mod(1,2), Mod(2,3))
 %1 = Mod(5, 6)
 ? chinese(Mod(x,x^2-1), Mod(x+1,x^2+1))
 %2 = Mod(-1/2*x^2 + x + 1/2, x^4 - 1)
 @eprog\noindent
 This function also allows $p$-adics $p^v (u + O(p^d))$ of non-negative
 valuation $v$, converted to the obvious intmod $p^{v} u$ modulo $p^{v+d}$
 and $O(p^v)$ is converted to $0$ modulo $p^v$.
 \bprog
 ? chinese(1 + O(2), 2 + O(3))
 %3 = Mod(5, 6)
 @eprog\noindent
 Finally, we allow vector and matrix arguments of same dimensions,
 in which case the operation is recursively applied to each component
 of the vector or matrix.
 \bprog
 ? chinese([Mod(1,2),Mod(1,3)], [Mod(1,5),Mod(2,7)])
 %3 = [Mod(1, 10), Mod(16, 21)]
 ? M = mathilbert(3);
 ? chinese(Mod(M,7), Mod(M,11))
 %4 =
 [ Mod(1, 77) Mod(39, 77) Mod(26, 77)]

 [Mod(39, 77) Mod(26, 77) Mod(58, 77)]

 [Mod(26, 77) Mod(58, 77) Mod(31, 77)]
 @eprog\noindent
 For polynomial arguments in the same variable, the function is applied to each
 coefficient. If the polynomials have different degrees, the high degree terms
 are understood as $0$ modulo $N$ if the low degree terms are defined mod $N$:
 \bprog
  ? chinese((x+1)*Mod(1,2), (x^2+2*x+1)*Mod(1,3))
  %3 = Mod(4, 6)*x^2 + Mod(5, 6)*x + Mod(3, 6)
 @eprog

 If $y$ is omitted, and $x$ is a vector, \kbd{chinese} is applied recursively
 to the components of $x$, yielding a residue belonging to the same class as all
 components of $x$.

 Finally $\kbd{chinese}(x,x) = x$ regardless of the type of $x$; this allows
 vector arguments to contain other data, so long as they are identical in both
 vectors.
Variant: \fun{GEN}{chinese1}{GEN x} is also available.

Function: _polint_worker
Section: programming/internals
C-Name: nmV_polint_center_tree_worker
Prototype: GGGGG
Help: used for parallel chinese
Doc: used for parallel chinese

Function: _nxMV_polint_worker
Section: programming/internals
C-Name: nxMV_polint_center_tree_worker
Prototype: GGGGG
Help: used for parallel chinese
Doc: used for parallel chinese
