001 /* 002 * $Id: HenselMultUtilTest.java 3725 2011-08-05 15:47:41Z kredel $ 003 */ 004 005 package edu.jas.ufd; 006 007 008 import java.util.ArrayList; 009 import java.util.List; 010 011 import org.apache.log4j.BasicConfigurator; 012 013 import junit.framework.Test; 014 import junit.framework.TestCase; 015 import junit.framework.TestSuite; 016 017 import edu.jas.arith.PrimeList; 018 import edu.jas.arith.BigInteger; 019 import edu.jas.arith.ModInteger; 020 import edu.jas.arith.ModIntegerRing; 021 import edu.jas.arith.ModLong; 022 import edu.jas.arith.ModLongRing; 023 import edu.jas.arith.ModularRingFactory; 024 import edu.jas.structure.Power; 025 import edu.jas.kern.ComputerThreads; 026 import edu.jas.poly.ExpVector; 027 import edu.jas.poly.GenPolynomial; 028 import edu.jas.poly.GenPolynomialRing; 029 import edu.jas.poly.PolyUtil; 030 import edu.jas.poly.TermOrder; 031 //import edu.jas.application.Ideal; 032 //import edu.jas.application.Residue; 033 //import edu.jas.application.ResidueRing; 034 035 036 /** 037 * HenselMultUtil tests with JUnit. 038 * Two seperate classes because of package dependency. 039 * @see edu.jas.application.HenselMultUtilTest 040 * @author Heinz Kredel. 041 */ 042 043 public class HenselMultUtilTest extends TestCase { 044 045 046 /** 047 * main. 048 */ 049 public static void main(String[] args) { 050 BasicConfigurator.configure(); 051 junit.textui.TestRunner.run(suite()); 052 ComputerThreads.terminate(); 053 } 054 055 056 /** 057 * Constructs a <CODE>HenselMultUtilTest</CODE> object. 058 * @param name String. 059 */ 060 public HenselMultUtilTest(String name) { 061 super(name); 062 } 063 064 065 /** 066 */ 067 public static Test suite() { 068 TestSuite suite = new TestSuite(HenselMultUtilTest.class); 069 return suite; 070 } 071 072 073 TermOrder tord = new TermOrder(TermOrder.INVLEX); 074 075 076 GenPolynomialRing<BigInteger> dfac; 077 078 079 GenPolynomialRing<BigInteger> cfac; 080 081 082 GenPolynomialRing<GenPolynomial<BigInteger>> rfac; 083 084 085 BigInteger ai; 086 087 088 BigInteger bi; 089 090 091 BigInteger ci; 092 093 094 BigInteger di; 095 096 097 BigInteger ei; 098 099 100 GenPolynomial<BigInteger> a; 101 102 103 GenPolynomial<BigInteger> b; 104 105 106 GenPolynomial<BigInteger> c; 107 108 109 GenPolynomial<BigInteger> d; 110 111 112 GenPolynomial<BigInteger> e; 113 114 115 int rl = 2; 116 117 118 int kl = 5; 119 120 121 int ll = 5; 122 123 124 int el = 3; 125 126 127 float q = 0.3f; 128 129 130 @Override 131 protected void setUp() { 132 a = b = c = d = e = null; 133 ai = bi = ci = di = ei = null; 134 dfac = new GenPolynomialRing<BigInteger>(new BigInteger(1), rl, tord); 135 cfac = new GenPolynomialRing<BigInteger>(new BigInteger(1), rl - 1, tord); 136 rfac = new GenPolynomialRing<GenPolynomial<BigInteger>>(cfac, 1, tord); 137 } 138 139 140 @Override 141 protected void tearDown() { 142 a = b = c = d = e = null; 143 ai = bi = ci = di = ei = null; 144 dfac = null; 145 cfac = null; 146 rfac = null; 147 ComputerThreads.terminate(); 148 } 149 150 151 protected static java.math.BigInteger getPrime1() { 152 return PrimeList.getLongPrime(60,93); 153 } 154 155 156 protected static java.math.BigInteger getPrime2() { 157 return PrimeList.getLongPrime(30,35); 158 } 159 160 161 /** 162 * Test multivariate Hensel lifting monic case list. 163 */ 164 public void testHenselLiftingMonicList() { 165 java.math.BigInteger p; 166 //p = getPrime1(); 167 p = new java.math.BigInteger("19"); 168 //p = new java.math.BigInteger("5"); 169 BigInteger m = new BigInteger(p); 170 171 ModIntegerRing pm = new ModIntegerRing(p, false); 172 //ModLongRing pl = new ModLongRing(p, false); 173 GenPolynomialRing<ModInteger> pfac = new GenPolynomialRing<ModInteger>(pm, 4, tord, new String[]{ "w", "x", "y", "z" }); 174 GenPolynomialRing<BigInteger> ifac = new GenPolynomialRing<BigInteger>(new BigInteger(),pfac); 175 176 BigInteger mi = m; 177 long k = 5L; 178 long d = 3L; 179 java.math.BigInteger pk = p.pow((int)k); 180 m = new BigInteger(pk); 181 182 ModIntegerRing pkm = new ModIntegerRing(pk, false); 183 //ModLongRing pkl = new ModLongRing(pk, false); 184 GenPolynomialRing<ModInteger> pkfac = new GenPolynomialRing<ModInteger>(pkm, pfac); 185 dfac = new GenPolynomialRing<BigInteger>(mi, pfac); 186 187 //GreatestCommonDivisor<BigInteger> ufd = GCDFactory.getProxy(mi); 188 GreatestCommonDivisor<BigInteger> ufd = GCDFactory.getImplementation(mi); 189 190 //ModLong v = pl.fromInteger(3L); 191 ModInteger v = pkm.fromInteger(3L); 192 List<ModInteger> V = new ArrayList<ModInteger>(1); 193 V.add(v); 194 if ( pkfac.nvar > 2 ) { 195 V.add(pkm.fromInteger(5L)); 196 } 197 if ( pkfac.nvar > 3 ) { 198 V.add(pkm.fromInteger(7L)); 199 } 200 //System.out.println("V = " + V); 201 202 GenPolynomial<ModInteger> ap; 203 GenPolynomial<ModInteger> cp; 204 GenPolynomial<ModInteger> rp; 205 206 List<GenPolynomial<BigInteger>> A = new ArrayList<GenPolynomial<BigInteger>>(); 207 208 for (int i = 1; i < 2; i++) { 209 //a = dfac.random(kl + 7 * i, ll, el + 1, q).abs(); 210 //b = dfac.random(kl + 7 * i, ll, el + 0, q).abs(); 211 //c = dfac.random(kl + 7 * i, ll, el + 2, q).abs(); 212 a = dfac.parse(" ( z^2 + y^2 + 4 x^3 - x + 1 + w ) "); 213 b = dfac.parse(" ( z + y + x^2 + 10 + w ) "); 214 //c = dfac.parse(" z + x + (y - 2)*(2 + y) "); 215 216 A.add(a); 217 A.add(b); 218 //A.add(c); 219 //System.out.println("A = " + A); 220 A = ufd.coPrime(A); 221 //System.out.println("coprime(A) = " + A); 222 if ( A.size() == 0 ) { 223 continue; 224 } 225 c = A.get(0).multiply(A.get(1)); 226 //c = dfac.parse(" y^2 + x^2 "); 227 cp = PolyUtil.<ModInteger> fromIntegerCoefficients(pkfac,c); 228 //System.out.println("c = " + c); 229 230 List<GenPolynomial<ModInteger>> Ap = new ArrayList<GenPolynomial<ModInteger>>(A.size()); 231 for ( GenPolynomial<BigInteger> ai : A ) { 232 ap = PolyUtil.<ModInteger> fromIntegerCoefficients(pkfac,ai); 233 Ap.add(ap); 234 } 235 //System.out.println("A mod p^k = " + Ap); 236 //System.out.println("v = " + v + ", vp = " + vp); 237 GenPolynomialRing<ModInteger> ckfac = pkfac.contract(1); 238 v = V.get(2); 239 List<GenPolynomial<ModInteger>> Ae = new ArrayList<GenPolynomial<ModInteger>>(A.size()); 240 for ( GenPolynomial<ModInteger> a : Ap ) { 241 GenPolynomial<ModInteger> ae = PolyUtil.<ModInteger> evaluateMain(ckfac,a,v); 242 Ae.add(ae); 243 } 244 //System.out.println("A(v) mod p^k = " + Ae); 245 ckfac = ckfac.contract(1); 246 v = V.get(1); 247 List<GenPolynomial<ModInteger>> Ae1 = new ArrayList<GenPolynomial<ModInteger>>(A.size()); 248 for ( GenPolynomial<ModInteger> a : Ae ) { 249 GenPolynomial<ModInteger> ae = PolyUtil.<ModInteger> evaluateMain(ckfac,a,v); 250 Ae1.add(ae); 251 } 252 Ae = Ae1; 253 //System.out.println("A(v,v) mod p^k = " + Ae); 254 ckfac = ckfac.contract(1); 255 v = V.get(0); 256 Ae1 = new ArrayList<GenPolynomial<ModInteger>>(A.size()); 257 for ( GenPolynomial<ModInteger> a : Ae ) { 258 GenPolynomial<ModInteger> ae = PolyUtil.<ModInteger> evaluateMain(ckfac,a,v); 259 Ae1.add(ae); 260 } 261 Ae = Ae1; 262 //System.out.println("A(v,v,v) mod p^k = " + Ae); 263 264 try { 265 List<GenPolynomial<ModInteger>> lift; 266 lift = HenselMultUtil.<ModInteger> liftHenselMonic(c, cp, Ae, V, k); // 5 is max 267 //System.out.println("\nliftMultiHensel:"); 268 //System.out.println("lift = " + lift); 269 //System.out.println("A = " + A); 270 boolean t = HenselMultUtil.<ModInteger> isHenselLift(c, cp, Ae, k, lift); 271 assertTrue("isHenselLift: ", t); 272 } catch (ArithmeticException e) { 273 // ok, can happen 274 } catch (NoLiftingException e) { 275 // can now happen: fail("" + e); 276 System.out.println("e = " + e); 277 } 278 } 279 } 280 281 282 /** 283 * Test multivariate Hensel lifting list, 2 variables. 284 */ 285 public void testHenselLifting2List() { 286 java.math.BigInteger p; 287 //p = getPrime1(); 288 p = new java.math.BigInteger("19"); 289 //p = new java.math.BigInteger("5"); 290 BigInteger m = new BigInteger(p); 291 292 ModIntegerRing pm = new ModIntegerRing(p, false); 293 GenPolynomialRing<ModInteger> pfac = new GenPolynomialRing<ModInteger>(pm, 2, tord, new String[]{ "x", "y" }); 294 GenPolynomialRing<BigInteger> ifac = new GenPolynomialRing<BigInteger>(new BigInteger(),pfac); 295 GenPolynomialRing<GenPolynomial<BigInteger>> irfac = ifac.recursive(ifac.nvar-1); 296 297 BigInteger mi = m; 298 long k = 5L; 299 long d = 3L; 300 java.math.BigInteger pk = p.pow((int)k); 301 m = new BigInteger(pk); 302 //System.out.println("m = " + m + " = " + p + "^" + k); 303 304 ModIntegerRing pkm = new ModIntegerRing(pk, false); 305 //ModLongRing pkl = new ModLongRing(pk, false); 306 GenPolynomialRing<ModInteger> pkfac = new GenPolynomialRing<ModInteger>(pkm, pfac); 307 dfac = new GenPolynomialRing<BigInteger>(mi, pfac); 308 309 //GreatestCommonDivisor<BigInteger> ufd = GCDFactory.getProxy(mi); 310 GreatestCommonDivisor<BigInteger> ufd = GCDFactory.getImplementation(mi); 311 312 //ModLong v = pl.fromInteger(3L); 313 ModInteger v = pkm.fromInteger(3L); 314 List<ModInteger> V = new ArrayList<ModInteger>(1); 315 V.add(v); 316 //System.out.println("V = " + V); 317 318 GenPolynomial<ModInteger> ap; 319 GenPolynomial<ModInteger> cp; 320 GenPolynomial<ModInteger> rp; 321 322 List<GenPolynomial<BigInteger>> A = new ArrayList<GenPolynomial<BigInteger>>(); 323 324 for (int i = 1; i < 2; i++) { 325 a = dfac.parse(" ( x^3 y - 1 ) "); 326 b = dfac.parse(" ( 1 + y ) "); 327 e = dfac.parse(" ( y^2 - x ) "); 328 329 A.add(a); 330 A.add(b); 331 A.add(e); 332 //System.out.println("A = " + A); 333 A = ufd.coPrime(A); 334 //System.out.println("coprime(A) = " + A); // polynomials are rearranged 335 if ( A.size() == 0 ) { 336 continue; 337 } 338 c = A.get(0).multiply(A.get(1)).multiply(A.get(2)); 339 //c = dfac.parse(" y^2 + x^2 "); 340 cp = PolyUtil.<ModInteger> fromIntegerCoefficients(pkfac,c); 341 //System.out.println("c = " + c); 342 //System.out.println("cp = " + cp); 343 GenPolynomial<GenPolynomial<BigInteger>> cr = PolyUtil.<BigInteger>recursive(irfac,c); 344 GenPolynomial<GenPolynomial<BigInteger>> crr = PolyUtil.<BigInteger>switchVariables(cr); 345 //System.out.println("crr = " + crr); 346 GenPolynomial<BigInteger> cl = crr.leadingBaseCoefficient(); 347 //System.out.println("cl = " + cl + ", cl.ring = " + cl.ring); 348 349 FactorAbstract<BigInteger> factorizer = FactorFactory. getImplementation(new BigInteger()); 350 List<GenPolynomial<BigInteger>> CF = factorizer.factorsRadical(cl); 351 //System.out.println("CF = " + CF); 352 353 List<GenPolynomial<BigInteger>> CL = new ArrayList<GenPolynomial<BigInteger>>(2); 354 CL.add( CF.get(0) ); 355 CL.add( CF.get(2) ); 356 CL.add( CF.get(1) ); 357 //CL.add( CF.get(0) ); 358 //System.out.println("CL = " + CL); 359 360 List<GenPolynomial<ModInteger>> Ap = new ArrayList<GenPolynomial<ModInteger>>(A.size()); 361 for ( GenPolynomial<BigInteger> ai : A ) { 362 ap = PolyUtil.<ModInteger> fromIntegerCoefficients(pkfac,ai); 363 Ap.add(ap); 364 } 365 //System.out.println("A mod p^k = " + Ap); 366 //System.out.println("v = " + v + ", V = " + V); 367 368 GenPolynomialRing<ModInteger> ckfac = pkfac.contract(1); 369 370 v = V.get(0); 371 List<GenPolynomial<ModInteger>> Ae = new ArrayList<GenPolynomial<ModInteger>>(A.size()); 372 for ( GenPolynomial<ModInteger> a : Ap ) { // Ap 373 GenPolynomial<ModInteger> ae = PolyUtil.<ModInteger> evaluateMain(ckfac,a,v); 374 Ae.add(ae); 375 } 376 //System.out.println("A(v) mod p^k = " + Ae); 377 378 try { 379 List<GenPolynomial<ModInteger>> lift; 380 lift = HenselMultUtil.<ModInteger> liftHensel(c, cp, Ae, V, k, CL); // 5 is max 381 //System.out.println("\nliftMultiHensel:"); 382 //System.out.println("lift = " + lift); 383 //System.out.println("A = " + A); 384 boolean t = HenselMultUtil.<ModInteger> isHenselLift(c, cp, Ae, k, lift); 385 assertTrue("isHenselLift: ", t); 386 } catch (ArithmeticException e) { 387 // ok, can happen 388 System.out.println("e = " + e); 389 } catch (NoLiftingException e) { 390 // can now happen: 391 fail("" + e); 392 System.out.println("e = " + e); 393 } 394 } 395 } 396 397 398 /** 399 * Test multivariate Hensel lifting list, 3 variables. 400 */ 401 public void xtestHenselLifting3List() { 402 java.math.BigInteger p; 403 //p = getPrime1(); 404 p = new java.math.BigInteger("19"); 405 //p = new java.math.BigInteger("5"); 406 BigInteger m = new BigInteger(p); 407 408 ModIntegerRing pm = new ModIntegerRing(p, false); 409 GenPolynomialRing<ModInteger> pfac = new GenPolynomialRing<ModInteger>(pm, 3, tord, new String[]{ "x", "y", "z" }); 410 GenPolynomialRing<BigInteger> ifac = new GenPolynomialRing<BigInteger>(new BigInteger(),pfac); 411 GenPolynomialRing<GenPolynomial<BigInteger>> irfac = ifac.recursive(ifac.nvar-1); 412 413 BigInteger mi = m; 414 long k = 3L; 415 long d = 3L; 416 java.math.BigInteger pk = p.pow((int)k); 417 m = new BigInteger(pk); 418 //System.out.println("m = " + m); 419 420 ModIntegerRing pkm = new ModIntegerRing(pk, false); 421 //ModLongRing pkl = new ModLongRing(pk, false); 422 GenPolynomialRing<ModInteger> pkfac = new GenPolynomialRing<ModInteger>(pkm, pfac); 423 dfac = new GenPolynomialRing<BigInteger>(mi, pfac); 424 425 //GreatestCommonDivisor<BigInteger> ufd = GCDFactory.getProxy(mi); 426 GreatestCommonDivisor<BigInteger> ufd = GCDFactory.getImplementation(mi); 427 428 //ModLong v = pl.fromInteger(3L); 429 ModInteger v = pkm.fromInteger(3L); 430 List<ModInteger> V = new ArrayList<ModInteger>(1); 431 V.add(v); 432 if ( pkfac.nvar > 2 ) { 433 V.add(pkm.fromInteger(5L)); 434 } 435 if ( pkfac.nvar > 3 ) { 436 V.add(pkm.fromInteger(7L)); 437 } 438 //System.out.println("V = " + V); 439 440 GenPolynomial<ModInteger> ap; 441 GenPolynomial<ModInteger> cp; 442 GenPolynomial<ModInteger> rp; 443 444 List<GenPolynomial<BigInteger>> A = new ArrayList<GenPolynomial<BigInteger>>(); 445 446 for (int i = 1; i < 2; i++) { 447 //a = dfac.random(kl + 7 * i, ll, el + 1, q).abs(); 448 //b = dfac.random(kl + 7 * i, ll, el + 0, q).abs(); 449 //c = dfac.random(kl + 7 * i, ll, el + 2, q).abs(); 450 //a = dfac.parse(" ( z^2 + y^2 + 4 x^3 - x + 1 + w ) "); 451 //b = dfac.parse(" ( z y x + x^2 + 10 + w ) "); 452 a = dfac.parse(" ( x^3 z - y ) "); 453 //a = dfac.parse(" ( x - y ) "); 454 b = dfac.parse(" ( 1 + y + z ) "); 455 e = dfac.parse(" ( z^2 y - x ) "); 456 457 A.add(a); 458 A.add(b); 459 A.add(e); 460 //System.out.println("A = " + A); 461 A = ufd.coPrime(A); 462 //System.out.println("coprime(A) = " + A); // polynomials are rearranged 463 if ( A.size() == 0 ) { 464 continue; 465 } 466 c = A.get(0).multiply(A.get(1)).multiply(A.get(2)); 467 //c = dfac.parse(" y^2 + x^2 "); 468 cp = PolyUtil.<ModInteger> fromIntegerCoefficients(pkfac,c); 469 //System.out.println("c = " + c); 470 GenPolynomial<GenPolynomial<BigInteger>> cr = PolyUtil.<BigInteger>recursive(irfac,c); 471 GenPolynomial<GenPolynomial<BigInteger>> crr = PolyUtil.<BigInteger>switchVariables(cr); 472 //System.out.println("crr = " + crr); 473 GenPolynomial<BigInteger> cl = crr.leadingBaseCoefficient(); 474 //System.out.println("cl = " + cl + ", cl.ring = " + cl.ring); 475 476 FactorAbstract<BigInteger> factorizer = FactorFactory. getImplementation(new BigInteger()); 477 List<GenPolynomial<BigInteger>> CF = factorizer.factorsRadical(cl); 478 //System.out.println("CF = " + CF); 479 480 List<GenPolynomial<BigInteger>> CL = new ArrayList<GenPolynomial<BigInteger>>(2); 481 CL.add( CF.get(0) ); 482 CL.add( CF.get(2) ); 483 CL.add( CF.get(1) ); 484 //System.out.println("CL = " + CL); 485 486 List<GenPolynomial<ModInteger>> Ap = new ArrayList<GenPolynomial<ModInteger>>(A.size()); 487 for ( GenPolynomial<BigInteger> ai : A ) { 488 ap = PolyUtil.<ModInteger> fromIntegerCoefficients(pkfac,ai); 489 Ap.add(ap); 490 } 491 //System.out.println("A mod p^k = " + Ap); 492 //System.out.println("v = " + v + ", V = " + V); 493 494 GenPolynomialRing<ModInteger> ckfac = pkfac.contract(1); 495 //v = V.get(2); 496 List<GenPolynomial<ModInteger>> Ae = new ArrayList<GenPolynomial<ModInteger>>(A.size()); 497 //for ( GenPolynomial<ModInteger> a : Ap ) { 498 // GenPolynomial<ModInteger> ae = PolyUtil.<ModInteger> evaluateMain(ckfac,a,v); 499 // Ae.add(ae); 500 //} 501 //System.out.println("A(v) mod p^k = " + Ae); 502 //ckfac = ckfac.contract(1); 503 504 Ae = Ap; 505 v = V.get(1); 506 List<GenPolynomial<ModInteger>> Ae1 = new ArrayList<GenPolynomial<ModInteger>>(A.size()); 507 for ( GenPolynomial<ModInteger> a : Ae ) { 508 GenPolynomial<ModInteger> ae = PolyUtil.<ModInteger> evaluateMain(ckfac,a,v); 509 Ae1.add(ae); 510 } 511 Ae = Ae1; 512 //System.out.println("A(v) mod p^k = " + Ae); 513 ckfac = ckfac.contract(1); 514 515 v = V.get(0); 516 Ae1 = new ArrayList<GenPolynomial<ModInteger>>(A.size()); 517 for ( GenPolynomial<ModInteger> a : Ae ) { // Ap 518 GenPolynomial<ModInteger> ae = PolyUtil.<ModInteger> evaluateMain(ckfac,a,v); 519 Ae1.add(ae); 520 } 521 Ae = Ae1; 522 //System.out.println("A(v,v) mod p^k = " + Ae); 523 524 try { 525 List<GenPolynomial<ModInteger>> lift; 526 lift = HenselMultUtil.<ModInteger> liftHensel(c, cp, Ae, V, k, CL); // 5 is max 527 //System.out.println("\nliftMultiHensel:"); 528 //System.out.println("lift = " + lift); 529 //System.out.println("A = " + A); 530 boolean t = HenselMultUtil.<ModInteger> isHenselLift(c, cp, Ae, k, lift); 531 assertTrue("isHenselLift: ", t); 532 } catch (ArithmeticException e) { 533 // ok, can happen 534 System.out.println("e = " + e); 535 } catch (NoLiftingException e) { 536 // can now happen: 537 fail("" + e); 538 System.out.println("e = " + e); 539 } 540 } 541 } 542 543 544 /** 545 * Test multivariate Hensel lifting list, 4 variables. 546 */ 547 public void xtestHenselLifting4List() { 548 java.math.BigInteger p; 549 //p = getPrime1(); 550 p = new java.math.BigInteger("19"); 551 //p = new java.math.BigInteger("5"); 552 BigInteger m = new BigInteger(p); 553 554 ModIntegerRing pm = new ModIntegerRing(p, false); 555 GenPolynomialRing<ModInteger> pfac = new GenPolynomialRing<ModInteger>(pm, 4, tord, new String[]{ "x", "y", "z", "w" }); 556 GenPolynomialRing<BigInteger> ifac = new GenPolynomialRing<BigInteger>(new BigInteger(),pfac); 557 GenPolynomialRing<GenPolynomial<BigInteger>> irfac = ifac.recursive(ifac.nvar-1); 558 559 BigInteger mi = m; 560 long k = 3L; 561 long d = 3L; 562 java.math.BigInteger pk = p.pow((int)k); 563 m = new BigInteger(pk); 564 //System.out.println("m = " + m); 565 566 ModIntegerRing pkm = new ModIntegerRing(pk, false); 567 //ModLongRing pkl = new ModLongRing(pk, false); 568 GenPolynomialRing<ModInteger> pkfac = new GenPolynomialRing<ModInteger>(pkm, pfac); 569 dfac = new GenPolynomialRing<BigInteger>(mi, pfac); 570 571 //GreatestCommonDivisor<BigInteger> ufd = GCDFactory.getProxy(mi); 572 GreatestCommonDivisor<BigInteger> ufd = GCDFactory.getImplementation(mi); 573 574 //ModLong v = pl.fromInteger(3L); 575 ModInteger v = pkm.fromInteger(3L); 576 List<ModInteger> V = new ArrayList<ModInteger>(1); 577 V.add(v); 578 if ( pkfac.nvar > 2 ) { 579 V.add(pkm.fromInteger(5L)); 580 } 581 if ( pkfac.nvar > 3 ) { 582 V.add(pkm.fromInteger(7L)); 583 } 584 //System.out.println("V = " + V); 585 586 GenPolynomial<ModInteger> ap; 587 GenPolynomial<ModInteger> cp; 588 GenPolynomial<ModInteger> rp; 589 590 List<GenPolynomial<BigInteger>> A = new ArrayList<GenPolynomial<BigInteger>>(); 591 592 for (int i = 1; i < 2; i++) { 593 a = dfac.parse(" ( x^3 w - y ) "); 594 b = dfac.parse(" ( 1 + y + z + w ) "); 595 e = dfac.parse(" ( z^2 y w - x ) "); 596 597 A.add(a); 598 A.add(b); 599 A.add(e); 600 //System.out.println("A = " + A); 601 A = ufd.coPrime(A); 602 //System.out.println("coprime(A) = " + A); // polynomials are rearranged 603 if ( A.size() == 0 ) { 604 continue; 605 } 606 c = A.get(0).multiply(A.get(1)).multiply(A.get(2)); 607 cp = PolyUtil.<ModInteger> fromIntegerCoefficients(pkfac,c); 608 //System.out.println("c = " + c); 609 GenPolynomial<GenPolynomial<BigInteger>> cr = PolyUtil.<BigInteger>recursive(irfac,c); 610 GenPolynomial<GenPolynomial<BigInteger>> crr = PolyUtil.<BigInteger>switchVariables(cr); 611 //System.out.println("crr = " + crr); 612 GenPolynomial<BigInteger> cl = crr.leadingBaseCoefficient(); 613 //System.out.println("cl = " + cl + ", cl.ring = " + cl.ring); 614 615 FactorAbstract<BigInteger> factorizer = FactorFactory. getImplementation(new BigInteger()); 616 List<GenPolynomial<BigInteger>> CF = factorizer.factorsRadical(cl); 617 //System.out.println("CF = " + CF); 618 619 List<GenPolynomial<BigInteger>> CL = new ArrayList<GenPolynomial<BigInteger>>(2); 620 CL.add( CF.get(0) ); 621 CL.add( CF.get(2) ); 622 CL.add( CF.get(1) ); 623 //System.out.println("CL = " + CL); 624 625 List<GenPolynomial<ModInteger>> Ap = new ArrayList<GenPolynomial<ModInteger>>(A.size()); 626 for ( GenPolynomial<BigInteger> ai : A ) { 627 ap = PolyUtil.<ModInteger> fromIntegerCoefficients(pkfac,ai); 628 Ap.add(ap); 629 } 630 //System.out.println("A mod p^k = " + Ap); 631 //System.out.println("v = " + v + ", V = " + V); 632 633 GenPolynomialRing<ModInteger> ckfac = pkfac.contract(1); 634 v = V.get(2); 635 List<GenPolynomial<ModInteger>> Ae = new ArrayList<GenPolynomial<ModInteger>>(A.size()); 636 for ( GenPolynomial<ModInteger> a : Ap ) { 637 GenPolynomial<ModInteger> ae = PolyUtil.<ModInteger> evaluateMain(ckfac,a,v); 638 Ae.add(ae); 639 } 640 //System.out.println("A(v) mod p^k = " + Ae); 641 ckfac = ckfac.contract(1); 642 643 v = V.get(1); 644 List<GenPolynomial<ModInteger>> Ae1 = new ArrayList<GenPolynomial<ModInteger>>(A.size()); 645 for ( GenPolynomial<ModInteger> a : Ae ) { 646 GenPolynomial<ModInteger> ae = PolyUtil.<ModInteger> evaluateMain(ckfac,a,v); 647 Ae1.add(ae); 648 } 649 Ae = Ae1; 650 //System.out.println("A(v,v) mod p^k = " + Ae); 651 ckfac = ckfac.contract(1); 652 653 v = V.get(0); 654 Ae1 = new ArrayList<GenPolynomial<ModInteger>>(A.size()); 655 for ( GenPolynomial<ModInteger> a : Ae ) { // Ap 656 GenPolynomial<ModInteger> ae = PolyUtil.<ModInteger> evaluateMain(ckfac,a,v); 657 Ae1.add(ae); 658 } 659 Ae = Ae1; 660 //System.out.println("A(v,v,v) mod p^k = " + Ae); 661 662 try { 663 List<GenPolynomial<ModInteger>> lift; 664 lift = HenselMultUtil.<ModInteger> liftHensel(c, cp, Ae, V, k, CL); // 5 is max 665 //System.out.println("\nliftMultiHensel:"); 666 //System.out.println("lift = " + lift); 667 //System.out.println("A = " + A); 668 boolean t = HenselMultUtil.<ModInteger> isHenselLift(c, cp, Ae, k, lift); 669 assertTrue("isHenselLift: ", t); 670 } catch (ArithmeticException e) { 671 // ok, can happen 672 System.out.println("e = " + e); 673 } catch (NoLiftingException e) { 674 // can now happen: 675 fail("" + e); 676 System.out.println("e = " + e); 677 } 678 } 679 } 680 681 682 /** 683 * Test univariate and multivariate Hensel lifting list, 2 variables. 684 */ 685 public void testHenselLifting2FullList() { 686 java.math.BigInteger p; 687 //p = getPrime1(); 688 p = new java.math.BigInteger("19"); 689 //p = new java.math.BigInteger("5"); 690 BigInteger m = new BigInteger(p); 691 692 ModLongRing pm = new ModLongRing(p, false); 693 GenPolynomialRing<ModLong> pfac = new GenPolynomialRing<ModLong>(pm, 2, tord, new String[]{ "x", "y" }); 694 GenPolynomialRing<BigInteger> ifac = new GenPolynomialRing<BigInteger>(new BigInteger(),pfac); 695 GenPolynomialRing<GenPolynomial<BigInteger>> irfac = ifac.recursive(ifac.nvar-1); 696 GenPolynomialRing<BigInteger> icfac = ifac.contract(ifac.nvar-1); 697 GenPolynomialRing<ModLong> pcfac = pfac.contract(pfac.nvar-1); 698 699 BigInteger mi = m; 700 long k = 5L; 701 long d = 3L; 702 java.math.BigInteger pk = p.pow((int)k); 703 m = new BigInteger(pk); 704 //System.out.println("m = " + m + " = " + p + "^" + k); 705 706 ModLongRing pkm = new ModLongRing(pk, false); 707 GenPolynomialRing<ModLong> pkfac = new GenPolynomialRing<ModLong>(pkm, pfac); 708 dfac = new GenPolynomialRing<BigInteger>(mi, pfac); 709 710 //GreatestCommonDivisor<BigInteger> ufd = GCDFactory.getProxy(mi); 711 GreatestCommonDivisor<BigInteger> ufd = GCDFactory.getImplementation(mi); 712 713 ModLong v = pkm.fromInteger(3L); 714 List<ModLong> V = new ArrayList<ModLong>(1); 715 V.add(v); 716 //System.out.println("V = " + V); 717 718 GenPolynomial<ModLong> ap; 719 GenPolynomial<ModLong> cp; 720 GenPolynomial<ModLong> rp; 721 722 List<GenPolynomial<BigInteger>> A = new ArrayList<GenPolynomial<BigInteger>>(); 723 724 for (int i = 1; i < 2; i++) { 725 a = dfac.parse(" ( x^3 y - 1 ) "); 726 b = dfac.parse(" ( 1 + y ) "); 727 e = dfac.parse(" ( y^2 - x ) "); 728 729 A.add(a); 730 A.add(b); 731 A.add(e); 732 //System.out.println("A = " + A); 733 A = ufd.coPrime(A); 734 //System.out.println("coprime(A) = " + A); // polynomials are rearranged 735 if ( A.size() == 0 ) { 736 continue; 737 } 738 c = A.get(0).multiply(A.get(1)).multiply(A.get(2)); 739 cp = PolyUtil.<ModLong> fromIntegerCoefficients(pkfac,c); 740 //System.out.println("c = " + c); 741 GenPolynomial<GenPolynomial<BigInteger>> cr = PolyUtil.<BigInteger>recursive(irfac,c); 742 GenPolynomial<GenPolynomial<BigInteger>> crr = PolyUtil.<BigInteger>switchVariables(cr); 743 //System.out.println("crr = " + crr); 744 GenPolynomial<BigInteger> cl = crr.leadingBaseCoefficient(); 745 //System.out.println("cl = " + cl + ", cl.ring = " + cl.ring); 746 747 FactorAbstract<BigInteger> factorizer = FactorFactory. getImplementation(new BigInteger()); 748 List<GenPolynomial<BigInteger>> CF = factorizer.factorsRadical(cl); 749 //System.out.println("CF = " + CF); 750 751 List<GenPolynomial<BigInteger>> CL = new ArrayList<GenPolynomial<BigInteger>>(2); 752 CL.add( CF.get(0) ); 753 CL.add( CF.get(2) ); 754 CL.add( CF.get(1) ); 755 //CL.add( CF.get(0) ); 756 //System.out.println("CL = " + CL); 757 758 List<GenPolynomial<ModLong>> Apk = new ArrayList<GenPolynomial<ModLong>>(A.size()); 759 for ( GenPolynomial<BigInteger> ai : A ) { 760 ap = PolyUtil.<ModLong> fromIntegerCoefficients(pkfac,ai); 761 Apk.add(ap); 762 } 763 //System.out.println("A mod p^k = " + Apk); 764 //System.out.println("v = " + v + ", V = " + V); 765 766 GenPolynomialRing<ModLong> ckfac = pkfac.contract(1); 767 768 v = V.get(0); 769 List<GenPolynomial<ModLong>> Ae = new ArrayList<GenPolynomial<ModLong>>(A.size()); 770 for ( GenPolynomial<ModLong> a : Apk ) { // Ap 771 GenPolynomial<ModLong> ae = PolyUtil.<ModLong> evaluateMain(ckfac,a,v); 772 Ae.add(ae); 773 } 774 //System.out.println("A(v) mod p^k = " + Ae); 775 776 List<GenPolynomial<ModLong>> Ap = new ArrayList<GenPolynomial<ModLong>>(A.size()); 777 for ( GenPolynomial<BigInteger> ai : PolyUtil.<ModLong>integerFromModularCoefficients(icfac,Ae) ) { 778 ap = PolyUtil.<ModLong> fromIntegerCoefficients(pcfac,ai); 779 Ap.add(ap); 780 } 781 //System.out.println("A(v) mod p = " + Ap); 782 783 try { 784 List<GenPolynomial<ModLong>> lift; 785 lift = HenselMultUtil.<ModLong> liftHenselFull(c, Ap, V, k, CL); // 5 is max 786 //System.out.println("\nliftMultiHensel:"); 787 //System.out.println("lift = " + lift); 788 //System.out.println("A = " + A); 789 boolean t = HenselMultUtil.<ModLong> isHenselLift(c, cp, Ap, k, lift); 790 assertTrue("isHenselLift: ", t); 791 } catch (ArithmeticException e) { 792 // ok, can happen 793 System.out.println("e = " + e); 794 } catch (NoLiftingException e) { 795 // can now happen: 796 fail("" + e); 797 System.out.println("e = " + e); 798 } 799 } 800 } 801 802 803 /** 804 * Test univariate and multivariate Hensel lifting list, 3 variables. 805 */ 806 public void testHenselLifting3FullList() { 807 java.math.BigInteger p; 808 //p = getPrime1(); 809 p = new java.math.BigInteger("19"); 810 //p = new java.math.BigInteger("5"); 811 BigInteger m = new BigInteger(p); 812 813 ModLongRing pm = new ModLongRing(p, false); 814 GenPolynomialRing<ModLong> pfac = new GenPolynomialRing<ModLong>(pm, 3, tord, new String[]{ "x", "y", "z" }); 815 GenPolynomialRing<BigInteger> ifac = new GenPolynomialRing<BigInteger>(new BigInteger(),pfac); 816 GenPolynomialRing<GenPolynomial<BigInteger>> irfac = ifac.recursive(ifac.nvar-1); 817 GenPolynomialRing<BigInteger> icfac = ifac.contract(ifac.nvar-1); 818 GenPolynomialRing<ModLong> pcfac = pfac.contract(pfac.nvar-1); 819 820 BigInteger mi = m; 821 long k = 5L; 822 long d = 3L; 823 java.math.BigInteger pk = p.pow((int)k); 824 m = new BigInteger(pk); 825 //System.out.println("m = " + m + " = " + p + "^" + k); 826 827 ModLongRing pkm = new ModLongRing(pk, false); 828 GenPolynomialRing<ModLong> pkfac = new GenPolynomialRing<ModLong>(pkm, pfac); 829 dfac = new GenPolynomialRing<BigInteger>(mi, pfac); 830 831 //GreatestCommonDivisor<BigInteger> ufd = GCDFactory.getProxy(mi); 832 GreatestCommonDivisor<BigInteger> ufd = GCDFactory.getImplementation(mi); 833 834 ModLong v = pkm.fromInteger(3L); 835 List<ModLong> V = new ArrayList<ModLong>(1); 836 V.add(v); 837 if ( pkfac.nvar > 2 ) { 838 V.add(pkm.fromInteger(5L)); 839 } 840 //System.out.println("V = " + V); 841 842 GenPolynomial<ModLong> ap; 843 GenPolynomial<ModLong> cp; 844 GenPolynomial<ModLong> rp; 845 846 List<GenPolynomial<BigInteger>> A = new ArrayList<GenPolynomial<BigInteger>>(); 847 848 for (int i = 1; i < 2; i++) { 849 a = dfac.parse(" ( x^3 z - y ) "); 850 b = dfac.parse(" ( 1 + y + z ) "); 851 e = dfac.parse(" ( z^2 y - x ) "); 852 853 A.add(a); 854 A.add(b); 855 A.add(e); 856 //System.out.println("A = " + A); 857 A = ufd.coPrime(A); 858 //System.out.println("coprime(A) = " + A); // polynomials are rearranged 859 if ( A.size() == 0 ) { 860 continue; 861 } 862 c = A.get(0).multiply(A.get(1)).multiply(A.get(2)); 863 cp = PolyUtil.<ModLong> fromIntegerCoefficients(pkfac,c); 864 //System.out.println("c = " + c); 865 //System.out.println("cp = " + cp); 866 GenPolynomial<GenPolynomial<BigInteger>> cr = PolyUtil.<BigInteger>recursive(irfac,c); 867 GenPolynomial<GenPolynomial<BigInteger>> crr = PolyUtil.<BigInteger>switchVariables(cr); 868 //System.out.println("crr = " + crr); 869 GenPolynomial<BigInteger> cl = crr.leadingBaseCoefficient(); 870 //System.out.println("cl = " + cl + ", cl.ring = " + cl.ring); 871 872 FactorAbstract<BigInteger> factorizer = FactorFactory. getImplementation(new BigInteger()); 873 List<GenPolynomial<BigInteger>> CF = factorizer.factorsRadical(cl); 874 //System.out.println("CF = " + CF); 875 876 List<GenPolynomial<BigInteger>> CL = new ArrayList<GenPolynomial<BigInteger>>(2); 877 CL.add( CF.get(0) ); 878 CL.add( CF.get(2) ); 879 CL.add( CF.get(1) ); 880 //System.out.println("CL = " + CL); 881 882 List<GenPolynomial<ModLong>> Apk = new ArrayList<GenPolynomial<ModLong>>(A.size()); 883 for ( GenPolynomial<BigInteger> ai : A ) { 884 ap = PolyUtil.<ModLong> fromIntegerCoefficients(pkfac,ai); 885 Apk.add(ap); 886 } 887 //System.out.println("A mod p^k = " + Apk); 888 //System.out.println("v = " + v + ", V = " + V); 889 890 GenPolynomialRing<ModLong> ckfac = pkfac.contract(1); 891 List<GenPolynomial<ModLong>> Ae = new ArrayList<GenPolynomial<ModLong>>(A.size()); 892 893 Ae = Apk; 894 v = V.get(0); 895 List<GenPolynomial<ModLong>> Ae1 = new ArrayList<GenPolynomial<ModLong>>(A.size()); 896 for ( GenPolynomial<ModLong> a : Ae ) { 897 GenPolynomial<ModLong> ae = PolyUtil.<ModLong> evaluateMain(ckfac,a,v); 898 Ae1.add(ae); 899 } 900 Ae = Ae1; 901 //System.out.println("A(v) mod p^k = " + Ae); 902 GenPolynomial<ModLong> cpp = PolyUtil.<ModLong> evaluateMain(ckfac,cp,v); 903 //System.out.println("cpp = " + cpp); 904 ckfac = ckfac.contract(1); 905 906 v = V.get(1); 907 Ae1 = new ArrayList<GenPolynomial<ModLong>>(A.size()); 908 for ( GenPolynomial<ModLong> a : Ae ) { // Ap 909 GenPolynomial<ModLong> ae = PolyUtil.<ModLong> evaluateMain(ckfac,a,v); 910 Ae1.add(ae); 911 } 912 Ae = Ae1; 913 //System.out.println("A(v,v) mod p^k = " + Ae); 914 GenPolynomial<ModLong> cppp = PolyUtil.<ModLong> evaluateMain(ckfac,cpp,v); 915 //System.out.println("cppp = " + cppp); 916 917 List<GenPolynomial<ModLong>> Ap = new ArrayList<GenPolynomial<ModLong>>(A.size()); 918 for ( GenPolynomial<BigInteger> ai : PolyUtil.<ModLong>integerFromModularCoefficients(icfac,Ae) ) { 919 ap = PolyUtil.<ModLong> fromIntegerCoefficients(pcfac,ai); 920 Ap.add(ap); 921 } 922 //System.out.println("A(v,v) mod p = " + Ap); 923 GenPolynomial<ModLong> cpppp = PolyUtil.<ModLong> fromIntegerCoefficients(pcfac, PolyUtil.<ModLong>integerFromModularCoefficients(icfac,cppp)); 924 //System.out.println("cpppp = " + cpppp); 925 926 GenPolynomial<ModLong> aa = pcfac.getONE(); 927 for ( GenPolynomial<ModLong> x : Ap ) { 928 aa = aa.multiply(x); 929 } 930 assertTrue("prod(A(v,v)) mod p = " + aa + ", cpppp = " + cpppp + ", aa != cpppp: ", cpppp.equals(aa)); 931 932 try { 933 List<GenPolynomial<ModLong>> lift; 934 lift = HenselMultUtil.<ModLong> liftHenselFull(c, Ap, V, k, CL); // 5 is max 935 //System.out.println("\nliftMultiHensel:"); 936 //System.out.println("lift = " + lift); 937 //System.out.println("A = " + A); 938 boolean t = HenselMultUtil.<ModLong> isHenselLift(c, cp, Ap, k, lift); 939 assertTrue("isHenselLift: ", t); 940 } catch (ArithmeticException e) { 941 // ok, can happen 942 System.out.println("e = " + e); 943 } catch (NoLiftingException e) { 944 // can now happen: 945 fail("" + e); 946 System.out.println("e = " + e); 947 } 948 } 949 } 950 951 952 /** 953 * Test univariate and multivariate Hensel lifting list, 3 variables. 954 */ 955 public void testHenselLifting4FullList() { 956 java.math.BigInteger p; 957 //p = getPrime1(); 958 p = new java.math.BigInteger("19"); 959 //p = new java.math.BigInteger("5"); 960 BigInteger m = new BigInteger(p); 961 962 ModLongRing pm = new ModLongRing(p, false); 963 GenPolynomialRing<ModLong> pfac = new GenPolynomialRing<ModLong>(pm, 4, tord, new String[]{ "x", "y", "z", "w" }); 964 GenPolynomialRing<BigInteger> ifac = new GenPolynomialRing<BigInteger>(new BigInteger(),pfac); 965 GenPolynomialRing<GenPolynomial<BigInteger>> irfac = ifac.recursive(ifac.nvar-1); 966 GenPolynomialRing<BigInteger> icfac = ifac.contract(ifac.nvar-1); 967 GenPolynomialRing<ModLong> pcfac = pfac.contract(pfac.nvar-1); 968 969 BigInteger mi = m; 970 long k = 5L; 971 long d = 3L; 972 java.math.BigInteger pk = p.pow((int)k); 973 m = new BigInteger(pk); 974 //System.out.println("m = " + m); 975 976 ModLongRing pkm = new ModLongRing(pk, false); 977 GenPolynomialRing<ModLong> pkfac = new GenPolynomialRing<ModLong>(pkm, pfac); 978 dfac = new GenPolynomialRing<BigInteger>(mi, pfac); 979 980 //GreatestCommonDivisor<BigInteger> ufd = GCDFactory.getProxy(mi); 981 GreatestCommonDivisor<BigInteger> ufd = GCDFactory.getImplementation(mi); 982 983 ModLong v = pkm.fromInteger(3L); 984 List<ModLong> V = new ArrayList<ModLong>(1); 985 V.add(v); 986 if ( pkfac.nvar > 2 ) { 987 V.add(pkm.fromInteger(5L)); 988 } 989 if ( pkfac.nvar > 3 ) { 990 V.add(pkm.fromInteger(7L)); 991 } 992 //System.out.println("V = " + V); 993 994 GenPolynomial<ModLong> ap; 995 GenPolynomial<ModLong> cp; 996 GenPolynomial<ModLong> rp; 997 998 List<GenPolynomial<BigInteger>> A = new ArrayList<GenPolynomial<BigInteger>>(); 999 1000 for (int i = 1; i < 2; i++) { 1001 a = dfac.parse(" ( x^3 w - y ) "); 1002 b = dfac.parse(" ( 1 + y + z + w ) "); 1003 e = dfac.parse(" ( z^2 y w - x ) "); 1004 1005 A.add(a); 1006 A.add(b); 1007 A.add(e); 1008 //System.out.println("A = " + A); 1009 A = ufd.coPrime(A); 1010 //System.out.println("coprime(A) = " + A); // polynomials are rearranged 1011 if ( A.size() == 0 ) { 1012 continue; 1013 } 1014 c = A.get(0).multiply(A.get(1)).multiply(A.get(2)); 1015 cp = PolyUtil.<ModLong> fromIntegerCoefficients(pkfac,c); 1016 //System.out.println("c = " + c); 1017 GenPolynomial<GenPolynomial<BigInteger>> cr = PolyUtil.<BigInteger>recursive(irfac,c); 1018 GenPolynomial<GenPolynomial<BigInteger>> crr = PolyUtil.<BigInteger>switchVariables(cr); 1019 //System.out.println("crr = " + crr); 1020 GenPolynomial<BigInteger> cl = crr.leadingBaseCoefficient(); 1021 //System.out.println("cl = " + cl + ", cl.ring = " + cl.ring); 1022 1023 FactorAbstract<BigInteger> factorizer = FactorFactory. getImplementation(new BigInteger()); 1024 List<GenPolynomial<BigInteger>> CF = factorizer.factorsRadical(cl); 1025 //System.out.println("CF = " + CF); 1026 1027 List<GenPolynomial<BigInteger>> CL = new ArrayList<GenPolynomial<BigInteger>>(2); 1028 CL.add( CF.get(0) ); 1029 CL.add( CF.get(2) ); 1030 CL.add( CF.get(1) ); 1031 //System.out.println("CL = " + CL); 1032 1033 List<GenPolynomial<ModLong>> Apk = new ArrayList<GenPolynomial<ModLong>>(A.size()); 1034 for ( GenPolynomial<BigInteger> ai : A ) { 1035 ap = PolyUtil.<ModLong> fromIntegerCoefficients(pkfac,ai); 1036 Apk.add(ap); 1037 } 1038 //System.out.println("A mod p^k = " + Apk); 1039 //System.out.println("v = " + v + ", V = " + V); 1040 1041 GenPolynomialRing<ModLong> ckfac = pkfac.contract(1); 1042 v = V.get(0); 1043 List<GenPolynomial<ModLong>> Ae = new ArrayList<GenPolynomial<ModLong>>(A.size()); 1044 for ( GenPolynomial<ModLong> a : Apk ) { 1045 GenPolynomial<ModLong> ae = PolyUtil.<ModLong> evaluateMain(ckfac,a,v); 1046 Ae.add(ae); 1047 } 1048 //System.out.println("A(v) mod p^k = " + Ae); 1049 ckfac = ckfac.contract(1); 1050 1051 v = V.get(1); 1052 List<GenPolynomial<ModLong>> Ae1 = new ArrayList<GenPolynomial<ModLong>>(A.size()); 1053 for ( GenPolynomial<ModLong> a : Ae ) { 1054 GenPolynomial<ModLong> ae = PolyUtil.<ModLong> evaluateMain(ckfac,a,v); 1055 Ae1.add(ae); 1056 } 1057 Ae = Ae1; 1058 //System.out.println("A(v,v) mod p^k = " + Ae); 1059 ckfac = ckfac.contract(1); 1060 1061 v = V.get(2); 1062 Ae1 = new ArrayList<GenPolynomial<ModLong>>(A.size()); 1063 for ( GenPolynomial<ModLong> a : Ae ) { // Ap 1064 GenPolynomial<ModLong> ae = PolyUtil.<ModLong> evaluateMain(ckfac,a,v); 1065 Ae1.add(ae); 1066 } 1067 Ae = Ae1; 1068 //System.out.println("A(v,v,v) mod p^k = " + Ae); 1069 1070 List<GenPolynomial<ModLong>> Ap = new ArrayList<GenPolynomial<ModLong>>(A.size()); 1071 for ( GenPolynomial<BigInteger> ai : PolyUtil.<ModLong>integerFromModularCoefficients(icfac,Ae) ) { 1072 ap = PolyUtil.<ModLong> fromIntegerCoefficients(pcfac,ai); 1073 Ap.add(ap); 1074 } 1075 //System.out.println("A(v,v,v) mod p = " + Ap); 1076 1077 try { 1078 List<GenPolynomial<ModLong>> lift; 1079 //lift = HenselMultUtil.<ModLong> liftHensel(c, cp, Ae, V, k, CL); // 5 is max 1080 lift = HenselMultUtil.<ModLong> liftHenselFull(c, Ap, V, k, CL); // 5 is max 1081 //System.out.println("\nliftMultiHensel:"); 1082 //System.out.println("lift = " + lift); 1083 //System.out.println("A = " + A); 1084 boolean t = HenselMultUtil.<ModLong> isHenselLift(c, cp, Ap, k, lift); 1085 assertTrue("isHenselLift: ", t); 1086 } catch (ArithmeticException e) { 1087 // ok, can happen 1088 System.out.println("e = " + e); 1089 } catch (NoLiftingException e) { 1090 // can now happen: 1091 fail("" + e); 1092 System.out.println("e = " + e); 1093 } 1094 } 1095 } 1096 1097 }