source: git/Singular/LIB/lrcalc.lib

spielwiese
Last change on this file was 9a3493, checked in by Oleksandr Iena <o.g.yena@…>, 3 years ago
Libraries formal checker problems * trailing spaces and too long lines fixed ** chern.lib ** goettsche.lib ** lrcalc.lib
  • Property mode set to 100644
File size: 13.8 KB
Line 
1////////////////////////////////////////////////////////////////
2version="version lrcalc.lib 4.1.2.0 Feb_2019 ";   //$Id$
3category="Littlewood-Richardson coefficients";
4info="
5LIBRARY:  lrcalc.lib    An interface to the Littlewood-Richardson Calculator by Anders Buch
6
7AUTHOR:  Oleksandr Iena,      o.g.yena@gmail.com
8
9OVERVIEW:
10  An interface to the documented functions of the Littlewood-Richardson Calculator
11  by Anders Buch is implemented.
12  The library requires the Littlewood-Richardson Calculator by Anders Buch,
13  which is available at http://math.rutgers.edu/~asbuch/lrcalc/
14
15REFERENCES:
16  [1] http://math.rutgers.edu/~asbuch/lrcalc/
17      http://math.rutgers.edu/~asbuch/lrcalc/lrcalc-1.2/README
18
19PROCEDURES:
20  LRinstall()                  installs the Littlewood-Richardson Calculator
21  LRcoef(z, x, y);             Littlewood-Richardson coefficient c^z_{x, y}
22  LRskew(z, x)                 partitions y for which the Littlewood-Richardson coefficient
23                               c^z_{x,y} is non-zero together with that coefficient
24  LRmult(x, y)                 partitions z for which the Littlewood-Richardson coefficient
25                               c^z_{x,y} is non-zero together with that coefficient
26  LRcoprod(z)                  pairs of partitions x and y for which the Littlewood-Richardson
27                               coefficient c^z_{x,y} is non-zero together with that coefficient
28  LRschubmult(x, y)            expantion of a product of two Schubert polynomials
29                               in the basis of Schubert polynomials
30";
31//----------------------------------------------------------
32
33proc LRinstall()
34"USAGE:   LRinstall();
35RETURN:   int (exit status of the shell)
36PURPOSE:  installs the Littlewood-Richardson Calculator
37EXAMPLE:  example LRinstall; shows an example
38NOTE:
39"
40{
41  int i;
42  string s;
43  s = "wget math.rutgers.edu/~asbuch/lrcalc/lrcalc-1.2.tar.gz";
44  s = s + " && tar zxvf lrcalc-1.2.tar.gz && cd lrcalc-1.2";
45  s = s + " && ./configure && make && sudo make install";
46  i=system("sh", s);
47  return(i);
48}
49example
50{
51  "EXAMPLE:"; echo = 2;
52  // In order to install the Littlewood-Richardson Calculator
53  // type "LRinstall();"
54  // This will execute the following commands:
55  // wget math.rutgers.edu/~asbuch/lrcalc/lrcalc-1.2.tar.gz
56  // tar zxvf lrcalc-1.2.tar.gz
57  // cd lrcalc-1.2
58  // ./configure
59  // make
60  // sudo make install
61}
62//----------------------------------------------------------
63
64proc LRcoef(list u, list l1, list l2)
65"USAGE:   LRcoef(z, x, y);  z, x, y lists of integers (partitions)
66RETURN:   bigint
67PURPOSE:  computes the Littlewood-Richardson coefficient c^z_{x, y}
68EXAMPLE:  example LRcoef; shows an example
69NOTE:
70"
71{
72  // construct a string with the required lrcalc command to be passed to shell
73  string s="lrcalc coef";
74  int i;
75  int sz;
76  sz=size(u);
77  for(i=1; i<=sz; i++)
78  {
79    s=s+" "+string(u[i]);
80  }
81  s=s+" -";
82  sz=size(l1);
83  for(i=1; i<=sz; i++)
84  {
85    s=s+" "+string(l1[i]);
86  }
87  s=s+" -";
88  sz=size(l2);
89  for(i=1; i<=sz; i++)
90  {
91    s=s+" "+string(l2[i]);
92  }
93  s=read("|: "+s); // execute the string in shell and return the output string back to Singular
94  return( string2int(s) ); // return the integer represented by this string
95}
96example
97{
98  "EXAMPLE:"; echo = 2;
99  // Compute the Littlewood-Richardson coefficient c^z_{x, y}
100  // for z= (3, 2, 1), x=(2, 1), y=(2, 1)
101  list z = 3, 2, 1;
102  list x = 2, 1;
103  list y = 2, 1;
104  LRcoef(z, x, y);
105}
106//----------------------------------------------------------
107
108proc LRskew(list I, list J, list #)
109"USAGE:   LRskew(z, x [,s, r]);  z, x lists of integers (partitions)
110          s string equal to 'r', r non-negative integer
111RETURN:   list of lists
112PURPOSE:  computes the partitions y for which the Littlewood-Richardson
113          coefficient c^z_{x,y} is non-zero together with that coefficient;
114          only partitions up to length r are computed
115          if the optional parameters age given
116EXAMPLE:  example LRskew; shows an example
117NOTE:
118"
119{
120  // construct a string with the required lrcalc command to be passed to shell
121  string s="lrcalc skew";
122  int sz;
123  // take care of the optional parameters
124  sz = size(#);
125  if(sz!=0) // if there are optional parameters
126  {
127    if(typeof(#[1])=="string") // if the first optional parameter is a string
128    {
129      if(#[1]=="r") // if it equals "r"
130      {
131        if(sz>1) // if there is a second optional parameter
132        {
133          if(typeof(#[2])=="int") // that is integer
134          {
135            if(#[2]>=0) // and non-negative
136            {
137              s=s+ " -r "+string(#[2]); // add the corresponding string to the lrcalc command
138            }
139          }
140        }
141      }
142    }
143  }
144  int i;
145  sz=size(I);
146  for(i=1; i<=sz; i++)
147  {
148    s=s+" "+string(I[i]);
149  }
150  s=s+" /";
151  sz=size(J);
152  for(i=1; i<=sz; i++)
153  {
154    s=s+" "+string(J[i]);
155  }
156  // execute the string in shell and return the output string back to Singular
157  link L="|: "+s+" && echo end";
158  list rez; // the result will be computed here
159  list T;
160  int next;
161  while(1)
162  {
163    s=read(L);
164    if(s=="end")
165    {
166      break;
167    }
168    i=1;
169    next=find(s," ",i);
170    if(next ==0){break;}
171    T=list(string2int(s[i,next-i]));
172    i=next+1;
173    next=find(s, "(", i);
174    i=next+1;
175    next=find(s, ")", i);
176    T= T+list( string2list(s[i,next-i]) );
177    rez=rez+ list(T);
178  }
179  close(L);
180  return( rez ); // return the result
181}
182example
183{
184  "EXAMPLE:"; echo = 2;
185  // Compute the partitions y for which the Littlewood-Richardson coefficient
186  // c^z_{x,y} is non-zero together with that coefficient
187  // for z= (3, 2, 1), x=(2, 1)
188  list z = 3, 2, 1;
189  list x = 2, 1;
190  LRskew(z, x);
191  // Now compute only the partitions with at most 2 entries
192  LRskew(z, x, "r", 2);
193}
194//----------------------------------------------------------
195
196proc LRmult(list I, list J, list #)
197"USAGE:   LRmult(x, y);  x, y lists of integers (partitions)
198          LRmult(x, y [, s, r]);  x, y lists of integers (partitions),
199          s string equal to 'r',  r integer
200          LRmult(x, y [, s, m, k]);  x, y lists of integers (partitions),
201          s string equal to 'q' or 'f',  m, k integers
202RETURN:   list of lists
203PURPOSE:  computes the partitions z for which the Littlewood-Richardson
204          coefficient c^z_{x,y} is non-zero together with that coefficient;
205          partitions up to length r
206EXAMPLE:  example LRmult; shows an example
207NOTE:
208"
209{
210  // construct a string with the required lrcalc command to be passed to shell
211  string s="lrcalc mult";
212  int i;
213  int sz;
214  // take care of the optional parameters
215  sz = size(#);
216  if(sz!=0) // if there are optional parameters
217  {
218    if(typeof(#[1])=="string") // if the first optional parameter is a string
219    {
220      if(#[1]=="r") // if the first optional parameter is "r"
221      {
222        if(sz>1) // if there is a second optional parameter
223        {
224          if(typeof(#[2])=="int") // which is an integer
225          {
226            if(#[2]>=0) // and non-negative
227            {
228              s=s+ " -r "+string(#[2]); // add the corresponding string to the lrcalc command
229            }
230          }
231        }
232      }
233      if( (#[1]=="q") || (#[1]=="f") ) // if the first optional parameter is "q" or "f"
234      {
235        if(sz>2) // if there are a second and a third parameters
236        {
237          if( ( typeof(#[2])=="int" ) && ( typeof(#[3])=="int" ) ) // that are integers
238          {
239            if( (#[2]>0)&&(#[3]>0) ) // and positive
240            {
241              // add the corresponding string to the lrcalc command
242              s=s+ " -"+#[1]+" "+string(#[2])+","+string(#[3]);
243            }
244          }
245        }
246      }
247    }
248  }
249  sz=size(I);
250  for(i=1; i<=sz; i++)
251  {
252    s=s+" "+string(I[i]);
253  }
254  s=s+" -";
255  sz=size(J);
256  for(i=1; i<=sz; i++)
257  {
258    s=s+" "+string(J[i]);
259  }
260  // execute the string in shell and return the output string back to Singular
261  link L="|: "+s+" && echo end";
262  list rez; // the result will be computed here
263  list T;
264  int next;
265  while(1)
266  {
267    s=read(L);
268    if(s=="end")
269    {
270      break;
271    }
272    i=1;
273    next=find(s," ",i);
274    if(next ==0){break;}
275    T=list(string2int(s[i,next-i]));
276    i=next+1;
277    next=find(s, "(", i);
278    i=next+1;
279    next=find(s, ")", i);
280    T= T+list( string2list(s[i,next-i]) );
281    rez=rez+ list(T);
282  }
283  close(L);
284  return( rez ); // return the result
285}
286example
287{
288  "EXAMPLE:"; echo = 2;
289  // Compute the partitions z for which the Littlewood-Richardson coefficient
290  // c^z_{x,y} is non-zero together with that coefficient
291  // for x= (2, 1), y=(2, 1)
292  list x = 2, 1;
293  list y = 2, 1;
294  LRmult(x, y);
295  // Now compute only the partitions with at most 2 entries
296  LRmult(x, y, "r", 2);
297  // Now compute the product in the quantum cohomology ring of the Grassmannian Gr(3,3+2).
298  LRmult(x, y, "q", 3, 2);
299  // Compute the same product with the output given in fusion ring notation
300  LRmult(x, y, "f", 3, 2);
301}
302//----------------------------------------------------------
303
304proc LRcoprod(list I)
305"USAGE:   LRcoprod(z);  z list of integers (partition)
306RETURN:   list of lists
307PURPOSE:  computes the pairs of partitions x and y for which
308          the Littlewood-Richardson coefficient c^z_{x,y} is non-zero
309          together with that coefficient
310EXAMPLE:  example LRcoprod; shows an example
311NOTE:
312"
313{
314  // construct a string with the required lrcalc command to be passed to shell
315  string s="lrcalc coprod";
316  int i;
317  int sz;
318  sz=size(I);
319  for(i=1; i<=sz; i++)
320  {
321    s=s+" "+string(I[i]);
322  }
323   // execute the string in shell and return the output string back to Singular
324  link L="|: "+s+" && echo end";
325  list rez; // the result will be computed here
326  list T;
327  int next;
328  while(1)
329  {
330    s=read(L);
331    if(s=="end")
332    {
333      break;
334    }
335    i=1;
336    next=find(s," ",i);
337    if(next ==0){break;}
338    T=list(string2int(s[i,next-i]));
339    i=next+1;
340    next=find(s, "(", i);
341    i=next+1;
342    next=find(s, ")", i);
343    T= T+list( string2list(s[i,next-i]) );
344    i=next+1;
345    next=find(s, "(", i);
346    i=next+1;
347    next=find(s, ")", i);
348    T= T+list( string2list(s[i,next-i]) );
349    rez=rez+ list(T);
350  }
351  close(L);
352  return( rez ); // return the result
353}
354example
355{
356  "EXAMPLE:"; echo = 2;
357  // Compute the pairs of partitions x and y for which the Littlewood-Richardson
358  // coefficient c^z_{x,y} is non-zero together with that coefficient
359  // for z= (3, 2, 1)
360  list z = 3, 2, 1;
361  LRcoprod(z);
362}
363//----------------------------------------------------------
364
365proc LRschubmult(list I, list J)
366"USAGE:   LRschubmult(x, y);  x, y lists of integers
367RETURN:   list of lists
368PURPOSE:  computes the expantion of a product
369          of two Schubert polynomials in the basis of Schubert polynomials
370EXAMPLE:  example LRschubmult; shows an example
371NOTE:
372"
373{
374  // construct a string with the required lrcalc command to be passed to shell
375  string s="schubmult";
376  int i;
377  int sz;
378  sz=size(I);
379  for(i=1; i<=sz; i++)
380  {
381    s=s+" "+string(I[i]);
382  }
383  s=s+" -";
384  sz=size(J);
385  for(i=1; i<=sz; i++)
386  {
387    s=s+" "+string(J[i]);
388  }
389  // execute the string in shell and return the output string back to Singular
390  link L="|: "+s+" && echo end";
391  list rez; // the result will be computed here
392  list T;
393  int next;
394  while(1)
395  {
396    s=read(L);
397    if(s=="end")
398    {
399      break;
400    }
401    i=1;
402    next=find(s," ",i);
403    if(next ==0){break;}
404    T=list(string2int(s[i,next-i]));
405    i=next+1;
406    next=find(s, "(", i);
407    i=next+1;
408    next=find(s, ")", i);
409    T= T+list( string2list(s[i,next-i]) );
410    rez=rez+ list(T);
411  }
412  close(L);
413  return( rez ); // return the result
414}
415example
416{
417  "EXAMPLE:"; echo = 2;
418  // Compute the expantion of a square of the Schubert polynomial
419  // corresponding to  (1 3 2) in the basis of Schubert polynomials
420  list x = 1, 3, 2;
421  LRschubmult(x, x);
422}
423//----------------------------------------------------------------------------------------
424// The procedures below are for the internal usage only
425//----------------------------------------------------------------------------------------
426
427static proc string2list(string s)
428"USAGE:   string2list(s);  s string
429RETURN:   list of integers
430PURPOSE:  converts a string representing integers separated by commas
431          into a list of integers
432EXAMPLE:  example string2list; shows an example
433NOTE:
434"
435{
436  list l; // the result will be computed here
437  if(size(s)==0) // if the string is empty
438  {
439    return(list(0)); // return zero
440  }
441  // otherwise form the corresponding list
442  execute("l="+s+";")
443  return(l); // return the result
444}
445example
446{
447  "EXAMPLE:"; echo = 2;
448  // Convert the string "3, 2, 1" into the corresponding list of integers
449  string s= "3, 2, 1";
450  string2list(s);
451}
452//----------------------------------------------------------
453
454static proc string2int(string s)
455"USAGE:   string2int(s);  s string
456RETURN:   biging
457PURPOSE:  converts a string representing a non-negative integer into integer
458EXAMPLE:  example string2int; shows an example
459NOTE:
460"
461{
462  bigint rez;
463  int sz=size(s);
464  if(sz==0) // if the string s is empty, return zero
465  {
466    return(bigint(0));
467  }
468  // read the first character of the string and transform it to the corresponding digit
469  while(1)
470  {
471    if(s[1]=="0")
472    {
473      rez=0; break;
474    }
475    if(s[1]=="1")
476    {
477      rez=1; break;
478    }
479    if(s[1]=="2")
480    {
481      rez=2; break;
482    }
483    if(s[1]=="3")
484    {
485      rez=3; break;
486    }
487    if(s[1]=="4")
488    {
489      rez=4; break;
490    }
491    if(s[1]=="5")
492    {
493      rez=5; break;
494    }
495    if(s[1]=="6")
496    {
497      rez=6; break;
498    }
499    if(s[1]=="7")
500    {
501      rez=7; break;
502    }
503    if(s[1]=="8")
504    {
505      rez=8; break;
506    }
507    if(s[1]=="9")
508    {
509      rez=9; break;
510    }
511  }
512  if(sz==1) // if the string is of length 1
513  {
514    return(bigint(rez)); // return the result
515  }
516  // otherwise compute the result recursively
517  return( rez*bigint(10)^(sz-1) + string2int(s[2,sz-1]) );
518}
519example
520{
521  "EXAMPLE:"; echo = 2;
522  // Convert the string "728" into the corresponding integer
523  string s= "728";
524  string2int(s);
525}
526//----------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.