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