source: git/Singular/LIB/nctools.lib @ 91c978

fieker-DuValspielwiese
Last change on this file since 91c978 was 91c978, checked in by Viktor Levandovskyy <levandov@…>, 19 years ago
*levandov: makeup things for the documentation together with minor fixes in code and English git-svn-id: file:///usr/local/Singular/svn/trunk@7758 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 22.0 KB
Line 
1///////////////////////////////////////////////////////////////////////////////
2version="$Id: nctools.lib,v 1.10 2005-02-23 18:10:46 levandov Exp $";
3category="Noncommutative";
4info="
5LIBRARY: nctools.lib     General tools for noncommutative algebras
6AUTHORS:   Levandovskyy V.,     levandov@mathematik.uni-kl.de,
7@*         Lobillo, F.J.,       jlobillo@ugr.es,
8@*         Rabelo, C.,          crabelo@ugr.es.
9
10SUPPORT: DFG (Deutsche Forschungsgesellschaft) and Metodos algebraicos y efectivos en grupos cuanticos, BFM2001-3141, MCYT, Jose Gomez-Torrecillas (Main researcher).
11
12PROCEDURES:
13Gweights(r);            computes weights for a compatible ordering in a G-algebra,
14weightedRing(r);        changes the ordering of a ring to a weighted one,
15ndc([v]);               the ideal of non-degeneracy conditions in G-algebra,
16RootOfUnity(n);         the minimal polynomial for the n-th primitive root of unity,
17Weyl([p]);              creates Weyl algebra structure in a basering (two different realizations),
18CreateWeyl(n, [p]);     returns n-th Weyl algebra in (x(i),D(i)) presentation; in char p, if an integer p is given,
19Heisenberg(N, [p,d]);   returns N-th  Heisenberg algebra in (x(i),y(i),h) realization,
20Exterior();             returns qring, the exterior algebra of a basering,
21Fin_dim_algebra(matrix M, list #); creates finite dimensional algebra structure from the basering and the multiplication matrix M,
22
23AUXILIARY PROCEDURES:
24Newton(f);              Newton diagram of a polynomial f,
25NCRelations(r);         recovers the non-commutative relations of a G-algebra,
26IsCentral(p,[v]);       check for the commutativity of polynomial p with the G-algebra,
27Is_NC();                checks whether basering is noncommutative,
28UpOneMatrix(N);         returns NxN matrix with 1's in the whole upper triagle,
29
30ALIAS PROCEDURES:
31wRing(r);               alias to weightedRing,
32";
33
34///////////////////////////////////////////////////////////////////////////////
35
36// This procedure computes a weights vector for a G-Algebra
37// r must be a G-algebra
38
39proc Gweights(def r)
40"USAGE:   Gweights(r); r a ring or a square matrix
41RETURN:   a weight vector for the G-algebra:
42          r itself, if it is of the type ring,
43          or for a G-algebra, defined by the square matrix r
44NOTE:    with Gweights you obtain 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 wRing or weightedRing to obtain directly the G-Algebra.
45EXAMPLE: example Gweights; shows examples
46SEE ALSO: wRing, weightedRing
47"{
48  matrix tails;
49  int novalid=0;
50  if (typeof(r)=="ring") //a ring is admissible as input
51  {
52    setring r;
53    def l = NCRelations(r);
54    tails = l[2]; // l=C,D we need D, the tails of the relations
55  }
56  else
57  {
58    if ( (typeof(r)=="matrix") || (typeof(r)=="intmat") )
59    {
60      if ( nrows(r)==ncols(r) ) //the input is a square matrix
61      {
62        tails = matrix(r);
63      }
64      else
65      {
66        novalid = 1;
67      }
68    }
69    else
70    {
71      novalid=1;
72    }
73  }
74  if (novalid==0)
75  {
76    intmat IM = SimplMat(tails);
77    if ( size(IM)>1 )
78    {
79      int n  = ncols(tails);
80      int m  = nrows(IM)-1;
81      int m1 = 0;
82      int m2 = m;
83      int m3 = 0;
84      ring simplexring=(real,10),(x),lp;// The simplex procedure requires a basering of this type
85      matrix M = IM;
86      list sol = simplex (M,m,n,m1,m2,m3);
87      return(weightvector(sol));
88    }
89    else
90    {
91      "Invalid input"; //usually because the input is a one variable ring
92      return();
93    }
94  }
95  else
96  {
97    "The input must be a ring or a square matrix";
98    return();
99  }
100}
101example
102{
103  "EXAMPLE:";echo=2;
104  ring r = (0,q),(a,b,c,d),lp;
105  matrix C[4][4];
106  C[1,2]=q; C[1,3]=q; C[1,4]=1; C[2,3]=1; C[2,4]=q; C[3,4]=q;
107  matrix D[4][4];
108  D[1,4]=(q-1/q)*b*c;
109  ncalgebra(C,D);
110  setring r; r;
111  Gweights(r);
112  Gweights(D);
113}
114
115///////////////////////////////////////////////////////////////////////////////
116
117// This procedure take a ring r, call to Gweights(r) and use the output
118// of Gweights(r) to make a change of order in r
119// The output is a new ring, equal to r but the order
120// r must be a G-algebra
121
122proc weightedRing(def r)
123"USAGE:   weightedRing(r); r a ring
124RETURN:  ring with the relations of r with order changed to comply with
125the ordering condition for G-algebras
126NOTE:    you have to activate this ring with the "setring" command
127EXAMPLE: example weightedRing; shows examples
128SEE ALSO: wRing, Gweights
129"{
130  def wv=Gweights(r);
131  if (typeof(wv)=="intvec")
132  {
133    setring r;
134    int n=nvars(r);
135    // Generating an nxn-intmat order
136    intmat m[n][n];
137    m[1,1]=wv[1];
138    int i;
139    for (i=2; i<=n; i++)
140    {
141      m[1,i]=wv[i];
142      m[i,n+2-i]=1;
143    }
144    // End of generation.
145    def lr=NCRelations(r);
146    string newringstring="ring newring=("+charstr(r)+"),("+varstr(r)+"),M("+string(m)+")";
147    execute (newringstring);
148    def lnewring=imap(r,lr);
149    ncalgebra(lnewring[1],lnewring[2]);
150    return(newring);
151  }
152  else
153  {
154    "Invalid input.";//usually because the input is a one variable ring
155    return();
156  }
157}
158example
159{
160  "EXAMPLE:";echo=2;
161  ring r = (0,q),(a,b,c,d),lp;
162  matrix C[4][4];
163  C[1,2]=q; C[1,3]=q; C[1,4]=1; C[2,3]=1; C[2,4]=q; C[3,4]=q;
164  matrix D[4][4];
165  D[1,4]=(q-1/q)*b*c;
166  ncalgebra(C,D);
167  setring r; r;
168  def t=weightedRing(r);
169  setring t; t;
170}
171
172///////////////////////////////////////////////////////////////////////////////
173
174proc wRing(def r)
175"USAGE:   see weightedRing
176"{
177  def a=weightedRing(r);
178  if (typeof(a)=="ring") { return(a); }
179  "Error";
180  return();
181}
182example
183{
184  "EXAMPLE:";echo=2;
185  LIB "qmatrix.lib";
186  def r=quant(2); // generate quant(2) and store it in r
187  setring r; // set the ring r the active ring
188  r;
189  def s=wRing(r);
190  setring s;
191  s;
192}
193
194///////////////////////////////////////////////////////////////////////////////
195
196// This procedure computes ei+ej-f with f running in Newton(pij) and deletes the zero rows
197
198static proc Cij(intmat M, int i,j)
199{
200  M=(-1)*M;
201  int nc=ncols(M);
202  intvec N;
203  int k;
204  for (k=1; k<=nrows(M); k++)
205  {
206    M[k,i]=M[k,i]+1;
207    M[k,j]=M[k,j]+1;
208    if (intvec(M[k,1..nc])!=0)
209    {
210      N=N,intvec(M[k,1..nc]);
211    } // we only want non-zero rows
212  }
213  if (size(N)>1)
214  {
215    N=N[2..size(N)]; // Deleting the zero added in the definition of N
216    M=intmat(N,size(N)/nc,nc); // Conversion from vector to matrix
217  }
218  else
219  {
220    intmat M[1][1]=0;
221  }
222  return (M);
223}
224
225///////////////////////////////////////////////////////////////////////////////
226
227// This procedure run over the matrix of pij calculating Cij
228
229static proc Ct(matrix P)
230{
231  int    k = ncols(P);
232  intvec T = 0;
233  int    i,j;
234//  int notails=1;
235  def S;
236  for (j=2; j<=k; j++)
237  {
238    for (i=1; i<j; i++)
239    {
240      if ( P[i,j] != 0 )
241      {
242//        notails=0;
243        S = Newton(P[i,j]);
244        S = Cij(S,i,j);
245        if ( size(S)>1 )
246        {
247          T = T,S;
248        }
249      }
250    }
251  }
252  if ( size(T)==1 )
253  {
254    intmat C[1][1] = 0;
255  }
256  else
257  {
258    T=T[2..size(T)]; // Deleting the zero added in the definition of T
259    intmat C = intmat(T,size(T)/k,k); // Conversion from vector to matrix
260  }
261  return (C);
262}
263
264///////////////////////////////////////////////////////////////////////////////
265
266// The purpose of this procedure is to produce the input matrix required by simplex procedure
267
268static proc SimplMat(matrix P)
269{
270  intmat C=Ct(P);
271  if (size(C)>1)
272  {
273    int r = nrows(C);
274    int n = ncols(C);
275    int f = 1+n+r;
276    intmat M[f][n+1]=0;
277    int i;
278    for (i=2; i<=(n+1); i++)
279    {
280      M[1,i]=-1; // (0,-1,-1,-1,...) objective function in the first row
281    }
282    for (i=2; i<=f; i++) {M[i,1]=1;} // All the independent terms are 1
283    for (i=2; i<=(n+1); i++) {M[i,i]=-1;} // wi>=1 is an identity matrix
284    M[(n+2)..f,2..(n+1)]=(-1)*intvec(C); // <wi,a> >= 1, a in C ...
285  }
286  else
287  {
288    int n = ncols(P);
289    int f = 1+n;
290    intmat M[f][n+1]=0;
291    int i;
292    for (i=2; i<=(n+1); i++) {M[1,i]=-1;} // (0,-1,-1,-1,...) objective function in the first row
293    for (i=2; i<=f; i++) {M[i,1]=1;} // All the independent terms are 1
294    for (i=2; i<=(n+1); i++) {M[i,i]=-1;} // wi>=1 is an identity matrix
295  }
296  return (M);
297}
298
299///////////////////////////////////////////////////////////////////////////////
300
301// This procedure generates a nice output of the simplex method consisting of a vector
302// with the solutions. The vector is ordered.
303
304static proc weightvector(list l)
305"ASSUME:  l is the output of simplex.
306RETURNS: if there is a solution, an intvec with the solution."
307{
308  matrix m=l[1];
309  intvec nv=l[3];
310  int sol=l[2];
311  int rows=nrows(m);
312  int N=l[6];
313  intmat wv[1][N]=0;
314  int i;
315  if (sol)
316  {
317    "no solution satisfies the given constraints";
318  }
319  else
320  {
321    for ( i = 2; i <= rows; i++ )
322    {
323      if ( nv[i-1] <= N )
324      {
325        wv[1,nv[i-1]]=int(m[i,1]);
326      }
327    }
328  }
329  return (intvec(wv));
330}
331
332///////////////////////////////////////////////////////////////////////////////
333
334// This procedure calculates the Newton diagram of the polynomial f
335// The output is a intmat M, each row of M is the exp of a monomial in f
336
337proc Newton(poly f)
338"USAGE:   Newton(f); f a poly
339RETURN:  intmat, representing the Newton diagram of f
340NOTE:    each row is the exponent of a monomial of f
341EXAMPLE: example Newton; shows examples
342"{
343  int n=nvars(basering);
344  intvec N=0;
345  if ( f != 0 )
346  {
347    while ( f != 0 )
348    {
349      N = N, leadexp(f);
350      f = f-lead(f);
351    }
352  }
353  else
354  {
355    N=N, leadexp(f);
356  }
357  N = N[2..size(N)]; // Deletes the zero added in the definition of T
358  intmat M=intmat(N,(size(N)/n),n); // Conversion from vector to matrix
359  return (M);
360}
361example
362{
363  "EXAMPLE:";echo=2;
364  ring r = 0,(x,y,z),lp;
365  poly f=x2y+3xz-5y+3;
366  Newton(f);
367}
368
369///////////////////////////////////////////////////////////////////////////////
370
371// This procedure recover the non-conmutative relations (matrices C and D)
372
373proc NCRelations(def r)
374"USAGE:   NCRelations(r); r a ring
375RETURN:  a list with two elements, both elements are of type matrix and
376         represent the matrices C,D defining the non-commutative relations
377         of the G-algebra r
378EXAMPLE: example NCRelations; shows examples
379"{
380  list l;
381  if (typeof(r)=="ring")
382  {
383    int n=nvars(r);
384    matrix C[n][n]=0;
385    matrix D[n][n]=0;
386    poly f; poly g;
387    if (n>1)
388    {
389      int i,j;
390      for (i=2; i<=n; i++)
391      {
392        for (j=1; j<i; j++)
393        {
394          f=var(i)*var(j); // yx=c*xy+...
395          g=var(j)*var(i); // xy
396          while (C[j,i]==0)
397          {
398            if (leadmonom(f)==leadmonom(g))
399            {
400              C[j,i]=leadcoef(f);
401              D[j,i]=D[j,i]+f-lead(f);
402            }
403            else
404            {
405              D[j,i]=D[j,i]+lead(f);
406              f=f-lead(f);
407            }
408          }
409        }
410      }
411      l=C,D;
412    }
413    else { "The ring must have two or more variables"; }
414  }
415  else { "The input must be of a type ring";}
416  return (l);
417}
418example
419{
420  "EXAMPLE:";echo=2;
421  ring r = 0,(x,y,z),dp;
422  matrix C[3][3]=0,1,2,0,0,-1,0,0,0;
423  print(C);
424  matrix D[3][3]=0,1,2y,0,0,-2x+y+1;
425  print(D);
426  ncalgebra(C,D);
427  r;
428  def l=NCRelations(r);
429  print (l[1]);
430  print (l[2]);
431}
432
433///////////////////////////////////////////////////////////////////////////////
434
435proc Fin_dim_algebra(matrix M, list #)
436"USAGE:   Fin_dim_algebra(M,[r]); M a matrix, r an optional ring.
437RETURN:  nothing. Creates finite dimensional algebra structure in a ring r
438(if it is given) or in a basering (by default) from the matrix M. Exports the ideal called Quot for further qring definition.
439NOTE: matrix M will be read according to relations x_j*x_i = M[i,j]; Quot is not given in its two-sided Groebner basis.
440EXAMPLE: Fin_dim_algebra; shows examples
441"
442{
443  if (size(#) >0)
444  {
445    if ( typeof(#[1])!="ring" ) { return();}
446    else
447    {
448      def @R1 = #[1];
449      setring @R1;
450    }
451  }
452  int i,j;
453  int n=nvars(basering);
454  poly p;
455  ideal I;
456  number c;
457  matrix C[n][n];
458  matrix D[n][n];
459  for (i=1; i<=n; i++)
460  {
461    for (j=i; j<=n; j++)
462    {
463      p=var(i)*var(j)-M[i,j];
464      if ( (size(I)==1) && (I[1]==0) )   { I=p; }
465      else { I=I,p; }
466      if (j>i)
467      {
468        if ((M[i,j]!=0) && (M[j,i]!=0))
469        {
470          c = leadcoef(M[j,i])/leadcoef(M[i,j]);
471        }
472        else
473        {
474          c = 1;
475        }
476        C[i,j]=c;
477        D[i,j]= - M[j,i] +c*M[i,j];
478      }
479    }
480  }
481  ncalgebra(C,D);
482  ideal Quot = I;
483  export Quot;
484}
485example
486{
487  "EXAMPLE:";echo=2;
488  ring r=(0,a,b),(x(1..3)),dp;
489  matrix S[3][3];
490  S[2,3]=a*x(1); S[3,2]=-b*x(1);
491  Fin_dim_algebra(S);
492  Quot = twostd(Quot);
493  qring Qr = Quot;
494  Qr;
495}
496
497///////////////////////////////////////////////////////////////////////////////
498
499proc IsCentral(poly p, list #)
500"USAGE:   IsCentral(p,[v]); p poly, v an integer (with v!=0 procedure will be verbose)
501RETURN:  integer (1 if p commutes with all variables, 0 otherwise)
502EXAMPLE: example IsCentral; shows examples
503"{
504  int N = nvars(basering);
505  int in;
506  int flag = 1;
507  poly   q = 0;
508  for (in=1; in<=N; in++)
509  {
510    q = p*var(in)-var(in)*p;
511    if (q!=0)
512    {
513      if (size(#) >0 )
514      {
515        "Noncentral at:", var(in);
516      }
517      flag = 0;
518    }
519  }
520  return(flag);
521}
522example
523{
524  "EXAMPLE:";echo=2;
525  ring r=0,(x,y,z),dp;
526  matrix D[3][3]=0;
527  D[1,2]=-z;
528  D[1,3]=2*x;
529  D[2,3]=-2*y;
530  ncalgebra(1,D); // this is U(sl_2)
531  poly c = 4*x*y+z^2-2*z;
532  IsCentral(c,0);
533  poly h = x*c;
534  IsCentral(h,1);
535}
536
537///////////////////////////////////////////////////////////////////////////////
538
539proc UpOneMatrix(int N)
540"USAGE:   UpOneMatrix(N); N an integer, the number of columns
541RETURN:  intmat, NxN matrix with 1's in the whole upper triagle
542NOTE: helpful for setting noncommutative algebras with complicated
543coefficient matrices
544EXAMPLE: example UpOneMatrix; shows examples
545"{
546  int ii,jj;
547  intmat U[N][N]=0;
548  for (ii=1;ii<N;ii++)
549  {
550    for (jj=ii+1;jj<=N;jj++)
551    {
552      U[ii,jj]=1;
553    }
554  }
555  return(U);
556}
557example
558{
559  "EXAMPLE:";echo=2;
560  ring r=(0,q),(x,y,z),dp;
561  matrix C=UpOneMatrix(3);
562  C[1,3]=q;
563  ncalgebra(C,0);
564  r;
565}
566
567///////////////////////////////////////////////////////////////////////////////
568proc ndc(list #)
569"USAGE:   ndc([v]); v an optional integer. If v!=0 procedure will be verbose
570RETURN:  ideal of non-degeneracy conditions of the basering
571EXAMPLE: example ndc; shows examples
572"
573{
574  // if the second argument is given, produces ndc wrt powers x^N
575  int N = 1;
576  int Verbose = 0;
577  if ( size(#)>=1 ) { Verbose = int(#[1]); }
578  if ( size(#)>=2 ) { N = int(#[2]); }
579  int cnt = 1;
580  int numvars = nvars(basering);
581  int a,b,c;
582  poly p = 1;
583  ideal res = 0;
584  for (cnt=1; cnt<=N; cnt++)
585  {
586    if (Verbose) { "Processing degree :",cnt;}
587    for (a=1; a<=numvars-2; a++)
588    {
589      for (b=a+1; b<=numvars-1; b++)
590      {
591        for(c=b+1; c<=numvars; c++)
592        {
593          p = (var(c)^cnt)*(var(b)^cnt);
594          p = p*(var(a)^cnt);
595          p = p-(var(c)^cnt)*((var(b)^cnt)*(var(a)^cnt));
596          if (Verbose) {a,".",b,".",c,".";}
597          if (p!=0)
598          {
599            if ( res==0 )
600            {
601              res[1] = p;
602            }
603            else
604            {
605              res = res,p;
606            }
607            if (Verbose) { "failed:",p; }
608          }
609        }
610      }
611    }
612    if (Verbose) { "done"; }
613  }
614  return(res);
615}
616example
617{
618  "EXAMPLE:";echo=2;
619  ring r = (0,q1,q2),(x,y,z),dp;
620  matrix C[3][3];
621  C[1,2]=q2; C[1,3]=q1; C[2,3]=1;
622  matrix D[3][3];
623  D[1,2]=x; D[1,3]=z;
624  ncalgebra(C,D);
625  r;
626  ideal j=ndc(); // the silent version
627  j;
628  ideal i=ndc(1); // the verbose version
629  i;
630}
631
632///////////////////////////////////////////////////////////////////////////////
633proc RootOfUnity(int n)
634"USAGE:   RootOfUnity(n); n an integer
635RETURN:  number, the n-th primitive root of unity (for use as minpoly)
636NOTE: works only in field extensions by one element
637EXAMPLE: example RootOfUnity; shows examples
638"
639{
640  if ( npars(basering) !=1 )
641  {
642    "the procedure works only with one parameter";
643    return(0);
644  }
645  if (n<1) { return(0); }
646  number mp = par(1);
647  if (n==1) { return(mp-1); }
648  if (n==2) { return(mp+1); }
649  def OldRing = basering;
650  string CH = charstr(basering);
651  string MCH;
652  int j=1;
653  while ( (CH[j] !=",") && (j<=size(CH)))
654  {
655    MCH=MCH+CH[j]; j++;
656  }
657  string SR = "ring @@rR="+MCH+","+parstr(basering)+",dp;";
658  execute(SR);
659  poly @t=var(1)^n-1; // (x^2i-1)=(x^i-1)(x^i+1)
660  list l=factorize(@t);
661  ideal @l=l[1];
662  list @d;
663  int s=size(@l);
664  int d=deg(@l[s]);
665  int cnt=1;
666  poly res;
667  for (j=s-1; j>=1; j--)
668  {
669    if ( deg(@l[j]) > d) { d=deg(@l[j]); }
670  }
671  for (j=1; j<=s; j++)
672  {
673    if ( deg(@l[j]) == d) { @d[cnt]=@l[j]; cnt++; }
674  }
675  if ( size(@d)==1 )
676  {
677    res = poly(@d[1]);
678  }
679  else
680  {
681    j=1;
682    while  ( j <= size(@d) )
683    {
684      res = @d[j]-lead(@d[j]);
685      if ( leadcoef(res) >=0 ) { j++; }
686      else { break; }
687    }
688    res = @d[j];
689  }
690  setring OldRing;
691  poly I = imap(@@rR,res);
692  mp = leadcoef(I);
693  kill @@rR;
694  return(mp);
695}
696example
697{
698  "EXAMPLE:";echo=2;
699  ring r8 = (0,q),(x,y,z),dp;
700  minpoly = RootOfUnity(8);
701  r8;
702  ring r7 = (0,q),(x,y,z),dp;
703  minpoly = RootOfUnity(7);
704  r7;
705  ring r6 = (0,q),(x,y,z),dp;
706  minpoly = RootOfUnity(6);
707  r6;
708}
709
710///////////////////////////////////////////////////////////////////////////////
711proc Weyl(list #)
712"USAGE:   Weyl([p]); p an optional integer.
713RETURN:  nothing. Creates Weyl algebra structure in a basering. By default
714mimics (x(1..N),d(1..N)) realization. If p is given and is not zero,
715uses (x(1),d(1),x(2),d(2),... ) realization.
716EXAMPLE: example Weyl; shows examples
717"
718{
719  string rname=nameof(basering);
720  if ( rname == "basering") // i.e. no ring has been set yet
721  {
722    "You have to call the procedure from the ring";
723    return();
724  }
725  int @chr = 0;
726  if ( size(#) > 0 )
727  {
728    if ( typeof( #[1] ) == "int" )
729    {
730      @chr = #[1];
731    }
732  }
733  int nv = nvars(basering);
734  int N = nv div 2;
735  if ((nv % 2) != 0)
736  {
737    "Cannot create Weyl structure for an odd number of generators";
738    return();
739  }
740  matrix @D[nv][nv];
741  int i;
742  for ( i=1; i<=N; i++ )
743  {
744    if ( @chr==0 ) // default
745    {
746      @D[i,N+i]=1;
747    }
748    else
749    {
750      @D[2*i-1,2*i]=1;
751    }
752  }
753  ncalgebra(1,@D);
754  return();
755}
756example
757{
758  "EXAMPLE:";echo=2;
759  ring A1=0,(x(1..2),d(1..2)),dp;
760  Weyl();
761  A1;
762  kill A1;
763  ring B1=0,(x1,d1,x2,d2),dp;
764  Weyl(1);
765  B1;
766}
767
768///////////////////////////////////////////////////////////////////////////////
769proc Heisenberg(int N, list #)
770"USAGE:   Heisenberg(N, [p,d]); N an integer (setting 2*N+1 variables), p an optional integer (field characteristic), d an optional integer (power of h in the commutator)
771RETURN:  N-th  Heisenberg algebra in x(i),y(i),h realization
772NOTE: you have to activate this ring with the "setring" command
773EXAMPLE: example Heisenberg; shows examples
774"
775{
776  int @chr = 0;
777  int @deg = 1;
778  if ( size(#) > 0 )
779  {
780    if ( typeof( #[1] ) == "int" )
781    {
782      @chr = #[1];
783    }
784  }
785  if ( size(#) > 1 )
786  {
787    if ( typeof( #[2] ) == "int" )
788    {
789      @deg = #[2];
790      if (@deg <1) { @deg = 1; }
791    }
792  }
793  ring @@r=@chr,(x(1..N),y(1..N),h),lp;
794  matrix D[2*N+1][2*N+1];
795  int i;
796  for (i=1;i<=N;i++)
797  {
798    D[i,N+i]=h^@deg;
799  }
800  ncalgebra(1,D);
801  return(@@r);
802}
803example
804{
805  "EXAMPLE:";echo=2;
806  def a = Heisenberg(2);
807  setring a;
808  a;
809}
810
811///////////////////////////////////////////////////////////////////////////////
812
813proc Exterior(list #)
814"USAGE:   Exterior();
815RETURN:  qring, the exterior algebra of a basering
816NOTE: you have to activate this qring with the "setring" command
817EXAMPLE: example Exterior; shows examples
818"
819{
820  string rname=nameof(basering);
821  if ( rname == "basering") // i.e. no ring has been set yet
822  {
823    "You have to call the procedure from the ring";
824    return();
825  }
826  int N = nvars(basering);
827  string NewRing = "ring @R=("+charstr(basering)+"),("+varstr(basering)+"),("+ordstr(basering)+");";
828  execute(NewRing);
829  matrix @E = UpOneMatrix(N);
830  @E = -1*(@E);
831  ncalgebra(@E,0);
832  int i;
833  ideal Q;
834  for ( i=1; i<=N; i++ )
835  {
836    Q[i] = var(i)^2;
837  }
838  Q = twostd(Q);
839  qring @EA = Q;
840  return(@EA);
841}
842example
843{
844  "EXAMPLE:";echo=2;
845  ring R = 0,(x(1..3)),dp;
846  def ER = Exterior();
847  setring ER;
848  ER;
849}
850
851///////////////////////////////////////////////////////////////////////////////
852
853proc CreateWeyl(int n, list #)
854"USAGE:   CreateWeyl(n,[p]); n an integer, n>0; p an optional integer (field characteristic)
855RETURN:  a ring, describing n-th Weyl algebra
856NOTE:    You have to activate this ring with the "setring" command.
857         The presentation of n-th Weyl algebra is classical:
858         D(i)x(i)=x(i)D(i)+1
859SEE ALSO: Weyl
860EXAMPLE: example CreateWeyl; shows examples
861"{
862  if (n<1)
863  {
864    Print("Incorrect input");
865    return();
866  }
867  int @p = 0;
868  if ( size(#) > 0 )
869  {
870    if ( typeof( #[1] ) == "int" )
871    {
872      @p = #[1];
873    }
874  }
875  if (n ==1)
876  {
877    ring @rr = @p,(x,D),dp;
878  }
879  else
880  {
881    ring @rr = @p,(x(1..n),D(1..n)),dp;
882  }
883  setring @rr;
884  Weyl();
885  return(@rr);
886}
887example
888{ "EXAMPLE:"; echo = 2;
889   def a = CreateWeyl(3);
890   setring a;
891   a;
892}
893
894//////////////////////////////////////////////////////////////////////
895
896proc Is_NC()
897"USAGE:   Is_NC();
898RETURN:   1, if basering is noncommutative; 0 otherwise.
899EXAMPLE: example Is_NC; shows examples
900"{
901  string rname=nameof(basering);
902  if ( rname == "basering") // i.e. no ring has been set yet
903  {
904    "You have to call the procedure from the ring";
905    return();
906  }
907  int n = nvars(basering);
908  int i,j;
909  poly p;
910  for (i=1; i<n; i++)
911  {
912    for (j=i+1; j<=n; j++)
913    {
914      p = var(j)*var(i) - var(i)*var(j);
915      if (p!=0) { return(1);}
916    }
917  }
918  return(0);
919}
920example
921{ "EXAMPLE:"; echo = 2;
922   def a = CreateWeyl(2);
923   setring a;
924   Is_NC();
925   kill a;
926   ring r = 17,(x(1..7)),dp;
927   Is_NC();
928   kill r;
929}
930
931//////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.