@@ -268,6 +268,43 @@ TEST_FUNCTION_START(nmod_mpoly_gcd_cofactors, state)
268268 const slong max_threads = 5 ;
269269 slong i , j , k , tmul = 3 ;
270270
271+ /* issue #2581: the LINZIP scale system in gcds_zippel was generically
272+ underdetermined for these inputs and the evaluation-point retry loop
273+ effectively never terminated */
274+ {
275+ nmod_mpoly_ctx_t ctx ;
276+ nmod_mpoly_t g , a , b , t ;
277+ nmod_mpoly_t abar , bbar ;
278+ const char * vars [] = {"l1" , "l2" , "l3" , "a1" , "a2" , "a3" ,
279+ "b1" , "b2" , "b3" , "g1" , "g2" , "g3" };
280+
281+ nmod_mpoly_ctx_init (ctx , 12 , ORD_LEX , UWORD (2147483647 ));
282+ nmod_mpoly_init (g , ctx );
283+ nmod_mpoly_init (a , ctx );
284+ nmod_mpoly_init (b , ctx );
285+ nmod_mpoly_init (t , ctx );
286+ nmod_mpoly_init (abar , ctx );
287+ nmod_mpoly_init (bbar , ctx );
288+
289+ nmod_mpoly_set_str_pretty (t , "l1*a2-l1*a3-l2*a1+l2*a3+l3*a1-l3*a2" , vars , ctx );
290+ nmod_mpoly_set_str_pretty (a , "(b1*g2*g3+b2*g1*g3+b3*g1*g2)^2" , vars , ctx );
291+ nmod_mpoly_set_str_pretty (b , "a1*b1^2*g2^3*g3 + a1*b1^2*g2*g3^3 + 2*a1*b1*b2*g1*g2^2*g3 + 2*a1*b1*b2*g1*g3^3 + 2*a1*b1*b3*g1*g2^3 + 2*a1*b1*b3*g1*g2*g3^2 + a1*b2^2*g1^2*g2*g3 + a1*b2^2*g2*g3^3 + a1*b2*b3*g1^2*g2^2 + a1*b2*b3*g1^2*g3^2 + 2*a1*b2*b3*g2^2*g3^2 + a1*b3^2*g1^2*g2*g3 + a1*b3^2*g2^3*g3 - a2*b1^2*g2*g3^3 - 2*a2*b1*b2*g1*g3^3 - 2*a2*b1*b3*g1*g2*g3^2 - a2*b2^2*g2*g3^3 + a2*b2*b3*g1^2*g2^2 - 2*a2*b2*b3*g1^2*g3^2 - a2*b2*b3*g2^2*g3^2 - a2*b3^2*g1^2*g2*g3 - a3*b1^2*g2^3*g3 - 2*a3*b1*b2*g1*g2^2*g3 - 2*a3*b1*b3*g1*g2^3 - a3*b2^2*g1^2*g2*g3 - 2*a3*b2*b3*g1^2*g2^2 + a3*b2*b3*g1^2*g3^2 - a3*b2*b3*g2^2*g3^2 - a3*b3^2*g2^3*g3" , vars , ctx );
292+ nmod_mpoly_mul (a , a , t , ctx );
293+ nmod_mpoly_mul (a , a , t , ctx );
294+ nmod_mpoly_mul (b , b , t , ctx );
295+
296+ gcd_check (g , abar , bbar , a , b , t , ctx , 0 , 0 , "issue 2581" );
297+
298+ nmod_mpoly_clear (g , ctx );
299+ nmod_mpoly_clear (a , ctx );
300+ nmod_mpoly_clear (b , ctx );
301+ nmod_mpoly_clear (t , ctx );
302+ nmod_mpoly_clear (abar , ctx );
303+ nmod_mpoly_clear (bbar , ctx );
304+ nmod_mpoly_ctx_clear (ctx );
305+ }
306+
307+
271308 {
272309 nmod_mpoly_ctx_t ctx ;
273310 nmod_mpoly_t g , abar , bbar , a , b , t ;
0 commit comments