Changeset 4a0d86 in git
- Timestamp:
- Jul 29, 2004, 6:47:07 PM (19 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- f12d4f65e05f0c6728f1743580a54e40d44c0f21
- Parents:
- c78800c4f81d04521b30784cfce28ba3589d6539
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/nctools.lib
rc78800 r4a0d86 1 1 /////////////////////////////////////////////////////////////////////////////// 2 version="$Id: nctools.lib,v 1. 5 2004-05-12 11:36:15levandov Exp $";2 version="$Id: nctools.lib,v 1.6 2004-07-29 16:47:07 levandov Exp $"; 3 3 category="Noncommutative"; 4 4 info=" … … 38 38 39 39 proc Gweights(def r) 40 "USAGE: Gweights(r); r a ring 41 RETURN: a weights vector for the G- Algebrar42 NOTE: with Gweights you only obtain a vector, then you must use it to redefine the G-Algebra. Another posibility is to use wRing or weightedRing to obtain directly the G-Algebra.40 "USAGE: Gweights(r); r a ring or a square matrix 41 RETURN: a weights vector for the G-algebra r or for a G-algebra which tails matrix is r 42 NOTE: with Gweights you only obtain a vector, then you must use it to redefine the G-Algebra. If the input is a matrix and the output is the zero vector then there is not a G-algebra structure associated to these relations with respect to the given variables. Another possibility is to use wRing or weightedRing to obtain directly the G-Algebra. 43 43 EXAMPLE: example Gweights; shows examples 44 44 SEE ALSO: wRing, weightedRing 45 45 "{ 46 if (typeof(r)=="ring") 46 matrix tails; 47 int novalid=0; 48 if (typeof(r)=="ring") //a ring is admissible as input 47 49 { 48 50 setring r; 49 def l=NCRelations(r); 50 intmat IM=SimplMat(l[2]); // l=C,D we need D 51 if (size(IM)>1) 52 { 53 int n=nvars(basering); 54 int m=nrows(IM)-1; 55 int m1=0; 56 int m2=m; 57 int m3=0; 51 def l = NCRelations(r); 52 tails = l[2]; // l=C,D we need D, the tails of the relations 53 } 54 else 55 { 56 if ( (typeof(r)=="matrix") || (typeof(r)=="intmat") ) 57 { 58 if ( nrows(r)==ncols(r) ) //the input is a square matrix 59 { 60 tails = matrix(r); 61 } 62 else 63 { 64 novalid = 1; 65 } 66 } 67 else 68 { 69 novalid=1; 70 } 71 } 72 if (novalid==0) 73 { 74 intmat IM = SimplMat(tails); 75 if ( size(IM)>1 ) 76 { 77 int n = ncols(tails); 78 int m = nrows(IM)-1; 79 int m1 = 0; 80 int m2 = m; 81 int m3 = 0; 58 82 ring simplexring=(real,10),(x),lp;// The simplex procedure requires a basering of this type 59 matrix M =IM;60 list sol =simplex (M,m,n,m1,m2,m3);83 matrix M = IM; 84 list sol = simplex (M,m,n,m1,m2,m3); 61 85 return(weightvector(sol)); 62 } 63 else 64 { 65 "Invalid input .";86 } 87 else 88 { 89 "Invalid input"; //usually because the input is a one variable ring 66 90 return(); 67 91 } 68 } 69 else 70 { 71 "The input must be a ring .";92 } 93 else 94 { 95 "The input must be a ring or a square matrix"; 72 96 return(); 73 97 } … … 92 116 setring r; r; 93 117 Gweights(r); 118 Gweights(D); 119 Gweights(C); 94 120 } 95 121 … … 121 147 m[i,n+2-i]=1; 122 148 } 123 // End of generati ng.149 // End of generation. 124 150 def lr=NCRelations(r); 125 151 string newringstring="ring newring=("+charstr(r)+"),("+varstr(r)+"),M("+string(m)+")"; … … 128 154 ncalgebra(lnewring[1],lnewring[2]); 129 155 return(newring); 130 } 131 else 132 { 133 "Invalid input."; 156 } 157 else 158 { 159 "Invalid input.";//usually because the input is a one variable ring 134 160 return(); 135 161 } … … 166 192 "Error"; 167 193 return(); 168 } 169 example 194 } 195 example 170 196 { 171 197 "EXAMPLE:";echo=2; … … 202 228 N=N[2..size(N)]; // Deleting the zero added in the definition of N 203 229 M=intmat(N,size(N)/nc,nc); // Conversion from vector to matrix 204 } 205 else 230 } 231 else 206 232 { 207 233 intmat M[1][1]=0; … … 216 242 static proc Ct(matrix P) 217 243 { 218 int k=ncols(P); 219 int n=nvars(basering); 220 intvec T=0; 221 int i,j; 244 int k = ncols(P); 245 intvec T = 0; 246 int i,j; 247 // int notails=1; 248 def S; 222 249 for (j=2; j<=k; j++) 223 250 { 224 251 for (i=1; i<j; i++) 225 252 { 226 if ( deg(P[i,j])>0)253 if ( P[i,j] != 0 ) 227 254 { 228 def S=Newton(P[i,j]); 229 S=Cij(S,i,j); 230 if (size(S)>1) {T=T,S;} 255 // notails=0; 256 S = Newton(P[i,j]); 257 S = Cij(S,i,j); 258 if ( size(S)>1 ) 259 { 260 T = T,S; 261 } 231 262 } 232 263 } 233 264 } 234 if ( size(T)==1)235 { 236 intmat C[1][1] ;237 } 238 else 265 if ( size(T)==1 ) 266 { 267 intmat C[1][1] = 0; 268 } 269 else 239 270 { 240 271 T=T[2..size(T)]; // Deleting the zero added in the definition of T 241 intmat C =intmat(T,size(T)/n,n); // Conversion from vector to matrix272 intmat C = intmat(T,size(T)/k,k); // Conversion from vector to matrix 242 273 } 243 274 return (C); … … 251 282 { 252 283 intmat C=Ct(P); 253 if (size(C)>1) 254 { 255 int r=nrows(C); 256 int n=nvars(basering); 257 int f=1+n+r; 284 if (size(C)>1) 285 { 286 int r = nrows(C); 287 int n = ncols(C); 288 int f = 1+n+r; 289 intmat M[f][n+1]=0; 290 int i; 291 for (i=2; i<=(n+1); i++) 292 { 293 M[1,i]=-1; // (0,-1,-1,-1,...) objective function in the first row 294 } 295 for (i=2; i<=f; i++) {M[i,1]=1;} // All the independent terms are 1 296 for (i=2; i<=(n+1); i++) {M[i,i]=-1;} // wi>=1 is an identity matrix 297 M[(n+2)..f,2..(n+1)]=(-1)*intvec(C); // <wi,a> >= 1, a in C ... 298 } 299 else 300 { 301 int n = ncols(P); 302 int f = 1+n; 258 303 intmat M[f][n+1]=0; 259 304 int i; … … 261 306 for (i=2; i<=f; i++) {M[i,1]=1;} // All the independent terms are 1 262 307 for (i=2; i<=(n+1); i++) {M[i,i]=-1;} // wi>=1 is an identity matrix 263 M[(n+2)..f,2..(n+1)]=(-1)*intvec(C); // <wi,a> >= 1, a in C ...264 }265 else266 {267 intmat M=C;268 308 } 269 309 return (M); … … 276 316 277 317 static proc weightvector(list l) 318 278 319 "ASSUME: l is the output of simplex. 279 320 RETURNS: if there is a solution, an intvec with the solution." … … 286 327 intmat wv[1][N]=0; 287 328 int i; 288 if (sol) 329 if (sol) 289 330 { 290 331 "no solution satisfies the given constraints"; 291 332 } 292 else 293 { 294 for ( i = 2; i <= rows; i++ ) 295 { 296 if ( nv[i-1] <= N ) 333 else 334 { 335 for ( i = 2; i <= rows; i++ ) 336 { 337 if ( nv[i-1] <= N ) 297 338 { 298 339 wv[1,nv[i-1]]=int(m[i,1]); … … 316 357 int n=nvars(basering); 317 358 intvec N=0; 318 if ( deg(f)>0)319 { 320 while ( leadexp(f)!=0)321 { 322 N =N, leadexp(f);323 f =f-lead(f);324 } 325 } 326 else 327 { 328 N=N, leadexp(f); 329 } 330 N =N[2..size(N)]; // Deletes the zero added in the definition of T359 if ( f != 0 ) 360 { 361 while ( f != 0 ) 362 { 363 N = N, leadexp(f); 364 f = f-lead(f); 365 } 366 } 367 else 368 { 369 N=N, leadexp(f); 370 } 371 N = N[2..size(N)]; // Deletes the zero added in the definition of T 331 372 intmat M=intmat(N,(size(N)/n),n); // Conversion from vector to matrix 332 373 return (M); … … 373 414 C[j,i]=leadcoef(f); 374 415 D[j,i]=D[j,i]+f-lead(f); 375 } 376 else 416 } 417 else 377 418 { 378 419 D[j,i]=D[j,i]+lead(f); … … 384 425 l=C,D; 385 426 } 386 else { "The ring must have two or more variables"; } 427 else { "The ring must have two or more variables"; } 387 428 } 388 429 else { "The input must be of a type ring";} … … 417 458 { 418 459 if ( typeof(#[1])!="ring" ) { return();} 419 else 460 else 420 461 { 421 462 def @R1 = #[1]; … … 433 474 { 434 475 for (j=i; j<=n; j++) 435 { 476 { 436 477 p=var(i)*var(j)-M[i,j]; 437 478 if ( (size(I)==1) && (I[1]==0) ) { I=p; } … … 463 504 S[2,3]=a*x(1); S[3,2]=-b*x(1); 464 505 Fin_dim_algebra(S); 465 Quot = system("twostd",Quot);506 Quot = twostd(Quot); 466 507 qring Qr = Quot; 467 508 Qr; … … 475 516 EXAMPLE: example IsCentral; shows examples 476 517 "{ 477 int N =nvars(basering);518 int N = nvars(basering); 478 519 int in; 479 int flag =1;480 poly q=0;520 int flag = 1; 521 poly q = 0; 481 522 for (in=1; in<=N; in++) 482 523 { 483 q =p*var(in)-var(in)*p;524 q = p*var(in)-var(in)*p; 484 525 if (q!=0) 485 526 { … … 502 543 D[2,3]=-2*y; 503 544 ncalgebra(1,D); // this is U(sl_2) 504 poly c=4*x*y+z^2-2*z; 505 IsCentral(c,1); 506 } 507 508 /////////////////////////////////////////////////////////////////////////////// 509 510 proc UpOneMatrix (int N) 545 poly c = 4*x*y+z^2-2*z; 546 IsCentral(c,0); 547 poly h = x*c; 548 IsCentral(h,1); 549 } 550 551 /////////////////////////////////////////////////////////////////////////////// 552 553 proc UpOneMatrix(int N) 511 554 "USAGE: UpOneMatrix(N); N an integer, the number of columns 512 555 RETURN: intmat, NxN matrix with 1's in the whole upper triagle … … 537 580 /////////////////////////////////////////////////////////////////////////////// 538 581 539 proc ndc 582 proc ndc(list #) 540 583 "USAGE: ndc([v]); v an optional integer. If v!=0 procedure will be verbose 541 584 RETURN: ideal of non-degeneracy conditions … … 544 587 // if the second argument is given, produces ndc wrt powers x^N 545 588 { 546 int N =1;547 int Verbose =0;589 int N = 1; 590 int Verbose = 0; 548 591 if ( size(#)>=1 ) { Verbose = int(#[1]); } 549 592 if ( size(#)>=2 ) { N = int(#[2]); } 550 int cnt =1;551 int numvars =nvars(basering);593 int cnt = 1; 594 int numvars = nvars(basering); 552 595 int a,b,c; 553 poly p =1;554 ideal res =0;555 for (cnt=1; cnt<=N;cnt++)596 poly p = 1; 597 ideal res = 0; 598 for (cnt=1; cnt<=N; cnt++) 556 599 { 557 600 if (Verbose) { "Processing degree :",cnt;} … … 562 605 for(c=b+1; c<=numvars; c++) 563 606 { 564 p =(var(c)^cnt)*(var(b)^cnt);565 p =p*(var(a)^cnt);566 p =p-(var(c)^cnt)*((var(b)^cnt)*(var(a)^cnt));607 p = (var(c)^cnt)*(var(b)^cnt); 608 p = p*(var(a)^cnt); 609 p = p-(var(c)^cnt)*((var(b)^cnt)*(var(a)^cnt)); 567 610 if (Verbose) {a,".",b,".",c,".";} 568 if (p!=0) 611 if (p!=0) 569 612 { 570 613 if ( res==0 ) 571 614 { 572 res[1] =p;615 res[1] = p; 573 616 } 574 617 else 575 618 { 576 res =res,p;619 res = res,p; 577 620 } 578 621 if (Verbose) { "failed:",p; } … … 615 658 } 616 659 if (n<1) { return(0); } 617 number mp = par(1); 660 number mp = par(1); 618 661 if (n==1) { return(mp-1); } 619 662 if (n==2) { return(mp+1); } … … 623 666 int j=1; 624 667 while ( (CH[j] !=",") && (j<=size(CH))) 625 { 668 { 626 669 MCH=MCH+CH[j]; j++; 627 670 } … … 644 687 if ( deg(@l[j]) == d) { @d[cnt]=@l[j]; cnt++; } 645 688 } 646 if ( size(@d)==1 ) 647 { 648 res = poly(@d[1]); 689 if ( size(@d)==1 ) 690 { 691 res = poly(@d[1]); 649 692 } 650 693 else … … 652 695 j=1; 653 696 while ( j <= size(@d) ) 654 { 697 { 655 698 res = @d[j]-lead(@d[j]); 656 699 if ( leadcoef(res) >=0 ) { j++; } … … 777 820 { 778 821 "EXAMPLE:";echo=2; 779 def a =Heisenberg(2);822 def a = Heisenberg(2); 780 823 setring a; 781 824 a; … … 809 852 Q[i] = var(i)^2; 810 853 } 811 Q = system("twostd",Q);854 Q = twostd(Q); 812 855 qring @EA = Q; 813 856 return(@EA); … … 846 889 } 847 890 } 848 ring @rr=@p,(x(1..n),D(1..n)),dp; 891 if (n ==1) 892 { 893 ring @rr = @p,(x,D),dp; 894 } 895 else 896 { 897 ring @rr = @p,(x(1..n),D(1..n)),dp; 898 } 899 setring @rr; 849 900 Weyl(); 850 901 return(@rr);
Note: See TracChangeset
for help on using the changeset viewer.