factor.tst 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. COMMENT FACTORIZER TEST FILE;
  2. ARRAY A(20),B(20);
  3. FACTORIZE(X**2-1,A); %To make sure factorizer is loaded;
  4. SYMBOLIC RANDOMIZE(); %To set RANDOM-SEED. This can be set direct if
  5. %deterministic behavior is required.
  6. ALGEBRAIC PROCEDURE TEST(PROB,NFAC);
  7. BEGIN
  8. SCALAR BASETIME;
  9. P := FOR I:=1:NFAC PRODUCT A(I);
  10. WRITE "Problem number ",PROB;
  11. LISP BASETIME := TIME();
  12. LISP PRIN2T LIST("The random seed is",RANDOM!-SEED);
  13. M := FACTORIZE(P, B);
  14. LISP BASETIME := TIME() - BASETIME;
  15. LISP LPRI LIST("Time =",BASETIME);
  16. LISP TERPRI();
  17. Q := FOR I:=0:M PRODUCT B(I);
  18. IF (M=NFAC) AND (P=Q) THEN RETURN OK;
  19. WRITE "This example failed";
  20. FOR I:=0:M DO WRITE B(I);
  21. RETURN FAILED
  22. END;
  23. % Wang test case 1;
  24. A(1) := X*Y+Z+10$
  25. A(2) := X*Z+Y+30$
  26. A(3) := X+Y*Z+20$
  27. TEST(1,3);
  28. % Wang test case 2;
  29. A(1) := X**3*Z+X**3*Y+Z-11$
  30. A(2) := X**2*Z**2+X**2*Y**2+Y+90$
  31. TEST(2,2);
  32. % Wang test case 3;
  33. A(1) := X**3*Y**2+X*Z**4+X+Z$
  34. A(2) := X**3+X*Y*Z+Y**2+Y*Z**3$
  35. TEST(3,2);
  36. % Wang test case 4;
  37. A(1) := X**2*Z+Y**4*Z**2+5$
  38. A(2) := X*Y**3+Z**2$
  39. A(3) := -X**3*Y+Z**2+3$
  40. A(4) := X**3*Y**4+Z**2$
  41. TEST(4,4);
  42. % Wang test case 5;
  43. A(1) := 3*U**2*X**3*Y**4*Z+X*Z**2+Y**2*Z**2+19*Y**2$
  44. A(2) := U**2*Y**4*Z**2+X**2*Z+5$
  45. A(3) := U**2+X**3*Y**4+Z**2$
  46. TEST(5,3);
  47. % Wang test case 6;
  48. A(1) := W**4*X**5*Y**6-W**4*Z**3+W**2*X**3*Y+X*Y**2*Z**2$
  49. A(2) := W**4*Z**6-W**3*X**3*Y-W**2*X**2*Y**2*Z**2+X**5*Z
  50. -X**4*Y**2+Y**2*Z**3$
  51. A(3) := -X**5*Z**3+X**2*Y**3+Y*Z$
  52. TEST(6,3);
  53. % Wang test case 7;
  54. A(1) := X+Y+Z-2$
  55. A(2) := X+Y+Z-2$
  56. A(3) := X+Y+Z-3$
  57. A(4) := X+Y+Z-3$
  58. A(5) := X+Y+Z-3$
  59. TEST(7,5);
  60. % Wang test case 8;
  61. A(1) := -Z**31-W**12*Z**20+Y**18-Y**14+X**2*Y**2+X**21+W**2$
  62. A(2) := -15*Y**2*Z**16+29*W**4*X**12*Z**3+21*X**3*Z**2+3*W**15*Y**20$
  63. TEST(8,2);
  64. % Wang test case 9;
  65. A(1) := 18*U**2*W**3*X*Z**2+10*U**2*W*X*Y**3+15*U*Z**2+6*W**2*Y**3*Z**2$
  66. A(2) := X$
  67. A(3) := 25*U**2*W**3*Y*Z**4+32*U**2*W**4*Y**4*Z**3-
  68. 48*U**2*X**2*Y**3*Z**3-2*U**2*W*X**2*Y**2+44*U*W*X*Y**4*Z**4-
  69. 8*U*W*X**3*Z**4+4*W**2*X+11*W**2*X**3*Y+12*Y**3*Z**2$
  70. A(4) := Z$
  71. A(5) := Z$
  72. A(6) := U$
  73. A(7) := U$
  74. A(8) := U$
  75. A(9) := U$
  76. TEST(9,9);
  77. % Wang test case 10;
  78. A(1) := 31*U**2*X*Z+35*W**2*Y**2+40*W*X**2+6*X*Y$
  79. A(2) := 42*U**2*W**2*Y**2+47*U**2*W**2*Z+22*U**2*W**2+9*U**2*W*X**2+21
  80. *U**2*W*X*Y*Z+37*U**2*Y**2*Z+U**2*W**2*X*Y**2*Z**2+8*U**2*W**2
  81. *Z**2+24*U**2*W*X*Y**2*Z**2+24*U**2*X**2*Y*Z**2+12*U**2*X*Y**2
  82. *Z**2+13*U*W**2*X**2*Y**2+27*U*W**2*X**2*Y+39*U*W*X*Z+43*U*
  83. X**2*Y+44*U*W**2* Z**2+37*W**2*X*Y+29*W**2*Y**2+31*W**2*Y*Z**2
  84. +12*W*X**2*Y*Z+43*W*X*Y*Z**2+22*X*Y**2+23*X*Y*Z+24*X*Y+41*Y**2
  85. *Z$
  86. TEST(10,2);
  87. % Wang test case 11;
  88. A(1) := -36*U**2*W**3*X*Y*Z**3-31*U**2*W**3*Y**2+20*U**2*W**2*X**2*Y**2
  89. *Z**2-36*U**2*W*X*Y**3*Z+46*U**2*W*X+9*U**2*Y**2-36*U*W**2*Y**3
  90. +9*U*W*Y**3-5*U*W*X**2*Y**3+48*U*W*X**3*Y**2*Z+23*U*W*X**3*Y**2
  91. -43*U*X**3*Y**3*Z**3-46*U*X**3*Y**2+29*W**3*X*Y**3*Z**2-
  92. 14*W**3*X**3*Y**3*Z**2-45*X**3-8*X*Y**2$
  93. A(2) := 13*U**3*W**2*X*Y*Z**3-4*U*X*Y**2-W**3*Z**3-47*X*Y$
  94. A(3) := X$
  95. A(4) := Y$
  96. TEST(11,4);
  97. % Wang test case 12;
  98. A(1) := X+Y+Z-3$
  99. A(2) := X+Y+Z-3$
  100. A(3) := X+Y+Z-3$
  101. TEST(12,3);
  102. % Wang test case 13;
  103. A(1) := 2*W*Z+45*X**3-9*Y**3-Y**2+3*Z**3$
  104. A(2) := W**2*Z**3-W**2+47*X*Y$
  105. TEST(13,2);
  106. % Wang test case 14;
  107. A(1) := 18*X**4*Y**5+41*X**4*Y**2-37*X**4+26*X**3*Y**4+38*X**2*Y**4-29*
  108. X**2*Y**3-22*Y**5$
  109. A(2) := 33*X**5*Y**6-22*X**4+35*X**3*Y+11*Y**2$
  110. TEST(14,2);
  111. % Wang test case 15;
  112. A(1) := 12*W**2*X*Y*Z**3-W**2*Z**3+W**2-29*X-3*X*Y**2$
  113. A(2) := 14*W**2*Y**2+2*W*Z+18*X**3*Y-8*X*Y**2-Y**2+3*Z**3$
  114. A(3) := Z$
  115. A(4) := Z$
  116. A(5) := Y$
  117. A(6) := Y$
  118. A(7) := Y$
  119. A(8) := X$
  120. A(9) := X$
  121. A(10) := X$
  122. A(11) := X$
  123. A(12) := X$
  124. A(13) := X$
  125. TEST(15,13);
  126. % Test 16 - the 40th degree polynomial that comes from
  127. % SIGSAM problem number 7;
  128. A(1) := 8192*Y**10+20480*Y**9+58368*Y**8-161792*Y**7+198656*Y**6+
  129. 199680*Y**5-414848*Y**4-4160*Y**3+171816*Y**2-48556*Y+469$
  130. A(2) := 8192*Y**10+12288*Y**9+66560*Y**8-22528*Y**7-138240*Y**6+
  131. 572928*Y**5-90496*Y**4-356032*Y**3+113032*Y**2+23420*Y-8179$
  132. A(3) := 4096*Y**10+8192*Y**9+1600*Y**8-20608*Y**7+20032*Y**6+87360*Y**5-
  133. 105904*Y**4+18544*Y**3+11888*Y**2-3416*Y+1$
  134. A(4) := 4096*Y**10+8192*Y**9-3008*Y**8-30848*Y**7+21056*Y**6+146496*
  135. Y**5-221360*Y**4+1232*Y**3+144464*Y**2-78488*Y+11993$
  136. TEST(16,4);
  137. % Test 17 - taken from Erich Kaltofen's thesis. This polynomial
  138. % splits mod all possible primes p;
  139. A(1) := X**25-25*X**20-3500*X**15-57500*X**10+21875*X**5-3125$
  140. TEST(17,1);
  141. % Test 18 - another 'hard-to-factorize' univariate;
  142. A(1) := X**18+9*X**17+45*X**16+126*X**15+189*X**14+27*X**13-
  143. 540*X**12-1215*X**11+1377*X**10+15444*X**9+46899*X**8+
  144. 90153*X**7+133893*X**6+125388*X**5+29160*X**4-
  145. 32076*X**3+26244*X**2-8748*X+2916$
  146. TEST(18,1);
  147. % Test 19 - another example chosen to lead to false splits mod p;
  148. A(1) := X**16+4*X**12-16*X**11+80*X**9+2*X**8+160*X**7+
  149. 128*X**6-160*X**5+28*X**4-48*X**3+128*X**2-16*X+1$
  150. A(2) := X**16+4*X**12+16*X**11-80*X**9+2*X**8-160*X**7+
  151. 128*X**6+160*X**5+28*X**4+48*X**3+128*X**2+16*X+1$
  152. TEST(19,2);
  153. % End of all tests;
  154. END;