1 | /////////////////////////////////////////////////////////////////////////////// |
---|
2 | version="$Id: nctools.lib,v 1.18 2006-07-18 15:48:27 Singular Exp $"; |
---|
3 | category="Noncommutative"; |
---|
4 | info=" |
---|
5 | LIBRARY: nctools.lib General tools for noncommutative algebras |
---|
6 | AUTHORS: Levandovskyy V., levandov@mathematik.uni-kl.de, |
---|
7 | @* Lobillo, F.J., jlobillo@ugr.es, |
---|
8 | @* Rabelo, C., crabelo@ugr.es. |
---|
9 | |
---|
10 | SUPPORT: DFG (Deutsche Forschungsgesellschaft) and Metodos algebraicos y efectivos en grupos cuanticos, BFM2001-3141, MCYT, Jose Gomez-Torrecillas (Main researcher). |
---|
11 | |
---|
12 | MAIN PROCEDURES: |
---|
13 | Gweights(r); compute weights for a compatible ordering in a G-algebra, |
---|
14 | weightedRing(r); change the ordering of a ring to a weighted one, |
---|
15 | ndcond(); the ideal of non-degeneracy conditions in G-algebra, |
---|
16 | Weyl([p]); create Weyl algebra structure in a basering (two different realizations), |
---|
17 | makeWeyl(n, [p]); return n-th Weyl algebra in (x(i),D(i)) presentation, |
---|
18 | makeHeisenberg(N, [p,d]); return n-th Heisenberg algebra in (x(i),y(i),h) realization, |
---|
19 | Exterior(); return qring, the exterior algebra of a basering, |
---|
20 | findimAlgebra(M,[r]); create finite dimensional algebra structure from the basering and the multiplication matrix M, |
---|
21 | |
---|
22 | AUXILIARY PROCEDURES: |
---|
23 | ncRelations(r); recover the non-commutative relations of a G-algebra, |
---|
24 | isCentral(p); check for the commutativity of a polynomial in the G-algebra, |
---|
25 | isNC(); check whether basering is noncommutative, |
---|
26 | UpOneMatrix(N); return NxN matrix with 1's in the whole upper triagle, |
---|
27 | "; |
---|
28 | |
---|
29 | LIB "ring.lib"; // for rootofUnity |
---|
30 | LIB "poly.lib"; // for newtonDiag |
---|
31 | |
---|
32 | /////////////////////////////////////////////////////////////////////////////// |
---|
33 | |
---|
34 | // This procedure computes a weights vector for a G-algebra r |
---|
35 | |
---|
36 | proc Gweights(def r) |
---|
37 | "USAGE: Gweights(r); r a ring or a square matrix |
---|
38 | RETURN: intvec |
---|
39 | PURPOSE: compute the weight vector for the following G-algebra: |
---|
40 | @* for r itself, if it is of the type ring, |
---|
41 | @* or for a G-algebra, defined by the square polynomial matrix r |
---|
42 | THEORY: @code{Gweights} returns a vector, which must be used 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 @code{weightedRing} to obtain directly the G-algebra with the new weighted ordering. |
---|
43 | EXAMPLE: example Gweights; shows examples |
---|
44 | SEE ALSO: weightedRing |
---|
45 | "{ |
---|
46 | matrix tails; |
---|
47 | int novalid=0; |
---|
48 | if (typeof(r)=="ring") //a ring is admissible as input |
---|
49 | { |
---|
50 | setring r; |
---|
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; |
---|
82 | ring simplexring=(real,10),(x),lp;// The simplex procedure requires a basering of this type |
---|
83 | matrix M = IM; |
---|
84 | list sol = simplex (M,m,n,m1,m2,m3); |
---|
85 | return(weightvector(sol)); |
---|
86 | } |
---|
87 | else |
---|
88 | { |
---|
89 | "Invalid input"; //usually because the input is a one variable ring |
---|
90 | return(); |
---|
91 | } |
---|
92 | } |
---|
93 | else |
---|
94 | { |
---|
95 | "The input must be a ring or a square matrix"; |
---|
96 | return(); |
---|
97 | } |
---|
98 | } |
---|
99 | example |
---|
100 | { |
---|
101 | "EXAMPLE:";echo=2; |
---|
102 | ring r = (0,q),(a,b,c,d),lp; |
---|
103 | matrix C[4][4]; |
---|
104 | C[1,2]=q; C[1,3]=q; C[1,4]=1; C[2,3]=1; C[2,4]=q; C[3,4]=q; |
---|
105 | matrix D[4][4]; |
---|
106 | D[1,4]=(q-1/q)*b*c; |
---|
107 | ncalgebra(C,D); |
---|
108 | r; |
---|
109 | Gweights(r); |
---|
110 | Gweights(D); |
---|
111 | } |
---|
112 | |
---|
113 | /////////////////////////////////////////////////////////////////////////////// |
---|
114 | |
---|
115 | // This procedure take a ring r, call to Gweights(r) and use the output |
---|
116 | // of Gweights(r) to make a change of order in r |
---|
117 | // The output is a new ring, equal to r but the order |
---|
118 | // r must be a G-algebra |
---|
119 | |
---|
120 | proc weightedRing(def r) |
---|
121 | "USAGE: weightedRing(r); r a ring |
---|
122 | RETURN: ring |
---|
123 | PURPOSE: equip the variables of a ring with such weights,that the relations of new ring (with weighted variables) satisfies the ordering condition for G-algebras |
---|
124 | NOTE: activate this ring with the \"setring\" command |
---|
125 | EXAMPLE: example weightedRing; shows examples |
---|
126 | SEE ALSO: Gweights |
---|
127 | "{ |
---|
128 | def wv=Gweights(r); |
---|
129 | if (typeof(wv)=="intvec") |
---|
130 | { |
---|
131 | setring r; |
---|
132 | int n=nvars(r); |
---|
133 | // Generating an nxn-intmat order |
---|
134 | intmat m[n][n]; |
---|
135 | m[1,1]=wv[1]; |
---|
136 | int i; |
---|
137 | for (i=2; i<=n; i++) |
---|
138 | { |
---|
139 | m[1,i]=wv[i]; |
---|
140 | m[i,n+2-i]=1; |
---|
141 | } |
---|
142 | // End of generation. |
---|
143 | def lr=ncRelations(r); |
---|
144 | string newringstring="ring newring=("+charstr(r)+"),("+varstr(r)+"),M("+string(m)+")"; |
---|
145 | execute (newringstring); |
---|
146 | def lnewring=imap(r,lr); |
---|
147 | ncalgebra(lnewring[1],lnewring[2]); |
---|
148 | return(newring); |
---|
149 | } |
---|
150 | else |
---|
151 | { |
---|
152 | "Invalid input.";//usually because the input is a one variable ring |
---|
153 | return(); |
---|
154 | } |
---|
155 | } |
---|
156 | example |
---|
157 | { |
---|
158 | "EXAMPLE:";echo=2; |
---|
159 | ring r = (0,q),(a,b,c,d),lp; |
---|
160 | matrix C[4][4]; |
---|
161 | C[1,2]=q; C[1,3]=q; C[1,4]=1; C[2,3]=1; C[2,4]=q; C[3,4]=q; |
---|
162 | matrix D[4][4]; |
---|
163 | D[1,4]=(q-1/q)*b*c; |
---|
164 | ncalgebra(C,D); |
---|
165 | r; |
---|
166 | def t=weightedRing(r); |
---|
167 | setring t; t; |
---|
168 | } |
---|
169 | |
---|
170 | /////////////////////////////////////////////////////////////////////////////// |
---|
171 | |
---|
172 | // This procedure computes ei+ej-f with f running in Newton(pij) and deletes the zero rows |
---|
173 | |
---|
174 | static proc Cij(intmat M, int i,j) |
---|
175 | { |
---|
176 | M=(-1)*M; |
---|
177 | int nc=ncols(M); |
---|
178 | intvec N; |
---|
179 | int k; |
---|
180 | for (k=1; k<=nrows(M); k++) |
---|
181 | { |
---|
182 | M[k,i]=M[k,i]+1; |
---|
183 | M[k,j]=M[k,j]+1; |
---|
184 | if (intvec(M[k,1..nc])!=0) |
---|
185 | { |
---|
186 | N=N,intvec(M[k,1..nc]); |
---|
187 | } // we only want non-zero rows |
---|
188 | } |
---|
189 | if (size(N)>1) |
---|
190 | { |
---|
191 | N=N[2..size(N)]; // Deleting the zero added in the definition of N |
---|
192 | M=intmat(N,size(N)/nc,nc); // Conversion from vector to matrix |
---|
193 | } |
---|
194 | else |
---|
195 | { |
---|
196 | intmat M[1][1]=0; |
---|
197 | } |
---|
198 | return (M); |
---|
199 | } |
---|
200 | |
---|
201 | /////////////////////////////////////////////////////////////////////////////// |
---|
202 | |
---|
203 | // This procedure run over the matrix of pij calculating Cij |
---|
204 | |
---|
205 | static proc Ct(matrix P) |
---|
206 | { |
---|
207 | int k = ncols(P); |
---|
208 | intvec T = 0; |
---|
209 | int i,j; |
---|
210 | // int notails=1; |
---|
211 | def S; |
---|
212 | for (j=2; j<=k; j++) |
---|
213 | { |
---|
214 | for (i=1; i<j; i++) |
---|
215 | { |
---|
216 | if ( P[i,j] != 0 ) |
---|
217 | { |
---|
218 | // notails=0; |
---|
219 | S = newtonDiag(P[i,j]); |
---|
220 | S = Cij(S,i,j); |
---|
221 | if ( size(S)>1 ) |
---|
222 | { |
---|
223 | T = T,S; |
---|
224 | } |
---|
225 | } |
---|
226 | } |
---|
227 | } |
---|
228 | if ( size(T)==1 ) |
---|
229 | { |
---|
230 | intmat C[1][1] = 0; |
---|
231 | } |
---|
232 | else |
---|
233 | { |
---|
234 | T=T[2..size(T)]; // Deleting the zero added in the definition of T |
---|
235 | intmat C = intmat(T,size(T)/k,k); // Conversion from vector to matrix |
---|
236 | } |
---|
237 | return (C); |
---|
238 | } |
---|
239 | |
---|
240 | /////////////////////////////////////////////////////////////////////////////// |
---|
241 | |
---|
242 | // The purpose of this procedure is to produce the input matrix required by simplex procedure |
---|
243 | |
---|
244 | static proc SimplMat(matrix P) |
---|
245 | { |
---|
246 | intmat C=Ct(P); |
---|
247 | if (size(C)>1) |
---|
248 | { |
---|
249 | int r = nrows(C); |
---|
250 | int n = ncols(C); |
---|
251 | int f = 1+n+r; |
---|
252 | intmat M[f][n+1]=0; |
---|
253 | int i; |
---|
254 | for (i=2; i<=(n+1); i++) |
---|
255 | { |
---|
256 | M[1,i]=-1; // (0,-1,-1,-1,...) objective function in the first row |
---|
257 | } |
---|
258 | for (i=2; i<=f; i++) {M[i,1]=1;} // All the independent terms are 1 |
---|
259 | for (i=2; i<=(n+1); i++) {M[i,i]=-1;} // wi>=1 is an identity matrix |
---|
260 | M[(n+2)..f,2..(n+1)]=(-1)*intvec(C); // <wi,a> >= 1, a in C ... |
---|
261 | } |
---|
262 | else |
---|
263 | { |
---|
264 | int n = ncols(P); |
---|
265 | int f = 1+n; |
---|
266 | intmat M[f][n+1]=0; |
---|
267 | int i; |
---|
268 | for (i=2; i<=(n+1); i++) {M[1,i]=-1;} // (0,-1,-1,-1,...) objective function in the first row |
---|
269 | for (i=2; i<=f; i++) {M[i,1]=1;} // All the independent terms are 1 |
---|
270 | for (i=2; i<=(n+1); i++) {M[i,i]=-1;} // wi>=1 is an identity matrix |
---|
271 | } |
---|
272 | return (M); |
---|
273 | } |
---|
274 | |
---|
275 | /////////////////////////////////////////////////////////////////////////////// |
---|
276 | |
---|
277 | // This procedure generates a nice output of the simplex method consisting of a vector |
---|
278 | // with the solutions. The vector is ordered. |
---|
279 | |
---|
280 | static proc weightvector(list l) |
---|
281 | "ASSUME: l is the output of simplex. |
---|
282 | RETURN: if there is a solution, an intvec with it will be returned" |
---|
283 | { |
---|
284 | matrix m=l[1]; |
---|
285 | intvec nv=l[3]; |
---|
286 | int sol=l[2]; |
---|
287 | int rows=nrows(m); |
---|
288 | int N=l[6]; |
---|
289 | intmat wv[1][N]=0; |
---|
290 | int i; |
---|
291 | if (sol) |
---|
292 | { |
---|
293 | "no solution satisfies the given constraints"; |
---|
294 | } |
---|
295 | else |
---|
296 | { |
---|
297 | for ( i = 2; i <= rows; i++ ) |
---|
298 | { |
---|
299 | if ( nv[i-1] <= N ) |
---|
300 | { |
---|
301 | wv[1,nv[i-1]]=int(m[i,1]); |
---|
302 | } |
---|
303 | } |
---|
304 | } |
---|
305 | return (intvec(wv)); |
---|
306 | } |
---|
307 | |
---|
308 | |
---|
309 | |
---|
310 | /////////////////////////////////////////////////////////////////////////////// |
---|
311 | |
---|
312 | // This procedure recover the non-conmutative relations (matrices C and D) |
---|
313 | |
---|
314 | proc ncRelations(def r) |
---|
315 | "USAGE: ncRelations(r); r a ring |
---|
316 | RETURN: list L with two elements, both elements are of type matrix: |
---|
317 | @* L[1] = matrix of coefficients C, |
---|
318 | @* L[2] = matrix of polynomials D |
---|
319 | PURPOSE: recover the noncommutative relations via matrices C and D from |
---|
320 | a noncommutative ring |
---|
321 | SEE ALSO: ringlist, G-algebras |
---|
322 | EXAMPLE: example ncRelations; shows examples |
---|
323 | "{ |
---|
324 | list l; |
---|
325 | if (typeof(r)=="ring") |
---|
326 | { |
---|
327 | int n=nvars(r); |
---|
328 | matrix C[n][n]=0; |
---|
329 | matrix D[n][n]=0; |
---|
330 | poly f; poly g; |
---|
331 | if (n>1) |
---|
332 | { |
---|
333 | int i,j; |
---|
334 | for (i=2; i<=n; i++) |
---|
335 | { |
---|
336 | for (j=1; j<i; j++) |
---|
337 | { |
---|
338 | f=var(i)*var(j); // yx=c*xy+... |
---|
339 | g=var(j)*var(i); // xy |
---|
340 | while (C[j,i]==0) |
---|
341 | { |
---|
342 | if (leadmonom(f)==leadmonom(g)) |
---|
343 | { |
---|
344 | C[j,i]=leadcoef(f); |
---|
345 | D[j,i]=D[j,i]+f-lead(f); |
---|
346 | } |
---|
347 | else |
---|
348 | { |
---|
349 | D[j,i]=D[j,i]+lead(f); |
---|
350 | f=f-lead(f); |
---|
351 | } |
---|
352 | } |
---|
353 | } |
---|
354 | } |
---|
355 | l=C,D; |
---|
356 | } |
---|
357 | else { "The ring must have two or more variables"; } |
---|
358 | } |
---|
359 | else { "The input must be of a type ring";} |
---|
360 | return (l); |
---|
361 | } |
---|
362 | example |
---|
363 | { |
---|
364 | "EXAMPLE:";echo=2; |
---|
365 | ring r = 0,(x,y,z),dp; |
---|
366 | matrix C[3][3]=0,1,2,0,0,-1,0,0,0; |
---|
367 | print(C); |
---|
368 | matrix D[3][3]=0,1,2y,0,0,-2x+y+1; |
---|
369 | print(D); |
---|
370 | ncalgebra(C,D); |
---|
371 | r; |
---|
372 | def l=ncRelations(r); |
---|
373 | print (l[1]); |
---|
374 | print (l[2]); |
---|
375 | } |
---|
376 | |
---|
377 | /////////////////////////////////////////////////////////////////////////////// |
---|
378 | |
---|
379 | proc findimAlgebra(matrix M, list #) |
---|
380 | "USAGE: findimAlgebra(M,[r]); M a matrix, r an optional ring |
---|
381 | RETURN: nothing |
---|
382 | PURPOSE: define a finite dimensional algebra structure on a ring |
---|
383 | NOTE: the matrix M is used to define the relations x(j)*x(i) = M[i,j] in the |
---|
384 | basering (by default) or in the optional ring r. |
---|
385 | @* The procedure equips the ring with the noncommutative structure. |
---|
386 | @* The procedure exports the ideal (not a two-sided Groebner basis!), called @code{fdQuot}, for further qring definition. |
---|
387 | THEORY: finite dimensional algebra can be represented as a factor algebra |
---|
388 | of a G-algebra modulo certain two-sided ideal. The relations of a f.d. algebra are thus naturally divided into two groups: firstly, the relations |
---|
389 | on the variables of the ring, making it into G-algebra and the rest of them, which constitute the ideal which will be factored out. |
---|
390 | EXAMPLE: example findimAlgebra; shows examples |
---|
391 | " |
---|
392 | { |
---|
393 | if (size(#) >0) |
---|
394 | { |
---|
395 | if ( typeof(#[1])!="ring" ) { return();} |
---|
396 | else |
---|
397 | { |
---|
398 | def @R1 = #[1]; |
---|
399 | setring @R1; |
---|
400 | } |
---|
401 | } |
---|
402 | int i,j; |
---|
403 | int n=nvars(basering); |
---|
404 | poly p; |
---|
405 | ideal I; |
---|
406 | number c; |
---|
407 | matrix C[n][n]; |
---|
408 | matrix D[n][n]; |
---|
409 | for (i=1; i<=n; i++) |
---|
410 | { |
---|
411 | for (j=i; j<=n; j++) |
---|
412 | { |
---|
413 | p=var(i)*var(j)-M[i,j]; |
---|
414 | if ( (size(I)==1) && (I[1]==0) ) { I=p; } |
---|
415 | else { I=I,p; } |
---|
416 | if (j>i) |
---|
417 | { |
---|
418 | if ((M[i,j]!=0) && (M[j,i]!=0)) |
---|
419 | { |
---|
420 | c = leadcoef(M[j,i])/leadcoef(M[i,j]); |
---|
421 | } |
---|
422 | else |
---|
423 | { |
---|
424 | c = 1; |
---|
425 | } |
---|
426 | C[i,j]=c; |
---|
427 | D[i,j]= - M[j,i] +c*M[i,j]; |
---|
428 | } |
---|
429 | } |
---|
430 | } |
---|
431 | ncalgebra(C,D); |
---|
432 | ideal fdQuot = I; |
---|
433 | export fdQuot; |
---|
434 | } |
---|
435 | example |
---|
436 | { |
---|
437 | "EXAMPLE:";echo=2; |
---|
438 | ring r=(0,a,b),(x(1..3)),dp; |
---|
439 | matrix S[3][3]; |
---|
440 | S[2,3]=a*x(1); S[3,2]=-b*x(1); |
---|
441 | findimAlgebra(S); |
---|
442 | fdQuot = twostd(fdQuot); |
---|
443 | qring Qr = fdQuot; |
---|
444 | Qr; |
---|
445 | } |
---|
446 | |
---|
447 | /////////////////////////////////////////////////////////////////////////////// |
---|
448 | |
---|
449 | proc isCentral(poly p, list #) |
---|
450 | "USAGE: isCentral(p); p poly |
---|
451 | RETURN: int, 1 if p commutes with all variables and 0 otherwise |
---|
452 | PURPOSE: check whether p is central in a basering (that is, commutes with every generator of a ring) |
---|
453 | NOTE: if @code{printlevel} > 0, the procedure displays intermediate information (by default, @code{printlevel}=0 ) |
---|
454 | EXAMPLE: example isCentral; shows examples |
---|
455 | "{ |
---|
456 | //v an integer (with v!=0, procedure will be verbose) |
---|
457 | int N = nvars(basering); |
---|
458 | int in; |
---|
459 | int flag = 1; |
---|
460 | poly q = 0; |
---|
461 | for (in=1; in<=N; in++) |
---|
462 | { |
---|
463 | q = p*var(in)-var(in)*p; |
---|
464 | if (q!=0) |
---|
465 | { |
---|
466 | if ( (size(#) >0 ) || (printlevel>0) ) |
---|
467 | { |
---|
468 | "Noncentral at:", var(in); |
---|
469 | } |
---|
470 | flag = 0; |
---|
471 | } |
---|
472 | } |
---|
473 | return(flag); |
---|
474 | } |
---|
475 | example |
---|
476 | { |
---|
477 | "EXAMPLE:";echo=2; |
---|
478 | ring r=0,(x,y,z),dp; |
---|
479 | matrix D[3][3]=0; |
---|
480 | D[1,2]=-z; |
---|
481 | D[1,3]=2*x; |
---|
482 | D[2,3]=-2*y; |
---|
483 | ncalgebra(1,D); // this is U(sl_2) |
---|
484 | poly c = 4*x*y+z^2-2*z; |
---|
485 | printlevel = 0; |
---|
486 | isCentral(c); |
---|
487 | poly h = x*c; |
---|
488 | printlevel = 1; |
---|
489 | isCentral(h); |
---|
490 | } |
---|
491 | |
---|
492 | /////////////////////////////////////////////////////////////////////////////// |
---|
493 | |
---|
494 | proc UpOneMatrix(int N) |
---|
495 | "USAGE: UpOneMatrix(n); n an integer |
---|
496 | RETURN: intmat |
---|
497 | PURPOSE: compute an n x n matrix with 1's in the whole upper triangle |
---|
498 | NOTE: helpful for setting noncommutative algebras with complicated |
---|
499 | coefficient matrices |
---|
500 | EXAMPLE: example UpOneMatrix; shows examples |
---|
501 | "{ |
---|
502 | int ii,jj; |
---|
503 | intmat U[N][N]=0; |
---|
504 | for (ii=1;ii<N;ii++) |
---|
505 | { |
---|
506 | for (jj=ii+1;jj<=N;jj++) |
---|
507 | { |
---|
508 | U[ii,jj]=1; |
---|
509 | } |
---|
510 | } |
---|
511 | return(U); |
---|
512 | } |
---|
513 | example |
---|
514 | { |
---|
515 | "EXAMPLE:";echo=2; |
---|
516 | ring r = (0,q),(x,y,z),dp; |
---|
517 | matrix C = UpOneMatrix(3); |
---|
518 | C[1,3] = q; |
---|
519 | print(C); |
---|
520 | ncalgebra(C,0); |
---|
521 | r; |
---|
522 | } |
---|
523 | |
---|
524 | /////////////////////////////////////////////////////////////////////////////// |
---|
525 | proc ndcond(list #) |
---|
526 | "USAGE: ndcond(); |
---|
527 | RETURN: ideal |
---|
528 | PURPOSE: compute the non-degeneracy conditions of the basering |
---|
529 | NOTE: if @code{printlevel} > 0, the procedure displays intermediate information (by default, @code{printlevel}=0 ) |
---|
530 | EXAMPLE: example ndcond; shows examples |
---|
531 | " |
---|
532 | { |
---|
533 | // internal documentation, for tests etc |
---|
534 | // 1st arg: v an optional integer (if v!=0, will be verbose) |
---|
535 | // if the second argument is given, produces ndc wrt powers x^N |
---|
536 | int N = 1; |
---|
537 | int Verbose = 0; |
---|
538 | if ( size(#)>=1 ) { Verbose = int(#[1]); } |
---|
539 | if ( size(#)>=2 ) { N = int(#[2]); } |
---|
540 | Verbose = ((Verbose) || (printlevel>0)); |
---|
541 | int cnt = 1; |
---|
542 | int numvars = nvars(basering); |
---|
543 | int a,b,c; |
---|
544 | poly p = 1; |
---|
545 | ideal res = 0; |
---|
546 | for (cnt=1; cnt<=N; cnt++) |
---|
547 | { |
---|
548 | if (Verbose) { "Processing degree :",cnt;} |
---|
549 | for (a=1; a<=numvars-2; a++) |
---|
550 | { |
---|
551 | for (b=a+1; b<=numvars-1; b++) |
---|
552 | { |
---|
553 | for(c=b+1; c<=numvars; c++) |
---|
554 | { |
---|
555 | p = (var(c)^cnt)*(var(b)^cnt); |
---|
556 | p = p*(var(a)^cnt); |
---|
557 | p = p-(var(c)^cnt)*((var(b)^cnt)*(var(a)^cnt)); |
---|
558 | if (Verbose) {a,".",b,".",c,".";} |
---|
559 | if (p!=0) |
---|
560 | { |
---|
561 | if ( res==0 ) |
---|
562 | { |
---|
563 | res[1] = p; |
---|
564 | } |
---|
565 | else |
---|
566 | { |
---|
567 | res = res,p; |
---|
568 | } |
---|
569 | if (Verbose) { "failed:",p; } |
---|
570 | } |
---|
571 | } |
---|
572 | } |
---|
573 | } |
---|
574 | if (Verbose) { "done"; } |
---|
575 | } |
---|
576 | return(res); |
---|
577 | } |
---|
578 | example |
---|
579 | { |
---|
580 | "EXAMPLE:";echo=2; |
---|
581 | ring r = (0,q1,q2),(x,y,z),dp; |
---|
582 | matrix C[3][3]; |
---|
583 | C[1,2]=q2; C[1,3]=q1; C[2,3]=1; |
---|
584 | matrix D[3][3]; |
---|
585 | D[1,2]=x; D[1,3]=z; |
---|
586 | ncalgebra(C,D); |
---|
587 | r; |
---|
588 | ideal j=ndcond(); // the silent version |
---|
589 | j; |
---|
590 | printlevel=1; |
---|
591 | ideal i=ndcond(); // the verbose version |
---|
592 | i; |
---|
593 | } |
---|
594 | |
---|
595 | |
---|
596 | /////////////////////////////////////////////////////////////////////////////// |
---|
597 | proc Weyl(list #) |
---|
598 | "USAGE: Weyl([p]); p an optional integer |
---|
599 | RETURN: nothing |
---|
600 | PURPOSE: create a Weyl algebra structure on a basering |
---|
601 | NOTE: suppose the number of variables of a basering is 2k. |
---|
602 | (if this number is odd, an error message will be returned) |
---|
603 | @* by default, the procedure treats first k variables as coordinates x_i and the last k as differentials d_i |
---|
604 | @* if nonzero p is given, the procedure treats 2k variables of a basering as k pairs (x_i,d_i), i.e. variables with odd numbers are treated as coordinates and with even numbers as differentials |
---|
605 | SEE ALSO: makeWeyl |
---|
606 | EXAMPLE: example Weyl; shows examples |
---|
607 | " |
---|
608 | { |
---|
609 | //there are two possibilities for choosing the PBW basis. |
---|
610 | //The variables have names x(i) for coordinates and d(i) for partial |
---|
611 | // differentiations. By default, the procedure |
---|
612 | //creates a ring, where the variables are ordered as x(1..n),d(1..n). the |
---|
613 | // tensor product-like realization x(1),d(1),x(2),d(2),... is used. |
---|
614 | string rname=nameof(basering); |
---|
615 | if ( rname == "basering") // i.e. no ring has been set yet |
---|
616 | { |
---|
617 | "You have to call the procedure from the ring"; |
---|
618 | return(); |
---|
619 | } |
---|
620 | int @chr = 0; |
---|
621 | if ( size(#) > 0 ) |
---|
622 | { |
---|
623 | if ( typeof( #[1] ) == "int" ) |
---|
624 | { |
---|
625 | @chr = #[1]; |
---|
626 | } |
---|
627 | } |
---|
628 | int nv = nvars(basering); |
---|
629 | int N = nv div 2; |
---|
630 | if ((nv % 2) != 0) |
---|
631 | { |
---|
632 | "Cannot create Weyl structure for an odd number of generators"; |
---|
633 | return(); |
---|
634 | } |
---|
635 | matrix @D[nv][nv]; |
---|
636 | int i; |
---|
637 | for ( i=1; i<=N; i++ ) |
---|
638 | { |
---|
639 | if ( @chr==0 ) // default |
---|
640 | { |
---|
641 | @D[i,N+i]=1; |
---|
642 | } |
---|
643 | else |
---|
644 | { |
---|
645 | @D[2*i-1,2*i]=1; |
---|
646 | } |
---|
647 | } |
---|
648 | ncalgebra(1,@D); |
---|
649 | return(); |
---|
650 | } |
---|
651 | example |
---|
652 | { |
---|
653 | "EXAMPLE:";echo=2; |
---|
654 | ring A1=0,(x(1..2),d(1..2)),dp; |
---|
655 | Weyl(); |
---|
656 | A1; |
---|
657 | kill A1; |
---|
658 | ring B1=0,(x1,d1,x2,d2),dp; |
---|
659 | Weyl(1); |
---|
660 | B1; |
---|
661 | } |
---|
662 | |
---|
663 | /////////////////////////////////////////////////////////////////////////////// |
---|
664 | proc makeHeisenberg(int N, list #) |
---|
665 | "USAGE: makeHeisenberg(n, [p,d]); int n (setting 2n+1 variables), optional int p (field characteristic), optional int d (power of h in the commutator) |
---|
666 | RETURN: nothing |
---|
667 | PURPOSE: create an n-th Heisenberg algebra in the variables x(1),y(1),...,x(n),y(n),h |
---|
668 | SEE ALSO: makeWeyl |
---|
669 | NOTE: activate this ring with the \"setring\" command |
---|
670 | EXAMPLE: example makeHeisenberg; shows examples |
---|
671 | " |
---|
672 | { |
---|
673 | int @chr = 0; |
---|
674 | int @deg = 1; |
---|
675 | if ( size(#) > 0 ) |
---|
676 | { |
---|
677 | if ( typeof( #[1] ) == "int" ) |
---|
678 | { |
---|
679 | @chr = #[1]; |
---|
680 | } |
---|
681 | } |
---|
682 | if ( size(#) > 1 ) |
---|
683 | { |
---|
684 | if ( typeof( #[2] ) == "int" ) |
---|
685 | { |
---|
686 | @deg = #[2]; |
---|
687 | if (@deg <1) { @deg = 1; } |
---|
688 | } |
---|
689 | } |
---|
690 | ring @@r=@chr,(x(1..N),y(1..N),h),lp; |
---|
691 | matrix D[2*N+1][2*N+1]; |
---|
692 | int i; |
---|
693 | for (i=1;i<=N;i++) |
---|
694 | { |
---|
695 | D[i,N+i]=h^@deg; |
---|
696 | } |
---|
697 | ncalgebra(1,D); |
---|
698 | return(@@r); |
---|
699 | } |
---|
700 | example |
---|
701 | { |
---|
702 | "EXAMPLE:";echo=2; |
---|
703 | def a = makeHeisenberg(2); |
---|
704 | setring a; a; |
---|
705 | def H3 = makeHeisenberg(3, 7, 2); |
---|
706 | setring H3; H3; |
---|
707 | } |
---|
708 | |
---|
709 | /////////////////////////////////////////////////////////////////////////////// |
---|
710 | proc Exterior(list #) |
---|
711 | "USAGE: Exterior(); |
---|
712 | RETURN: qring |
---|
713 | PURPOSE: create the exterior algebra of a basering |
---|
714 | NOTE: activate this qring with the \"setring\" command |
---|
715 | THEORY: given a basering, this procedure introduces the anticommutative relations x(j)x(i)=-x(i)x(j) for all j>i, |
---|
716 | @* moreover, creates a factor algebra modulo the two-sided ideal, generated by x(i)^2 for all i |
---|
717 | EXAMPLE: example Exterior; shows examples |
---|
718 | " |
---|
719 | { |
---|
720 | string rname=nameof(basering); |
---|
721 | if ( rname == "basering") // i.e. no ring has been set yet |
---|
722 | { |
---|
723 | "You have to call the procedure from the ring"; |
---|
724 | return(); |
---|
725 | } |
---|
726 | int N = nvars(basering); |
---|
727 | string NewRing = "ring @R=("+charstr(basering)+"),("+varstr(basering)+"),("+ordstr(basering)+");"; |
---|
728 | execute(NewRing); |
---|
729 | matrix @E = UpOneMatrix(N); |
---|
730 | @E = -1*(@E); |
---|
731 | ncalgebra(@E,0); |
---|
732 | int i; |
---|
733 | ideal Q; |
---|
734 | for ( i=1; i<=N; i++ ) |
---|
735 | { |
---|
736 | Q[i] = var(i)^2; |
---|
737 | } |
---|
738 | Q = twostd(Q); |
---|
739 | qring @EA = Q; |
---|
740 | return(@EA); |
---|
741 | } |
---|
742 | example |
---|
743 | { |
---|
744 | "EXAMPLE:";echo=2; |
---|
745 | ring R = 0,(x(1..3)),dp; |
---|
746 | def ER = Exterior(); |
---|
747 | setring ER; |
---|
748 | ER; |
---|
749 | } |
---|
750 | |
---|
751 | /////////////////////////////////////////////////////////////////////////////// |
---|
752 | proc makeWeyl(int n, list #) |
---|
753 | "USAGE: makeWeyl(n,[p]); n an integer, n>0; p an optional integer (field characteristic) |
---|
754 | RETURN: ring |
---|
755 | PURPOSE: create an n-th Weyl algebra |
---|
756 | NOTE: activate this ring with the \"setring\" command. |
---|
757 | @* The presentation of an n-th Weyl algebra is classical: D(i)x(i)=x(i)D(i)+1, |
---|
758 | @* where x(i) correspond to coordinates and D(i) to partial differentiations, i=1,...,n. |
---|
759 | SEE ALSO: Weyl |
---|
760 | EXAMPLE: example makeWeyl; shows examples |
---|
761 | "{ |
---|
762 | if (n<1) |
---|
763 | { |
---|
764 | print("Incorrect input"); |
---|
765 | return(); |
---|
766 | } |
---|
767 | int @p = 0; |
---|
768 | if ( size(#) > 0 ) |
---|
769 | { |
---|
770 | if ( typeof( #[1] ) == "int" ) |
---|
771 | { |
---|
772 | @p = #[1]; |
---|
773 | } |
---|
774 | } |
---|
775 | if (n ==1) |
---|
776 | { |
---|
777 | ring @rr = @p,(x,D),dp; |
---|
778 | } |
---|
779 | else |
---|
780 | { |
---|
781 | ring @rr = @p,(x(1..n),D(1..n)),dp; |
---|
782 | } |
---|
783 | setring @rr; |
---|
784 | Weyl(); |
---|
785 | return(@rr); |
---|
786 | } |
---|
787 | example |
---|
788 | { "EXAMPLE:"; echo = 2; |
---|
789 | def a = makeWeyl(3); |
---|
790 | setring a; |
---|
791 | a; |
---|
792 | } |
---|
793 | |
---|
794 | ////////////////////////////////////////////////////////////////////// |
---|
795 | proc isNC() |
---|
796 | "USAGE: isNC(); |
---|
797 | PURPOSE: check whether a basering is commutative or not |
---|
798 | RETURN: int, 1 if basering is noncommutative and 0 otherwise |
---|
799 | EXAMPLE: example isNC; shows examples |
---|
800 | "{ |
---|
801 | string rname=nameof(basering); |
---|
802 | if ( rname == "basering") // i.e. no ring has been set yet |
---|
803 | { |
---|
804 | "You have to call the procedure from the ring"; |
---|
805 | return(); |
---|
806 | } |
---|
807 | int n = nvars(basering); |
---|
808 | int i,j; |
---|
809 | poly p; |
---|
810 | for (i=1; i<n; i++) |
---|
811 | { |
---|
812 | for (j=i+1; j<=n; j++) |
---|
813 | { |
---|
814 | p = var(j)*var(i) - var(i)*var(j); |
---|
815 | if (p!=0) { return(1);} |
---|
816 | } |
---|
817 | } |
---|
818 | return(0); |
---|
819 | } |
---|
820 | example |
---|
821 | { "EXAMPLE:"; echo = 2; |
---|
822 | def a = makeWeyl(2); |
---|
823 | setring a; |
---|
824 | isNC(); |
---|
825 | kill a; |
---|
826 | ring r = 17,(x(1..7)),dp; |
---|
827 | isNC(); |
---|
828 | kill r; |
---|
829 | } |
---|
830 | |
---|
831 | ////////////////////////////////////////////////////////////////////// |
---|