- Timestamp:
- Feb 26, 2020, 5:15:14 PM (4 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- ec0708752f1b91087c273c68f2c17b842db5a772
- Parents:
- 0d6d56592c854c03d576138fd39bd0808f01ce94
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/difform.lib
r0d6d565 r3be959 23 23 diffAlgebra(); provides the differential algebra structure and the differential forms dx_1,...,dx_n 24 24 diffAlgebraStructure(); generates the structure of the differential algebra from the basering 25 diffAlgebraCheck(); checks if the basering already has a differential algebra26 diffAlgebraSwitch(); changes the basering to the differential algebra for computations27 25 diffAlgebraGens(); defines the differential forms dx_1,...,dx_n 28 26 diffAlgebraUnivDerIdeal(ideal); computes the image of an ideal under the universal derivation … … 71 69 KEYWORDS: differential forms;differentials;differential algebra 72 70 "; 73 //////////////////////////////////////////////////////////////////////////////////////////////// 74 //////////////////////////////////////////////////////////////////////////////////////////////// 75 76 77 //////////////////////////////////////////////////////////////////////////////////////////////// 78 //////////////////////////////////////////////////////////////////////////////////////////////// 79 // Initialization of library // 80 //////////////////////////////////////////////////////////////////////////////////////////////// 81 //////////////////////////////////////////////////////////////////////////////////////////////// 82 71 // Libraries needed 72 LIB "inout.lib"; 73 74 //////////////////////////////////////////////////////////////////////////////// 75 // Initialization of library // 76 //////////////////////////////////////////////////////////////////////////////// 83 77 84 78 static proc mod_init() 85 79 { 86 87 80 // Type of differential forms: 81 // These are considered as elements (polynomials) in the differential algebra 88 82 // NOTE: the polynomials 'form' are not visible in the basering - only in the differential algebra 89 83 newstruct("difform","poly form"); 90 84 91 85 // Type of derivations - these are maps: Omega_R^1 -> R … … 95 89 newstruct("derivation","list genIm"); 96 90 97 98 99 100 101 102 103 104 91 // Overloads for difform 92 system("install", "difform", "=", difformFromPoly, 1); 93 system("install", "difform", "print", difformPrint, 1); 94 95 system("install", "difform", "+", difformAdd, 2); 96 system("install", "difform", "-", difformSub, 2); 97 system("install", "difform", "-", difformNeg, 1); 98 system("install", "difform", "*", difformMul, 2); 105 99 system("install", "difform", "/", difformDiv, 2); 106 107 100 system("install", "difform", "==", difformEqu, 2); 101 system("install", "difform", "<>", difformNeq, 2); 108 102 system("install", "difform", ">", difformIsBigger,2); 109 103 system("install", "difform", "<", difformIsSmaller,2); 110 104 111 105 system("install", "difform", "deg", difformDeg, 1); 112 106 system("install", "difform", "homog", difformIsHomog, 1); 113 107 … … 126 120 system("install", "derivation", "diff", derivationLie, 2); 127 121 128 // Libraries needed 129 LIB "inout.lib"; 130 } 131 132 133 //////////////////////////////////////////////////////////////////////////////////////////////// 134 //////////////////////////////////////////////////////////////////////////////////////////////// 135 // Construction of differential algebra // 136 //////////////////////////////////////////////////////////////////////////////////////////////// 137 //////////////////////////////////////////////////////////////////////////////////////////////// 122 } 123 124 125 //////////////////////////////////////////////////////////////////////////////// 126 // Construction of differential algebra // 127 //////////////////////////////////////////////////////////////////////////////// 138 128 139 129 140 130 // TODO: check if qringNF option is set - if yes: turn off and set afterwards on 141 131 proc diffAlgebra() 142 "USAGE: 143 SIDE EFFECTS: 144 145 146 NOTE: 147 148 149 150 KEYWORDS: 151 SEE ALSO: diffAlgebraStructure, diffAlgebraGens,diffAlgebraUnivDerIdeal152 EXAMPLE: 132 "USAGE: diffAlgebra(); 133 SIDE EFFECTS: If R is the basering, the differential algebra is constructed with name Omega_R 134 and the differential forms dx_1,...,dx_n are available. The name of the differential 135 algebra is stored in the attribute attrib(R,"diffAlgebra"). 136 NOTE: - computations with differential forms need the structure of the differential algebra, 137 so this procedure should be executed first. 138 - the variable names 'd' or 'D' should be avoided. 139 - the procedure also works for quotient rings 140 KEYWORDS: differential algebra; differential forms; differentials 141 SEE ALSO: diffAlgebraStructure; diffAlgebraGens; diffAlgebraUnivDerIdeal 142 EXAMPLE: example diffAlgebra; shows an example" 153 143 { 154 144 155 145 // Build the differential algebra and store its name as an attribute 156 string diffAlg_name= diffAlgebraStructure();157 attrib(basering,"diffAlgebra", diffAlg_name);146 ring Omega_R = diffAlgebraStructure(); 147 attrib(basering,"diffAlgebra","Omega_R"); 158 148 159 149 // Construct the differential forms dx_1,...,dx_n over the basering … … 173 163 string info_text = "// The differential algebra " + attrib(basering,"diffAlgebra") + " was constructed and the differential forms " + basic_forms + " are available."; 174 164 print(info_text); 175 return();176 177 165 } 178 166 example … … 200 188 qring S = std(I); 201 189 diffAlgebra(); 202 setring Omega_ S;190 setring Omega_R; 203 191 204 192 // The differential algebra is given by: 205 193 basering; 206 194 207 kill Omega_ S,dx,dy,dz;208 } 209 210 211 //////////////////////////////////////////////////////////////////////////////// ////////////////195 kill Omega_R,dx,dy,dz; 196 } 197 198 199 //////////////////////////////////////////////////////////////////////////////// 212 200 213 201 … … 224 212 { 225 213 226 string basering_name = nameof(basering); 227 list base_list = ringlist(basering); 214 list base_list = ringlist(basering); 228 215 def R_old = basering; 229 216 ideal quot_ideal = base_list[4]; 230 217 231 // Add Dx_1,...,Dx_n as first variables 232 list ext_var = base_list[2]; 233 int n = size(ext_var); 234 int i; 235 236 for(i = 1; i <= n; i++){ 237 ext_var[n+i] = ext_var[i]; 238 ext_var[i] = "D" + ext_var[n+i]; 239 } 240 241 base_list[2] = ext_var; 218 // Add Dx_1,...,Dx_n as first variables 219 list ext_var = base_list[2]; 220 int n = size(ext_var); 221 int i; 222 223 for(i = 1; i <= n; i++) 224 { 225 ext_var[n+i] = ext_var[i]; 226 ext_var[i] = "D" + ext_var[n+i]; 227 } 228 229 base_list[2] = ext_var; 242 230 243 231 // Preserve the monomial order of the basering … … 246 234 base_list[3] = list(list("dp",weight_vec)) + base_list[3]; 247 235 248 // Add relations x_i*x_j = x_j*x_i and dx_i*dx_j = -dx_j*dx_i 249 int k = 2*n; 250 matrix C[k][k]; 251 matrix D[k][k]; 252 int j; 253 254 // Generate strictly upper triangular matrix describing the relations 255 for(i = 1; i <= k; i++){ 256 for(j = i+1; j <= k ; j++){ 257 if(j <= n){ 258 C[i,j] = -1; 259 }else{ 260 C[i,j] = 1; 261 } 262 } 263 } 236 // Add relations x_i*x_j = x_j*x_i and dx_i*dx_j = -dx_j*dx_i 237 int k = 2*n; 238 matrix C[k][k]; 239 matrix D[k][k]; 240 int j; 241 242 // Generate strictly upper triangular matrix describing the relations 243 for(i = 1; i <= k; i++) 244 { 245 for(j = i+1; j <= k ; j++) 246 { 247 if(j <= n) 248 { 249 C[i,j] = -1; 250 } 251 else 252 { 253 C[i,j] = 1; 254 } 255 } 256 } 264 257 265 258 base_list[4] = ideal(0); 266 base_list[5] = C; 267 base_list[6] = D; 268 269 // Pass to non-commutative ring with extra variables and relations 270 ring R_intermediate = ring(base_list); 271 272 // Add relations Dx_i*Dx_i = 0 via generating a quotient ring 273 ideal REL; 274 for(i = 1; i <= n; i++){ 275 REL[i] = var(i)*var(i); 276 } 277 278 // Build the differential algebra for the polynomial ring - the free module 259 base_list[5] = C; 260 base_list[6] = D; 261 262 // Pass to non-commutative ring with extra variables and relations 263 ring R_intermediate = ring(base_list); 264 265 // Add relations Dx_i*Dx_i = 0 via generating a quotient ring 266 ideal REL; 267 for(i = 1; i <= n; i++) 268 { 269 REL[i] = var(i)*var(i); 270 } 271 272 // Build the differential algebra for the polynomial ring - the free module 279 273 qring diffAlg_poly = twostd(REL); 280 274 … … 282 276 ideal quot_ideal = imap(R_old,quot_ideal); 283 277 284 if(quot_ideal != 0){ 285 286 // Compute the universal derivation of the generators of the ideal 287 quot_ideal = quot_ideal + diffAlgebraUnivDerIdeal(quot_ideal); 288 289 // Add the additional relations, generate the differential algebra with name Omega_R and export it 290 string diffAlg_name = "Omega_" + basering_name; 291 execute("qring " + diffAlg_name + " = twostd(quot_ideal);"); 292 execute("exportto(Top," + diffAlg_name + ");"); 293 294 return(diffAlg_name); 278 if(size(quot_ideal) != 0) 279 { 280 // Compute the universal derivation of the generators of the ideal 281 quot_ideal = quot_ideal + diffAlgebraUnivDerIdeal(quot_ideal); 282 283 // Add the additional relations, generate the differential algebra with name Omega_R and export it 284 qring Omega_R = twostd(quot_ideal); 285 exportto(Top,Omega_R); 286 287 return(Omega_R); 295 288 } 296 289 297 290 // Give the differential algebra the name Omega_basering and export it 298 string diffAlg_name = "Omega_" + basering_name; 299 execute("ring " + diffAlg_name + " = diffAlg_poly;"); 300 execute("exportto(Top," + diffAlg_name + ");"); 301 302 return(diffAlg_name); 303 304 } 305 306 307 //////////////////////////////////////////////////////////////////////////////////////////////// 308 309 310 proc diffAlgebraCheck() 311 "USAGE: diffAlgebraCheck(); 312 SIDE EFFECTS: Checks if the basering has a differential algebra and aborts with an error if this is not the case 313 REMARKS: The procedure checks if the name in the attribute attrib(basering,"diffAlgebra") is not empty. This 314 is the case if the procedure diffAlgebra was executed first. 315 NOTE: whenever computations with differential forms are done, it should be checked if the differential 316 algebra was already generated since differential forms are polynomials in the differential algebra 317 KEYWORDS: differential algebra 318 SEE ALSO: diffAlgebraSwitch" 319 { 320 string diffAlg_name = attrib(basering,"diffAlgebra"); 321 if(size(diffAlg_name) == 0){ 322 ERROR("Ring does not have a differential algebra!"); 323 } 324 } 325 326 327 //////////////////////////////////////////////////////////////////////////////////////////////// 328 329 330 proc diffAlgebraSwitch() 331 "USAGE: diffAlgebraSwitch(); 332 ASSUME: The differential algebra was already constructed. 333 SIDE EFFECTS: Changes the ring: from the basering to the differential algebra. 334 NOTE: whenever computations with differential forms are done, the ring must be changed to the differential 335 algebra since differential forms are polynomials there. But first it should be checked if the algebra 336 is actually available: so before executing diffAlgebraSwitch there should always be an preceding diffAlgebraCheck 337 KEYWORDS: differential algebra 338 SEE ALSO: diffAlgebraCheck" 339 { 340 341 string diffAlg_name = attrib(basering,"diffAlgebra"); 342 execute("setring " + diffAlg_name); 343 execute("keepring " + diffAlg_name); 344 345 } 346 347 348 //////////////////////////////////////////////////////////////////////////////////////////////// 291 ring Omega_R = diffAlg_poly; 292 exportto(Top,Omega_R); 293 294 return(Omega_R); 295 } 296 297 298 //////////////////////////////////////////////////////////////////////////////// 299 300 301 //////////////////////////////////////////////////////////////////////////////// 302 303 304 //////////////////////////////////////////////////////////////////////////////// 349 305 350 306 … … 356 312 { 357 313 358 diffAlgebraSwitch();359 360 list ext_var = ringlist( basering)[2];314 setring Omega_R; 315 316 list ext_var = ringlist(Omega_R)[2]; 361 317 int n = size(ext_var) div 2; 362 318 int i; … … 391 347 ideal d_I; 392 348 393 for(j = 1; j <= k; j++){ 349 for(j = 1; j <= k; j++) 350 { 394 351 d_I[j] = 0; 395 for(i = 1; i <= n; i++){ 352 for(i = 1; i <= n; i++) 353 { 396 354 d_I[j] = d_I[j] + diff(I[j],var(i+n))*var(i); 397 355 } 398 356 } 399 400 357 return(d_I); 401 358 … … 435 392 436 393 // Get information from input 437 for(i = 1; i <= n; i++){ 438 if(typeof(#[i]) == "string"){ 439 440 if(#[i] == "gen" && typeof(#[i+1]) == "string"){ 394 for(i = 1; i <= n; i++) 395 { 396 if(typeof(#[i]) == "string") 397 { 398 if(#[i] == "gen" && typeof(#[i+1]) == "string") 399 { 441 400 gen_ord = #[i+1]; 442 if(typeof(#[i+2]) == "intvec"){ 401 if(typeof(#[i+2]) == "intvec") 402 { 443 403 intvec gen_weight = #[i+2]; 444 404 } 445 405 } 446 447 if(#[i] == "ringvar" && typeof(#[i+1]) == "string"){406 if(#[i] == "ringvar" && typeof(#[i+1]) == "string") 407 { 448 408 ringvar_ord = #[i+1]; 449 if(typeof(#[i+2]) == "intvec"){ 409 if(typeof(#[i+2]) == "intvec") 410 { 450 411 intvec ringvar_weight = #[i+2]; 451 412 } … … 456 417 // Check input for consistency 457 418 // Generator ordering must be a valid monomial ordering 458 if(gen_ord != "" && gen_ord != "lp" && gen_ord != "rp" && gen_ord != "dp" && gen_ord != "Dp" && gen_ord != "wp" && gen_ord != "Wp"){ 459 if(gen_ord != "ls" && gen_ord != "ds" && gen_ord != "Ds" && gen_ord != "ws" && gen_ord != "Ws"){ 419 if(gen_ord != "" && gen_ord != "lp" && gen_ord != "rp" && gen_ord != "dp" && gen_ord != "Dp" && gen_ord != "wp" && gen_ord != "Wp") 420 { 421 if(gen_ord != "ls" && gen_ord != "ds" && gen_ord != "Ds" && gen_ord != "ws" && gen_ord != "Ws") 422 { 460 423 ERROR("Not a valid ordering!"); 461 424 } 462 425 } 463 464 426 // Ringvariable ordering must be a valid monomial ordering 465 if(ringvar_ord != "" && ringvar_ord != "lp" && ringvar_ord != "rp" && ringvar_ord != "dp" && ringvar_ord != "Dp" && ringvar_ord != "wp" && ringvar_ord != "Wp"){ 466 if(ringvar_ord != "ls" && ringvar_ord != "ds" && ringvar_ord != "Ds" && ringvar_ord != "ws" && ringvar_ord != "Ws"){ 427 if(ringvar_ord != "" && ringvar_ord != "lp" && ringvar_ord != "rp" && ringvar_ord != "dp" && ringvar_ord != "Dp" && ringvar_ord != "wp" && ringvar_ord != "Wp") 428 { 429 if(ringvar_ord != "ls" && ringvar_ord != "ds" && ringvar_ord != "Ds" && ringvar_ord != "ws" && ringvar_ord != "Ws") 430 { 467 431 ERROR("Not a valid ordering!"); 468 432 } 469 433 } 470 471 434 // If the generator ordering is a weighted monomial ordering, a weight-vector is needed 472 if(gen_ord == "wp" || gen_ord == "Wp" || gen_ord == "ws" || gen_ord == "Ws"){ 473 if(!defined(gen_weight)){ 435 if(gen_ord == "wp" || gen_ord == "Wp" || gen_ord == "ws" || gen_ord == "Ws") 436 { 437 if(!defined(gen_weight)) 438 { 474 439 ERROR("No weight vector given!"); 475 440 } 476 477 if(size(gen_weight) != k){441 if(size(gen_weight) != k) 442 { 478 443 ERROR("Weight vector has wrong size!"); 479 444 } 480 }else{ 445 } 446 else 447 { 481 448 // If a weight vector is given although the monomial ordering is not weighted 482 if(defined(gen_weight)){ 449 if(defined(gen_weight)) 450 { 483 451 kill gen_weight; 484 452 } 485 453 } 486 487 454 // If the ordering for the ring variables is a weighted monmial ordering, a weight-vector is needed 488 if(ringvar_ord == "wp" || ringvar_ord == "Wp" || ringvar_ord == "ws" || ringvar_ord == "Ws"){ 489 if(!defined(ringvar_weight)){ 455 if(ringvar_ord == "wp" || ringvar_ord == "Wp" || ringvar_ord == "ws" || ringvar_ord == "Ws") 456 { 457 if(!defined(ringvar_weight)) 458 { 490 459 ERROR("No weight vector given!"); 491 460 } 492 493 if(size(ringvar_weight) != k){461 if(size(ringvar_weight) != k) 462 { 494 463 ERROR("Weight vector has wrong size!"); 495 464 } 496 }else{ 465 } 466 else 467 { 497 468 // If a weight vector is given although the monomial ordering is not weighted 498 if(defined(ringvar_weight)){ 469 if(defined(ringvar_weight)) 470 { 499 471 kill ringvar_weight; 500 472 } 501 473 } 502 503 474 list L_diff_Alg = ringlist(basering); 504 475 n = size(L_diff_Alg[3]); 505 476 506 477 // Change ordering of generators 507 if(gen_ord != ""){ 478 if(gen_ord != "") 479 { 508 480 L_diff_Alg[3][1][1] = gen_ord; 509 if(defined(gen_weight)){ 481 if(defined(gen_weight)) 482 { 510 483 L_diff_Alg[3][1][2] = gen_weight; 511 484 } … … 513 486 514 487 // Change the ordering of the ringvariables 515 if(ringvar_ord != ""){ 488 if(ringvar_ord != "") 489 { 516 490 list L; 517 491 L[1] = L_diff_Alg[3][1]; 518 519 492 L[2] = list(); 520 493 L[2][1] = ringvar_ord; 521 if(defined(ringvar_weight)){ 494 if(defined(ringvar_weight)) 495 { 522 496 L[2][2] = ringvar_weight; 523 }else{ 497 } 498 else 499 { 524 500 L[2][2] = 1:k; 525 501 } 526 527 502 L_diff_Alg[3] = L; 528 503 } … … 530 505 def T = ring(L_diff_Alg); 531 506 return(T); 532 533 507 } 534 508 … … 539 513 proc diffAlgebraListGen(list #) 540 514 "USAGE: diffAlgebraListGen(#); # list 541 RETURN: - a list of gener etors of the differential algebra as module over the basering515 RETURN: - a list of generators of the differential algebra as module over the basering 542 516 - a list of generators of a graded part of the differential algebra 543 517 REMARKS: In order to find all generators, they are counted 'binary': The generators are in … … 552 526 EXAMPLE: example diffAlgebraListGen; shows an example" 553 527 { 554 555 diffAlgebraCheck();556 557 528 int n = size(ringlist(basering)[2]); 558 529 int i,k,j; … … 564 535 565 536 // Get optional degree 566 if(size(#) > 0){ 567 if(typeof(#[1]) == "int"){ 537 if(size(#) > 0) 538 { 539 if(typeof(#[1]) == "int") 540 { 568 541 degr = #[1]; 569 542 } … … 572 545 // Build the list of all dx_i 573 546 def R_old = basering; 574 diffAlgebraSwitch(); 575 576 for(i = 1; i <= n; i++){ 547 setring Omega_R; 548 549 for(i = 1; i <= n; i++) 550 { 577 551 current_var.form = var(i); 578 552 var_list[i] = current_var; … … 583 557 // Find all generators (of given degree) 584 558 list dual_i; 585 for(i = 1; i < 2^n; i++){ 559 for(i = 1; i < 2^n; i++) 560 { 586 561 // Compute dual number representation 587 562 dual_i = diffAlgebraIntToDual(i); … … 590 565 591 566 // Convert dual number to generator 592 for(j = 1; j <= k; j++){ 593 if(dual_i[j] != 0){ 567 for(j = 1; j <= k; j++) 568 { 569 if(dual_i[j] != 0) 570 { 594 571 current_gen = current_gen*var_list[j]; 595 572 } … … 597 574 598 575 // Add generator if it has the given degree or degree was not chosen 599 if(degr == -1 || difformDeg(current_gen) == degr){ 576 if(degr == -1 || difformDeg(current_gen) == degr) 577 { 600 578 GEN_list = GEN_list + list(current_gen); 601 579 } … … 603 581 604 582 // Add generator 1 605 if(degr == 0 || degr == -1){ 583 if(degr == 0 || degr == -1) 584 { 606 585 difform gen_one = 1; 607 586 GEN_list = list(gen_one) + GEN_list; … … 609 588 610 589 return(difformListSort(GEN_list)); 611 612 590 } 613 591 example … … 631 609 632 610 633 //////////////////////////////////////////////////////////////////////////////// ////////////////611 //////////////////////////////////////////////////////////////////////////////// 634 612 635 613 … … 641 619 SEE ALSO: diffAlgebraListGen" 642 620 { 643 644 621 list dual_number; 645 622 646 while(l div 2 != 0){ 623 while(l div 2 != 0) 624 { 647 625 dual_number = dual_number + list(l mod 2); 648 626 l = l div 2; 649 627 } 650 651 628 dual_number = dual_number + list(l mod 2); 652 653 629 return(dual_number); 654 655 } 656 657 658 //////////////////////////////////////////////////////////////////////////////////////////////// 659 //////////////////////////////////////////////////////////////////////////////////////////////// 660 // Procedures for type difform // 661 //////////////////////////////////////////////////////////////////////////////////////////////// 662 //////////////////////////////////////////////////////////////////////////////////////////////// 663 664 665 //////////////////////////////////////////////////////////////////////////////////////////////// 666 //----------------------------------- Structural procedures ----------------------------------// 667 //////////////////////////////////////////////////////////////////////////////////////////////// 630 } 631 632 633 //////////////////////////////////////////////////////////////////////////////// 634 //////////////////////////////////////////////////////////////////////////////// 635 // Procedures for type difform // 636 //////////////////////////////////////////////////////////////////////////////// 637 //////////////////////////////////////////////////////////////////////////////// 638 639 640 //////////////////////////////////////////////////////////////////////////////// 641 //----------------------- Structural procedures ------------------------------// 642 //////////////////////////////////////////////////////////////////////////////// 668 643 669 644 … … 677 652 { 678 653 679 diffAlgebraCheck();680 654 def R_old = basering; 681 diffAlgebraSwitch();655 setring Omega_R; 682 656 683 657 poly g = imap(R_old,f); … … 686 660 687 661 return(df); 688 689 662 } 690 663 example … … 712 685 713 686 714 //////////////////////////////////////////////////////////////////////////////// ////////////////687 //////////////////////////////////////////////////////////////////////////////// 715 688 716 689 … … 726 699 EXAMPLE: example difformCoef; shows an example" 727 700 { 728 729 diffAlgebraCheck();730 701 def R_old = basering; 731 diffAlgebraSwitch();702 setring Omega_R; 732 703 def diff_Alg = basering; 733 704 … … 736 707 int i; 737 708 738 // Build the wedge product of all differential forms dx_i 739 poly wedge_mon = 1; 740 for(i = 1; i <= n; i++){ 741 wedge_mon = wedge_mon*var(i); 742 } 743 744 // Find the coefficients of the generators 709 // Build the wedge product of all differential forms dx_i 710 poly wedge_mon = 1; 711 for(i = 1; i <= n; i++) 712 { 713 wedge_mon = wedge_mon*var(i); 714 } 715 716 // Find the coefficients of the generators 745 717 matrix df_coefs = coef(f,wedge_mon); 746 718 int k = ncols(df_coefs); … … 753 725 list repr; 754 726 755 for(i = 1;i <= k;i++){ 756 repr[i] = list(); 757 setring diff_Alg; 758 759 // Generators as differential forms 760 current_gen.form = df_coefs[1,i]; 761 762 // Coefficients are polynomials in the basering 763 coeff_above = df_coefs[2,i]; 764 setring R_old; 765 coeff = imap(diff_Alg,coeff_above); 766 767 repr[i][1] = current_gen; 768 repr[i][2] = coeff; 727 for(i = 1;i <= k;i++) 728 { 729 repr[i] = list(); 730 setring diff_Alg; 731 732 // Generators as differential forms 733 current_gen.form = df_coefs[1,i]; 734 735 // Coefficients are polynomials in the basering 736 coeff_above = df_coefs[2,i]; 737 setring R_old; 738 coeff = imap(diff_Alg,coeff_above); 739 740 repr[i][1] = current_gen; 741 repr[i][2] = coeff; 769 742 } 770 743 771 744 // Return representation 772 745 return(repr); 773 774 746 } 775 747 example … … 797 769 798 770 799 //////////////////////////////////////////////////////////////////////////////// ////////////////771 //////////////////////////////////////////////////////////////////////////////// 800 772 801 773 … … 809 781 SEE ALSO: difformToString" 810 782 { 811 812 diffAlgebraSwitch(); 783 setring Omega_R; 813 784 string df_out_un = string(df.form); 814 list vars_ = ringlist( basering)[2];785 list vars_ = ringlist(Omega_R)[2]; 815 786 int n = size(vars_) div 2; 816 787 int i,j; 817 788 818 789 // Replace the Dx_i in the string with the dx_i 819 for(i = 1; i <= n; i++){ 790 for(i = 1; i <= n; i++) 791 { 820 792 j = find(df_out_un,string(vars_[i])); 821 793 822 while(j!=0){ 794 while(j!=0) 795 { 823 796 df_out_un[j] = "d"; 824 797 j = find(df_out_un,vars_[i]); 825 798 } 826 799 } 827 828 800 return(df_out_un); 829 830 } 831 832 833 //////////////////////////////////////////////////////////////////////////////////////////////// 834 801 } 802 803 //////////////////////////////////////////////////////////////////////////////// 835 804 836 805 // TODO: check optionIsSet("qringNF") - ADD ring.lib !!! and reduce by hand … … 848 817 EXAMPLE: example difformToString; shows an example" 849 818 { 850 851 819 // Get the coefficients 852 820 list repr = difformCoef(df); … … 857 825 int i; 858 826 859 for(i = 1; i <= n; i++){ 860 if(typeof(#[i]) == "string"){ 861 if(#[i] == "gen" && typeof(#[i+1]) == "string"){ 827 for(i = 1; i <= n; i++) 828 { 829 if(typeof(#[i]) == "string") 830 { 831 if(#[i] == "gen" && typeof(#[i+1]) == "string") 832 { 862 833 gen_ord = #[i+1]; 863 if(typeof(#[i+2]) == "intvec"){ 834 if(typeof(#[i+2]) == "intvec") 835 { 864 836 intvec gen_weight = #[i+2]; 865 837 } … … 869 841 870 842 // Sort the generator/coefficients by the chosen ordering 871 if(gen_ord != ""){ 872 if(defined(gen_weight)){ 843 if(gen_ord != "") 844 { 845 if(defined(gen_weight)) 846 { 873 847 repr = difformListSort(repr,"Llist","gen",gen_ord,gen_weight); 874 }else{ 848 } 849 else 850 { 875 851 repr = difformListSort(repr,"Llist","gen",gen_ord); 876 852 } 877 }else{ 853 } 854 else 855 { 878 856 repr = difformListSort(repr,"Llist"); 879 857 } … … 888 866 string df_coef_str; 889 867 890 for(i = n; i >= 1; i--){ 868 for(i = n; i >= 1; i--) 869 { 891 870 df_gen = repr[i][1]; 892 871 df_gen_str = difformGenToString(df_gen); … … 895 874 896 875 // Check the coefficients and generators 897 while(1){ 876 while(1) 877 { 898 878 // Special cases without brackets: 899 879 … … 912 892 913 893 // Add a plus sign 914 if(i > 1){ 894 if(i > 1) 895 { 915 896 df_out = df_out + "+"; 916 897 } 917 898 } 918 899 919 return(df_out); 920 900 return(df_out); 921 901 } 922 902 example … … 955 935 EXAMPLE: example difformPrint; shows an example" 956 936 { 957 958 937 // Print in ds-order on the generators 959 print(difformToString(df,"gen","ds")); 960 return(); 961 938 print(difformToString(df,"gen","ds")); 962 939 } 963 940 example … … 990 967 " 991 968 { 992 993 diffAlgebraCheck();994 969 list df_gen_repr = difformCoef(df); 995 970 int n = size(df_gen_repr); 996 971 997 if(n == 1 && df_gen_repr[1][2] == 1){ 972 if(n == 1 && df_gen_repr[1][2] == 1) 973 { 998 974 return(1); 999 975 } 1000 1001 976 return(0); 1002 1003 977 } 1004 978 example … … 1043 1017 EXAMPLE: example difformAdd; shows an example" 1044 1018 { 1045 1046 diffAlgebraCheck(); 1047 diffAlgebraSwitch(); 1019 setring Omega_R; 1048 1020 1049 1021 difform dsum; … … 1089 1061 EXAMPLE: example difformSub; shows an example" 1090 1062 { 1091 1092 diffAlgebraCheck(); 1093 diffAlgebraSwitch(); 1063 setring Omega_R; 1094 1064 1095 1065 difform dsub; … … 1098 1068 1099 1069 return(dsub); 1100 1101 1070 } 1102 1071 example … … 1135 1104 EXAMPLE: example difformNeg; shows an example" 1136 1105 { 1137 1138 diffAlgebraCheck(); 1139 diffAlgebraSwitch(); 1106 setring Omega_R; 1140 1107 1141 1108 difform dneg; … … 1144 1111 1145 1112 return(dneg); 1146 1147 1113 } 1148 1114 example … … 1163 1129 1164 1130 1165 //////////////////////////////////////////////////////////////////////////////// ////////////////1131 //////////////////////////////////////////////////////////////////////////////// 1166 1132 1167 1133 … … 1173 1139 EXAMPLE: example difformMul; shows an example" 1174 1140 { 1175 1176 diffAlgebraCheck(); 1177 diffAlgebraSwitch(); 1141 setring Omega_R; 1178 1142 1179 1143 difform dmul; … … 1182 1146 1183 1147 return(dmul); 1184 1185 1148 } 1186 1149 example … … 1219 1182 EXAMPLE: example difformDiv; shows an example" 1220 1183 { 1221 1222 diffAlgebraCheck(); 1223 diffAlgebraSwitch(); 1184 setring Omega_R; 1224 1185 1225 1186 difform ddiv; … … 1228 1189 1229 1190 return(ddiv); 1230 1231 1191 } 1232 1192 example … … 1255 1215 1256 1216 1257 //////////////////////////////////////////////////////////////////////////////// ////////////////1217 //////////////////////////////////////////////////////////////////////////////// 1258 1218 1259 1219 … … 1265 1225 EXAMPLE: example difformEqu; shows an example" 1266 1226 { 1267 1268 diffAlgebraCheck(); 1269 diffAlgebraSwitch(); 1270 1227 setring Omega_R; 1271 1228 return(df.form == dg.form); 1272 1273 1229 } 1274 1230 example … … 1293 1249 1294 1250 1295 //////////////////////////////////////////////////////////////////////////////// ////////////////1251 //////////////////////////////////////////////////////////////////////////////// 1296 1252 1297 1253 … … 1303 1259 EXAMPLE: example difformNeq; shows an example" 1304 1260 { 1305 1306 1261 return(!difformEqu(df,dg)); 1307 1308 1262 } 1309 1263 example … … 1347 1301 EXAMPLE: example difformIsBigger; shows an example" 1348 1302 { 1349 1350 diffAlgebraCheck(); 1351 diffAlgebraSwitch(); 1303 setring Omega_R; 1352 1304 1353 1305 poly df_form = df.form; 1354 1306 poly dg_form = dg.form; 1355 1307 1356 if(size(#) > 0){ 1357 def diff_Alg = basering; 1308 if(size(#) > 0) 1309 { 1310 def diff_Alg = Omega_R; 1358 1311 ring T = diffAlgebraChangeOrd(#); 1359 1312 … … 1364 1317 1365 1318 return(df_form > dg_form); 1366 1367 1319 } 1368 1320 example … … 1392 1344 1393 1345 1394 //////////////////////////////////////////////////////////////////////////////// ////////////////1346 //////////////////////////////////////////////////////////////////////////////// 1395 1347 1396 1348 … … 1411 1363 EXAMPLE: example difformIsSmaller; shows an example" 1412 1364 { 1413 1414 diffAlgebraCheck(); 1415 diffAlgebraSwitch(); 1365 setring Omega_R; 1416 1366 1417 1367 poly df_form = df.form; 1418 1368 poly dg_form = dg.form; 1419 1369 1420 if(size(#) > 0){ 1370 if(size(#) > 0) 1371 { 1421 1372 def diff_Alg = basering; 1422 1373 ring T = diffAlgebraChangeOrd(#); … … 1426 1377 return(df_form_T < dg_form_T); 1427 1378 } 1428 1429 1379 return(df.form < dg.form); 1430 1431 1380 } 1432 1381 example … … 1456 1405 1457 1406 1458 //////////////////////////////////////////////////////////////////////////////// ////////////////1459 //------------ ------------- Procedures for computing with the degree -------------------------//1460 //////////////////////////////////////////////////////////////////////////////// ////////////////1407 //////////////////////////////////////////////////////////////////////////////// 1408 //------------ Procedures for computing with the degree ----------------------// 1409 //////////////////////////////////////////////////////////////////////////////// 1461 1410 1462 1411 … … 1471 1420 EXAMPLE: example difformDeg; shows an example" 1472 1421 { 1473 1474 diffAlgebraCheck(); 1475 diffAlgebraSwitch(); 1422 setring Omega_R; 1476 1423 1477 1424 // Degree of a difform is the degree of the poly with weights 0 for the basering variables 1478 int n = size(ringlist( basering)[2]) div 2;1425 int n = size(ringlist(Omega_R)[2]) div 2; 1479 1426 int i; 1480 1427 intvec var_weights; 1481 1428 1482 for(i = 1; i <= n; i++){ 1429 for(i = 1; i <= n; i++) 1430 { 1483 1431 var_weights[i] = 1; 1484 1432 var_weights[i+n] = 0; 1485 1433 } 1486 1487 1434 return(deg(df.form,var_weights)); 1488 1489 1435 } 1490 1436 example … … 1511 1457 } 1512 1458 1513 1514 //////////////////////////////////////////////////////////////////////////////////////////////// 1459 //////////////////////////////////////////////////////////////////////////////// 1515 1460 1516 1461 … … 1525 1470 EXAMPLE: example difformIsHomog; shows an example" 1526 1471 { 1527 1528 diffAlgebraCheck(); 1529 diffAlgebraSwitch(); 1530 1531 int n = size(ringlist(basering)[2]) div 2; 1472 setring Omega_R; 1473 1474 int n = size(ringlist(Omega_R)[2]) div 2; 1532 1475 int i; 1533 1476 intvec var_weights; 1534 1477 1535 for(i = 1; i <= n; i++){ 1478 for(i = 1; i <= n; i++) 1479 { 1536 1480 var_weights[i] = 1; 1537 1481 var_weights[i+n] = 0; 1538 1482 } 1539 1540 1483 return(homog(df.form,var_weights)); 1541 1542 1484 } 1543 1485 example … … 1572 1514 1573 1515 1574 //////////////////////////////////////////////////////////////////////////////// ////////////////1516 //////////////////////////////////////////////////////////////////////////////// 1575 1517 1576 1518 … … 1583 1525 EXAMPLE: example difformIsHomogDeg; shows an example" 1584 1526 { 1585 1586 1527 int df_deg = difformDeg(df); 1587 1528 int is_hom = difformIsHomog(df); 1588 1529 return(df_deg == p && is_hom == 1); 1589 1590 1530 } 1591 1531 example … … 1620 1560 1621 1561 1622 //////////////////////////////////////////////////////////////////////////////// ////////////////1562 //////////////////////////////////////////////////////////////////////////////// 1623 1563 1624 1564 … … 1632 1572 EXAMPLE: example difformHomogDecomp; shows an example" 1633 1573 { 1634 1635 diffAlgebraCheck();1636 1637 1574 // Highest degree is the nr. of variables in the basering 1638 1575 int n = size(ringlist(basering)[2]); … … 1643 1580 1644 1581 // Generate a list full of 0s 1645 for(i = 1;i <= (n+1); i++){ 1582 for(i = 1;i <= (n+1); i++) 1583 { 1646 1584 homog_part[i] = 0; 1647 1585 } … … 1652 1590 1653 1591 // Sort in list 1654 for(i = 1; i <= k; i++){ 1592 for(i = 1; i <= k; i++) 1593 { 1655 1594 current_gen = df_gen_repr[i][1]; 1656 1595 current_coef = df_gen_repr[i][2]; 1657 1596 j = difformDeg(current_gen); 1658 1597 1659 if(j == 0){ 1598 if(j == 0) 1599 { 1660 1600 homog_part[n+1] = homog_part[n+1] + current_coef*current_gen; 1661 }else{ 1601 } 1602 else 1603 { 1662 1604 homog_part[j] = homog_part[j] + current_coef*current_gen; 1663 1605 } 1664 1606 } 1665 1666 1607 return(homog_part); 1667 1668 1608 } 1669 1609 example … … 1686 1626 1687 1627 1688 //////////////////////////////////////////////////////////////////////////////// ////////////////1689 //--------------- --------- Procedures for lists of differential forms ------------------------//1690 //////////////////////////////////////////////////////////////////////////////// ////////////////1628 //////////////////////////////////////////////////////////////////////////////// 1629 //--------------- Procedures for lists of differential forms -----------------// 1630 //////////////////////////////////////////////////////////////////////////////// 1691 1631 1692 1632 … … 1699 1639 EXAMPLE: example difformListCont; shows an example" 1700 1640 { 1701 1702 diffAlgebraCheck();1703 1704 1641 int n = size(L); 1705 1642 int i; 1706 1643 1707 for(i = 1; i <= n; i++){ 1708 if(typeof(L[i]) == "difform"){ 1709 if(difformEqu(df,L[i])){ 1644 for(i = 1; i <= n; i++) 1645 { 1646 if(typeof(L[i]) == "difform") 1647 { 1648 if(difformEqu(df,L[i])) 1649 { 1710 1650 return(1); 1711 1651 } 1712 1652 } 1713 1653 } 1714 1715 1654 return(0); 1716 1717 1655 } 1718 1656 example … … 1742 1680 1743 1681 1744 //////////////////////////////////////////////////////////////////////////////// ////////////////1682 //////////////////////////////////////////////////////////////////////////////// 1745 1683 1746 1684 … … 1768 1706 EXAMPLE: example difformListSort; shows an example" 1769 1707 { 1770 1771 diffAlgebraCheck();1772 1773 1708 list orderings = #; 1774 1709 int n = size(orderings); … … 1778 1713 1779 1714 // Check for double list 1780 for(i = 1; i <= n; i++){ 1781 if(typeof(orderings[i]) == "string"){ 1782 if(orderings[i] == "Dlist"){ 1715 for(i = 1; i <= n; i++) 1716 { 1717 if(typeof(orderings[i]) == "string") 1718 { 1719 if(orderings[i] == "Dlist") 1720 { 1783 1721 Dlist_flag = 1; 1784 1722 orderings = delete(orderings,i); … … 1788 1726 1789 1727 // Check for list of lists 1790 for(i = 1; i <= n; i++){ 1791 if(typeof(orderings[i]) == "string"){ 1792 if(orderings[i] == "Llist"){ 1728 for(i = 1; i <= n; i++) 1729 { 1730 if(typeof(orderings[i]) == "string") 1731 { 1732 if(orderings[i] == "Llist") 1733 { 1793 1734 Llist_flag = 1; 1794 1735 orderings = delete(orderings,i); … … 1798 1739 1799 1740 // Not both list forms allowed 1800 if(Dlist_flag == 1 && Llist_flag == 1){ 1741 if(Dlist_flag == 1 && Llist_flag == 1) 1742 { 1801 1743 ERROR("Cannot sort double list of lists!"); 1802 1744 } 1803 1745 1804 1746 // Double list detected 1805 if(Dlist_flag == 1){ 1747 if(Dlist_flag == 1) 1748 { 1806 1749 poly temp_form_sec; 1807 1750 list L_sec = L[2]; … … 1810 1753 1811 1754 // List of lists detected 1812 if(Llist_flag == 1){ 1755 if(Llist_flag == 1) 1756 { 1813 1757 poly temp_form_sec; 1814 1758 n = size(L); … … 1817 1761 1818 1762 // Transform list of lists to double list 1819 for(i = 1; i <= n; i++){ 1763 for(i = 1; i <= n; i++) 1764 { 1820 1765 L_temp[i] = L[i][1]; 1821 1766 L_sec[i] = L[i][2]; … … 1829 1774 n = size(L); 1830 1775 1831 for(i = 1; i <= n; i++){ 1776 for(i = 1; i <= n; i++) 1777 { 1832 1778 temp_form = L[i]; 1833 1779 1834 if(Dlist_flag == 1 || Llist_flag == 1){ 1780 if(Dlist_flag == 1 || Llist_flag == 1) 1781 { 1835 1782 temp_form_sec = L_sec[i]; 1836 1783 } … … 1838 1785 j = i; 1839 1786 1840 while(j > 1){ 1841 if(difformIsBigger(L[j-1],temp_form,orderings)){ 1787 while(j > 1) 1788 { 1789 if(difformIsBigger(L[j-1],temp_form,orderings)) 1790 { 1842 1791 L[j] = L[j-1]; 1843 1792 1844 if(Dlist_flag == 1 || Llist_flag == 1){ 1793 if(Dlist_flag == 1 || Llist_flag == 1) 1794 { 1845 1795 L_sec[j] = L_sec[j-1]; 1846 1796 } 1847 1797 1848 1798 j--; 1849 }else{ 1799 } 1800 else 1801 { 1850 1802 break; 1851 1803 } … … 1854 1806 L[j] = temp_form; 1855 1807 1856 if(Dlist_flag == 1 || Llist_flag == 1){ 1808 if(Dlist_flag == 1 || Llist_flag == 1) 1809 { 1857 1810 L_sec[j] = temp_form_sec; 1858 1811 } … … 1860 1813 1861 1814 // For double list - return a double list 1862 if(Dlist_flag == 1){ 1815 if(Dlist_flag == 1) 1816 { 1863 1817 return(list(L,L_sec)); 1864 1818 } 1865 1819 1866 1820 // For list of lists - return a list of lists 1867 if(Llist_flag == 1){ 1821 if(Llist_flag == 1) 1822 { 1868 1823 L_temp = list(); 1869 for(i = 1; i <= n; i++){ 1824 for(i = 1; i <= n; i++) 1825 { 1870 1826 L_temp[i] = list(L[i],L_sec[i]); 1871 1827 } … … 1873 1829 return(L_temp); 1874 1830 } 1875 1876 1831 return(L); 1877 1878 1832 } 1879 1833 example … … 1918 1872 1919 1873 1920 //////////////////////////////////////////////////////////////////////////////// ////////////////1921 //---- -------- Procedures for computing with universal derivation and differential -----------//1922 //////////////////////////////////////////////////////////////////////////////// ////////////////1874 //////////////////////////////////////////////////////////////////////////////// 1875 //---- Procedures for computing with universal derivation and differential ---// 1876 //////////////////////////////////////////////////////////////////////////////// 1923 1877 1924 1878 … … 1930 1884 EXAMPLE: example difformUnivDer; shows an example" 1931 1885 { 1932 1933 diffAlgebraCheck(); 1934 1935 difform df = 0; 1886 difform df = 0; 1936 1887 difform d_var; 1937 int n = size(ringlist(basering)[2]); 1938 int i; 1939 1940 // Build the image under the universal derivation 1941 for(i = 1; i <= n; i++){ 1888 int n = size(ringlist(basering)[2]); 1889 int i; 1890 1891 // Build the image under the universal derivation 1892 for(i = 1; i <= n; i++) 1893 { 1942 1894 execute("d_var = d" + string(var(i))); 1943 1895 df = df + diff(f,var(i))*d_var; 1944 } 1945 1946 return(df); 1947 1896 } 1897 return(df); 1948 1898 } 1949 1899 example … … 1965 1915 1966 1916 1967 //////////////////////////////////////////////////////////////////////////////// ////////////////1917 //////////////////////////////////////////////////////////////////////////////// 1968 1918 1969 1919 … … 1980 1930 EXAMPLE: example difformDiff; shows an example" 1981 1931 { 1982 1983 diffAlgebraCheck();1984 1985 1932 difform d_df = 0; 1986 1933 list df_gen_repr = difformCoef(df); … … 1989 1936 1990 1937 // Derivate each coefficient 1991 for(i = 1; i <= n; i++){ 1938 for(i = 1; i <= n; i++) 1939 { 1992 1940 d_df = d_df + difformUnivDer(df_gen_repr[i][2])*df_gen_repr[i][1]; 1993 1941 } 1994 1995 1942 return(d_df); 1996 1997 1943 } 1998 1944 example … … 2025 1971 2026 1972 2027 //////////////////////////////////////////////////////////////////////////////// ////////////////2028 //////////////////////////////////////////////////////////////////////////////// ////////////////2029 // Procedures for type derivation//2030 //////////////////////////////////////////////////////////////////////////////// ////////////////2031 //////////////////////////////////////////////////////////////////////////////// ////////////////2032 2033 2034 //////////////////////////////////////////////////////////////////////////////// ////////////////2035 //-------------------------- --------- Structural procedures ----------------------------------//2036 //////////////////////////////////////////////////////////////////////////////// ////////////////1973 //////////////////////////////////////////////////////////////////////////////// 1974 //////////////////////////////////////////////////////////////////////////////// 1975 // Procedures for type derivation // 1976 //////////////////////////////////////////////////////////////////////////////// 1977 //////////////////////////////////////////////////////////////////////////////// 1978 1979 1980 //////////////////////////////////////////////////////////////////////////////// 1981 //-------------------------- Structural procedures ---------------------------// 1982 //////////////////////////////////////////////////////////////////////////////// 2037 1983 2038 1984 … … 2051 1997 EXAMPLE: example derivationFromList; shows an example" 2052 1998 { 2053 2054 diffAlgebraCheck();2055 2056 1999 // Check the structure of the given list 2057 2000 derivationCheckList(L); … … 2062 2005 derivation phi; 2063 2006 phi.genIm = L; 2064 2065 2007 return(phi); 2066 2067 2008 } 2068 2009 example … … 2095 2036 2096 2037 2097 //////////////////////////////////////////////////////////////////////////////// ////////////////2038 //////////////////////////////////////////////////////////////////////////////// 2098 2039 2099 2040 … … 2111 2052 SEE ALSO: derivationFromList, difformIsGen, difformListCont" 2112 2053 { 2113 2114 if(size(L) != 2){2054 if(size(L) != 2) 2055 { 2115 2056 ERROR("Given list has wrong size!"); 2116 2057 } 2117 2118 if(typeof(L[1]) != "list" || typeof(L[2]) != "list"){2058 if(typeof(L[1]) != "list" || typeof(L[2]) != "list") 2059 { 2119 2060 ERROR("Given list does not contain lists!"); 2120 2061 } 2121 2122 if(size(L[1]) != size(L[2])){2062 if(size(L[1]) != size(L[2])) 2063 { 2123 2064 ERROR("Given list does not have the right form!"); 2124 2065 } … … 2128 2069 2129 2070 // Need an image for any generator 2130 if(n != size(ringlist(basering)[2])){ 2071 if(n != size(ringlist(basering)[2])) 2072 { 2131 2073 ERROR("Given list has wrong size!"); 2132 2074 } 2133 2075 2134 for(i = 1; i <= n; i++){ 2076 for(i = 1; i <= n; i++) 2077 { 2135 2078 // Right type needed 2136 if(typeof(L[1][i]) != "difform" || (typeof(L[2][i]) != "poly" && typeof(L[2][i]) != "int" && typeof(L[2][i]) != "number")){ 2079 if(typeof(L[1][i]) != "difform" || (typeof(L[2][i]) != "poly" && typeof(L[2][i]) != "int" && typeof(L[2][i]) != "number")) 2080 { 2137 2081 ERROR("Given list contains wrong type!"); 2138 2082 } 2139 2083 2140 2084 // Generator of Omega_R^1 2141 if(!(difformIsGen(L[1][i]) && deg(L[1][i]) == 1)){ 2085 if(!(difformIsGen(L[1][i]) && deg(L[1][i]) == 1)) 2086 { 2142 2087 ERROR("Given list contains a non-generator or a generator not of degree 1!"); 2143 2088 } … … 2146 2091 // Now check the list L[1] for duplicates of the generators 2147 2092 list L_i; 2148 for(i = 1; i <= n; i++){ 2093 for(i = 1; i <= n; i++) 2094 { 2149 2095 L_i = delete(L[1],i); 2150 if(difformListCont(L_i,L[1][i])){ 2096 if(difformListCont(L_i,L[1][i])) 2097 { 2151 2098 ERROR("Given list contains duplicate of a generator!"); 2152 2099 } … … 2155 2102 2156 2103 2157 //////////////////////////////////////////////////////////////////////////////// ////////////////2104 //////////////////////////////////////////////////////////////////////////////// 2158 2105 2159 2106 … … 2167 2114 EXAMPLE: example derivationFromPoly; shows an example" 2168 2115 { 2169 2170 diffAlgebraCheck();2171 2172 2116 list L; 2173 2117 // First entry of list are the degree-1 generators … … 2179 2123 int n = size(L[1]); 2180 2124 int i; 2181 for(i = 1; i <= n; i++){ 2125 for(i = 1; i <= n; i++) 2126 { 2182 2127 L[2][i] = f; 2183 2128 } … … 2187 2132 phi.genIm = L; 2188 2133 return(phi); 2189 2190 2134 } 2191 2135 example … … 2206 2150 2207 2151 2208 //////////////////////////////////////////////////////////////////////////////// ////////////////2152 //////////////////////////////////////////////////////////////////////////////// 2209 2153 2210 2154 … … 2220 2164 EXAMPLE: example derivationConstructor; shows an example" 2221 2165 { 2222 2223 if(typeof(inp) == "list"){2166 if(typeof(inp) == "list") 2167 { 2224 2168 derivation der_cons = derivationFromList(inp); 2225 2169 return(der_cons); 2226 2170 } 2227 if(typeof(inp) == "poly" || typeof(inp) == "number" || typeof(inp) == "int" || typeof(inp) == "bigint"){ 2171 if(typeof(inp) == "poly" || typeof(inp) == "number" || typeof(inp) == "int" || typeof(inp) == "bigint") 2172 { 2228 2173 derivation der_cons = derivationFromPoly(inp); 2229 2174 return(der_cons); … … 2266 2211 EXAMPLE: example derivationToString; shows an example" 2267 2212 { 2268 2269 diffAlgebraCheck();2270 2213 list temp_genIm = phi.genIm; 2271 2214 … … 2275 2218 int i; 2276 2219 2277 for(i = 1; i <= n; i++){ 2278 if(typeof(#[i]) == "string"){ 2279 if(#[i] == "gen" && typeof(#[i+1]) == "string"){ 2220 for(i = 1; i <= n; i++) 2221 { 2222 if(typeof(#[i]) == "string") 2223 { 2224 if(#[i] == "gen" && typeof(#[i+1]) == "string") 2225 { 2280 2226 gen_ord = #[i+1]; 2281 if(typeof(#[i+2]) == "intvec"){ 2227 if(typeof(#[i+2]) == "intvec") 2228 { 2282 2229 intvec gen_weight = #[i+2]; 2283 2230 } … … 2287 2234 2288 2235 // Sort the generator/coefficients by the chosen ordering 2289 if(gen_ord != ""){ 2290 if(defined(gen_weight)){ 2236 if(gen_ord != "") 2237 { 2238 if(defined(gen_weight)) 2239 { 2291 2240 temp_genIm = difformListSort(temp_genIm,"Dlist","gen",gen_ord,gen_weight); 2292 }else{ 2241 } 2242 else 2243 { 2293 2244 temp_genIm = difformListSort(temp_genIm,"Dlist","gen",gen_ord); 2294 2245 } … … 2304 2255 int ring_name_size = size(ring_name); 2305 2256 2306 for(i = 1; i <= n; i++){ 2257 for(i = 1; i <= n; i++) 2258 { 2307 2259 phi_out = phi_out + tab(6 + ring_name_size) + difformGenToString(gens[i]) + " |--> " + string(images[i]) + newline; 2308 2260 } 2309 2261 2310 2262 return(phi_out); 2311 2312 2263 } 2313 2264 example … … 2336 2287 2337 2288 2338 //////////////////////////////////////////////////////////////////////////////// ////////////////2289 //////////////////////////////////////////////////////////////////////////////// 2339 2290 2340 2291 … … 2347 2298 EXAMPLE: example derivationPrint; shows an example" 2348 2299 { 2349 2350 2300 // Orders the generators in ls-order 2351 2301 print(derivationToString(phi,"gen","ls")); 2352 2353 2302 } 2354 2303 example … … 2377 2326 2378 2327 2379 //////////////////////////////////////////////////////////////////////////////// ////////////////2380 //-------------------- ---------- Basic computational procedures ------------------------------//2381 //////////////////////////////////////////////////////////////////////////////// ////////////////2328 //////////////////////////////////////////////////////////////////////////////// 2329 //-------------------- Basic computational procedures ------------------------// 2330 //////////////////////////////////////////////////////////////////////////////// 2382 2331 2383 2332 … … 2392 2341 EXAMPLE: example derivationAdd; shows an example" 2393 2342 { 2394 2395 diffAlgebraCheck();2396 2397 2343 // Structure for derivation 2398 2344 derivation add_der; … … 2405 2351 int i; 2406 2352 2407 for(i = 1; i <= n; i++){ 2353 for(i = 1; i <= n; i++) 2354 { 2408 2355 // Lists are sorted the same way 2409 2356 add_list[2][i] = phi.genIm[2][i] + psi.genIm[2][i]; … … 2413 2360 add_der.genIm = add_list; 2414 2361 return(add_der); 2415 2416 2362 } 2417 2363 example … … 2443 2389 2444 2390 2445 //////////////////////////////////////////////////////////////////////////////// ////////////////2391 //////////////////////////////////////////////////////////////////////////////// 2446 2392 2447 2393 … … 2456 2402 EXAMPLE: example derivationSub; shows an example" 2457 2403 { 2458 2459 diffAlgebraCheck();2460 2461 2404 // Structure for derivation 2462 2405 derivation sub_der; … … 2469 2412 int i; 2470 2413 2471 for(i = 1; i <= n; i++){ 2414 for(i = 1; i <= n; i++) 2415 { 2472 2416 // Lists are sorted the same way 2473 2417 sub_list[2][i] = phi.genIm[2][i] - psi.genIm[2][i]; … … 2477 2421 sub_der.genIm = sub_list; 2478 2422 return(sub_der); 2479 2480 2423 } 2481 2424 example … … 2507 2450 2508 2451 2509 //////////////////////////////////////////////////////////////////////////////// ////////////////2452 //////////////////////////////////////////////////////////////////////////////// 2510 2453 2511 2454 … … 2517 2460 EXAMPLE: example derivationNeg; shows an example" 2518 2461 { 2519 2520 diffAlgebraCheck();2521 2522 2462 // Structure for derivation 2523 2463 derivation neg_der; … … 2530 2470 int i; 2531 2471 2532 for(i = 1; i <= n; i++){ 2472 for(i = 1; i <= n; i++) 2473 { 2533 2474 neg_list[2][i] = -phi.genIm[2][i]; 2534 2475 } … … 2537 2478 neg_der.genIm = neg_list; 2538 2479 return(neg_der); 2539 2540 2480 } 2541 2481 example … … 2566 2506 2567 2507 2568 //////////////////////////////////////////////////////////////////////////////// ////////////////2508 //////////////////////////////////////////////////////////////////////////////// 2569 2509 2570 2510 … … 2578 2518 EXAMPLE: derivationMul; shows an example" 2579 2519 { 2580 2581 diffAlgebraCheck();2582 2583 2520 // Structure for derivation 2584 2521 derivation mul_der; … … 2591 2528 int i; 2592 2529 2593 for(i = 1; i <= n; i++){ 2530 for(i = 1; i <= n; i++) 2531 { 2594 2532 // Lists are sorted the same way 2595 2533 mul_list[2][i] = phi.genIm[2][i]*psi.genIm[2][i]; … … 2599 2537 mul_der.genIm = mul_list; 2600 2538 return(mul_der); 2601 2602 2539 } 2603 2540 example … … 2629 2566 2630 2567 2631 //////////////////////////////////////////////////////////////////////////////// ////////////////2568 //////////////////////////////////////////////////////////////////////////////// 2632 2569 2633 2570 … … 2642 2579 EXAMPLE: example derivationEqu; shows an example" 2643 2580 { 2644 2645 diffAlgebraCheck();2646 2647 2581 int n = size(phi.genIm[1]); 2648 2582 int i; 2649 2583 2650 for(i = 1; i <= n; i++){ 2584 for(i = 1; i <= n; i++) 2585 { 2651 2586 // Lists are sorted the same way 2652 if(phi.genIm[2][i] != psi.genIm[2][i]){ 2587 if(phi.genIm[2][i] != psi.genIm[2][i]) 2588 { 2653 2589 // Different images 2654 2590 return(0); … … 2658 2594 // Images are the same 2659 2595 return(1); 2660 2661 2596 } 2662 2597 example … … 2687 2622 2688 2623 2689 //////////////////////////////////////////////////////////////////////////////// ////////////////2624 //////////////////////////////////////////////////////////////////////////////// 2690 2625 2691 2626 … … 2699 2634 EXAMPLE: example derivationNeq; shows an example" 2700 2635 { 2701 2702 2636 return(!derivationEqu(phi,psi)); 2703 2704 2637 } 2705 2638 example … … 2730 2663 2731 2664 2732 //////////////////////////////////////////////////////////////////////////////// ////////////////2665 //////////////////////////////////////////////////////////////////////////////// 2733 2666 2734 2667 … … 2747 2680 EXAMPLE: example derivationEval; shows an example" 2748 2681 { 2749 2750 diffAlgebraCheck(); 2751 2752 if(!homog(df)){ 2682 if(!homog(df)) 2683 { 2753 2684 ERROR("Cannot apply derivation to non-homogeneous element!"); 2754 2685 } 2755 2686 2756 if(deg(df) != 1 && deg(df) != -1){ 2687 if(deg(df) != 1 && deg(df) != -1) 2688 { 2757 2689 ERROR("Cannot apply derivation to differential form not of degree 1!"); 2758 2690 } … … 2765 2697 int j = 1; 2766 2698 2767 for(i = 1; i <= n; i++){ 2699 for(i = 1; i <= n; i++) 2700 { 2768 2701 // Both lists are sorted by the monomial ordering on the differential algebra 2769 2702 // So the generators are sorted the same way in both lists 2770 2703 // If given df does not involve all generators avoid gaps using j 2771 if(j <= k){ 2772 if(df_gen_repr[j][1] == phi.genIm[1][i]){ 2704 if(j <= k) 2705 { 2706 if(df_gen_repr[j][1] == phi.genIm[1][i]) 2707 { 2773 2708 df_eval = df_eval + df_gen_repr[j][2]*phi.genIm[2][i]; 2774 2709 j++; … … 2776 2711 } 2777 2712 } 2778 2779 2713 return(df_eval); 2780 2781 2714 } 2782 2715 example … … 2819 2752 2820 2753 2821 //////////////////////////////////////////////////////////////////////////////// ////////////////2822 //------------ ----------- Procedures for computing the Lie-Derivative ------------------------//2823 //////////////////////////////////////////////////////////////////////////////// ////////////////2754 //////////////////////////////////////////////////////////////////////////////// 2755 //------------ Procedures for computing the Lie-Derivative -------------------// 2756 //////////////////////////////////////////////////////////////////////////////// 2824 2757 2825 2758 … … 2834 2767 SEE ALSO: derivationContraction" 2835 2768 { 2836 2837 2769 // Sort the list, that dx_1 is the first form, dx_2 the second,... 2838 2770 list gen_list = phi.genIm[1]; … … 2845 2777 2846 2778 // Go through all degree-1 generators and test if, dx_i occurs in d_gen 2847 for(i = 1; i <= n; i++){ 2848 if(d_gen / gen_list[i] != 0){ 2779 for(i = 1; i <= n; i++) 2780 { 2781 if(d_gen / gen_list[i] != 0) 2782 { 2849 2783 applic = applic + ((-1)^(j+1))*derivationEval(phi,gen_list[i])*(d_gen/gen_list[i]); 2850 2784 j++; … … 2855 2789 2856 2790 2857 //////////////////////////////////////////////////////////////////////////////// ////////////////2791 //////////////////////////////////////////////////////////////////////////////// 2858 2792 2859 2793 … … 2869 2803 EXAMPLE: example derivationContraction; shows an example" 2870 2804 { 2871 2872 diffAlgebraCheck();2873 2874 2805 list coef_list = difformCoef(df); 2875 2806 int k = size(coef_list); … … 2878 2809 2879 2810 // Apply the contraction map to the generators since it is linear 2880 for(i = 1; i <= k; i++){ 2811 for(i = 1; i <= k; i++) 2812 { 2881 2813 applic = applic + coef_list[i][2]*derivationContractionGen(phi,coef_list[i][1]); 2882 2814 } 2883 2884 2815 return(applic); 2885 2886 2816 } 2887 2817 example … … 2917 2847 2918 2848 2919 //////////////////////////////////////////////////////////////////////////////// ////////////////2849 //////////////////////////////////////////////////////////////////////////////// 2920 2850 2921 2851 … … 2930 2860 EXAMPLE: example derivationLie; shows an example" 2931 2861 { 2932 2933 2862 difform lie_form = derivationContraction(phi,difformDiff(df)) + difformDiff(derivationContraction(phi,df)); 2934 2863 return(lie_form); 2935 2936 2864 } 2937 2865 example … … 2969 2897 2970 2898 2971 //////////////////////////////////////////////////////////////////////////////// ////////////////2972 //////////////////////////////////////////////////////////////////////////////// ////////////////2973 2974 2975 //////////////////////////////////////////////////////////////////////////////// ////////////////2976 //////////////////////////////////////////////////////////////////////////////// ////////////////2977 // Test examples//2978 //////////////////////////////////////////////////////////////////////////////// ////////////////2979 //////////////////////////////////////////////////////////////////////////////// ////////////////2899 //////////////////////////////////////////////////////////////////////////////// 2900 //////////////////////////////////////////////////////////////////////////////// 2901 2902 2903 //////////////////////////////////////////////////////////////////////////////// 2904 //////////////////////////////////////////////////////////////////////////////// 2905 // Test examples // 2906 //////////////////////////////////////////////////////////////////////////////// 2907 //////////////////////////////////////////////////////////////////////////////// 2980 2908 2981 2909 2982 2910 // EXAMPLE: differential algebra over ring of characteristic 0 2983 proc diffAlgebra_example_1(){ 2911 proc diffAlgebra_example_1() 2912 { 2984 2913 ring R = 0,(x,y,z),dp; 2985 2914 diffAlgebra(); 2986 2987 2915 exportto(Top,R); 2988 2916 } 2989 2917 2990 2918 2991 //////////////////////////////////////////////////////////////////////////////// ////////////////2919 //////////////////////////////////////////////////////////////////////////////// 2992 2920 2993 2921 2994 2922 // EXAMPLE: differential algebra over big ring of characteristic 0 and block ordering 2995 proc diffAlgebra_example_2(){ 2923 proc diffAlgebra_example_2() 2924 { 2996 2925 ring R = 0,(a,b,x,y,z,t,s,e,r,w,i),(ls(3),dp(4),lp); 2997 2926 diffAlgebra(); 2998 2999 2927 exportto(Top,R); 3000 2928 } 3001 2929 3002 2930 3003 //////////////////////////////////////////////////////////////////////////////// ////////////////2931 //////////////////////////////////////////////////////////////////////////////// 3004 2932 3005 2933 3006 2934 // EXAMPLE: differential algebra over ring of positive characteristic 3007 proc diffAlgebra_example_3(){ 2935 proc diffAlgebra_example_3() 2936 { 3008 2937 ring R = 31,(a,b,x),dp; 3009 2938 diffAlgebra(); 3010 3011 2939 exportto(Top,R); 3012 2940 } 3013 2941 3014 2942 3015 //////////////////////////////////////////////////////////////////////////////// ////////////////2943 //////////////////////////////////////////////////////////////////////////////// 3016 2944 3017 2945 3018 2946 // EXAMPLE: differential algebra over quotient ring 3019 proc diffAlgebra_example_4(){ 2947 proc diffAlgebra_example_4() 2948 { 3020 2949 ring S = 0,(x,y,z),lp; 3021 2950 ideal I = x2-y4,xyz; 3022 2951 qring R = std(I); 3023 2952 diffAlgebra(); 3024 3025 2953 exportto(Top,R); 3026 2954 } 3027 2955 3028 2956 3029 //////////////////////////////////////////////////////////////////////////////// ////////////////2957 //////////////////////////////////////////////////////////////////////////////// 3030 2958 3031 2959 3032 2960 // EXAMPLE: differential form over ring of characteristic 0 3033 proc difform_example_1(){ 2961 proc difform_example_1() 2962 { 3034 2963 ring R = 0,(x,y,z),ds; 3035 2964 diffAlgebra(); … … 3042 2971 3043 2972 3044 //////////////////////////////////////////////////////////////////////////////// ////////////////2973 //////////////////////////////////////////////////////////////////////////////// 3045 2974 3046 2975 3047 2976 // EXAMPLE: differential form over ring of positive characteristic 3048 proc difform_example_2(){ 2977 proc difform_example_2() 2978 { 3049 2979 ring R = 31,(x,y,z,a,b,c),lp; 3050 2980 diffAlgebra(); … … 3057 2987 3058 2988 3059 //////////////////////////////////////////////////////////////////////////////// ////////////////2989 //////////////////////////////////////////////////////////////////////////////// 3060 2990 3061 2991 3062 2992 // EXAMPLE: derivation by list 3063 proc derivation_example_1(){ 2993 proc derivation_example_1() 2994 { 3064 2995 ring R = 0,(x,y,z),lp; 3065 2996 diffAlgebra(); … … 3076 3007 3077 3008 3078 //////////////////////////////////////////////////////////////////////////////// ////////////////3009 //////////////////////////////////////////////////////////////////////////////// 3079 3010 3080 3011 3081 3012 // EXAMPLE: derivation by list 3082 proc derivation_example_2(){ 3013 proc derivation_example_2() 3014 { 3083 3015 ring R = 0,(a,b,c,x,y,z),lp; 3084 3016 diffAlgebra(); … … 3094 3026 3095 3027 3096 //////////////////////////////////////////////////////////////////////////////// ////////////////3028 //////////////////////////////////////////////////////////////////////////////// 3097 3029 3098 3030 3099 3031 // EXAMPLE: derivations by list 3100 proc derivation_example_3(){ 3032 proc derivation_example_3() 3033 { 3101 3034 ring R = 0,(x,y,z),dp; 3102 3035 diffAlgebra(); … … 3121 3054 } 3122 3055 3123
Note: See TracChangeset
for help on using the changeset viewer.