Changeset 30bd62 in git
- Timestamp:
- Jul 30, 2019, 4:14:32 PM (4 years ago)
- Branches:
- (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
- Children:
- f835e7ef57d0065a19c0d736e27fbf9149ddf87a
- Parents:
- ce45c3875a5144c82068f119b9783eeb7adcfcea
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/ellipticcovers.lib
rce45c3 r30bd62 67 67 68 68 69 proc mod_init() 70 { 71 newstruct("graph","list vertices, list edges"); 72 newstruct("Net","list rows"); 73 74 system("install","graph","print",printGraph,1); 75 system("install","Net","print",printNet,1); 76 system("install","Net","+",catNet,2); 77 78 } 79 69 static proc mod_init() 70 { 71 newstruct("graph","list vertices, list edges"); 72 newstruct("Net","list rows"); 73 74 system("install","graph","print",printGraph,1); 75 system("install","Net","print",printNet,1); 76 system("install","Net","+",catNet,2); 77 } 80 78 81 79 static proc catNet(Net N, Net M) 82 80 { 83 list L;84 list LN=N.rows;85 list LM=M.rows;86 int widthN=size(LN[1]);87 int widthM=size(LM[1]);88 int nm=max(size(LN),size(LM));89 for (int j=1; j<=nm; j++)90 {81 list L; 82 list LN=N.rows; 83 list LM=M.rows; 84 int widthN=size(LN[1]); 85 int widthM=size(LM[1]); 86 int nm=max(size(LN),size(LM)); 87 for (int j=1; j<=nm; j++) 88 { 91 89 if (j>size(LN)){LN[j]=emptyString(widthN);} 92 90 if (j>size(LM)){LM[j]=emptyString(widthM);} 93 91 L[j]=LN[j]+LM[j]; 94 } 95 Net NM; 96 NM.rows=L; 97 return(NM);} 92 } 93 Net NM; 94 NM.rows=L; 95 return(NM); 96 } 98 97 99 98 … … 111 110 static proc printNet(Net N) 112 111 { 113 list L = N.rows; 114 for (int j=1; j<=size(L); j++) 115 { 116 print(L[j]); 117 } 118 } 119 120 static proc net(def M){ 121 if (typeof(M)=="list"){ 112 list L = N.rows; 113 for (int j=1; j<=size(L); j++) 114 { 115 print(L[j]); 116 } 117 } 118 119 static proc net(def M) 120 { 121 if (typeof(M)=="list") 122 { 122 123 return(netList(M)); 123 124 } … … 126 127 L[1]=string(M); 127 128 N.rows=L; 128 return(N);} 129 return(N); 130 } 129 131 130 132 … … 147 149 G; 148 150 } 149 150 151 151 152 152 proc makeGraph(list v, list e) … … 170 170 G; 171 171 } 172 173 172 174 173 proc propagator(def xy, def d) … … 195 194 " 196 195 { 197 if ((typeof(xy)=="list")||(typeof(d)=="int")) { 196 if ((typeof(xy)=="list")||(typeof(d)=="int")) 197 { 198 198 number x = xy[1]; 199 199 number y = xy[2]; … … 201 201 if (d==0) {return(x^2*y^2/(x^2-y^2)^2);} 202 202 number p=0; 203 for (int j=1; j<=d; j++){ 203 for (int j=1; j<=d; j++) 204 { 204 205 if (d%j==0){p=p+(j*x^(4*j)+j*y^(4*j))/(x*y)^(2*j);} 205 206 } 206 207 return(p); 207 208 } 208 if ((typeof(xy)=="graph")||(typeof(d)=="list")) { 209 if ((typeof(xy)=="graph")||(typeof(d)=="list")) 210 { 209 211 list xl = ringlist(basering)[1][2]; 210 212 list ed = xy.edges; 211 213 number f=1; 212 for (int j=1; j<=size(ed); j++){ 214 for (int j=1; j<=size(ed); j++) 215 { 213 216 execute("number xx1 = "+xl[ed[j][1]]); 214 217 execute("number xx2 = "+xl[ed[j][2]]); … … 219 222 return(f); 220 223 } 221 if ((typeof(xy)=="graph")||(typeof(d)=="int")) { 222 } 223 ERROR("wrong input type");} 224 if ((typeof(xy)=="graph")||(typeof(d)=="int")) 225 { 226 } 227 ERROR("wrong input type"); 228 } 224 229 example 225 230 { "EXAMPLE:"; echo=2; … … 230 235 propagator(G,list(1,1,1,0,0,0)); 231 236 } 232 233 234 235 236 237 237 238 proc computeConstant(number f,number xx) … … 240 241 RETURN: number, the constant coefficient of the Laurent series of f in the variable x. 241 242 THEORY: Computes the constant coefficient of the Laurent series by iterative differentiation. 242 243 243 KEYWORDS: Laurent series 244 244 EXAMPLE: example computeConstant; shows an example … … 250 250 int j; 251 251 poly de; 252 while (tst==0){ 253 ff=f*xx^k; 254 for (j=1; j<=k; j++){ 255 ff=diff(ff,xx)/j; 256 } 257 de = subst(denominator(ff),xx,0); 258 if (de!=0){ 259 poly nu = subst(numerator(ff),xx,0); 260 return(number(nu/de)); 261 } 262 k=k+1; 263 } 264 ERROR("error in computeConstant");} 252 while (tst==0) 253 { 254 ff=f*xx^k; 255 for (j=1; j<=k; j++)i 256 { 257 ff=diff(ff,xx)/j; 258 } 259 de = subst(denominator(ff),xx,0); 260 if (de!=0) 261 { 262 poly nu = subst(numerator(ff),xx,0); 263 return(number(nu/de)); 264 } 265 k++; 266 } 267 ERROR("error in computeConstant"); 268 } 265 269 example 266 270 { "EXAMPLE:"; echo=2; … … 270 274 computeConstant(P,x2); 271 275 } 272 273 274 275 276 276 277 proc evaluateIntegral(number P, list xL) … … 289 290 { 290 291 number p = P; 291 for(int j=1; j<=size(xL); j++){ 292 for(int j=1; j<=size(xL); j++) 293 { 292 294 p=computeConstant(p,xL[j]); 293 295 } 294 return(p);} 296 return(p); 297 } 295 298 example 296 299 { "EXAMPLE:"; echo=2; … … 300 303 evaluateIntegral(p,list(x1,x3,x4,x2)); 301 304 } 302 303 305 304 306 proc permute (list N) … … 314 316 " 315 317 { 316 int i,j,k; 317 list L,L1; 318 if (size(N)==1){ 319 return(list(N)); 320 } else { 321 k=1; 322 for (i=1; i<=size(N); i++){ 323 L=permute(delete(N,i)); 324 for (j=1; j<=size(L); j++){ 325 L1[k]=L[j]+list(N[i]); 326 k=k+1; 327 } 328 } 329 } 330 return(L1);} 318 int i,j,k; 319 list L,L1; 320 if (size(N)==1) 321 { 322 return(list(N)); 323 } 324 else 325 { 326 k=1; 327 for (i=1; i<=size(N); i++) 328 { 329 L=permute(delete(N,i)); 330 for (j=1; j<=size(L); j++) 331 { 332 L1[k]=L[j]+list(N[i]); 333 k=k+1; 334 } 335 } 336 } 337 return(L1); 338 } 331 339 example 332 340 { "EXAMPLE:"; echo=2; … … 349 357 " 350 358 { 351 ring R = 2,(x(1..n)),dp; 352 ideal I = maxideal(a); 353 list L; 354 for (int j=1;j<=size(I);j++){ 355 L[j]=leadexp(I[j]); 356 } 357 return(L);} 359 ring R = 2,(x(1..n)),dp; 360 ideal I = maxideal(a); 361 list L; 362 for (int j=1;j<=size(I);j++)i 363 { 364 L[j]=leadexp(I[j]); 365 } 366 return(L); 367 } 358 368 example 359 369 { "EXAMPLE:"; echo=2; 360 370 partitions(3,7); 361 371 } 362 363 364 372 365 373 proc gromovWitten(def P,list #) … … 385 393 " 386 394 { 387 if (typeof(P)=="number") { 388 list xl = ringlist(basering)[1][2]; 389 int j; 390 for(j=1; j<=size(xl); j++){ 391 execute("number n= "+xl[j]); 392 xl[j]=n; 393 kill n; 394 } 395 list pxl = permute(xl); 396 number p = 0; 397 for(j=1; j<=size(pxl); j++){ 398 p=p+evaluateIntegral(P,pxl[j]); 399 } 400 return(p); 401 } 402 if (typeof(P)=="graph"){ 403 if (size(#)>1){ 404 return(gromovWitten(propagator(P,#))); 405 } else { 395 if (typeof(P)=="number") 396 { 397 list xl = ringlist(basering)[1][2]; 398 int j; 399 for(j=1; j<=size(xl); j++) 400 { 401 execute("number n= "+xl[j]); 402 xl[j]=n; 403 kill n; 404 } 405 list pxl = permute(xl); 406 number p = 0; 407 for(j=1; j<=size(pxl); j++) 408 { 409 p=p+evaluateIntegral(P,pxl[j]); 410 } 411 return(p); 412 } 413 if (typeof(P)=="graph") 414 { 415 if (size(#)>1) 416 { 417 return(gromovWitten(propagator(P,#))); 418 } 419 else 420 { 406 421 int d =#[1]; 407 422 list pa = partitions(size(P.edges),d); 408 423 list re; 409 424 int ti; 410 for (int j=1; j<=size(pa); j++) { 411 ti=timer; 412 re[j]=gromovWitten(propagator(P,pa[j])); 413 ti=timer-ti; 414 //print(string(j)+" / "+string(size(pa))+" "+string(pa[j])+" "+string(re[j])+" "+string(sum(re))+" "+string(ti)); 425 for (int j=1; j<=size(pa); j++) 426 { 427 ti=timer; 428 re[j]=gromovWitten(propagator(P,pa[j])); 429 ti=timer-ti; 430 //print(string(j)+" / "+string(size(pa))+" "+string(pa[j])+" "+string(re[j])+" "+string(sum(re))+" "+string(ti)); 415 431 } 416 return(lsum(re));417 432 return(lsum(re)); 433 } 418 434 } 419 435 } … … 427 443 gromovWitten(G,2); 428 444 } 429 430 431 445 432 446 proc computeGromovWitten(graph P,int d, int st, int en, list #) … … 443 457 " 444 458 { 445 number s =0; 446 list pararg; 447 list re; 448 list pa = partitions(size(P.edges),d); 449 int vb=0; 450 if (size(#)>0){vb=#[1];} 451 int ti; 452 if (vb>0){print(size(pa));} 453 for (int j=1; j<=size(pa); j++) { 454 if ((j>=st)&(j<=en)){ 455 ti=timer; 456 //pararg[j]=list(propagator(G,pa[j])); 457 re[j]=gromovWitten(propagator(P,pa[j])); 458 ti=timer-ti; 459 if (vb>0){print(string(j)+" / "+string(size(pa))+" "+string(pa[j])+" "+string(re[j])+" "+string(lsum(re))+" "+string(ti));} 460 } else {re[j]=s;} 461 } 462 //list re = parallelWaitAll("gromovWitten", pararg, list(list(list(2)))); 463 return(re); 459 number s =0; 460 list pararg; 461 list re; 462 list pa = partitions(size(P.edges),d); 463 int vb=0; 464 if (size(#)>0){vb=#[1];} 465 int ti; 466 if (vb>0){print(size(pa));} 467 for (int j=1; j<=size(pa); j++) 468 { 469 if ((j>=st)&(j<=en)) 470 { 471 ti=timer; 472 //pararg[j]=list(propagator(G,pa[j])); 473 re[j]=gromovWitten(propagator(P,pa[j])); 474 ti=timer-ti; 475 if (vb>0){print(string(j)+" / "+string(size(pa))+" "+string(pa[j])+" "+string(re[j])+" "+string(lsum(re))+" "+string(ti));} 476 } 477 else 478 {re[j]=s;} 479 } 480 //list re = parallelWaitAll("gromovWitten", pararg, list(list(list(2)))); 481 return(re); 464 482 } 465 483 example … … 471 489 computeGromovWitten(G,2,3,7,1); 472 490 } 473 474 491 475 492 proc lsum(list L) … … 485 502 { 486 503 execute(typeof(L[1])+" s"); 487 for(int j=1; j<=size(L); j++){ 488 s=s+L[j]; 489 } 490 return(s);} 504 for(int j=1; j<=size(L); j++) 505 { 506 s=s+L[j]; 507 } 508 return(s); 509 } 491 510 example 492 511 { "EXAMPLE:"; echo=2; … … 494 513 lsum(L); 495 514 } 496 497 498 515 499 516 proc generatingFunction(graph G, int d) … … 512 529 int j,jj; 513 530 list pa,L; 514 for (j=1; j<=d; j++){ 531 for (j=1; j<=d; j++) 532 { 515 533 pa = partitions(size(G.edges),j); 516 534 L = computeGromovWitten(G,j,1,size(pa)); 517 for (jj=1; jj<=size(pa); jj++) { 518 s=s+L[jj]*monomial(pa[jj]); 519 } 520 } 521 return(s);} 535 for (jj=1; jj<=size(pa); jj++) 536 { 537 s=s+L[jj]*monomial(pa[jj]); 538 } 539 } 540 return(s); 541 } 522 542 example 523 543 { "EXAMPLE:"; echo=2;
Note: See TracChangeset
for help on using the changeset viewer.