Changeset d43600 in git
 Timestamp:
 Apr 29, 2015, 4:17:55 PM (9 years ago)
 Branches:
 (u'fiekerDuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '648d28f488f6ff08f5607ff229b9ad9e4a5b93c2')
 Children:
 037ce1bfb1e8b7036c7a8f612851416dbee04829
 Parents:
 c133871de8f09fac0f6b53cf6614e2c8b5a9dd45
 Location:
 Singular/LIB
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

Singular/LIB/ffsolve.lib
rc133871 rd43600 34 34 poly lp; 35 35 // check assumptions 36 if(npars(basering)>1){ 36 if(npars(basering)>1) 37 { 37 38 ERROR("Basering must have at most one parameter"); 38 39 } 39 if(char(basering)==0){ 40 if(char(basering)==0) 41 { 40 42 ERROR("Basering must have finite characteristic"); 41 43 } 42 43 if(size(#)){ 44 if(size(#)==1 and typeof(#[1])=="list"){ 45 lSolvers = #[1]; 46 }else{ 47 lSolvers = #; 48 } 49 }else{ 50 if(deg(equations) == 2){ 44 if(hasGFCoefficient(basering)) 45 { 46 ERROR("not implemented for Galois fields"); 47 } 48 49 if(size(#)) 50 { 51 if(size(#)==1 and typeof(#[1])=="list") 52 { lSolvers = #[1]; } 53 else 54 { lSolvers = #; } 55 } 56 else 57 { 58 if(deg(equations) == 2) 59 { 51 60 lSolvers = "XLsolve", "PEsolve", "simplesolver", "GBsolve", "ZZsolve"; 52 }else{ 61 } 62 else 63 { 53 64 lSolvers = "PEsolve", "simplesolver", "GBsolve", "ZZsolve", "XLsolve"; 54 65 } 55 if(deg(equations) == 1){ 66 if(deg(equations) == 1) 67 { 56 68 lSolvers = "GBsolve"; 57 69 } … … 59 71 n = size(lSolvers); 60 72 R = random(1, n*(3*n+1) div 2); 61 for(i=1;i<n+1;i++){ 62 if(R<=(2*n+1i)){ 63 string solver = lSolvers[i]; 64 }else{ 73 string solver; 74 for(i=1;i<n+1;i++) 75 { 76 if(R<=(2*n+1i)) 77 { 78 solver = lSolvers[i]; 79 } 80 else 81 { 65 82 R=R(2*n+1i); 66 83 } 67 84 } 68 85 69 if(nvars(basering)==1){ 86 if(nvars(basering)==1) 87 { 70 88 return(facstd(equations)); 71 89 } … … 73 91 // search for the first univariate polynomial 74 92 found = 0; 75 for(i=1; i<=ncols(equations); i++){ 76 if(univariate(equations[i])>0){ 93 for(i=1; i<=ncols(equations); i++) 94 { 95 if(univariate(equations[i])>0) 96 { 77 97 factors=factorize(equations[i],1); 78 for(j=1; j<=ncols(factors); j++){ 79 if(deg(factors[j])==1){ 98 for(j=1; j<=ncols(factors); j++) 99 { 100 if(deg(factors[j])==1) 101 { 80 102 linfacs[size(linfacs)+1] = factors[j]; 81 103 } 82 104 } 83 if(deg(linfacs[1])>0){ 105 if(deg(linfacs[1])>0) 106 { 84 107 found=1; 85 108 break; … … 88 111 } 89 112 // if there is, collect its the linear factors 90 if(found){ 113 if(found) 114 { 91 115 // substitute the root and call recursively 92 116 ideal neweqs, invmapideal, ti; 93 117 map invmap; 94 for(k=1; k<=ncols(linfacs); k++){ 118 for(k=1; k<=ncols(linfacs); k++) 119 { 95 120 lp = linfacs[k]; 96 121 neweqs = reduce(equations, lp); … … 102 127 ideal mappingIdeal; 103 128 j=1; 104 for(i=1; i<=size(varexp); i++){ 105 if(varexp[i]){ 129 for(i=1; i<=size(varexp); i++) 130 { 131 if(varexp[i]) 132 { 106 133 mappingIdeal[i] = 0; 107 }else{ 134 } 135 else 136 { 108 137 mappingIdeal[i] = var(j); 109 138 j++; … … 112 141 map recmap = original_ring, mappingIdeal; 113 142 list tsols = ffsolve(recmap(neweqs), lSolvers); 114 if(size(tsols)==0){ 143 if(size(tsols)==0) 144 { 115 145 tsols = list(ideal(1)); 116 146 } 117 147 setring original_ring; 118 148 j=1; 119 for(i=1;i<=size(varexp);i++){ 120 if(varexp[i]==0){ 149 for(i=1;i<=size(varexp);i++) 150 { 151 if(varexp[i]==0) 152 { 121 153 invmapideal[j] = var(i); 122 154 j++; … … 127 159 128 160 // combine the solutions 129 for(j=1; j<=size(tempsols); j++){ 161 for(j=1; j<=size(tempsols); j++) 162 { 130 163 ti = std(tempsols[j]+lp); 131 if(deg(ti)>0){ 164 if(deg(ti)>0) 165 { 132 166 solutions = insert(solutions,ti); 133 167 } 134 168 } 135 169 } 136 }else{ 170 } 171 else 172 { 137 173 execute("solutions="+solver+"(equations);") ; 138 174 } … … 163 199 checks if I has common roots, then return 1, otherwise 164 200 return 0. 165 166 201 " 167 202 { … … 170 205 poly g; 171 206 // check assumptions 172 if(npars(basering)>1){ 207 if(npars(basering)>1) 208 { 173 209 ERROR("Basering must have at most one parameter"); 174 210 } 175 if(char(basering)==0){ 211 if(char(basering)==0) 212 { 176 213 ERROR("Basering must have finite characteristic"); 177 214 } 178 179 if( size(#) > 0 ){ 215 if(hasGFCoefficient(basering)) 216 { 217 ERROR("not implemented for Galois fields"); 218 } 219 220 if( size(#) > 0 ) 221 { 180 222 mode = #[1]; 181 }else{ 223 } 224 else 225 { 182 226 mode = 2; 183 227 } … … 185 229 g = productOfEqs( L ); 186 230 187 if(g == 0){ 188 if(mode==0){ 231 if(g == 0) 232 { 233 if(mode==0) 234 { 189 235 return(0); 190 236 } 191 237 return( list() ); 192 238 } 193 if(g == 1){ 239 if(g == 1) 240 { 194 241 list vectors = every_vector(); 195 for(j=1; j<=size(vectors); j++){ 242 for(j=1; j<=size(vectors); j++) 243 { 196 244 ideal res; 197 for(i=1; i<=nvars(basering); i++){ 245 for(i=1; i<=nvars(basering); i++) 246 { 198 247 res[i] = var(i)vectors[j][i]; 199 248 } … … 203 252 } 204 253 205 if( mode == 0 ){ 254 if( mode == 0 ) 255 { 206 256 return( 1 ); 207 }else{ 208 for(i=1; i<=nvars(basering); i++){ 257 } 258 else 259 { 260 for(i=1; i<=nvars(basering); i++) 261 { 209 262 start[i] = 0:order_of_extension(); 210 263 } 211 264 212 if( mode == 1){ 265 if( mode == 1) 266 { 213 267 results[size(results)+1] = melyseg(g, start); 214 }else{ 215 while(1){ 268 } 269 else 270 { 271 while(1) 272 { 216 273 start = melyseg(g, start); 217 if( size(start) > 0 ){ 274 if( size(start) > 0 ) 275 { 218 276 ideal res; 219 for(i=1; i<=nvars(basering); i++){ 277 for(i=1; i<=nvars(basering); i++) 278 { 220 279 res[i] = var(i)vec2elm(start[i]); 221 280 } … … 257 316 E = E+defaultIdeal(); 258 317 // check assumptions 259 if(npars(basering)>1){ 318 if(npars(basering)>1) 319 { 260 320 ERROR("Basering must have at most one parameter"); 261 321 } 262 if(char(basering)==0){ 322 if(char(basering)==0) 323 { 263 324 ERROR("Basering must have finite characteristic"); 264 325 } 265 for(k=1; k<=nvars(basering); k++){ 326 if(hasGFCoefficient(basering)) 327 { 328 ERROR("not implemented for Galois fields"); 329 } 330 for(k=1; k<=nvars(basering); k++) 331 { 266 332 partial_solutions = list(); 267 for(i=1; i<=size(solutions); i++){ 333 for(i=1; i<=size(solutions); i++) 334 { 268 335 partial_system = reduce(E, solutions[i]); 269 for(j=1; j<=ncols(partial_system); j++){ 270 if(univariate(partial_system[j])>0){ 336 for(j=1; j<=ncols(partial_system); j++) 337 { 338 if(univariate(partial_system[j])>0) 339 { 271 340 univar_poly = partial_system[j]; 272 341 break; … … 274 343 } 275 344 factors = factorize(univar_poly,1); 276 for(j=1; j<=ncols(factors); j++){ 277 if(deg(factors[j])==1){ 345 for(j=1; j<=ncols(factors); j++) 346 { 347 if(deg(factors[j])==1) 348 { 278 349 curr_sol = std(solutions[i]+ideal(factors[j])); 279 350 curr_sys = reduce(E, curr_sol); 280 351 correct = 1; 281 for(t=1; t<=ncols(curr_sys); t++){ 282 if(deg(curr_sys[t])==0){ 352 for(t=1; t<=ncols(curr_sys); t++) 353 { 354 if(deg(curr_sys[t])==0) 355 { 283 356 correct = 0; 284 357 break; 285 358 } 286 359 } 287 if(correct){ 360 if(correct) 361 { 288 362 partial_solutions = insert(partial_solutions, curr_sol); 289 363 } … … 322 396 string new_vars; 323 397 // check assumptions 324 if(npars(basering)>1){ 398 if(npars(basering)>1) 399 { 325 400 ERROR("Basering must have at most one parameter"); 326 401 } 327 if(char(basering)==0){ 402 if(char(basering)==0) 403 { 328 404 ERROR("Basering must have finite characteristic"); 329 405 } 406 if(hasGFCoefficient(basering)) 407 { 408 ERROR("not implemented for Galois fields"); 409 } 330 410 331 411 def original_ring = basering; 332 if(npars(basering)==1){ 412 if(npars(basering)==1) 413 { 333 414 int prime_coeff_field=0; 334 415 string minpolystr = "minpoly="+ 335 416 get_minpoly_str(size(original_ring),parstr(original_ring,1))+";" ; 336 }else{ 417 } 418 else 419 { 337 420 int prime_coeff_field=1; 338 421 } … … 344 427 ideal standard_basis = std(equation_system); 345 428 list basis_factors = facstd(standard_basis); 346 if( basis_factors[1][1] == 1){ 429 if( basis_factors[1][1] == 1) 430 { 347 431 return(results) 348 432 }; 349 433 350 for(i=1; i<= size(basis_factors); i++){ 434 for(i=1; i<= size(basis_factors); i++) 435 { 351 436 prop = 0; 352 for(j=1; j<=size(basis_factors[i]); j++){ 353 if( univariate(basis_factors[i][j])>0 and deg(basis_factors[i][j])>1){ 437 for(j=1; j<=size(basis_factors[i]); j++) 438 { 439 if( univariate(basis_factors[i][j])>0 and deg(basis_factors[i][j])>1) 440 { 354 441 prop =1; 355 442 break; 356 443 } 357 444 } 358 if(prop == 0){ 445 if(prop == 0) 446 { 359 447 ls = solvelinearpart( basis_factors[i] ); 360 if(ncols(ls) == nvars(basering) ){ 448 if(ncols(ls) == nvars(basering) ) 449 { 361 450 ctrl, newelement = add_if_new(ctrl, ls); 362 if(newelement){ 451 if(newelement) 452 { 363 453 results = insert(results, ls); 364 454 } 365 }else{ 455 } 456 else 457 { 366 458 slvbl = insert(slvbl, list(basis_factors[i],ls) ); 367 459 } 368 460 } 369 461 } 370 if(size(slvbl)<>0){ 371 for(int E = 1; E<= size(slvbl); E++){ 462 if(size(slvbl)<>0) 463 { 464 for(int E = 1; E<= size(slvbl); E++) 465 { 372 466 I = slvbl[E][1]; 373 467 linear_solution = slvbl[E][2]; … … 376 470 univar_part = ideal(); 377 471 multivar_part = ideal(); 378 for(i=1; i<=ncols(I); i++){ 379 if(univariate(I[i])>0){ 472 for(i=1; i<=ncols(I); i++) 473 { 474 if(univariate(I[i])>0) 475 { 380 476 univar_part = univar_part+I[i]; 381 }else{ 477 } 478 else 479 { 382 480 multivar_part = multivar_part+I[i]; 383 481 } … … 391 489 def R_new = changevar(new_vars, original_ring); 392 490 setring R_new; 393 if( !prime_coeff_field ){ 491 if( !prime_coeff_field ) 492 { 394 493 execute(minpolystr); 395 494 } 396 495 397 496 ideal mapping_ideal; 398 for(i=1; i<=size(unsolved_var_nums); i++){ 497 for(i=1; i<=size(unsolved_var_nums); i++) 498 { 399 499 mapping_ideal[unsolved_var_nums[i]] = var(i); 400 500 } … … 406 506 int unsolvable = 0; 407 507 sol_new = simplesolver(I_new); 408 if( size(sol_new) == 0){ 508 if( size(sol_new) == 0) 509 { 409 510 unsolvable = 1; 410 511 } 411 412 512 setring original_ring; 413 414 if(unsolvable){513 if(unsolvable) 514 { 415 515 list sol_old = list(); 416 }else{ 516 } 517 else 518 { 417 519 map G = R_new, unsolved_vars; 418 520 new_sols = G(sol_new); 419 for(i=1; i<=size(new_sols); i++){ 521 for(i=1; i<=size(new_sols); i++) 522 { 420 523 ideal sol = new_sols[i]+linear_solution; 421 524 sol = std(sol); 422 525 ctrl, newelement = add_if_new(ctrl, sol); 423 if(newelement){ 526 if(newelement) 527 { 424 528 results = insert(results, sol); 425 529 } … … 457 561 int SD = deg(I); 458 562 list solutions; 459 if(size(#)){ 460 if(typeof(#[1])=="int"){ D = #[1]; } 461 }else{ 462 D = 2; 463 } 563 if(size(#)) 564 { 565 if(typeof(#[1])=="int") { D = #[1]; } 566 } 567 else 568 { D = 2; } 464 569 list lMonomialsForMultiplying = monomialsOfDegreeAtMost(D+SD); 465 570 … … 467 572 list extended_system; 468 573 list mm; 469 for(k=1; k<=size(lMonomialsForMultiplying)SD; k++){ 574 for(k=1; k<=size(lMonomialsForMultiplying)SD; k++) 575 { 470 576 mm = lMonomialsForMultiplying[k]; 471 for(i=1; i<=m; i++){ 472 for(j=1; j<=size(mm); j++){ 577 for(i=1; i<=m; i++) 578 { 579 for(j=1; j<=size(mm); j++) 580 { 473 581 extended_system[size(extended_system)+1] = reduce(I[i]*mm[j], defaultIdeal()); 474 582 } … … 476 584 } 477 585 ideal new_system = I; 478 for(i=1; i<=size(extended_system); i++){ 586 for(i=1; i<=size(extended_system); i++) 587 { 479 588 new_system[m+i] = extended_system[i]; 480 589 } … … 511 620 def original_ring = basering; 512 621 // check assumptions 513 if(npars(basering)>1){ 622 if(npars(basering)>1) 623 { 514 624 ERROR("Basering must have at most one parameter"); 515 625 } 516 if(char(basering)==0){ 626 if(char(basering)==0) 627 { 517 628 ERROR("Basering must have finite characteristic"); 629 } 630 if(hasGFCoefficient(basering)) 631 { 632 ERROR("not implemented for Galois fields"); 518 633 } 519 634 … … 521 636 numeqs = ncols(I); 522 637 l = numeqs % nv; 523 if( l == 0){ 638 if( l == 0) 639 { 524 640 r = numeqs div nv; 525 }else{ 641 } 642 else 643 { 526 644 r = (numeqs div nv) +1; 527 645 } … … 529 647 530 648 list list_of_equations; 531 for(i=1; i<=r; i++){ 649 for(i=1; i<=r; i++) 650 { 532 651 list_of_equations[i] = ideal(); 533 652 } 534 for(i=0; i<numeqs; i++){ 653 for(i=0; i<numeqs; i++) 654 { 535 655 list_of_equations[(i div nv)+1][(i % nv) +1] = I[i+1]; 536 656 } … … 540 660 541 661 ideal IV; 542 for(i=1; i<=nv; i++){ 662 for(i=1; i<=nv; i++) 663 { 543 664 IV[i] = var(i); 544 665 } 545 666 546 667 matrix M_C[nv][nv]; 547 for(i=1;i<=nrows(M_C); i++){ 548 for(j=1; j<=ncols(M_C); j++){ 668 for(i=1;i<=nrows(M_C); i++) 669 { 670 for(j=1; j<=ncols(M_C); j++) 671 { 549 672 M_C[i,j] = @c(i)(j); 550 673 } … … 554 677 ideal IX_power_poly; 555 678 ideal IX_power_var; 556 for(i=1; i<=nv; i++){ 679 for(i=1; i<=nv; i++) 680 { 557 681 e = (size(original_ring)^(i1)); 558 682 IX_power_poly[i] = X^e; … … 564 688 565 689 ideal IC; 566 for(i=1; i<=ncols(M); i++){ 567 for(j=1; j<=ncols(IV); j++){ 690 for(i=1; i<=ncols(M); i++) 691 { 692 for(j=1; j<=ncols(IV); j++) 693 { 568 694 IC[(i1)*ncols(M)+j] = coeffs(M[1,i],IV[j])[2,1]; 569 695 } … … 572 698 ideal IC_solultion = std(Presolve::solvelinearpart(IC)); 573 699 574 575 700 matrix M_C_sol[nv][nv]; 576 for(i=1;i<=nrows(M_C_sol); i++){ 577 for(j=1; j<=ncols(M_C_sol); j++){ 701 for(i=1;i<=nrows(M_C_sol); i++) 702 { 703 for(j=1; j<=ncols(M_C_sol); j++) 704 { 578 705 M_C_sol[i,j] = reduce(@c(i)(j), std(IC_solultion)); 579 706 } … … 595 722 596 723 list list_of_F; 597 for(i=1; i<=r; i++){ 724 for(i=1; i<=r; i++) 725 { 598 726 list_of_F[i] = Z_phi( list_of_equations[i] ); 599 727 } 600 728 601 for(i=1; i<=nv; i++){ 602 603 for(j=1; j<=r; j++){ 729 for(i=1; i<=nv; i++) 730 { 731 for(j=1; j<=r; j++) 732 { 604 733 list_of_F[j] = subst( list_of_F[j], var(i), I_subs[i] ); 605 734 } 606 735 } 607 736 int s = size(original_ring); 608 if(npars(original_ring)==1){ 609 for(j=1; j<=r; j++){ 737 if(npars(original_ring)==1) 738 { 739 for(j=1; j<=r; j++) 740 { 610 741 list_of_F[j] = subst(list_of_F[j], par(1), (@y^( (s^nv1) div (s1) ))); 611 742 } … … 620 751 list list_of_F = rho(list_of_F); 621 752 poly G = 0; 622 for(i=1; i<=r; i++){ 753 for(i=1; i<=r; i++) 754 { 623 755 G = gcd(G, list_of_F[i]); 624 756 } 625 if(G==1){ 757 if(G==1) 758 { 626 759 return(list()); 627 760 } … … 630 763 631 764 ideal check; 632 for(i=1; i<=nv; i++){ 765 for(i=1; i<=nv; i++) 766 { 633 767 check[i] = X^(size(original_ring)^(i1)); 634 768 } … … 639 773 def sM; 640 774 matrix M_for_sol = fetch(ring_for_matrix, M_C_sol); 641 for(i=1; i<=size(factors[1]); i++){ 775 for(i=1; i<=size(factors[1]); i++) 776 { 642 777 sc = matrix(reduce(check, std(factors[1][i])), 1,nv ); 643 778 644 779 sl = list(); 645 780 sM = sc*M_for_sol; 646 for(j=1; j<=ncols(sM); j++){ 781 for(j=1; j<=ncols(sM); j++) 782 { 647 783 sl[j] = sM[1,j]; 648 784 } 649 785 fsols[i] = sl; 650 786 } 651 if(size(fsols)==0){ 787 if(size(fsols)==0) 788 { 652 789 return(list()); 653 790 } 654 791 setring ring_for_substitution; 655 792 list ssols = imap(ring_for_factorization, fsols); 656 if(npars(original_ring)==1){ 793 if(npars(original_ring)==1) 794 { 657 795 execute("poly P="+Z_get_minpoly(size(original_ring)^nv, "@y")); 658 796 poly RP = gcd(P, (@y^( (s^nv1) div (s1) ))a); 659 for(i=1; i<=size(ssols); i++){ 660 for(j=1; j<=size(ssols[i]); j++){ 797 for(i=1; i<=size(ssols); i++) 798 { 799 for(j=1; j<=size(ssols[i]); j++) 800 { 661 801 ssols[i][j] = reduce( ssols[i][j], std(RP)); 662 802 } … … 667 807 list final_solutions; 668 808 ideal ps; 669 for(i=1; i<=size(solutions); i++){ 809 for(i=1; i<=size(solutions); i++) 810 { 670 811 ps = ideal(); 671 for(j=1; j<=nvars(original_ring); j++){ 812 for(j=1; j<=nvars(original_ring); j++) 813 { 672 814 ps[j] = var(j)solutions[i][j]; 673 815 } … … 691 833 static proc linearReduce(ideal I, list mons) 692 834 { 693 system("nowarn", 1);835 //system("nowarn", 1); 694 836 int LRtime = rtimer; 695 837 int i,j ; 696 838 int prime_field = 1; 697 839 list solutions, monomials; 698 for(i=1; i<=size(mons); i++){ 840 for(i=1; i<=size(mons); i++) 841 { 699 842 monomials = reorderMonomials(mons[i])+monomials; 700 843 } … … 702 845 703 846 def original_ring = basering; 704 if(npars(basering)==1){ 847 if(npars(basering)==1) 848 { 705 849 prime_field=0; 706 850 string minpolystr = "minpoly=" … … 712 856 def ring_for_var_change = changevar( old_vars+","+new_vars, original_ring); 713 857 setring ring_for_var_change; 714 if( prime_field == 0){ 858 if( prime_field == 0) 859 { 715 860 execute(minpolystr); 716 861 } … … 721 866 intvec weights=1:nvars(original_ring); 722 867 723 for(i=1; i<= number_of_monomials; i++){ 868 for(i=1; i<= number_of_monomials; i++) 869 { 724 870 C[i] = monomials[i]  @y(i); 725 871 weights = weights,deg(monomials[i])+1; 726 872 } 727 873 ideal linear_eqs = I; 728 for(i=1; i<=ncols(C); i++){ 874 for(i=1; i<=ncols(C); i++) 875 { 729 876 linear_eqs = reduce(linear_eqs, C[i]); 730 877 } … … 732 879 def ring_for_elimination = changevar( new_vars, ring_for_var_change); 733 880 setring ring_for_elimination; 734 if( prime_field == 0){ 881 if( prime_field == 0) 882 { 735 883 execute(minpolystr); 736 884 } … … 741 889 742 890 setring ring_for_back_change; 743 if( prime_field == 0){ 891 if( prime_field == 0) 892 { 744 893 execute(minpolystr); 745 894 } … … 748 897 ideal C = imap(ring_for_var_change, C); 749 898 ideal J = lin_sol; 750 for(i=1; i<=ncols(C); i++){ 899 for(i=1; i<=ncols(C); i++) 900 { 751 901 J = reduce(J, C[i]); 752 902 } … … 762 912 int n = nvars(basering); 763 913 int t,i,l,j,s; 764 for(i=1; i<=n; i++){ 914 for(i=1; i<=n; i++) 915 { 765 916 monoms_one[i] = var(i); 766 917 } 767 918 monomials = list(monoms_one); 768 if(1 < k){ 769 for(t=2; t<=k; t++){ 919 if(1 < k) 920 { 921 for(t=2; t<=k; t++) 922 { 770 923 lower_monoms = monomials[t1]; 771 924 monoms = list(); 772 925 s = 1; 773 for(i=1; i<=n; i++){ 774 for(j=s; j<=size(lower_monoms); j++){ 926 for(i=1; i<=n; i++) 927 { 928 for(j=s; j<=size(lower_monoms); j++) 929 { 775 930 monoms = monoms+list(lower_monoms[j]*var(i)); 776 931 } … … 787 942 list univar_monoms, mixed_monoms; 788 943 789 for(int j=1; j<=size(monomials); j++){ 790 if( univariate(monomials[j])>0 ){ 944 for(int j=1; j<=size(monomials); j++) 945 { 946 if( univariate(monomials[j])>0 ) 947 { 791 948 univar_monoms = univar_monoms + list(monomials[j]); 792 }else{ 949 } 950 else 951 { 793 952 mixed_monoms = mixed_monoms + list(monomials[j]); 794 953 } … … 803 962 int i = 1; 804 963 805 while( start[1][1] <> char(basering) ){ 964 while( start[1][1] <> char(basering) ) 965 { 806 966 gsub[i+1] = subst( gsub[i], var(i), vec2elm(start[i])); 807 if( gsub[i+1] == 0 ){ 967 if( gsub[i+1] == 0 ) 968 { 808 969 list new = increment(start,i); 809 for(int l=1; l<=size(start); l++){ 810 if(start[l]<>new[l]){ 970 for(int l=1; l<=size(start); l++) 971 { 972 if(start[l]<>new[l]) 973 { 811 974 i = l; 812 975 break; … … 814 977 } 815 978 start = new; 816 }else{ 817 if(i == nvars(basering)){ 979 } 980 else 981 { 982 if(i == nvars(basering)) 983 { 818 984 return(start); 819 985 }else{ … … 827 993 static proc productOfEqs(ideal I) 828 994 { 829 system("nowarn", 1);995 //system("nowarn", 1); 830 996 ideal eqs = sort_ideal(I); 831 997 int i,q; … … 834 1000 ideal I = defaultIdeal(); 835 1001 836 for(i=1; i<=size(eqs); i++){ 1002 for(i=1; i<=size(eqs); i++) 1003 { 837 1004 if(g==0){return(g);} 838 1005 g = reduce(g*(eqs[i]^(q1)1), I); … … 846 1013 int n = nvars(original_ring); 847 1014 int prime_field=npars(basering); 848 if(prime_field){ 1015 if(prime_field) 1016 { 849 1017 string minpolystr = "minpoly="+ 850 1018 get_minpoly_str(size(original_ring),parstr(original_ring,1))+";" ; 851 1019 } 852 1020 853 if(size(#)){ 1021 if(size(#)) 1022 { 854 1023 int newvars = #[1]; 855 856 }else{ 1024 } 1025 else 1026 { 857 1027 int newvars = nvars(original_ring); 858 1028 } … … 860 1030 def newring = changevar(newvarstr, original_ring); 861 1031 setring newring; 862 if( prime_field ){ 1032 if( prime_field ) 1033 { 863 1034 execute(minpolystr); 864 1035 } … … 869 1040 { 870 1041 ideal I; 871 for(int i=1; i<=nvars(basering); i++){ 1042 for(int i=1; i<=nvars(basering); i++) 1043 { 872 1044 I[i] = var(i)^size(basering)var(i); 873 1045 } … … 879 1051 int oe=1; 880 1052 list rl = ringlist(basering); 881 if( size(rl[1]) <> 1){ 1053 if( size(rl[1]) <> 1) 1054 { 882 1055 oe = deg( subst(minpoly,par(1),var(1)) ); 883 1056 } … … 888 1061 { 889 1062 number g = 1; 890 if(npars(basering) == 1) { g=par(1); }1063 if(npars(basering) == 1) { g=par(1); } 891 1064 number e=0; 892 1065 int oe = size(v); 893 for(int i=1; i<=oe; i++){ 1066 for(int i=1; i<=oe; i++) 1067 { 894 1068 e = e+v[i]*g^(oei); 895 1069 } … … 903 1077 c = char(basering); 904 1078 905 if( size(#) == 1 ){ 1079 if( size(#) == 1 ) 1080 { 906 1081 i = #[1]; 907 }else{ 1082 } 1083 else 1084 { 908 1085 i = size(l); 909 1086 } 910 1087 911 1088 l[i] = nextVec(l[i]); 912 while( l[i][1] == c && i>1 ){ 1089 while( l[i][1] == c && i>1 ) 1090 { 913 1091 l[i] = 0:oe; 914 1092 i; 915 1093 l[i] = nextVec(l[i]); 916 1094 } 917 if( i < size(l) ){ 918 for(j=i+1; j<=size(l); j++){ 1095 if( i < size(l) ) 1096 { 1097 for(j=i+1; j<=size(l); j++) 1098 { 919 1099 l[j] = 0:oe; 920 1100 } … … 929 1109 c = char(basering); 930 1110 l[i] = l[i] + 1; 931 while( l[i] == c && i>1 ){ 1111 while( l[i] == c && i>1 ) 1112 { 932 1113 l[i] = 0; 933 1114 i; … … 941 1122 list element, list_of_elements; 942 1123 943 for(int i=1; i<=nvars(basering); i++){ 1124 for(int i=1; i<=nvars(basering); i++) 1125 { 944 1126 element[i] = 0:order_of_extension(); 945 1127 } 946 1128 947 while(size(list_of_elements) < size(basering)^nvars(basering)){ 1129 while(size(list_of_elements) < size(basering)^nvars(basering)) 1130 { 948 1131 list_of_elements = list_of_elements + list(element); 949 1132 element = increment(element); 950 1133 } 951 for(int i=1; i<=size(list_of_elements); i++){ 952 for(int j=1; j<=size(list_of_elements[i]); j++){ 1134 for(int i=1; i<=size(list_of_elements); i++) 1135 { 1136 for(int j=1; j<=size(list_of_elements[i]); j++) 1137 { 953 1138 list_of_elements[i][j] = vec2elm(list_of_elements[i][j]); 954 1139 } … … 960 1145 { 961 1146 int N=0; 962 if(order_of_extension() == 1){ 1147 if(order_of_extension() == 1) 1148 { 963 1149 N = int(a); 964 if(N<0){ 1150 if(N<0) 1151 { 965 1152 N = N + char(basering); 966 1153 } 967 }else{ 1154 } 1155 else 1156 { 968 1157 ideal C = coeffs(subst(a,par(1),var(1)),var(1)); 969 for(int i=1; i<=ncols(C); i++){ 1158 for(int i=1; i<=ncols(C); i++) 1159 { 970 1160 int c = int(C[i]); 971 if(c<0) { c = c + char(basering); }1161 if(c<0) { c = c + char(basering); } 972 1162 N = N + c*char(basering)^(i1); 973 1163 } … … 982 1172 string S = string(minpoly); 983 1173 string SMP; 984 if(S=="0"){ 1174 if(S=="0") 1175 { 985 1176 SMP = SMP+parname; 986 }else{ 987 for(int i=1; i<=size(S); i++){ 988 if(S[i]=="A"){ 1177 } 1178 else 1179 { 1180 for(int i=1; i<=size(S); i++) 1181 { 1182 if(S[i]=="A") 1183 { 989 1184 SMP = SMP+parname; 990 }else{ 1185 } 1186 else 1187 { 991 1188 SMP = SMP+S[i]; 992 1189 } … … 1003 1200 M = ncols(I); 1004 1201 OI = I; 1005 for(i=2; i<=M; i++){ 1202 for(i=2; i<=M; i++) 1203 { 1006 1204 j=i; 1007 while(size(OI[j1])>size(OI[j])){ 1205 while(size(OI[j1])>size(OI[j])) 1206 { 1008 1207 P = OI[j1]; 1009 1208 OI[j1] = OI[j]; 1010 1209 OI[j] = P; 1011 1210 j; 1012 if(j==1) { break; }1211 if(j==1) break; 1013 1212 } 1014 1213 } … … 1022 1221 1023 1222 I=std(I); 1024 for(i=1; i<=nvars(basering); i++){ 1223 for(i=1; i<=nvars(basering); i++) 1224 { 1025 1225 P = P + reduce(var(i),I)*var(1)^(i1); 1026 1226 } 1027 1227 newelement=1; 1028 for(i=1; i<=size(L); i++){ 1029 if(L[i]==P){ 1228 for(i=1; i<=size(L); i++) 1229 { 1230 if(L[i]==P) 1231 { 1030 1232 newelement=0; 1031 1233 break; 1032 1234 } 1033 1235 } 1034 if(newelement){ 1236 if(newelement) 1237 { 1035 1238 L = insert(L, P); 1036 1239 } … … 1044 1247 string S = string(minpoly); 1045 1248 string SMP; 1046 if(S=="0"){ 1249 if(S=="0") 1250 { 1047 1251 SMP = SMP+parname; 1048 }else{ 1049 for(int i=1; i<=size(S); i++){ 1050 if(S[i]=="A"){ 1252 } 1253 else 1254 { 1255 for(int i=1; i<=size(S); i++) 1256 { 1257 if(S[i]=="A") 1258 { 1051 1259 SMP = SMP+parname; 1052 }else{ 1260 } 1261 else 1262 { 1053 1263 SMP = SMP+S[i]; 1054 1264 } … … 1061 1271 { 1062 1272 poly f; 1063 for(int i=1; i<= ncols(I); i++){ 1273 for(int i=1; i<= ncols(I); i++) 1274 { 1064 1275 f = f+I[i]*@y^(i1); 1065 1276 } … … 1070 1281 { 1071 1282 ideal DI; 1072 for(int i=1; i<=number_of_variables; i++){ 1283 for(int i=1; i<=number_of_variables; i++) 1284 { 1073 1285 DI[i] = var(i)^qvar(i); 1074 1286 } 
Singular/LIB/ring.lib
rc133871 rd43600 983 983 proc hasFieldCoefficient(def rng ) 984 984 "USAGE: hasFieldCoefficient ( rng ); 985 RETURN: 1 if the coeff cients form (and are considered to be) a field, 0 otherwise.985 RETURN: 1 if the coefficients form (and are considered to be) a field, 0 otherwise. 986 986 KEYWORDS: ring coefficients 987 987 EXAMPLE: example hasFieldCoefficient; shows an example
Note: See TracChangeset
for help on using the changeset viewer.