Changeset 3c4dcc in git


Ignore:
Timestamp:
May 6, 2005, 4:39:20 PM (18 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
Children:
0d217d3f1cc4c0449bdb078c65fd1f43cd1a2b84
Parents:
e6fb5315eb32da00236163ce10f9bdafaaa0bd47
Message:
*hannes: DOS->UNIX and white space cleanup


git-svn-id: file:///usr/local/Singular/svn/trunk@8073 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular/LIB
Files:
45 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/KVequiv.lib

    re6fb531 r3c4dcc  
    1 // $Id: KVequiv.lib,v 1.1 2001-11-27 15:56:15 anne Exp $
     1// $Id: KVequiv.lib,v 1.2 2005-05-06 14:38:03 hannes Exp $
    22// (anne, last modified 27.11.2001)
    33/////////////////////////////////////////////////////////////////////////////
     
    55/////////////////////////////////////////////////////////////////////////////
    66
    7 version="$Id: KVequiv.lib,v 1.1 2001-11-27 15:56:15 anne Exp $";
     7version="$Id: KVequiv.lib,v 1.2 2005-05-06 14:38:03 hannes Exp $";
    88info="
    99LIBRARY:  KVequiv.lib    PROCEDURES RELATED TO K_V-EQUIVALENCE
     
    1515 derlogV(iV);                   derlog(V(iV))
    1616 KVtangent(I,rname,dername,k)   K_V tangent space to given singularity
    17  KVversal(KVtan,I,rname,idname) K_V versal family 
     17 KVversal(KVtan,I,rname,idname) K_V versal family
    1818 KVvermap(KVtan,I)              section inducing K_V versal family
    1919 lft_vf(I,rname,idname)         liftable vector fields
     
    2121REMARKS:
    2222 * monomial ordering should be of type (c,...)
    23  * monomial ordering should be local on the original (2) rings 
     23 * monomial ordering should be local on the original (2) rings
    2424";
    2525////////////////////////////////////////////////////////////////////////////
     
    3131
    3232// then the ones written in C/C++
    33 LIB("loctriv.so"); 
     33LIB("loctriv.so");
    3434
    3535////////////////////////////////////////////////////////////////////////////
     
    3939proc derlogV(ideal iV)
    4040"USAGE:  @code{derlogV(iV)};   @code{iV} ideal
    41 RETURN:  matrix whose columns generate derlog(V(iV)) 
     41RETURN:  matrix whose columns generate derlog(V(iV))
    4242EXAMPLE: @code{example derlogV}; shows an example
    4343"
     
    7979                                                 @code{rname,dername} strings
    8080                                                 @code{[k]} int
    81 RETURN:   K_V tangent space to a singularity given as a section of a 
    82           model singularity 
    83 NOTE:     The model singularity lives in the ring given by rname and 
     81RETURN:   K_V tangent space to a singularity given as a section of a
     82          model singularity
     83NOTE:     The model singularity lives in the ring given by rname and
    8484          its derlog(V) is given by dername in that ring. The section is
    85           specified by the generators of mapi. If k is given, the first k 
     85          specified by the generators of mapi. If k is given, the first k
    8686          variables are used as variables, the remaining ones as parameters
    8787EXAMPLE:  @code{example KVtangent}; shows an example
     
    178178                                                  @code{rname,idname} strings
    179179RETURN:   list; The first entry of the list is the new ring in which the
    180           K_V versal family lives, the second is the name of the ideal 
    181           describing a K_V versal family of a singularity given as section 
     180          K_V versal family lives, the second is the name of the ideal
     181          describing a K_V versal family of a singularity given as section
    182182          of a model singularity (which was specified as idname in rname)
    183183NOTE:     The section is given by the generators of I, KVtan is the matrix
    184184          describing the K_V tangent space to the singularity (as returned
    185           by KVtangent). rname denotes the ring in which the model 
     185          by KVtangent). rname denotes the ring in which the model
    186186          singularity lives, and idname is the name of the ideal in this ring
    187187          defining the singularity.
     
    231231// Extend our current ring by adjoining the correct number of variables
    232232// A(i) for the parameters and copy our objects to this ring
    233 //--------------------------------------------------------------------------- 
     233//---------------------------------------------------------------------------
    234234  def rbas=basering;
    235235  ring rtemp=0,(A(1..size(kbKVt))),(c,dp);
     
    270270  ideal idy=ab,cd;
    271271  def dV=derlogV(idy);
    272   echo=1; 
     272  echo=1;
    273273  export ry; export dV; export idy; echo=2;
    274274  ring rx=0,(x,y,z),ds;
     
    279279  setring rnew;
    280280  `li[2]`;
    281   echo=1; 
     281  echo=1;
    282282  setring ry; kill idy; kill dV; setring rx; kill ry;
    283283}
     
    286286proc KVvermap(matrix KVtan, ideal mapi)
    287287"USAGE:   @code{KVvermap(KVtan,I)};  @code{KVtan} matrix, @code{I} ideal
    288 RETURN:   list; The first entry of the list is the new ring in which the 
    289           versal object lives, the second specifies a map describing the 
    290           section which yields a K_V versal family of the original 
     288RETURN:   list; The first entry of the list is the new ring in which the
     289          versal object lives, the second specifies a map describing the
     290          section which yields a K_V versal family of the original
    291291          singularity which was given as section of a model singularity
    292292NOTE:     The section is given by the generators of I, KVtan is the matrix
     
    321321// Extend our current ring by adjoining the correct number of variables
    322322// A(i) for the parameters and copy our objects to this ring
    323 //--------------------------------------------------------------------------- 
     323//---------------------------------------------------------------------------
    324324  def rbas=basering;
    325325  ring rtemp=0,(A(1..size(kbKVt))),(c,dp);
     
    350350  ideal idy=ab,cd;
    351351  def dV=derlogV(idy);
    352   echo=1; 
     352  echo=1;
    353353  export ry; export dV; export idy; echo=2;
    354354  ring rx=0,(x,y,z),ds;
     
    359359  setring rnew;
    360360  `li[2]`;
    361   echo=1; 
     361  echo=1;
    362362  setring ry; kill idy; kill dV; setring rx; kill ry;
    363363}
     
    373373RETURN: list
    374374        [1]: ring in which objects specified by the strings [2] and [3] live
    375         [2]: name of ideal describing the liftable vector fields - 
     375        [2]: name of ideal describing the liftable vector fields -
    376376             computed up to order b in the parameters
    377377        [3]: name of basis of the K_V-normal space of the original singularity
    378378        [4]: (if 6th argument is given)
    379              ring in which the reduction of the liftable vector fields has 
     379             ring in which the reduction of the liftable vector fields has
    380380             taken place.
    381381        [5]: name of liftable vector fields in ring [4]
     
    386386        ring rname in the ideal idname, the resulting expression is
    387387        quasihomogeneous; wv specifies the weight vector of the ring rname.
    388         b is the degree bound up in the perturbation parameters up to which
    389         computations are performed.
     388        b is the degree bound up in the perturbation parameters up to which
     389        computations are performed.
    390390NOTE:   the original ring should not contain any variables of name
    391391        A(i) or e(j)
    392 EXAMPLE:@code{example lft_vf;} gives an example 
     392EXAMPLE:@code{example lft_vf;} gives an example
    393393"
    394394{
     
    431431// first prepare derlog(V) for the model singularity
    432432// and set the correct weights
    433 //--------------------------------------------------------------------------- 
     433//---------------------------------------------------------------------------
    434434  def @dV=derlogV(`idname`);
    435435  export(@dV);
     
    453453  }
    454454//---------------------------------------------------------------------------
    455 // Construction of the versal family 
     455// Construction of the versal family
    456456//---------------------------------------------------------------------------
    457457  list lilit=KVvermap(KVt,mapi);
     
    464464//---------------------------------------------------------------------------
    465465// put the unperturbed and the perturbed tangent space into a module
    466 // (1st component unperturbed) and run a groebner basis computation 
     466// (1st component unperturbed) and run a groebner basis computation
    467467// which only considers spolys with non-vanishing first component
    468468//---------------------------------------------------------------------------
    469469  def rxa=basering;
    470   string rchange="ring rexa=" + charstr(basering) + ",(e(1.." + 
    471                  string(ncols(mapi)) + ")," + varstr(basering) + 
     470  string rchange="ring rexa=" + charstr(basering) + ",(e(1.." +
     471                 string(ncols(mapi)) + ")," + varstr(basering) +
    472472                 "),(c,ws(" + string((-1)*wv) + "," + string(ivm) + "),dp);";
    473473  execute(rchange);
     
    557557      mt=mt,Aus2[2,i];
    558558    }
    559   } 
     559  }
    560560//---------------------------------------------------------------------------
    561561// * change weights of the A(i) such that Aus2[1,i] and Aus2[2,i] have the
    562562//   same leading term, if the first one is non-zero
    563 // * reduce mt by mx 
     563// * reduce mt by mx
    564564// * find l such that (x_1,...,x_n)^l * eid can be used instead of noether
    565565//   which we have to avoid because we are playing with the weights
     
    571571  }
    572572  mx=jet(mx,counter*(b+1),qiv);
    573   rchange="ring rexaw=" + charstr(basering) + ",(" + varstr(basering) + 
     573  rchange="ring rexaw=" + charstr(basering) + ",(" + varstr(basering) +
    574574                      "),(c,ws(" + string((-1)*wv) + "," + string(ivm) +
    575575                      "," + string(oiv) + "));";
     
    654654  ideal idy=ab,cd;
    655655  def dV=derlogV(idy);
    656   echo=1; 
     656  echo=1;
    657657  export ry; export dV; export idy; echo=2;
    658658  ring rx=0,(x,y,z),ds;
     
    665665  `li[2]`;
    666666  `li[3]`;
    667   echo=1; 
     667  echo=1;
    668668  setring ry; kill idy; kill dV; setring rx; kill ry;
    669669}
  • Singular/LIB/algebra.lib

    re6fb531 r3c4dcc  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: algebra.lib,v 1.10 2005-04-28 09:22:14 Singular Exp $";
     2version="$Id: algebra.lib,v 1.11 2005-05-06 14:38:03 hannes Exp $";
    33category="Commutative Algebra";
    44info="
     
    9999// e.g.:
    100100               def S = l[2]; setring S; check;
    101         ");
     101        ");
    102102     return(l);
    103103    }
     
    287287"USAGE:   algDependent(f[,c]); f ideal (say, f = f1,...,fm), c integer
    288288RETURN:
    289 @format 
     289@format
    290290         a list l  of size 2, l[1] integer, l[2] ring:
    291291         - l[1] = 1 if f1,...,fm are algebraic dependent, 0 if not
     
    398398// e.g.:
    399399             def S = l[2]; setring S; ker;
    400         ");
     400        ");
    401401    return (L);
    402402}
     
    492492"USAGE:   is_injective(phi[,c,s]); phi map, pr reimage ring, c int, s string
    493493RETURN:
    494 @format 
     494@format
    495495         - 1 (type int) if phi is injective, 0 if not (if s is not given).
    496496         - If s is given, return a list l of size 2, l[1] int, l[2] ring:
     
    564564// e.g.:
    565565     def S = l[2]; setring S; ker;
    566         ");
     566        ");
    567567      return(L);
    568568    }
     
    754754"USAGE:   noetherNormal(id[,p]);  id ideal, p integer
    755755RETURN:
    756 @format 
     756@format
    757757         a list l two ideals, say I,J:
    758758         - I is generated by a subset of the variables with size(I) = dim(id)
  • Singular/LIB/brnoeth.lib

    re6fb531 r3c4dcc  
    1 version="$Id: brnoeth.lib,v 1.14 2005-04-19 15:23:38 Singular Exp $";
     1version="$Id: brnoeth.lib,v 1.15 2005-05-06 14:38:04 hannes Exp $";
    22category="Coding theory";
    33info="
     
    11481148  int i,j,k;
    11491149  int m,n;
    1150 //  list L@HNE=essdevelop(CHI); 
     1150//  list L@HNE=essdevelop(CHI);
    11511151  list LLL=ratdevelop(CHI);
    11521152  if (typeof(LLL[1])=="ring") {
     
    20432043             + "executing Adj_div, as 'a' is used for "
    20442044             + "the name of the parameter of the field extensions needed.");
    2045       ERROR("Please rename or kill the object named 'a'"); 
     2045      ERROR("Please rename or kill the object named 'a'");
    20462046    }
    20472047  }
     
    21972197          See @ref{Adj_div} for a description of the entries in L.
    21982198NOTE:     The list_expression should be the output of the procedure Adj_div.@*
    2199           Raising @code{printlevel}, additional comments are displayed 
     2199          Raising @code{printlevel}, additional comments are displayed
    22002200          (default: @code{printlevel=0}).
    22012201WARNING:  The parameter of the needed field extensions is called 'a'. Thus,
     
    22202220             + "executing Adj_div, as 'a' is used for "
    22212221             + "the name of the parameter of the field extensions needed.");
    2222       ERROR("Please rename or kill the object named 'a'"); 
     2222      ERROR("Please rename or kill the object named 'a'");
    22232223    }
    22242224  }
     
    29182918  if (typeof(LLL[1])=="ring") {
    29192919    def altring=basering;
    2920     def HNEring = LLL[1]; 
     2920    def HNEring = LLL[1];
    29212921    setring HNEring;
    29222922    def L@HNE = hne[1];
     
    29512951  }
    29522952  kill LLL;
    2953  
     2953
    29542954  list BRANCH=list();
    29552955  BRANCH[1]=Maux;
  • Singular/LIB/center.lib

    re6fb531 r3c4dcc  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: center.lib,v 1.13 2005-02-23 18:10:44 levandov Exp $";
     2version="$Id: center.lib,v 1.14 2005-05-06 14:38:08 hannes Exp $";
    33category="Noncommutative";
    44info="
     
    66AUTHOR:  Oleksandr Motsak,        motsak@mathematik.uni-kl.de.
    77OVERVIEW:
    8  This is a library for computing the central elements and centralizers of elements in various noncommutative algebras. 
     8 This is a library for computing the central elements and centralizers of elements in various noncommutative algebras.
    99 Implementation is based on algorithms, written in the frame of the diploma thesis by O. Motsak (advisor: Prof. S.A. Ovsienko, support: V. Levandovskyy), at Kyiv Taras Shevchenko University (Ukraine) with the title 'An algorithm for the computation of the center of noncommutative polynomial algebra'.
    1010
     
    1212
    1313PROCEDURES:
    14         center(MaxDeg[,N]);             computes the generators of the center of a basering,
    15         centralizer(f, MaxDeg[,N]);     computes the generators of the centralizer of f in a basering,
    16         inCenter(l);                    checks the centrality of elements of list/ideal/poly l
    17         inCentralizer(l, f);            checks the commutativity wrt polynomial f of polynomials of list/ideal/poly l
     14        center(MaxDeg[,N]);             computes the generators of the center of a basering,
     15        centralizer(f, MaxDeg[,N]);     computes the generators of the centralizer of f in a basering,
     16        inCenter(l);                    checks the centrality of elements of list/ideal/poly l
     17        inCentralizer(l, f);            checks the commutativity wrt polynomial f of polynomials of list/ideal/poly l
    1818
    1919KEYWORDS:  inCenter; inCentralizer; center; centralizer
    2020";
    2121
    22 
    2322/******************************************************/
    2423// stuff
     
    2625/******************************************************/
    2726static proc myValue ( def s, list # )
    28   "
    29         return s or (typeof(s))(#)
     27"
     28        return s or (typeof(s))(#)
    3029"
    3130{
     
    3433    {
    3534      if ( typeof( #[1] ) == typeof(s) )
    36         {
    37           @p = #[1];
    38         };
     35        {
     36          @p = #[1];
     37        };
    3938    };
    4039  return (@p);
     
    4443static proc myInt ( list # )
    4544  "
    46         return 0 or int(#)
     45        return 0 or int(#)
    4746"
    4847{
     
    5453static proc myPoly ( list # )
    5554  "
    56         return 0 or poly(#)
     55        return 0 or poly(#)
    5756"
    5857{
     
    6463static proc myRing ( list # )
    6564  "
    66         return basring or ring(#)
     65        return basring or ring(#)
    6766"
    6867{
     
    7473static proc myString ( list # )
    7574  "
    76         return basring or ring(#)
     75        return basring or ring(#)
    7776"
    7877{
     
    8483static proc myIdeal ( list # )
    8584  "
    86         return 0 or ideal(#)
     85        return 0 or ideal(#)
    8786"
    8887{
     
    107106      print (#);
    108107    };
    109 };   
     108};
    110109
    111110/******************************************************/
     
    134133static proc maxDeg( def z )
    135134  "
    136         returns: int : max of givendeg( z_i ), among all z_i \in z
    137                 returns -1 if z is empty or contain only 0 polynomial
    138 "
    139 {
    140   int max = -1; 
     135        returns: int : max of givendeg( z_i ), among all z_i \in z
     136                returns -1 if z is empty or contain only 0 polynomial
     137"
     138{
     139  int max = -1;
    141140  int d;
    142141
     
    144143    {
    145144      d = deg(z[i]);
    146       if( d > max ) 
    147         {
    148           max = d;
    149         };
     145      if( d > max )
     146        {
     147          max = d;
     148        };
    150149    };
    151150
     
    159158static proc myCoeff ( poly f, poly m )
    160159  "
    161         input: poly f,
    162         return: coeff at m
     160        input: poly f,
     161        return: coeff at m
    163162"
    164163{
     
    166165
    167166  int i = size(f);
    168        
     167
    169168  while ( (i>0) and (leadmonom(f[i])<m) )
    170169    {
     
    173172  if( i == 0 )
    174173    {
    175       return ( 0 );         
     174      return ( 0 );
    176175    };
    177176
     
    180179      return ( leadcoef(f[i]) );
    181180    };
    182        
     181
    183182  return ( 0 );
    184183};
     
    194193      V[k] = var(k);
    195194    };
    196        
     195
    197196  return (V);
    198197};
     
    207206
    208207  poly v, d; int i;
    209        
     208
    210209  for ( int k = 2; k <= N; k++ )
    211210    {
    212211      v = V[k];
    213212      for ( i = 1; i < k; i++ )
    214         {
    215           d = V[i];
    216           M[k,i] =  v*d - d*v;  // [var(k),var(i)]
    217           M[i,k] = -M[k,i];     // [var(i),var(k)] ==  -[var(k),var(i)]
    218         };
     213        {
     214          d = V[i];
     215          M[k,i] =  v*d - d*v;        // [var(k),var(i)]
     216          M[i,k] = -M[k,i];        // [var(i),var(k)] ==  -[var(k),var(i)]
     217        };
    219218    };
    220219
     
    233232  int i, j; poly a; poly d;
    234233
    235   int N         = nvars( basering );
    236   list V        = my_vars();
     234  int N         = nvars( basering );
     235  list V        = my_vars();
    237236  matrix M = my_commutators();
    238237
     
    240239
    241240  int cartan;
    242        
     241
    243242  list RESULT = list();
    244243  int  r_begin = 1;
    245244  int  r_end   = N;
    246        
     245
    247246
    248247  for ( int k = 1; k <= N; k++ )
     
    251250      cartan = 1;
    252251      for ( i = 1; i <= N; i++ )
    253         {
    254           d = M[k,i];
    255           for ( j = 1; j <= N; j++ )
    256             {
    257               a = myCoeff( d, V[j] );   
    258               A[i,j] =  a;
    259 
    260               if( (i!=j) and (a!=0) )
    261                 {
    262                   cartan = 0;
    263                 };                                     
    264             };
    265         };
     252        {
     253          d = M[k,i];
     254          for ( j = 1; j <= N; j++ )
     255            {
     256              a = myCoeff( d, V[j] );
     257              A[i,j] =  a;
     258
     259              if( (i!=j) and (a!=0) )
     260                {
     261                  cartan = 0;
     262                };
     263            };
     264        };
    266265
    267266      if ( cartan )
    268         {       
    269           RESULT[r_begin] = list( V[k], cartan, A );
    270           r_begin++;
    271         } else
    272           {
    273             RESULT[r_end] = list( V[k], cartan, A );
    274             r_end--;           
    275           };
    276                                
    277     };
    278        
     267        {
     268          RESULT[r_begin] = list( V[k], cartan, A );
     269          r_begin++;
     270        } else
     271          {
     272            RESULT[r_end] = list( V[k], cartan, A );
     273            r_end--;
     274          };
     275
     276    };
     277
    279278  return (RESULT);
    280279
     
    291290      kill ( @@@SORTEDVARARRAY );
    292291    };
    293  
     292
    294293  list @@@SORTEDVARARRAY;
    295294  list V = my_associated();
    296  
     295
    297296  // cartans - first then others...
    298  
     297
    299298  for ( int i = 1; i<= size(V); i++ )
    300299    {
    301300      @@@SORTEDVARARRAY[i] = V[i][1];
    302301    };
    303  
     302
    304303  Print( "@@@SORTEDVARARRAY: " + string(@@@SORTEDVARARRAY) );
    305    
    306   export(@@@SORTEDVARARRAY);   
     304
     305  export(@@@SORTEDVARARRAY);
    307306};
    308307
     
    321320  Print( "Error: my_var_init() was not called before this..." );
    322321  return( var(@number) );
    323    
     322
    324323};
    325324
     
    346345"
    347346{
    348   string s = "";       
    349        
     347  string s = "";
     348
    350349  while ( param != 0 )
    351350    {
    352351      s = string ( param % 2 ) + s;
    353352      param = param / 2;
    354       n --;     
     353      n --;
    355354    };
    356355  while ( n > 0 )
     
    375374      // setup redSB, redTail options
    376375      export(@@@MY_QIDEAL);
    377      
     376
    378377      option(redSB);
    379378      option(redTail);
    380      
     379
    381380    };
    382381};
     
    397396    {
    398397      /*
    399         int param = 1 ; // by def: reduce both 1st and 2nd entries
    400         param = myValue(param, #);
    401         string bits = myBitParam( param, 8 );
     398        int param = 1 ; // by def: reduce both 1st and 2nd entries
     399        param = myValue(param, #);
     400        string bits = myBitParam( param, 8 );
    402401      */
    403402      BCall( "QNF_poly", p );
    404      
     403
    405404      p = NF( p, @@@MY_QIDEAL );
    406      
     405
    407406      ECall( "QNF_poly", p );
    408407    }; // QRing
     
    423422+2    7 => reduce every 2nd entry
    424423
    425         --- (for PBW in qrings) ---
     424        --- (for PBW in qrings) ---
    426425
    427426+4    6 => kill out pbw entries where pbw monom (1) was affected
     
    429428//?? wofuer?
    430429+8    5 => reduce every 3rd entry
    431    
     430
    432431"
    433432{
     
    437436
    438437      int param = 1 + 2; // by def: reduce both 1st and 2nd entries
    439       param = myValue(param, #); 
    440        
     438      param = myValue(param, #);
     439
    441440      string bits = myBitParam( param, 8 );
    442441
     
    444443
    445444      poly temp;
    446        
     445
    447446      for ( int i = size(l); i>0 ; i -- )
    448         {
    449 
    450           if ( typeof( l[i] ) == "poly" )
    451             {
    452 
    453               if ( (bits[8] == "1") or (bits[6] == "1") )
    454                 {
    455                   temp = NF( l[i], @@@MY_QIDEAL );
    456                            
    457                   if ( bits[6] == "1" )
    458                     {// for PBW in qrings: kill out pbw entries where pbw monom was reduced
    459                            
    460                       if( temp != l[i] )
    461                         {
    462                           l = delete( l, i );
    463                           i --;
    464                           continue;
    465                         };
    466                     };
    467                            
    468                   if ( bits[8] == "1" )
    469                     {
    470                       l[i] = temp;
    471                     };
    472                 };
    473             };
    474 
    475           if ( typeof( l[i] ) == "list" )
    476             {   
    477               // 1st
    478              
    479               if ( size(l[i])>0 )
    480                 {               
    481                   if ( (bits[8] == "1") or (bits[6] == "1") )
    482                     {
    483                       if( typeof( l[i][1] ) == "poly" )
    484                         {
    485                            
    486                           temp = NF( l[i][1], @@@MY_QIDEAL );
    487                            
    488                           if ( bits[6] == "1" )
    489                             {// for PBW in qrings: kill out pbw entries where pbw monom was reduced
    490                                
    491                               if( temp != l[i][1] )
    492                                 {
    493                                   l = delete( l, i );
    494                                   i --;
    495                                   continue;
    496                                 };
    497                             };
    498                            
    499                           if ( bits[8] == "1" )
    500                             {
    501                               l[i][1] = temp;
    502                             };
    503                            
    504                         };
    505                     };
    506                 };
    507              
    508               // 2nd
    509                
    510               if ( size(l[i])>1 )
    511                 {               
    512                   if ( bits[7] == "1" )
    513                     {
    514                       if( typeof( l[i][2] ) == "poly" )
    515                         {
    516                           temp = NF( l[i][2], @@@MY_QIDEAL );
    517                          
    518                           l[i][2] = temp;
    519                         };
    520                     };
    521                 };
    522             };
    523         };
    524        
     447        {
     448
     449          if ( typeof( l[i] ) == "poly" )
     450            {
     451
     452              if ( (bits[8] == "1") or (bits[6] == "1") )
     453                {
     454                  temp = NF( l[i], @@@MY_QIDEAL );
     455
     456                  if ( bits[6] == "1" )
     457                    {// for PBW in qrings: kill out pbw entries where pbw monom was reduced
     458
     459                      if( temp != l[i] )
     460                        {
     461                          l = delete( l, i );
     462                          i --;
     463                          continue;
     464                        };
     465                    };
     466
     467                  if ( bits[8] == "1" )
     468                    {
     469                      l[i] = temp;
     470                    };
     471                };
     472            };
     473
     474          if ( typeof( l[i] ) == "list" )
     475            {
     476              // 1st
     477
     478              if ( size(l[i])>0 )
     479                {
     480                  if ( (bits[8] == "1") or (bits[6] == "1") )
     481                    {
     482                      if( typeof( l[i][1] ) == "poly" )
     483                        {
     484
     485                          temp = NF( l[i][1], @@@MY_QIDEAL );
     486
     487                          if ( bits[6] == "1" )
     488                            {// for PBW in qrings: kill out pbw entries where pbw monom was reduced
     489
     490                              if( temp != l[i][1] )
     491                                {
     492                                  l = delete( l, i );
     493                                  i --;
     494                                  continue;
     495                                };
     496                            };
     497
     498                          if ( bits[8] == "1" )
     499                            {
     500                              l[i][1] = temp;
     501                            };
     502
     503                        };
     504                    };
     505                };
     506
     507              // 2nd
     508
     509              if ( size(l[i])>1 )
     510                {
     511                  if ( bits[7] == "1" )
     512                    {
     513                      if( typeof( l[i][2] ) == "poly" )
     514                        {
     515                          temp = NF( l[i][2], @@@MY_QIDEAL );
     516
     517                          l[i][2] = temp;
     518                        };
     519                    };
     520                };
     521            };
     522        };
     523
    525524      ECall( "QNF_list", "list" );
    526        
     525
    527526    }; // Qring
    528    
     527
    529528  return ( l );
    530529};
     
    545544static proc uni_poly( poly p )
    546545  "
    547         returns polynomial with the same monomials but without coefficients.
    548 "
    549 {
    550   poly @tt = poly(0);   
     546        returns polynomial with the same monomials but without coefficients.
     547"
     548{
     549  poly @tt = poly(0);
    551550  for ( int @k = size(p); @k > 0; @k -- )
    552551    {
    553552      @tt = @tt + leadmonom(p[@k]);
    554     };   
    555   return (@tt); 
     553    };
     554  return (@tt);
    556555};
    557556
     
    560559{
    561560  int @n = size( @t );
    562  
     561
    563562  if ( @n == 0 )
    564563    {
    565564      return (@def);
    566565    };
    567    
     566
    568567  number @max = leadcoef(@t[1]);
    569568  number @mm;
    570  
    571   if ( @n > 1) 
     569
     570  if ( @n > 1)
    572571    {
    573572      for ( int @i = 2; @i <= @n ;@i ++ )
    574         {
    575           @mm = leadcoef ( @t[@i] );
    576           if ( @mm < 0 )
    577             {
    578               @mm = -@mm;
    579             };
    580          
    581           if( @mm > @max )
    582             {
    583               @max = @mm;
    584             };
    585         };
    586     };
    587  
     573        {
     574          @mm = leadcoef ( @t[@i] );
     575          if ( @mm < 0 )
     576            {
     577              @mm = -@mm;
     578            };
     579
     580          if( @mm > @max )
     581            {
     582              @max = @mm;
     583            };
     584        };
     585    };
     586
    588587  @max = @max + 1;
    589   if ( @max == 0 ) 
     588  if ( @max == 0 )
    590589    {
    591590      @max = @max + 1;
     
    599598{
    600599  int @l, @k;
    601  
     600
    602601  poly @t, @tt;
    603602
    604603  @l = size (@given);
    605  
     604
    606605  @t = poly(0);
    607606  for ( @k = @l; @k > 0; @k -- )
    608607    {
    609608      if (@num == 1)
    610         {
    611           @tt = @given[@k];
    612         } else
    613           {
    614             @tt = @given[@k][2];       
    615           };
    616      
     609        {
     610          @tt = @given[@k];
     611        } else
     612          {
     613            @tt = @given[@k][2];
     614          };
     615
    617616      @t = @t + uni_poly( @tt );
    618617    };
    619  
     618
    620619  return ( uni_poly(@t) );
    621620};
     
    626625static proc LM ( intvec exp )
    627626  "
    628         input : given exponent
    629         return: monom with this exponent...
     627        input : given exponent
     628        return: monom with this exponent...
    630629"
    631630{
     
    635634      @deg = exp[@i];
    636635      if ( @deg > 0 )
    637         {
    638           @f = @f * (var(@i)^(@deg));
    639         };
     636        {
     637          @f = @f * (var(@i)^(@deg));
     638        };
    640639    };
    641640
     
    651650static proc zSort ( list @z )
    652651  "
    653         Sort elements of a list of polynoms,
    654         and normalize
     652        Sort elements of a list of polynoms,
     653        and normalize
    655654"
    656655{
     
    664663    {
    665664      if ( @z[1] == 0 ) // if zero => empty list
    666         {
    667           return(list());
    668         };         
     665        {
     666          return(list());
     667        };
    669668
    670669      @z[1] =  @z[1] * ( 1/leadcoef(@z[1]) ) ;
     
    674673
    675674  int i = 1;
    676        
     675
    677676  while ( i<=n )
    678677    {
    679       if (size( @z[i] ) != 0) 
    680         {
    681           break;
    682         };
     678      if (size( @z[i] ) != 0)
     679        {
     680          break;
     681        };
    683682      i++;
    684683    };
    685        
     684
    686685  if ( i > n )
    687686    { // all zeroes
    688687      return(list());
    689688    };
    690        
     689
    691690  ideal id = @z[i];
    692691  i++;
    693        
     692
    694693  while ( i<= n )
    695694    {
    696695      if( @z[i] != 0 )
    697         {
    698           id=@z[i],id;
    699         };
     696        {
     697          id=@z[i],id;
     698        };
    700699      i++;
    701700    };
     
    711710      p = srt[1][i];
    712711      if ( p == 0 )
    713         {
    714           i --;
    715           continue;
    716         };
    717       p = p* (1/leadcoef(p));           // normalize
     712        {
     713          i --;
     714          continue;
     715        };
     716      p = p* (1/leadcoef(p));                // normalize
    718717      result = list(p) + result;
    719718    };
    720719
    721   //    "OUT SORT::";
    722   //    result;
    723        
     720  //        "OUT SORT::";
     721  //        result;
     722
    724723  return ( result );
    725724};
     
    730729static proc zRefine ( list @z )
    731730  "
    732         kill terms by leading monomials...
    733         Note: based on myCoeff 
     731        kill terms by leading monomials...
     732        Note: based on myCoeff
    734733"
    735734{
     
    746745  int flag = 1;
    747746
    748   while ( flag == 1 ) 
     747  while ( flag == 1 )
    749748    {
    750749      flag = 0;
     
    752751      @z = zSort(@z); // sort out, < ...
    753752
    754       if( size(@z) < 2 ) 
    755         {
    756           return (@z);
    757         };
     753      if( size(@z) < 2 )
     754        {
     755          return (@z);
     756        };
    758757
    759758      for ( @i = size(@z); @i > 0; @i -- ) // at 1st the biggest ... then smallest...
    760         {
    761 
    762           @ff    = @z[@i];
    763 
    764           if( size(@ff) == 0 )
    765             {
    766               @z = delete ( @z , @i );
    767               @i --;
    768               continue;
    769             };
    770 
    771           @ff    = @ff*(1/leadcoef(@ff));
    772           @z[@i] = @ff;
    773           @f    = leadmonom(@ff);
    774 
    775           for ( @j = (@i-1); (@j>0); @j --  )
    776             {
    777               @gg = @z[@j];
    778               @ng = myCoeff(@gg, @f); // leads?
    779               if( @ng!=0 )
    780                 {
    781                   @z[@j] = @gg - @ng * @ff;
    782                   flag = 1;
    783                 };             
    784             };
    785           for ( @j = (@i+1); (@j<=size(@z)); @j ++ )
    786             {
    787               @gg = @z[@j];
    788               @ng = myCoeff(@gg, @f);
    789               if( @ng!=0 )
    790                 {
    791                   @z[@j] = @gg - @ng * @ff;
    792                   flag = 1;
    793                 };             
    794             };
    795 
    796         };
     759        {
     760
     761          @ff    = @z[@i];
     762
     763          if( size(@ff) == 0 )
     764            {
     765              @z = delete ( @z , @i );
     766              @i --;
     767              continue;
     768            };
     769
     770          @ff    = @ff*(1/leadcoef(@ff));
     771          @z[@i] = @ff;
     772          @f         = leadmonom(@ff);
     773
     774          for ( @j = (@i-1); (@j>0); @j --  )
     775            {
     776              @gg = @z[@j];
     777              @ng = myCoeff(@gg, @f); // leads?
     778              if( @ng!=0 )
     779                {
     780                  @z[@j] = @gg - @ng * @ff;
     781                  flag = 1;
     782                };
     783            };
     784          for ( @j = (@i+1); (@j<=size(@z)); @j ++ )
     785            {
     786              @gg = @z[@j];
     787              @ng = myCoeff(@gg, @f);
     788              if( @ng!=0 )
     789                {
     790                  @z[@j] = @gg - @ng * @ff;
     791                  flag = 1;
     792                };
     793            };
     794
     795        };
    797796    };
    798797
    799798  ECall("zRefine", "list");
    800799
    801   return        ( @z );
    802 
    803 };
    804 
    805 
    806 /******************************************************/
    807 // procedures for building "bad leadmonomials" set 
     800  return         ( @z );
     801
     802};
     803
     804
     805/******************************************************/
     806// procedures for building "bad leadmonomials" set
    808807
    809808
     
    811810static proc checkPolyUniq( list l, poly p )
    812811  "
    813         check whether p sits already in l, assume l to be size-sorted <
    814         return: -1 if present
    815                 1 if we need to add
     812        check whether p sits already in l, assume l to be size-sorted <
     813        return: -1 if present
     814                1 if we need to add
    816815"
    817816{
     
    821820
    822821  int s = size(p);
    823        
     822
    824823  while( i<= n )
    825     { 
     824    {
    826825      if ( size(l[i]) >= s )
    827         {
    828           break;
    829         };
    830            
    831       i ++; 
     826        {
     827          break;
     828        };
     829
     830      i ++;
    832831    };
    833832
    834833  // now: size(l[i]) >= s
    835834  while( i<= n )
    836     { 
     835    {
    837836      if ( size(l[i]) == s )
    838         {
    839           break;
    840                
    841         };
    842       if ( l[i] == p ) 
    843         {
    844           ECall( "checkPolyUniq", -1 );
    845           return (-1);
    846         };
    847       i ++; 
     837        {
     838          break;
     839
     840        };
     841      if ( l[i] == p )
     842        {
     843          ECall( "checkPolyUniq", -1 );
     844          return (-1);
     845        };
     846      i ++;
    848847    };
    849848
     
    856855static proc addPolyUniq( list l, poly p )
    857856  "
    858         add p into l uniquely, and keep l size-sorted <
     857        add p into l uniquely, and keep l size-sorted <
    859858"
    860859{
    861860  BCall( "addPolyUniq", " { " + string(l) + " }, " + string(p) );
    862        
     861
    863862  int n = size(l);
    864863
     
    866865    {
    867866      l = list(p);
    868                
     867
    869868      ECall( "addPolyUniq", l );
    870                
     869
    871870      return (l);
    872871    };
    873872
    874873  int s = size(p);
    875        
     874
    876875  int i = 1;
    877876  while( i<= n )
    878877    {
    879878      if( size(l[i]) > s )
    880         {
    881           l = insert( l, p, i-1 ) ;
    882           break;
    883         };
    884                
     879        {
     880          l = insert( l, p, i-1 ) ;
     881          break;
     882        };
     883
    885884      if( size(l[i]) == s )
    886         {
    887           if ( l[i] == p )
    888             {
    889               break;
    890             };
    891         };
    892                
     885        {
     886          if ( l[i] == p )
     887            {
     888              break;
     889            };
     890        };
     891
    893892      i++;
    894893    };
    895        
     894
    896895  if( i > n )
    897896    {
    898897      l = l + list(p);
    899898    };
    900        
     899
    901900  ECall( "addPolyUniq", l );
    902901  return(l);
     
    907906static proc mergePolysUniq( list a, list b )
    908907  "
    909         merge lists uniq
     908        merge lists uniq
    910909"
    911910{
    912911  BCall( "mergePolysUniq", "{ " + string(a) + " }, { " + string(b) + "} " );
    913        
     912
    914913  for( int i = 1; i <= size(b); i ++ )
    915914    {
    916915      a = addPolyUniq(a, b[i]);
    917916    };
    918        
     917
    919918  ECall( "mergePolysUniq", a );
    920        
     919
    921920  return (a);
    922921};
     
    926925static proc sortPolysUniq( list a )
    927926  "
    928         sort list uniq
     927        sort list uniq
    929928"
    930929{
    931930  BCall( "sortPolysUniq", a );
    932        
     931
    933932  if( size(a) < 2 )
    934933    {
     
    936935      return(a);
    937936    };
    938        
     937
    939938  list b = list(a[1]);
    940        
     939
    941940  for( int i = 2; i <= size(a); i ++ )
    942941    {
    943942      b = addPolyUniq(b, a[i]);
    944943    };
    945        
     944
    946945  ECall( "sortPolysUniq", b );
    947        
     946
    948947  return (b);
    949948};
    950949
    951950/******************************************************/
    952 static proc addRecordUniq ( list leadD, list newD, intvec texp, poly tm, int kind, list prs ) 
    953   "
    954         if kind = 0 => for PBW - no products
    955         if kind = 1 => with products
     951static proc addRecordUniq ( list leadD, list newD, intvec texp, poly tm, int kind, list prs )
     952  "
     953        if kind = 0 => for PBW - no products
     954        if kind = 1 => with products
    956955"
    957956{
     
    962961
    963962  prs = sortPolysUniq(prs);
    964        
     963
    965964  // trick:
    966965  //  check for presens of a monomial @tm in current index poly of @leads (=> in list @leads)
    967966  //  if char = 0 then new_size > (if not present) or =  (if already present)
    968   //  if char > 0 then new_size > (if not present) or =< (if already present) 
     967  //  if char > 0 then new_size > (if not present) or =< (if already present)
    969968  // !!!!!
    970   if( size(tm + leadD[2]) > size(leadD[2]) ) 
     969  if( size(tm + leadD[2]) > size(leadD[2]) )
    971970    {
    972971      f_add = 1;
    973972    } else
    974973      {
    975         if ( kind != 0 )
    976           {
    977             for ( i = 1; i<= size(leadD[1]); i++ )
    978               {
    979                 if ( leadD[1][i][2] == tm )
    980                   {
    981                     for ( i = size(prs); i>0; i-- )
    982                       {
    983                         f_add = checkPolyUniq( leadD[1][i][3], prs[i] );
    984                         if( f_add == -1 )
    985                           {
    986                             prs = delete(prs, i);
    987                           };
    988                       };
    989 
    990                     break;
    991                   };
    992               };                       
    993           };
     974        if ( kind != 0 )
     975          {
     976            for ( i = 1; i<= size(leadD[1]); i++ )
     977              {
     978                if ( leadD[1][i][2] == tm )
     979                  {
     980                    for ( i = size(prs); i>0; i-- )
     981                      {
     982                        f_add = checkPolyUniq( leadD[1][i][3], prs[i] );
     983                        if( f_add == -1 )
     984                          {
     985                            prs = delete(prs, i);
     986                          };
     987                      };
     988
     989                    break;
     990                  };
     991              };
     992          };
    994993      };
    995994
     
    999998      list newlist ;
    1000999      if ( kind != 0 )
    1001         {
    1002           newlist =  list ( list ( texp, tm, prs ) );
    1003         } else
    1004           {
    1005             newlist =  list ( list ( texp, tm ) );
    1006           };
     1000        {
     1001          newlist =  list ( list ( texp, tm, prs ) );
     1002        } else
     1003          {
     1004            newlist =  list ( list ( texp, tm ) );
     1005          };
    10071006
    10081007
    10091008      if ( size(newD[1]) == 0 )
    1010         {
    1011           newD[1] =  newlist;
    1012           newD[2] =  tm;
    1013         } else
    1014           {
    1015 
    1016             if( size(tm + newD[2]) > size(newD[2]) )
    1017               {
    1018                 newD[1] = newD[1] + newlist;
    1019                 newD[2] = newD[2] + tm;
    1020               } else
    1021                 {
    1022                   if ( kind != 0 )
    1023                     {
    1024                       for ( i = 1; i<= size(newD[1]); i++ )
    1025                         {
    1026                           if ( newD[1][i][2] == tm )
    1027                             {
    1028                               newD[1][i][3] = mergePolysUniq( newD[1][i][3], prs );
    1029                               break;
    1030                             };
    1031                         };
    1032                     };
    1033                 };
    1034           };
     1009        {
     1010          newD[1] =  newlist;
     1011          newD[2] =  tm;
     1012        } else
     1013          {
     1014
     1015            if( size(tm + newD[2]) > size(newD[2]) )
     1016              {
     1017                newD[1] = newD[1] + newlist;
     1018                newD[2] = newD[2] + tm;
     1019              } else
     1020                {
     1021                  if ( kind != 0 )
     1022                    {
     1023                      for ( i = 1; i<= size(newD[1]); i++ )
     1024                        {
     1025                          if ( newD[1][i][2] == tm )
     1026                            {
     1027                              newD[1][i][3] = mergePolysUniq( newD[1][i][3], prs );
     1028                              break;
     1029                            };
     1030                        };
     1031                    };
     1032                };
     1033          };
    10351034    };
    10361035
     
    10441043{
    10451044  BCall ("mergeRecordsUniq", "{old leads}, {new leads}, " + string(kind) );
    1046        
     1045
    10471046  if(  size(new[1]) > 0 )
    10481047    {
    10491048      if ( size (old[1]) == 0 )
    1050         {
    1051           old = new;
    1052         } else
    1053           {
    1054             if ( kind != 0 )
    1055               {
    1056                 int io;
    1057                 for ( int in = 1; in <= size( new[1] ); in ++ )
    1058                   {
    1059                     if( size( new[1][in][2] + old[2] ) > size( old[2] ) )
    1060                       {
    1061                         old[1] = old[1] + list(new[1][in]);
    1062                         old[2] = old[2] + new[1][in][2];
    1063                       } else
    1064                         {
    1065                           for( io = 1; io <= size( old[1] ); io ++ )
    1066                             {
    1067                               if( old[1][io][2] == new[1][in][2] )
    1068                                 {
    1069                                   old[1][io][3] = mergePolysUniq( old[1][io][3], new[1][in][3] );
    1070                                   break;
    1071                                 };
    1072                             };                                         
    1073                         };
    1074                   };
    1075               } else
    1076                 {
    1077                   old[1] = old[1] + new[1];
    1078                   old[2] = old[2] + new[2];
    1079                 };
    1080           };
     1049        {
     1050          old = new;
     1051        } else
     1052          {
     1053            if ( kind != 0 )
     1054              {
     1055                int io;
     1056                for ( int in = 1; in <= size( new[1] ); in ++ )
     1057                  {
     1058                    if( size( new[1][in][2] + old[2] ) > size( old[2] ) )
     1059                      {
     1060                        old[1] = old[1] + list(new[1][in]);
     1061                        old[2] = old[2] + new[1][in][2];
     1062                      } else
     1063                        {
     1064                          for( io = 1; io <= size( old[1] ); io ++ )
     1065                            {
     1066                              if( old[1][io][2] == new[1][in][2] )
     1067                                {
     1068                                  old[1][io][3] = mergePolysUniq( old[1][io][3], new[1][in][3] );
     1069                                  break;
     1070                                };
     1071                            };
     1072                        };
     1073                  };
     1074              } else
     1075                {
     1076                  old[1] = old[1] + new[1];
     1077                  old[2] = old[2] + new[2];
     1078                };
     1079          };
    10811080    };
    10821081
     
    10961095  for( int @i = 0; @i <= @deg; @i ++ )
    10971096    {
    1098       @l[index(@i)]     = list( list() , 0);
    1099       // new items: 
    1100       // { 
    1101       //        list of leads,    - empty list
    1102       //        sum poly "index", - poly(0)
     1097      @l[index(@i)]         = list( list() , 0);
     1098      // new items:
     1099      // {
     1100      //        list of leads,    - empty list
     1101      //        sum poly "index", - poly(0)
    11031102      // }
    11041103    };
     
    11091108static proc zAddBad ( list @leads, list @newz, int @maxDeg, int kind )
    11101109  "
    1111         input:
    1112                 @leads: graded by deg list of
    1113                         rec:
    1114                         {
    1115                                 [1] - list of
    1116                                         rec:
    1117                                         {
    1118                                                 [1] - leadexp.
    1119                                                 [2] - leadmonom([1])
    1120                                         if kind != 0 (for zReduce) =>
    1121                                                 [3] - !list! of all possible products which give this leadexp
    1122                                         },
    1123                                 [2] - summ of all in [1] ('index' poly)
    1124                         }
    1125                 @newz: new elements for adding to @leads
    1126                 @maxDeg: maximal degree
    1127        
    1128                 if kind != 0 => keeps also list of all possible products which give leadexp of a record
    1129 
    1130         return:
    1131                 updated @leads list
     1110        input:
     1111                @leads: graded by deg list of
     1112                        rec:
     1113                        {
     1114                                [1] - list of
     1115                                        rec:
     1116                                        {
     1117                                                [1] - leadexp.
     1118                                                [2] - leadmonom([1])
     1119                                        if kind != 0 (for zReduce) =>
     1120                                                [3] - !list! of all possible products which give this leadexp
     1121                                        },
     1122                                [2] - summ of all in [1] ('index' poly)
     1123                        }
     1124                @newz: new elements for adding to @leads
     1125                @maxDeg: maximal degree
     1126
     1127                if kind != 0 => keeps also list of all possible products which give leadexp of a record
     1128
     1129        return:
     1130                updated @leads list
    11321131
    11331132"
     
    11361135
    11371136  int @newSize = size(@newz);
    1138   if ( @newSize < 1 ) 
     1137  if ( @newSize < 1 )
    11391138    {
    11401139      return (@leads);
     
    11441143
    11451144
    1146   poly  @m, @tm, @ttm;
     1145  poly         @m, @tm, @ttm;
    11471146  intvec @exp, @texp, @ttexp;
    11481147
     
    11511150
    11521151  poly @sum_old, @sum_new;
    1153        
     1152
    11541153  poly a, b, @temp;
    11551154
     
    11621161
    11631162  for ( @i = @newSize; @i > 0; @i -- )
    1164     {// for every new poly (@newz[@i]) do 
    1165 
    1166       @m   = leadmonom( @newz[@i] ); 
     1163    {// for every new poly (@newz[@i]) do
     1164
     1165      @m   = leadmonom( @newz[@i] );
    11671166      @deg = deg(@m);
    11681167      @exp = leadexp(@m);
     
    11721171
    11731172      for( @mydeg = @deg; @mydeg <= @maxDeg;  @mydeg = @mydeg + @deg )
    1174         {// adding all possiblities for @newz[@i]^@j;
    1175 
    1176           if ( @mydeg > @deg )
    1177             {
    1178               @texp     = @texp + @exp;
    1179               @tm       = LM ( @texp );
    1180               if ( kind != 0)
    1181                 {
    1182                   pr = QNF_poly( pr * @newz[@i] ); // degrees must be there!!!
    1183                 };
    1184             } else
    1185               {
    1186                 @texp   = @exp;
    1187                 @tm     = @m;
    1188                 if ( kind != 0)
    1189                   {
    1190                     pr = @newz[@i];
    1191                   };
    1192               };
    1193 
    1194           @temp =  QNF_poly(@tm);
    1195           if( @temp != @tm )
    1196             {
    1197               break;
    1198             };
    1199 
    1200           /*!!*/                        @newzz[index(@mydeg)] =
    1201                                           /*!!*/        addRecordUniq( @leads[index(@mydeg)], @newzz[index(@mydeg)], @texp, @tm, kind, list(pr) );
    1202 
    1203           for ( @dd = 1; (@dd <= @maxDeg) and ((@dd + @mydeg) <= @maxDeg ); @dd ++ )
    1204             { // for every good "deg"
    1205                                
    1206               @newdeg = @dd + @mydeg; // any deg should be additive!!!
    1207                                
    1208               for ( @k = size(@leads[index(@dd)][1]); @k > 0; @k -- )
    1209                 {
    1210 
    1211                   @ttexp        = (@leads[index(@dd)][1][@k][1]) + @texp;
    1212                   @ttm  = LM (@ttexp);
    1213                                        
    1214                   if ( kind != 0 )
    1215                     {
    1216                       prs = list();
    1217 
    1218                       for( pri = 1; pri <= size(@leads[index(@dd)][1][@k][3]); pri++)
    1219                         {
    1220                           // to do products into list and add one list !!!
    1221                           a = QNF_poly( pr*@leads[index(@dd)][1][@k][3][pri]);
    1222                           b = QNF_poly( @leads[index(@dd)][1][@k][3][pri]*pr);
    1223 
    1224                           prs= prs + list(a);
    1225 
    1226                           if ( a!=b )
    1227                             {
    1228                               prs= prs + list(b);
    1229                             };
    1230                         };
    1231 
    1232                     } else
    1233                       {
    1234                         prs = list(pr);
    1235                       };
    1236 
    1237                   @temp =  QNF_poly(@ttm);
    1238                   if( @temp == @ttm )
    1239                     {
    1240 
    1241                       /*!!*/                                            @newzz[index(@newdeg)] =
    1242                                                                           /*!!*/        addRecordUniq( @leads[index(@newdeg)], @newzz[index(@newdeg)], @ttexp, @ttm, kind, prs );
    1243                     };
    1244 
    1245 
    1246                 };                             
    1247             }; // for
    1248 
    1249           if ( @deg == 0 )
    1250             {
    1251               break;
    1252             };
    1253         };
     1173        {// adding all possiblities for @newz[@i]^@j;
     1174
     1175          if ( @mydeg > @deg )
     1176            {
     1177              @texp         = @texp + @exp;
     1178              @tm         = LM ( @texp );
     1179              if ( kind != 0)
     1180                {
     1181                  pr = QNF_poly( pr * @newz[@i] ); // degrees must be there!!!
     1182                };
     1183            } else
     1184              {
     1185                @texp         = @exp;
     1186                @tm         = @m;
     1187                if ( kind != 0)
     1188                  {
     1189                    pr = @newz[@i];
     1190                  };
     1191              };
     1192
     1193          @temp =  QNF_poly(@tm);
     1194          if( @temp != @tm )
     1195            {
     1196              break;
     1197            };
     1198
     1199          /*!!*/                        @newzz[index(@mydeg)] =
     1200                                          /*!!*/        addRecordUniq( @leads[index(@mydeg)], @newzz[index(@mydeg)], @texp, @tm, kind, list(pr) );
     1201
     1202          for ( @dd = 1; (@dd <= @maxDeg) and ((@dd + @mydeg) <= @maxDeg ); @dd ++ )
     1203            { // for every good "deg"
     1204
     1205              @newdeg = @dd + @mydeg; // any deg should be additive!!!
     1206
     1207              for ( @k = size(@leads[index(@dd)][1]); @k > 0; @k -- )
     1208                {
     1209
     1210                  @ttexp         = (@leads[index(@dd)][1][@k][1]) + @texp;
     1211                  @ttm         = LM (@ttexp);
     1212
     1213                  if ( kind != 0 )
     1214                    {
     1215                      prs = list();
     1216
     1217                      for( pri = 1; pri <= size(@leads[index(@dd)][1][@k][3]); pri++)
     1218                        {
     1219                          // to do products into list and add one list !!!
     1220                          a = QNF_poly( pr*@leads[index(@dd)][1][@k][3][pri]);
     1221                          b = QNF_poly( @leads[index(@dd)][1][@k][3][pri]*pr);
     1222
     1223                          prs= prs + list(a);
     1224
     1225                          if ( a!=b )
     1226                            {
     1227                              prs= prs + list(b);
     1228                            };
     1229                        };
     1230
     1231                    } else
     1232                      {
     1233                        prs = list(pr);
     1234                      };
     1235
     1236                  @temp =  QNF_poly(@ttm);
     1237                  if( @temp == @ttm )
     1238                    {
     1239
     1240                      /*!!*/                                                @newzz[index(@newdeg)] =
     1241                                                                          /*!!*/        addRecordUniq( @leads[index(@newdeg)], @newzz[index(@newdeg)], @ttexp, @ttm, kind, prs );
     1242                    };
     1243
     1244
     1245                };
     1246            }; // for
     1247
     1248          if ( @deg == 0 )
     1249            {
     1250              break;
     1251            };
     1252        };
    12541253
    12551254      for ( @mydeg = 0; @mydeg <= @maxDeg; @mydeg ++ )
    1256         { // adding currently generated to result
    1257           @leads[index(@mydeg)] = mergeRecordsUniq ( @leads[index(@mydeg)], @newzz[index(@mydeg)], kind );
    1258         };
     1255        { // adding currently generated to result
     1256          @leads[index(@mydeg)] = mergeRecordsUniq ( @leads[index(@mydeg)], @newzz[index(@mydeg)], kind );
     1257        };
    12591258
    12601259    };
     
    12721271static proc zReducePoly ( list leads, poly new, poly anfang )
    12731272  "
    1274         reduce poly new wrt found leads,
    1275         return: list of all possible reductions...
     1273        reduce poly new wrt found leads,
     1274        return: list of all possible reductions...
    12761275"
    12771276{
     
    12841283  list LEADS;
    12851284
    1286   int i, n; 
     1285  int i, n;
    12871286  list prs;
    12881287
     
    12951294
    12961295      if( size(LEADS[2] + lm ) <=  size(LEADS[2]) )
    1297         { // need to reduce, since leacmonom already in LEADS
    1298                    
    1299           for ( i = 1; i <= size(LEADS[1]); i++ )
    1300             {
    1301               if( LEADS[1][i][2] == lm )
    1302                 {
    1303                                
    1304                   lc = leadcoef( temp ); // no need be the unit
    1305 
    1306                   prs = LEADS[1][i][3]; // shouldbe generated by zAddBad with kind == 1
    1307                   n = size(prs) ;
    1308 
    1309                   if ( n == 1 )
    1310                     { // no recursion
    1311 
    1312                       temp = leadcoef(prs[1]) * temp - lc * prs[1]; // leadmonom goes down
    1313 
    1314                     } else
    1315                       { // do recursion
    1316 
    1317                         list result = list();
    1318                         poly newnew;
    1319                         int f_addrest = 0;
    1320                                                
    1321                         for( int pri = 1; pri <= n ; pri ++ )
    1322                           {     
    1323                             newnew = leadcoef(prs[pri]) * temp - lc * prs[pri]; // leadmonom goes down
    1324                                                        
    1325                             if( size( newnew ) > 0 )
    1326                               {
    1327                                 result = result + zReducePoly(leads, newnew, rest);
    1328                               } else
    1329                                 {
    1330                                   f_addrest = 1;
    1331                                 };
    1332                           };
    1333 
    1334                         if ( f_addrest == 1 )
    1335                           {
    1336                             result = result + list(rest);
    1337                           };
    1338                         return ( result );
    1339 
    1340                       };
    1341                   break;
    1342                 };
    1343             };
    1344 
    1345         } else
    1346           { // no such leadmonom in leads
    1347        
    1348             rest = rest + lead ( temp );
    1349             temp = temp - lead ( temp ); // leadcoeff goes down
    1350           };
     1296        { // need to reduce, since leacmonom already in LEADS
     1297
     1298          for ( i = 1; i <= size(LEADS[1]); i++ )
     1299            {
     1300              if( LEADS[1][i][2] == lm )
     1301                {
     1302
     1303                  lc = leadcoef( temp ); // no need be the unit
     1304
     1305                  prs = LEADS[1][i][3]; // shouldbe generated by zAddBad with kind == 1
     1306                  n = size(prs) ;
     1307
     1308                  if ( n == 1 )
     1309                    { // no recursion
     1310
     1311                      temp = leadcoef(prs[1]) * temp - lc * prs[1]; // leadmonom goes down
     1312
     1313                    } else
     1314                      { // do recursion
     1315
     1316                        list result = list();
     1317                        poly newnew;
     1318                        int f_addrest = 0;
     1319
     1320                        for( int pri = 1; pri <= n ; pri ++ )
     1321                          {
     1322                            newnew = leadcoef(prs[pri]) * temp - lc * prs[pri]; // leadmonom goes down
     1323
     1324                            if( size( newnew ) > 0 )
     1325                              {
     1326                                result = result + zReducePoly(leads, newnew, rest);
     1327                              } else
     1328                                {
     1329                                  f_addrest = 1;
     1330                                };
     1331                          };
     1332
     1333                        if ( f_addrest == 1 )
     1334                          {
     1335                            result = result + list(rest);
     1336                          };
     1337                        return ( result );
     1338
     1339                      };
     1340                  break;
     1341                };
     1342            };
     1343
     1344        } else
     1345          { // no such leadmonom in leads
     1346
     1347            rest = rest + lead ( temp );
     1348            temp = temp - lead ( temp ); // leadcoeff goes down
     1349          };
    13511350    };
    13521351
     
    13591358static proc zCancel ( list @tt, list @leads )
    13601359  "
    1361         just kill entries of plane PBW base with leading monomials in @leads...
     1360        just kill entries of plane PBW base with leading monomials in @leads...
    13621361"
    13631362{
     
    13721371  poly g, f;
    13731372
    1374   for ( @i = size(@tt); @i > 0 ; @i -- ) 
     1373  for ( @i = size(@tt); @i > 0 ; @i -- )
    13751374    // for all PBW entries:
    13761375    {
     
    13791378
    13801379      if ( size(f + g) > size(f) ) // if g not in @leads (works only for monomials)
    1381         {
    1382           result = list( @tt[@i] ) + result;
    1383         };
     1380        {
     1381          result = list( @tt[@i] ) + result;
     1382        };
    13841383    };
    13851384
     
    13941393static proc zReduce( list @z )
    13951394  "
    1396         reduce a set @z - base of Center as V.S.
    1397         into a minimal set!!
     1395        reduce a set @z - base of Center as V.S.
     1396        into a minimal set!!
    13981397"
    13991398{
    14001399  BCall( "zReduce", @z );
    1401        
     1400
    14021401  @z = zRefine ( @z );
    14031402  int n = size( @z );
     
    14081407    };
    14091408
    1410   int d = maxDeg( @z ); 
     1409  int d = maxDeg( @z );
    14111410
    14121411  if( d== -1 )
     
    14241423
    14251424  poly p;
    1426        
     1425
    14271426  for ( int i = 1; i <= n ; i++ )
    14281427    {// in this order... from least to maximal...
     
    14331432
    14341433      f_add = 1;
    1435                
     1434
    14361435      for( j = 1; j <= size(@red); j++ )
    1437         {
    1438           if ( @red[j] == 0 )
    1439             {
    1440               f_add = 0;
    1441               break; // nothing new....
    1442             };
    1443         };
    1444      
     1436        {
     1437          if ( @red[j] == 0 )
     1438            {
     1439              f_add = 0;
     1440              break; // nothing new....
     1441            };
     1442        };
     1443
    14451444      @red = zRefine( @red ); // there will be no zeroes after ???
    14461445
    14471446      if( size(@red) > 0 )
    1448         {                   
    1449           leads = zAddBad( leads, @red, d, 1);
    1450         };
    1451      
     1447        {
     1448          leads = zAddBad( leads, @red, d, 1);
     1449        };
     1450
    14521451      if ( f_add == 1 )
    1453         {
    1454           // we got something new....
    1455           result = result + list(@red); // ??? which one to add? => trying to add all
    1456         };
    1457     };
    1458        
     1452        {
     1453          // we got something new....
     1454          result = result + list(@red); // ??? which one to add? => trying to add all
     1455        };
     1456    };
     1457
    14591458  ECall( "zReduce", result );
    1460        
     1459
    14611460  return (result);
    14621461};
     
    14761475PBW[ index(0) ] = PBW part of degree 0:
    14771476record:
    1478         [1] : 1         // var(0) ;-)   
    1479         [2] : 0
    1480         [3] : 1
     1477        [1] : 1                // var(0) ;-)
     1478        [2] : 0
     1479        [3] : 1
    14811480"
    14821481{
    14831482  BCall( "PBW_init" );
    1484   return (list(list(1, 0, 1))); 
     1483  return (list(list(1, 0, 1)));
    14851484};
    14861485
     
    14891488static proc PBW_sys(list VARS, poly p)
    14901489  "
    1491         calculate the array [1..NVARS] of records:
    1492 record[i] = 
    1493                 [1] = var(i)            // i^{th} variable
    1494                 [2] = p*[1]-[1]*p       // [ p, var(i) ]
    1495                 [3] = deg(var(i))       // i^{th} variable's deg
    1496        
    1497         ?? need debug ??
     1490        calculate the array [1..NVARS] of records:
     1491record[i] =
     1492                [1] = var(i)                 // i^{th} variable
     1493                [2] = p*[1]-[1]*p         // [ p, var(i) ]
     1494                [3] = deg(var(i))         // i^{th} variable's deg
     1495
     1496        ?? need debug ??
    14981497"
    14991498{
     
    15011500  BCall( "PBW_sys" );
    15021501
    1503   poly t; 
     1502  poly t;
    15041503  for (int v = size(VARS); v>0; v -- )
    15051504    {
    1506       t         = VARS[v];
     1505      t            = VARS[v];
    15071506      VARS[v] = list( t, QNF_poly( p*t - t*p ), deg(t) ) ;
    15081507    };
    1509                
     1508
    15101509  return (VARS);
    15111510};
     
    15141513static proc PBW_done( list PBW )
    15151514  "
    1516         collects all together, from graded lists into plane list.       
    1517        
    1518         Note: also the last vars...
     1515        collects all together, from graded lists into plane list.
     1516
     1517        Note: also the last vars...
    15191518"
    15201519{
     
    15411540  list result = list(); // PBW[ index(k) ] ought to be empty ??
    15421541  int N = size(sys);
    1543        
     1542
    15441543  for ( int i = 1; i <= N; i ++ ) // for all vars
    15451544    {
    15461545      kk = (k - sys[i][3]);   // any deg should be additive function wrt multiplication
    15471546      if ( kk >= 0 )
    1548         {
    1549           nn = size( PBW[ index(kk) ] );
    1550           for ( ii = 1; ii <= nn; ii ++ )
    1551             {
    1552               temp = PBW[ index(kk) ][ii];
    1553 
    1554               if ( temp[3] <= i )
    1555                 {
    1556                   temp[2] = temp[2]*sys[i][1] + temp[1]*sys[i][2]; // recursive [,]
    1557                   temp[1] = temp[1]*sys[i][1];
    1558                   temp[3] = i;
    1559                                        
    1560                   result = result + list ( temp );
    1561                 };
    1562             };
    1563         };
     1547        {
     1548          nn = size( PBW[ index(kk) ] );
     1549          for ( ii = 1; ii <= nn; ii ++ )
     1550            {
     1551              temp = PBW[ index(kk) ][ii];
     1552
     1553              if ( temp[3] <= i )
     1554                {
     1555                  temp[2] = temp[2]*sys[i][1] + temp[1]*sys[i][2]; // recursive [,]
     1556                  temp[1] = temp[1]*sys[i][1];
     1557                  temp[3] = i;
     1558
     1559                  result = result + list ( temp );
     1560                };
     1561            };
     1562        };
    15641563    };
    15651564
     
    15671566  ECall( "PBW_next", "list result" );
    15681567  return (result);
    1569        
     1568
    15701569};
    15711570
     
    15791578
    15801579  PBW[index(0)] = PBW_init();
    1581        
     1580
    15821581  for (int k = 1; k <= MaxDeg; k ++ )
    1583     {           
     1582    {
    15841583      PBW[index(k)] = PBW_next( PBW, k, SYS );
    15851584    };
    15861585
    15871586  return (PBW_done( PBW ));
    1588 }; 
     1587};
    15891588
    15901589
     
    15931592
    15941593/******************************************************/
    1595 static proc FSS (list @given, poly @BASE_POLY) 
     1594static proc FSS (list @given, poly @BASE_POLY)
    15961595"
    15971596    Gauss with computation of kernel v.s basis
     
    16031602  list @nums = list ();
    16041603  intvec @ones;
    1605   int @j, @k, 
     1604  int @j, @k,
    16061605    @n, @v,
    16071606    @a, @nn;
    1608    
     1607
    16091608  @n = size( @BASE_POLY );
    16101609  @v = size( @given );
    1611    
     1610
    16121611  if ( (@v == 0) or (@n == 0) )
    1613     {   
     1612    {
    16141613      return (@given);
    16151614    };
     
    16371636      @w = leadexp(@BASE_POLY[@a]);
    16381637      for( @k = @v; @k > 0; @k -- )
    1639         {
    1640           if( @w == LM[@k][1] )
    1641             {
    1642               @t = LM[@k][2];
    1643               MD[@a, @k] = leadcoef( @t );
    1644               @t = @t - lead ( @t );
    1645               LM[@k][2]  = @t;
    1646 
    1647               LM[@k][1]  = leadexp(@t);
    1648             };
    1649         };
     1638        {
     1639          if( @w == LM[@k][1] )
     1640            {
     1641              @t = LM[@k][2];
     1642              MD[@a, @k] = leadcoef( @t );
     1643              @t = @t - lead ( @t );
     1644              LM[@k][2]  = @t;
     1645
     1646              LM[@k][1]  = leadexp(@t);
     1647            };
     1648        };
    16501649
    16511650    };
     
    16561655  number @div;
    16571656  //    @nums = list();
    1658    
     1657
    16591658  // Gauss
    16601659//  print("Before Gauss, Matrix: ");
    16611660//  print( MD );
    16621661
    1663    
     1662
    16641663  @x = 1;
    16651664  @y = 1;
     
    16681667    {
    16691668      @min =  leadcoef( MD[@y, @x] ); // curr diag.
    1670        
    1671       if ( @min == 0 ) 
    1672         // if zero on diag...
    1673         {
    1674           @j = 0;
    1675                
    1676           // let's find the minimal
    1677           for ( @k = @y+1; @k <= @n; @k ++ )
    1678             {
    1679               @max = leadcoef( MD[ @k, @x ] );
    1680               if ( @max != 0 )
    1681                 {
    1682                   @j = @k;                     
    1683                   @min = @max;
    1684                   //                @k ++;
    1685                   break; // this pure for
    1686                   // continue;
    1687                   // for find min
    1688                 };
    1689             }; // for (@k) // found minimal
    1690                
    1691           if ( @j == 0 )
    1692             {       
    1693               // das ist gut! //               
    1694               @nums = @nums + list ( list ( @x, @y ) );
    1695               @x ++;
    1696               continue; // while
    1697             } ;
    1698            
    1699           for ( @k = @x ; @k <= @v ; @k ++ )
    1700             {
    1701               @t =  MD[ @j, @k ];
    1702               MD[ @j, @k ] = MD[ @y, @k ];
    1703               MD[ @y, @k ] = @t;
    1704             };
    1705                
    1706         }; // if diag === zero.
     1669
     1670      if ( @min == 0 )
     1671        // if zero on diag...
     1672        {
     1673          @j = 0;
     1674
     1675          // let's find the minimal
     1676          for ( @k = @y+1; @k <= @n; @k ++ )
     1677            {
     1678              @max = leadcoef( MD[ @k, @x ] );
     1679              if ( @max != 0 )
     1680                {
     1681                  @j = @k;
     1682                  @min = @max;
     1683                  //                    @k ++;
     1684                  break; // this pure for
     1685                  // continue;
     1686                  // for find min
     1687                };
     1688            }; // for (@k) // found minimal
     1689
     1690          if ( @j == 0 )
     1691            {
     1692              // das ist gut! //
     1693              @nums = @nums + list ( list ( @x, @y ) );
     1694              @x ++;
     1695              continue; // while
     1696            } ;
     1697
     1698          for ( @k = @x ; @k <= @v ; @k ++ )
     1699            {
     1700              @t =  MD[ @j, @k ];
     1701              MD[ @j, @k ] = MD[ @y, @k ];
     1702              MD[ @y, @k ] = @t;
     1703            };
     1704
     1705        }; // if diag === zero.
    17071706      @ones[@y] = @x;
    1708            
    1709       if ( @min == 0 ) 
    1710         {
    1711           //        write_latex_str ( " ******************* ERROR ******************* " );
    1712           quit;
    1713         };
    1714            
    1715            
     1707
     1708      if ( @min == 0 )
     1709        {
     1710          //            write_latex_str ( " ******************* ERROR ******************* " );
     1711          quit;
     1712        };
     1713
     1714
    17161715      if ( @min != 1) // let's norm the row... to make the '1' !
    1717         {
    1718           @min = 1 / @min;
    1719           for ( @k = @x; @k <= @v; @k++ )
    1720             {
    1721               @max = leadcoef( MD[@y, @k] );
    1722                    
    1723               if ( @max == 0)
    1724                 {
    1725                   @k ++ ;
    1726                   continue; // for : norming the row...
    1727                 };
    1728                    
    1729               MD[@y, @k] = @max * @min;  // here must be Field ...
    1730             };
    1731                
    1732           //        @min = 1;
    1733                
    1734         };
    1735            
     1716        {
     1717          @min = 1 / @min;
     1718          for ( @k = @x; @k <= @v; @k++ )
     1719            {
     1720              @max = leadcoef( MD[@y, @k] );
     1721
     1722              if ( @max == 0)
     1723                {
     1724                  @k ++ ;
     1725                  continue; // for : norming the row...
     1726                };
     1727
     1728              MD[@y, @k] = @max * @min;  // here must be Field ...
     1729            };
     1730
     1731          //            @min = 1;
     1732
     1733        };
     1734
    17361735      // here must be @min != 0;
    17371736      for ( @k = 1; @k <= @n; @k++ )
    1738         {
    1739           @max = leadcoef( MD[@k, @x] );
    1740                
    1741           if ( ( @k == @y) || (@max == 0) )
    1742             {
    1743               @k ++ ;
    1744               continue;
    1745             };
    1746                
    1747           for ( @j = @x; @j <= @v ; @j ++ )
    1748             {
    1749               MD[ @k, @j ] = MD[ @k, @j ] - @max * MD[ @y, @j ];
    1750             };             
    1751          
    1752         }; //killing
    1753            
     1737        {
     1738          @max = leadcoef( MD[@k, @x] );
     1739
     1740          if ( ( @k == @y) || (@max == 0) )
     1741            {
     1742              @k ++ ;
     1743              continue;
     1744            };
     1745
     1746          for ( @j = @x; @j <= @v ; @j ++ )
     1747            {
     1748              MD[ @k, @j ] = MD[ @k, @j ] - @max * MD[ @y, @j ];
     1749            };
     1750
     1751        }; //killing
     1752
    17541753      @x ++;
    17551754      @y ++;
    17561755    }; //main while.
    17571756  /******************************************************/
    1758    
     1757
    17591758//  print("Gaussed Matrix: ");
    17601759//  print( MD );
     
    17621761  // computation of kernel's basis
    17631762
    1764   if ( @x <= @v ) 
     1763  if ( @x <= @v )
    17651764    {
    17661765      for ( @k = @x; @k <= @v ; @k ++ )
    1767         {
    1768           @nums = @nums + list ( list ( @k, @n+1 ) );   
    1769         }
     1766        {
     1767          @nums = @nums + list ( list ( @k, @n+1 ) );
     1768        }
    17701769    }
    1771    
     1770
    17721771//  print("Nums: " );
    17731772//  print (@nums);
    1774    
     1773
    17751774  list result = list();
    1776    
     1775
    17771776  // real calculations of the Base of a Ker as V.S.
    17781777
    17791778  for ( @k = 1; @k <= size(@nums) ; @k ++ )
    17801779    {
    1781       @x = @nums[@k][1]; 
    1782       @j  = @nums[@k][2]; 
    1783            
     1780      @x = @nums[@k][1];
     1781      @j  = @nums[@k][2];
     1782
    17841783      @t = @given[@x][1];
    1785            
     1784
    17861785      for ( @y = 1; @y < @j ; @y ++ )
    1787         // for every "@x" column
    1788         {
    1789           @max = leadcoef( MD[@y, @x] );
    1790           if ( (@max != 0) )
    1791             {
    1792               @a = @ones[@y];
    1793               @t = @t - @max * @given[@a][1];
    1794             };
    1795         };
    1796      
     1786        // for every "@x" column
     1787        {
     1788          @max = leadcoef( MD[@y, @x] );
     1789          if ( (@max != 0) )
     1790            {
     1791              @a = @ones[@y];
     1792              @t = @t - @max * @given[@a][1];
     1793            };
     1794        };
     1795
    17971796      result[@k] = @t;
    17981797    };
     
    18061805{
    18071806  BCall( "reduce_one_per_row" );
    1808        
     1807
    18091808  int @k;
    18101809  int @l = size (@given);
    1811        
     1810
    18121811  if( @l == 0 )
    18131812    {
    18141813      return (@given);
    18151814    };
    1816        
     1815
    18171816  int @char = char(basering);
    1818        
     1817
    18191818  intvec @marks;
    18201819
     
    18261825  list @unis = list ();
    18271826  poly p;
    1828        
     1827
    18291828  for ( @k = @l; @k > 0; @k -- )
    18301829    {
     
    18331832
    18341833      if( p == 0 )
    1835         {
    1836           @marks[@k] = 2;
    1837         } else
    1838           {
    1839             @marks[@k] = 1;
    1840             if ( @char == 0 )
    1841               {
    1842                 @t = @t + p;
    1843               };
    1844           };
    1845     };
    1846        
     1834        {
     1835          @marks[@k] = 2;
     1836        } else
     1837          {
     1838            @marks[@k] = 1;
     1839            if ( @char == 0 )
     1840              {
     1841                @t = @t + p;
     1842              };
     1843          };
     1844    };
     1845
    18471846  if ( @char != 0 )
    18481847    {
     
    18501849      execute( "ring NewRingWithGoodField = (0), (" + varstr(save) + "), (" + ordstr(save) + "); ");
    18511850      poly @t = 0;
    1852                
     1851
    18531852      if(! defined (@unis) )
    1854         {
    1855           list @unis = imap( save, @unis );
    1856         };
    1857                
     1853        {
     1854          list @unis = imap( save, @unis );
     1855        };
     1856
    18581857      for ( @k = @l; @k > 0; @k -- )
    1859         {
    1860           if( @marks[@k] == 1 )
    1861             {
    1862               @t = @t + @unis[@k];
    1863             };
    1864         };
    1865     };
    1866                
     1858        {
     1859          if( @marks[@k] == 1 )
     1860            {
     1861              @t = @t + @unis[@k];
     1862            };
     1863        };
     1864    };
     1865
    18671866  int @loop_size = size(@t);
    18681867  poly @for_delete, @tt;
    18691868  int @ll;
    1870        
     1869
    18711870  while( @loop_size > 0 )
    18721871    {
    18731872      @for_delete = poly(0);
    1874       @ll = size(@t);   
    1875                
     1873      @ll = size(@t);
     1874
    18761875      for ( @k = @ll; @k > 0; @k -- )
    1877         {
    1878           if ( leadcoef(@t[@k]) == 1 )
    1879             {
    1880               @for_delete = @for_delete + @t[@k];
    1881             };
    1882         };
     1876        {
     1877          if ( leadcoef(@t[@k]) == 1 )
     1878            {
     1879              @for_delete = @for_delete + @t[@k];
     1880            };
     1881        };
    18831882
    18841883      @loop_size = size( @for_delete );
    18851884
    18861885      if ( @loop_size>0 )
    1887         {
    1888           for( @k = @l ; @k > 0 ; @k -- )
    1889             {       
    1890               if ( @marks[@k] == 1)
    1891                 {
    1892                   @tt = @unis[@k];
    1893 
    1894                   if( size( @for_delete + @tt ) != ( size( @for_delete )  + size( @tt ) ) )
    1895                     {
    1896                       @t = @t - @tt;
    1897                       @marks[@k] = 0;
    1898                     };
    1899                 };
    1900             };         
    1901         };             
    1902     };
    1903        
     1886        {
     1887          for( @k = @l ; @k > 0 ; @k -- )
     1888            {
     1889              if ( @marks[@k] == 1)
     1890                {
     1891                  @tt = @unis[@k];
     1892
     1893                  if( size( @for_delete + @tt ) != ( size( @for_delete )  + size( @tt ) ) )
     1894                    {
     1895                      @t = @t - @tt;
     1896                      @marks[@k] = 0;
     1897                    };
     1898                };
     1899            };
     1900        };
     1901    };
     1902
    19041903  if ( @char != 0 )
    19051904    {
     
    19091908
    19101909  list @reduced = list();
    1911        
     1910
    19121911  for ( @k = @l ; @k>0 ; @k --)
    19131912    {
    19141913      if (@marks[@k]==2)
    1915         {
    1916           @reduced = list ( @given[@k] ) + @reduced ;
    1917         } else
    1918           {
    1919             if (@marks[@k]==1)
    1920               {
    1921                 @reduced = @reduced + list ( @given[@k] );
    1922               };
    1923           };
    1924     };
    1925    
     1914        {
     1915          @reduced = list ( @given[@k] ) + @reduced ;
     1916        } else
     1917          {
     1918            if (@marks[@k]==1)
     1919              {
     1920                @reduced = @reduced + list ( @given[@k] );
     1921              };
     1922          };
     1923    };
     1924
    19261925  ECall( "reduce_one_per_row", "structured list" );
    19271926  return (@reduced);
     
    19541953      @tt = @AD_GIVEN[@number][2];
    19551954      if ( size (@tt) == 0)
    1956         {
    1957           @AD_CALC = @AD_CALC + list ( @AD_GIVEN[@number][1] );
    1958         } else
    1959           {
    1960             @t = uni_poly( @tt );
    1961             @t_size = size(@t);
    1962        
    1963             @GR_TEMP = list ();
    1964             @GR_TEMP[1] = @t;
    1965             @GR_TEMP[2] = list ( @AD_GIVEN[@number] );
    1966 
    1967             @loop_size = size(@GR);
    1968             if ( @loop_size == 0 )
    1969               {
    1970                 @GR = list(@GR_TEMP);
    1971               } else
    1972                 {
    1973                   for ( @k = @loop_size; @k > 0 ; @k -- )
    1974                     {
    1975                       @tt = @GR[@k][1];
    1976                       if ( size( @t + @tt ) != ( @t_size + size(@tt) ) )
    1977                         // whether @tt and @i intersencts? ( will not work in char == 2 !!!)
    1978                         {
    1979 
    1980                           if ( char(basering) == 0 )
    1981                             {
    1982                               @GR_TEMP[1] = @GR_TEMP[1] + @tt;
    1983                             } else
    1984                               {
    1985                                 @GR_TEMP[1] = uni_poly( @GR_TEMP[1] + @tt );
    1986                               };
    1987                        
    1988                           @GR_TEMP[2] = @GR_TEMP[2] + @GR[@k][2];
    1989                           @GR = delete ( @GR, @k );
    1990                         };
    1991                     };
    1992                   @GR = @GR + list(@GR_TEMP);
    1993                 };
    1994           };
     1955        {
     1956          @AD_CALC = @AD_CALC + list ( @AD_GIVEN[@number][1] );
     1957        } else
     1958          {
     1959            @t = uni_poly( @tt );
     1960            @t_size = size(@t);
     1961
     1962            @GR_TEMP = list ();
     1963            @GR_TEMP[1] = @t;
     1964            @GR_TEMP[2] = list ( @AD_GIVEN[@number] );
     1965
     1966            @loop_size = size(@GR);
     1967            if ( @loop_size == 0 )
     1968              {
     1969                @GR = list(@GR_TEMP);
     1970              } else
     1971                {
     1972                  for ( @k = @loop_size; @k > 0 ; @k -- )
     1973                    {
     1974                      @tt = @GR[@k][1];
     1975                      if ( size( @t + @tt ) != ( @t_size + size(@tt) ) )
     1976                        // whether @tt and @i intersencts? ( will not work in char == 2 !!!)
     1977                        {
     1978
     1979                          if ( char(basering) == 0 )
     1980                            {
     1981                              @GR_TEMP[1] = @GR_TEMP[1] + @tt;
     1982                            } else
     1983                              {
     1984                                @GR_TEMP[1] = uni_poly( @GR_TEMP[1] + @tt );
     1985                              };
     1986
     1987                          @GR_TEMP[2] = @GR_TEMP[2] + @GR[@k][2];
     1988                          @GR = delete ( @GR, @k );
     1989                        };
     1990                    };
     1991                  @GR = @GR + list(@GR_TEMP);
     1992                };
     1993          };
    19951994      @number --;
    19961995    }; //  main while
    1997    
     1996
    19981997  list @res;
    19991998
     
    20012000    {
    20022001      if ( size (@GR[@k][2]) > 1 ) // ! zeroes in AD_CALC so here must be non zero
    2003         {
    2004           @res = FSS ( @GR[@k][2], uni_poly(@GR[@k][1]));
    2005          
    2006           if ( size (@res) > 0 )
    2007             {
    2008               @AD_CALC = @AD_CALC + @res;
    2009             };
    2010         };
    2011     };   
     2002        {
     2003          @res = FSS ( @GR[@k][2], uni_poly(@GR[@k][1]));
     2004
     2005          if ( size (@res) > 0 )
     2006            {
     2007              @AD_CALC = @AD_CALC + @res;
     2008            };
     2009        };
     2010    };
    20122011
    20132012  ECall( "calc_base" );
     
    20312030
    20322031  poly f, t;
    2033  
    2034   if ( typeof(#[1]) == "int") 
     2032
     2033  if ( typeof(#[1]) == "int")
    20352034    {
    20362035      int next = #[1];
     
    20382037    } else
    20392038      {
    2040         if ( typeof(#[1]) == "poly")
    2041           {
    2042             f = #[1];
    2043           } else
    2044             {
    2045               print("Error: cannot differentiate with '" + string(#)+"'");
    2046               return ();
    2047             };
     2039        if ( typeof(#[1]) == "poly")
     2040          {
     2041            f = #[1];
     2042          } else
     2043            {
     2044              print("Error: cannot differentiate with '" + string(#)+"'");
     2045              return ();
     2046            };
    20482047      };
    20492048
     
    20692068  list t = reduce_one_per_row( l, 0); // optimization (a1)
    20702069  return( QNF_list ( ApplyAd( calc_base(t), # ), 2) );          // calculation of groupps (a2) + gauss.
    2071    
     2070
    20722071};
    20732072
     
    20772076static proc makeIdeal ( list l )
    20782077  "
    2079         return: ideal: where the generators are polynomials from list, without 1 and zeroes
     2078        return: ideal: where the generators are polynomials from list, without 1 and zeroes
    20802079"
    20812080{
     
    20852084    {
    20862085      if ( typeof( l[i] ) == "list" )
    2087         {
    2088           p = l[i][1]; // just take the 1st polynom...
    2089         } else
    2090           {
    2091             p = l[i];
    2092           };
    2093                
     2086        {
     2087          p = l[i][1]; // just take the 1st polynom...
     2088        } else
     2089          {
     2090            p = l[i];
     2091          };
     2092
    20942093      p = cleardenom( p* (1/content(p)) );
    20952094      if ( (p != 1) and (p != 0) )
    2096         {
    2097           I = I, p;
    2098         };
    2099     };
    2100        
     2095        {
     2096          I = I, p;
     2097        };
     2098    };
     2099
    21012100  I = simplify ( I, 2 ); // no zeroes
    2102        
     2101
    21032102  return(I);
    21042103};
     
    21162115      t = var(k);
    21172116      if ( QNF_poly(t * p - p * t) != 0 )
    2118         {
    2119           if( toprint() )
    2120             {
    2121               "POLY: ", string (p), " is NOT in center";
    2122             };
    2123           return (0);
    2124         };
    2125     };
    2126 
    2127   if( toprint() ) 
     2117        {
     2118          if( toprint() )
     2119            {
     2120              "POLY: ", string (p), " is NOT in center";
     2121            };
     2122          return (0);
     2123        };
     2124    };
     2125
     2126  if( toprint() )
    21282127    {
    21292128      "POLY: ", string (p), " is in center";
     
    21372136  for ( int @i = 1; @i <= size(l); @i++ )
    21382137    {
    2139       if ( typeof(l[@i])=="poly" ) 
    2140         {
    2141           if (! inCenter_poly(l[@i]) )
    2142             {
    2143               return(0);
    2144             };
    2145                
    2146         } else
    2147           {
    2148             if ( (typeof(l[@i])=="list") or (typeof(l[@i])=="ideal") )
    2149               {
    2150                 if (! inCenter_list(l[@i]) )
    2151                   {
    2152                     return(0);
    2153                   };
    2154               };
    2155           };
     2138      if ( typeof(l[@i])=="poly" )
     2139        {
     2140          if (! inCenter_poly(l[@i]) )
     2141            {
     2142              return(0);
     2143            };
     2144
     2145        } else
     2146          {
     2147            if ( (typeof(l[@i])=="list") or (typeof(l[@i])=="ideal") )
     2148              {
     2149                if (! inCenter_list(l[@i]) )
     2150                  {
     2151                    return(0);
     2152                  };
     2153              };
     2154          };
    21562155    };
    21572156  return(1);
     
    21662165{
    21672166  if ( QNF_poly(f * p - p * f) != 0 )
    2168     {     
    2169       if( toprint() ) 
    2170         {
    2171           "POLY: ", string (p), " is NOT in centralizer(f)";
    2172         };
     2167    {
     2168      if( toprint() )
     2169        {
     2170          "POLY: ", string (p), " is NOT in centralizer(f)";
     2171        };
    21732172      return (0);
    21742173    };
    2175        
    2176   if( toprint() ) 
     2174
     2175  if( toprint() )
    21772176    {
    21782177      "POLY: ", string (p), " is in centralizer(f)";
     
    21862185  for ( int @i = 1; @i <= size(l); @i++ )
    21872186    {
    2188       if ( typeof(l[@i])=="poly" ) 
    2189         {
    2190           if (! inCentralizer_poly(l[@i], f) )
    2191             {
    2192               return(0);
    2193             };
    2194                
    2195         } else
    2196           {
    2197             if ( (typeof(l[@i])=="list") or (typeof(l[@i])=="ideal") )
    2198               {
    2199                 if (! inCentralizer_list(l[@i], f) )
    2200                   {
    2201                     return(0);
    2202                   };
    2203               };
    2204           };
     2187      if ( typeof(l[@i])=="poly" )
     2188        {
     2189          if (! inCentralizer_poly(l[@i], f) )
     2190            {
     2191              return(0);
     2192            };
     2193
     2194        } else
     2195          {
     2196            if ( (typeof(l[@i])=="list") or (typeof(l[@i])=="ideal") )
     2197              {
     2198                if (! inCentralizer_list(l[@i], f) )
     2199                  {
     2200                    return(0);
     2201                  };
     2202              };
     2203          };
    22052204    };
    22062205  return(1);
     
    22202219/* static */ proc center_min_iterative( int MaxDeg, list # )
    22212220  "
    2222         computes the 'minimal' set of central elements (of deg <= MaxDeg) in iterative way
    2223         Note: based on calc_k_base, zAddBad, zRefine, zCancel, PBW_*
     2221        computes the 'minimal' set of central elements (of deg <= MaxDeg) in iterative way
     2222        Note: based on calc_k_base, zAddBad, zRefine, zCancel, PBW_*
    22242223"
    22252224{
    22262225  BCall("center_min_iterative", MaxDeg, #);
    2227        
     2226
    22282227  int n = myInt(#);
    22292228  int m = ( MaxDeg < 0 ); // no bound on Degree
    2230        
     2229
    22312230  int MinDeg = 6; // starting guess for MaxDeg
    22322231  int Delta  = 4; // increment of MaxDeg
    2233        
     2232
    22342233  if( m )
    2235     {   
     2234    {
    22362235      // minimal guess
    2237       MaxDeg = MinDeg;         
    2238     };
    2239        
     2236      MaxDeg = MinDeg;
     2237    };
     2238
    22402239  list @q; int @i; int N = nvars(basering);
    22412240
     
    22502249  list SYS = PBW_sys( my_vars(), my_var(1) );
    22512250
    2252        
    2253   list @z = list ();                                    // center list
    2254   list @l = init_bads( MaxDeg );        // verbotten leadexps...
    2255        
     2251
     2252  list @z = list ();                                         // center list
     2253  list @l = init_bads( MaxDeg );         // verbotten leadexps...
     2254
    22562255  @q = PBW[ index(0) ];
    22572256
     
    22602259    {
    22612260      for ( @i = 2; @i <= N; @i ++ )
    2262         {
    2263           @q = calc_k_base (@q, my_var(@i));
    2264         };
     2261        {
     2262          @q = calc_k_base (@q, my_var(@i));
     2263        };
    22652264
    22662265      @q = zRefine (calc_k_base(@q)); // new center!
    22672266
    22682267
    2269       if ( size(@q) > 0 ) 
    2270         {
    2271           @z = @z + @q; // computed central elements
    2272                        
    2273           if( (n > 0) and (size(@z) > n) )
    2274             {
    2275               break; // found all central elements                     
    2276             };
    2277         };
     2268      if ( size(@q) > 0 )
     2269        {
     2270          @z = @z + @q; // computed central elements
     2271
     2272          if( (n > 0) and (size(@z) > n) )
     2273            {
     2274              break; // found all central elements
     2275            };
     2276        };
    22782277
    22792278      if( k == ( MaxDeg+1 ) )
    2280         {
    2281           if( (n == 0) and ( !m ) )
    2282             {
    2283               break; // that's all
    2284             };
    2285                        
    2286           MaxDeg = MaxDeg + Delta;
    2287                        
    2288           // renew bad list
    2289           @l = init_bads( MaxDeg );                     
    2290           @l = zAddBad( @l, @z, MaxDeg, 0 );
    2291                        
    2292         } else
    2293           {
    2294                
    2295             if ( size(@q) > 0 )
    2296               {
    2297                 @l = zAddBad( @l, @q, MaxDeg, 0 ); // add all possible 'leadexps' !
    2298               };
    2299                        
    2300           };
     2279        {
     2280          if( (n == 0) and ( !m ) )
     2281            {
     2282              break; // that's all
     2283            };
     2284
     2285          MaxDeg = MaxDeg + Delta;
     2286
     2287          // renew bad list
     2288          @l = init_bads( MaxDeg );
     2289          @l = zAddBad( @l, @z, MaxDeg, 0 );
     2290
     2291        } else
     2292          {
     2293
     2294            if ( size(@q) > 0 )
     2295              {
     2296                @l = zAddBad( @l, @q, MaxDeg, 0 ); // add all possible 'leadexps' !
     2297              };
     2298
     2299          };
    23012300
    23022301      PBW[index(k)] = PBW_next( PBW, k, SYS );
     
    23182317static proc center_vectorspace( int MaxDeg )
    23192318  "
    2320         pure calculation of center as a finitely dimensional Vector Space (deg <= MaxDeg )
     2319        pure calculation of center as a finitely dimensional Vector Space (deg <= MaxDeg )
    23212320"
    23222321{
    23232322  my_var_init();
    2324        
     2323
    23252324  int  N = nvars( basering );
    2326   list P = PBW_base( MaxDeg, my_var(1) ); 
    2327        
     2325  list P = PBW_base( MaxDeg, my_var(1) );
     2326
    23282327  for( int v = 2; v <= N; v++ )
    23292328    {
     
    23322331
    23332332  my_var_done();
    2334        
     2333
    23352334  return( calc_k_base ( P ) );
    23362335};
     
    23392338/* static */ proc center_min_vectorspace( int MaxDeg )
    23402339  "
    2341     computes the 'minimal' set of central elements (of deg <= MaxDeg) 
     2340    computes the 'minimal' set of central elements (of deg <= MaxDeg)
    23422341    by reducing the set of it's generators as vector space
    2343    
     2342
    23442343    Note: based on center_vectorspace.
    23452344    Note: reduction by zReduce.
     
    23812380  computes the 'minimal' set of elements (of deg <= MaxDeg) generating centralizer of p in iterative way
    23822381  Note: based on calc_k_base
    2383  
     2382
    23842383  !!! NEED DEBUG !!!
    23852384  Note: no proof that it is really centralizer and moreover 'minimal' centralizer
     
    23902389  int n = myInt(#);
    23912390  int m = (MaxDeg < 0);
    2392        
     2391
    23932392  int MinDeg = 6; // starting guess for MaxDeg
    23942393  int Delta  = 4; // increment of MaxDeg
    2395        
     2394
    23962395  if( m )
    23972396    {
     
    24112410  list @z  = list ();             // result list
    24122411  list @l  = init_bads( MaxDeg ); // verbotten loeadexps...
    2413        
     2412
    24142413  @q = PBW[ index(0) ];
    24152414
    24162415  for (int k = 1; k <= ( MaxDeg+1 ); k ++ )
    24172416    {
    2418       @q = zRefine( calc_k_base(@q), 1 ); 
    2419 
    2420       if ( size(@q) > 0 ) 
    2421         {
    2422           @z = @z + @q; // computed desired elements
    2423                  
    2424           if( (n > 0) and (size(@z) > n) )
    2425             {
    2426               break; // found needed elements
    2427             };
    2428         };
     2417      @q = zRefine( calc_k_base(@q), 1 );
     2418
     2419      if ( size(@q) > 0 )
     2420        {
     2421          @z = @z + @q; // computed desired elements
     2422
     2423          if( (n > 0) and (size(@z) > n) )
     2424            {
     2425              break; // found needed elements
     2426            };
     2427        };
    24292428
    24302429      if( k == ( MaxDeg+1 ) )
    2431         {
    2432           if( (n == 0) or ( !m ) )
    2433             {
    2434               break; // that's all
    2435             };                 
    2436                  
    2437           MaxDeg = MaxDeg + Delta;
    2438                  
    2439           // renew bad list
    2440           @l = init_bads( MaxDeg );                     
    2441           @l = zAddBad( @l, @z, MaxDeg, 0 );
    2442                  
    2443         } else
    2444           {
    2445                    
    2446             if ( size(@q) > 0 )
    2447               {
    2448                 @l = zAddBad( @l, @q, MaxDeg, 0 ); // add all possible 'leadexps' !
    2449               };
    2450                    
    2451           };
    2452                
     2430        {
     2431          if( (n == 0) or ( !m ) )
     2432            {
     2433              break; // that's all
     2434            };
     2435
     2436          MaxDeg = MaxDeg + Delta;
     2437
     2438          // renew bad list
     2439          @l = init_bads( MaxDeg );
     2440          @l = zAddBad( @l, @z, MaxDeg, 0 );
     2441
     2442        } else
     2443          {
     2444
     2445            if ( size(@q) > 0 )
     2446              {
     2447                @l = zAddBad( @l, @q, MaxDeg, 0 ); // add all possible 'leadexps' !
     2448              };
     2449
     2450          };
     2451
    24532452      PBW[index(k)] = PBW_next( PBW, k, SYS );
    24542453      PBW_PLAIN = PBW_PLAIN + zCancel( PBW[index(k-1)] , @l );
     
    24752474  QNF_init();
    24762475  def res;
    2477        
     2476
    24782477  if ( typeof(a) == "poly" )
    24792478    {
     
    24812480    } else
    24822481      {
    2483         if ( (typeof(a)=="list") or (typeof(a)=="ideal") )
    2484           {
    2485             res = inCenter_list(a);
    2486           } else
    2487             {
    2488               res = a;
    2489             };
     2482        if ( (typeof(a)=="list") or (typeof(a)=="ideal") )
     2483          {
     2484            res = inCenter_list(a);
     2485          } else
     2486            {
     2487              res = a;
     2488            };
    24902489      };
    2491        
     2490
    24922491  QNF_done();
    24932492  return (res);
     
    25132512
    25142513
    2515 /******************************************************************************/ 
     2514/******************************************************************************/
    25162515proc inCentralizer( def a, poly f )
    25172516"USAGE:   inCentralizer(a, f); a poly/list/ideal, f poly
     
    25242523  if ( typeof(a) == "poly" )
    25252524    {
    2526       res = inCentralizer_poly(a, f); 
     2525      res = inCentralizer_poly(a, f);
    25272526    } else
    25282527      {
    2529         if ( (typeof(a)=="list") or (typeof(a)=="ideal") )
    2530           {
    2531             res = inCentralizer_list(a, f);
    2532           } else
    2533             {
    2534               res = a;
    2535             };
     2528        if ( (typeof(a)=="list") or (typeof(a)=="ideal") )
     2529          {
     2530            res = inCentralizer_list(a, f);
     2531          } else
     2532            {
     2533              res = a;
     2534            };
    25362535      };
    25372536
     
    25832582  print( "Error: wrong arguments." );
    25842583  return();
    2585        
     2584
    25862585}
    25872586example
     
    25952594 ideal Z = center(2); // find all central elements of degree <= 2
    25962595 Z;
    2597  inCenter(Z); 
     2596 inCenter(Z);
    25982597 ideal ZZ = center(-1, 1 ); // find the first non trivial central element
    25992598 ZZ; "";
     
    26142613EXAMPLE:    example centralizer; shows an example"
    26152614{
    2616        
     2615
    26172616  if( myInt(#) > 0 )
    26182617    {
    26192618      return( centralizer_min_iterative( p, MaxDeg, # ) );
    26202619    };
    2621        
     2620
    26222621  if( MaxDeg >= 0 )
    26232622    {
     
    26252624      return( centralizer_min_vectorspace( p, MaxDeg ) );
    26262625    };
    2627        
     2626
    26282627  print( "Error: wrong arguments." );
    26292628  return();
     
    26422641 ideal c = centralizer(f, 2); // find all elements of degree <= 2 which lies in centralizer of f
    26432642 c;
    2644  inCentralizer(c, f); 
     2643 inCentralizer(c, f);
    26452644 ideal cc = centralizer(f, -1, 2 ); // find at least first two non trivial elements of the centralizer of f
    26462645 cc;
    2647  inCentralizer(cc, f); 
     2646 inCentralizer(cc, f);
    26482647 poly g = z^2-2*z; // any polynomial
    26492648 g; "";
    26502649 c = centralizer(g, 2); // find all elements of degree <= 2 which lies in centralizer of g
    26512650 c; "";
    2652  inCentralizer(c, g); 
     2651 inCentralizer(c, g);
    26532652 cc = centralizer(g, -1, 2 ); // find at least first two non trivial elements of the centralizer of g
    26542653 cc; "";
    2655  inCentralizer(cc, g); 
    2656 };
     2654 inCentralizer(cc, g);
     2655};
  • Singular/LIB/classify.lib

    re6fb531 r3c4dcc  
    11// KK,GMG last modified: 17.12.00
    22///////////////////////////////////////////////////////////////////////////////
    3 version  = "$Id: classify.lib,v 1.49 2001-08-27 14:47:48 Singular Exp $";
     3version  = "$Id: classify.lib,v 1.50 2005-05-06 14:38:10 hannes Exp $";
    44category="Singularities";
    55info="
     
    16461646        debug_log(6,"Koeffizient von x(" + string(RFlg[i]) + ")^2 ist:", a);
    16471647        if( (a != 0) || (i==n) )
    1648         {
     1648        {
    16491649          debug_log(6, "BREAK!!!!!!!!!!!!!!");
    16501650          break;
     
    16541654        B = maxideal(1);
    16551655        for( k=1; k<=n ; k=k+1)
    1656         {
     1656        {
    16571657          if(k==RFlg[j]) { B[rvar(x(k))] = x(k) + x(RFlg[i]); }
    16581658        }
     
    16721672                      string(P));
    16731673        if(P != 0)
    1674         {
     1674        {
    16751675          debug_log(6, "1 Koeffizient von x("+string(RFlg[i])+") ist: ",
    16761676                       string(P));
     
    16881688          P    = Coeff(fc, x(RFlg[i]), x(RFlg[i]));
    16891689          if( P != 0)
    1690           {
     1690          {
    16911691            fi = fc;
    16921692            continue;
  • Singular/LIB/control.lib

    re6fb531 r3c4dcc  
    1 version="$Id: control.lib,v 1.30 2005-05-06 09:41:58 Singular Exp $";
     1version="$Id: control.lib,v 1.31 2005-05-06 14:38:12 hannes Exp $";
    22category="System and Control Theory";
    33info="
     
    3535";
    3636
    37 LIB "homolog.lib"; 
     37LIB "homolog.lib";
    3838LIB "poly.lib";
    3939LIB "primdec.lib";
     
    7474RETURN:  no return value
    7575PURPOSE:  procedure for (well-) formatted output of modules, matrices, lists of modules, matrices; shows everything even if entries are long
    76 NOTE:  in case of other types( not 'module', 'matrix', 'list') works just as standard 'print' procedure 
     76NOTE:  in case of other types( not 'module', 'matrix', 'list') works just as standard 'print' procedure
    7777EXAMPLE:  example view; shows an example
    7878"{
     
    8888  int max;
    8989  string s;
    90  
     90
    9191  for(i=1;i<=@C;i++)
    92   { 
    93     max=0; 
    94    
     92  {
     93    max=0;
     94
    9595    for(j=1;j<=@R;j++)
    9696    {
     
    103103    MaxLength[i] = max;
    104104  };
    105  
     105
    106106  for(i=1;i<=@R;i++)
    107107  {
     
    111111      s=s+string(M[i,j])+space( MaxLength[j]-size( string( M[i,j] ) ) ) +",";
    112112    };
    113    
     113
    114114    s=s+string(M[i,j])+space( MaxLength[j]-size( string( M[i,j] ) ) );
    115115
     
    121121  };
    122122
    123   return();   
     123  return();
    124124  };
    125  
     125
    126126  if(typeof(M)=="list")
    127127  {
     
    132132      view(M[i]);
    133133      print("");
    134     }; 
     134    };
    135135
    136136    return();
     
    152152RETURN:  module
    153153EXAMPLE: example RightKernel; shows an example
    154 "{ 
     154"{
    155155  return(modulo(M,std(0)));
    156156}
     
    215215}
    216216example
    217 { 
     217{
    218218  "EXAMPLE:";echo =2;
    219219  // a trivial example:
     
    221221  matrix M[2][1] = 1,x2z;
    222222  print(M);
    223   print( LeftInverse(M) ); 
     223  print( LeftInverse(M) );
    224224  kill r;
    225225  // derived from the example TwoPendula:
     
    252252  matrix M[1][2] = 1,x2+z;
    253253  print(M);
    254   print( RightInverse(M) ); 
     254  print( RightInverse(M) );
    255255  kill r;
    256256  // derived from the TwoPendula example:
     
    307307};
    308308//------------------------------------------------------------------------
    309 static proc control_output(int i, int NVars, module R, module Ext_1, list Gen) 
    310 "USAGE:  control_output(i, NVars, R, Ext_1), 
     309static proc control_output(int i, int NVars, module R, module Ext_1, list Gen)
     310"USAGE:  control_output(i, NVars, R, Ext_1),
    311311PURPOSE: where
    312312@*         i is integer (number of first nonzero Ext or a number of variables in a basering + 1 in case that all the Exts are zero),
    313 @*         NVars:  integer, number of variables in a base ring,
    314 @*         R:  module R (cokernel representation),
    315 @*         Ext_1:  module, the first Ext(its cokernel representation)     
     313@*           NVars:  integer, number of variables in a base ring,
     314@*           R:  module R (cokernel representation),
     315@*           Ext_1:  module, the first Ext(its cokernel representation)
    316316RETURN:  list with all the contollability properties of the system which is to be returned in 'control' procedure
    317317NOTE:  this procedure is used in 'control' procedure
     
    323323  string Gen_mes = "Parameter constellations which might lead to a non-controllable system:";
    324324
    325   module RK = RightKernel(R); 
     325  module RK = RightKernel(R);
    326326  int d=dim_Our(std(transpose(R)));
    327327
    328328  if (i==1)
    329   { 
    330     return( 
     329  {
     330    return(
    331331            list ( Fn,
    332                    i,
    333                   "not controllable , image representation for controllable part:",
    334                    RK,     
    335                   "kernel representation for controllable part:",
    336                    LeftKernel( RK ),
    337                   "obstruction to controllability",
    338                    Ext_1,
    339                   "annihilator of torsion module (of obstruction to controllability)",
    340                    Ann_Our(Ext_1),
    341                    DofS,
    342                    d
    343                  )
     332                   i,
     333                  "not controllable , image representation for controllable part:",
     334                    RK,
     335                  "kernel representation for controllable part:",
     336                   LeftKernel( RK ),
     337                  "obstruction to controllability",
     338                   Ext_1,
     339                  "annihilator of torsion module (of obstruction to controllability)",
     340                   Ann_Our(Ext_1),
     341                   DofS,
     342                   d
     343                 )
    344344          );
    345345  };
    346  
     346
    347347  if(i>NVars)
    348   { 
     348  {
    349349    return( list(  Fn,
    350                    -1, 
     350                   -1,
    351351                  "strongly controllable(flat), image representation:",
    352                    RK,
    353                   "left inverse to image representation:",
    354                    LeftInverse(RK),
    355                    DofS,
    356                    d,
    357                    Gen_mes,
    358                    Gen)
     352                   RK,
     353                  "left inverse to image representation:",
     354                   LeftInverse(RK),
     355                   DofS,
     356                   d,
     357                   Gen_mes,
     358                   Gen)
    359359          );
    360360  };
    361  
     361
    362362  //
    363363  //now i<=NVars
    364364  //
    365        
     365
    366366  if( (i==2) )
    367367  {
    368368    return( list( Fn,
    369                   i, 
     369                  i,
    370370                 "controllable, not reflexive, image representation:",
    371                   RK,
     371                  RK,
    372372                  DofS,
    373373                  d,
    374                   Gen_mes,
    375                   Gen)
    376           ); 
     374                  Gen_mes,
     375                  Gen)
     376          );
    377377  };
    378    
     378
    379379  if( (i>=3) )
    380380  {
    381381    return( list ( Fn,
    382                    i, 
     382                   i,
    383383                  "reflexive, not strongly controllable, image representation:",
    384                    RK,
    385                    DofS,
    386                    d,
    387                    Gen_mes,
    388                    Gen)
     384                   RK,
     385                   DofS,
     386                   d,
     387                      Gen_mes,
     388                   Gen)
    389389          );
    390   }; 
    391 }; 
     390  };
     391};
    392392//-------------------------------------------------------------------------
    393393
     
    400400{
    401401  int i;
    402   int NVars=nvars(basering); 
     402  int NVars=nvars(basering);
    403403  // TODO: NVars to be replaced with the global hom. dimension of basering!!!
    404404  int ExtIsZero;
     
    406406  module R_std=std(R);
    407407  module Ext_1 = std(Ext_Our(1,R_std));
    408    
     408
    409409  ExtIsZero=is_zero_Our(Ext_1);
    410410  i=1;
     
    421421}
    422422example
    423 {"EXAMPLE:";echo = 2; 
     423{"EXAMPLE:";echo = 2;
    424424  // a WindTunnel example
    425425  ring A = (0,a, omega, zeta, k),(D1, delta),dp;
     
    444444  {
    445445    return ("control2 cannot be applied, since R does not have full row rank");
    446   } 
     446  }
    447447  intvec v=Opt_Our();
    448448  module R_std=std(R);
     
    457457}
    458458example
    459 {"EXAMPLE:";echo = 2; 
     459{"EXAMPLE:";echo = 2;
    460460  //a WindTunnel example
    461461  ring A = (0,a, omega, zeta, k),(D1, delta),dp;
     
    489489    [-D(2),D(1),0];
    490490  R=transpose(R);
    491   colrank(R); 
    492 };
    493  
     491  colrank(R);
     492};
     493
    494494//------------------------------------------------------------------------
    495 static proc autonom_output( int i, int NVars, module RC, int R_rank ) 
     495static proc autonom_output( int i, int NVars, module RC, int R_rank )
    496496"USAGE:  proc autonom_output(i, NVars, RC, R_rank)
    497            i:  integer, number of first nonzero Ext or 
    498                just number of variables in a base ring + 1 in case that all the Exts are zero
    499            NVars:  integer, number of variables in a base ring 
    500            RC: module, kernel-representation of controllable part of the system
    501            R_rank: integer, column rank of the representation matrix
     497           i:  integer, number of first nonzero Ext or
     498               just number of variables in a base ring + 1 in case that all the Exts are zero
     499           NVars:  integer, number of variables in a base ring
     500           RC: module, kernel-representation of controllable part of the system
     501           R_rank: integer, column rank of the representation matrix
    502502PURPOSE: compute all the autonomy properties of the system which is to be returned in 'autonom' procedure
    503 RETURN:  list 
     503RETURN:  list
    504504NOTE:  this procedure is used in 'autonom' procedure
    505505"
     
    509509  string Fn = "number of first nonzero Ext:";
    510510  if(i==0)
    511   { 
     511  {
    512512    return( list(  Fn,
    513513                   i,
    514514                  "not autonomous",
    515                    "kernel representation for controllable part",
    516                    RC,
    517                    "column rank of the matrix",
    518                    R_rank,
    519                    DofS,
    520                    d )
    521           );
     515                   "kernel representation for controllable part",
     516                   RC,
     517                   "column rank of the matrix",
     518                   R_rank,
     519                   DofS,
     520                   d )
     521          );
    522522  };
    523  
     523
    524524  if( i>NVars )
    525   { 
     525  {
    526526    return( list( Fn,
    527527                  -1,
    528528                  "trivial",
    529                   DofS,
    530                   d )
     529                  DofS,
     530                  d )
    531531          );
    532532  };
    533  
     533
    534534  //
    535535  //now i<=NVars
    536536  //
    537    
    538      
     537
     538
    539539  if( i==1 )
    540540  // in case that NVars==1 there is no sense to consider the notion
    541   // of strongly autonomous behavior, because it does not imply 
     541  // of strongly autonomous behavior, because it does not imply
    542542  // that system is overdetermined in this case
    543543  {
    544544    return( list ( Fn,
    545                    i, 
     545                   i,
    546546                  "autonomous, not overdetermined",
    547                    DofS,
    548                    d )
    549           ); 
     547                   DofS,
     548                   d )
     549          );
    550550  };
    551    
     551
    552552  if( i==NVars )
    553   { 
     553  {
    554554    return( list(  Fn,
    555555                   i,
    556556                  "strongly autonomous(fin. dimensional),in particular overdetermined",
    557                    DofS,
    558                    d)
    559           );
     557                   DofS,
     558                   d)
     559          );
    560560  };
    561  
     561
    562562  if( i<NVars )
    563563  {
     
    565565                   i,
    566566                  "overdetermined, not strongly autonomous",
    567                    DofS,
    568                    d)
     567                   DofS,
     568                   d)
    569569          );
    570570  };
    571 }; 
     571};
    572572//--------------------------------------------------------------------------
    573573proc autonom2(module R)
     
    578578EXAMPLE:  example autonom2; shows an example
    579579"
    580 { 
     580{
    581581  int d;
    582582  int NVars = nvars(basering);
     
    584584  module RC;  //for computation of controllable part if if exists
    585585  int R_rank = ncols(R);
    586   d     = dim_Our( std(RT) );  //this is the dimension of the system 
     586  d     = dim_Our( std(RT) );  //this is the dimension of the system
    587587  int i = NVars-d;  //First non-zero Ext
    588588  if( d==0 )
     
    599599  module R= [s1,-s2],
    600600            [s2, s1],
    601             [s3,-s4],
    602             [s4, s3];       
     601            [s3,-s4],
     602            [s4, s3];
    603603  R=transpose(R);
    604604  view( R );
    605605  view( autonom2(R) );
    606 }; 
     606};
    607607//----------------------------------------------------------
    608608proc autonom(module R)
     
    618618  module RC;
    619619  int R_rank=ncols(R);
    620   ExtIsZero=is_zero_Our(Ext_Our(0,RT));     
     620  ExtIsZero=is_zero_Our(Ext_Our(0,RT));
    621621  int i=0;
    622622  while( (ExtIsZero)&&(i<=NVars) )
     
    638638  module R= [s1,-s2],
    639639            [s2, s1],
    640             [s3,-s4],
    641             [s4, s3];       
     640            [s3,-s4],
     641            [s4, s3];
    642642  R=transpose(R);
    643643  view( R );
    644644  view( autonom(R) );
    645 }; 
     645};
    646646
    647647
     
    650650"USAGE:  genericity(M), M is a matrix/module
    651651PURPOSE: determine parametric expressions which have been assumed to be non-zero in the process of computing the Groebner basis
    652 RETURN:  list (of strings) 
    653 NOTE: we strongly recommend to switch on the redSB and redTail options; 
     652RETURN:  list (of strings)
     653NOTE: we strongly recommend to switch on the redSB and redTail options;
    654654@*    the procedure is effective with the lift procedure for modules with parameters
    655655EXAMPLE:  example genericity; shows an example
     
    672672  "EXAMPLE:"; echo = 2;
    673673  ring r=(0,m1,m2,M,g,L1,L2),Dt,dp;
    674   module RR = 
    675     [m1*L1*Dt^2, m2*L2*Dt^2, -1, (M+m1+m2)*Dt^2], 
     674  module RR =
     675    [m1*L1*Dt^2, m2*L2*Dt^2, -1, (M+m1+m2)*Dt^2],
    676676    [m1*L1^2*Dt^2-m1*L1*g, 0, 0, m1*L1*Dt^2],
    677677    [0, m2*L2^2*Dt^2-m2*L2*g, 0, m2*L2*Dt^2];
     
    730730      cl++;
    731731      p = p - lead(p); // for the next cycle
    732     }     
     732    }
    733733    if ( p!= 0)
    734734    {
     
    782782      for (j=1; j<=size(F);j++)
    783783      {
    784         q = F[j]-lead(F[j]);
    785         if (q!=0)
    786         {
    787           @L[cl] = F[j];
    788           cl++;
    789         }
     784        q = F[j]-lead(F[j]);
     785        if (q!=0)
     786        {
     787          @L[cl] = F[j];
     788          cl++;
     789        }
    790790      }
    791791    }
     
    814814  {
    815815    p = I[i];
    816     while (p !=0) 
    817     { 
    818       Den = Den, denominator(leadcoef(p)); 
    819       p   = p-lead(p); 
    820     }
    821   }
    822   Den = simplify(Den,2+4); 
     816    while (p !=0)
     817    {
     818      Den = Den, denominator(leadcoef(p));
     819      p   = p-lead(p);
     820    }
     821  }
     822  Den = simplify(Den,2+4);
    823823  string newvars = parstr(basering);
    824824  def save = basering;
     
    830830  int s1 = size(Den);
    831831  for (i=1; i<=s1; i++)
    832   { 
     832  {
    833833    if (Den[i] !=1)
    834     { 
    835       F= F, factorize(Den[i],1); 
    836     } 
    837   }
    838   F = simplify(F, 2+4+8); 
     834    {
     835      F= F, factorize(Den[i],1);
     836    }
     837  }
     838  F = simplify(F, 2+4+8);
    839839  ideal @L = F;
    840840  list SL;
     
    871871"USAGE:  canonize(L), L a list
    872872PURPOSE: modules in the list are canonized by computing their reduced minimal (= unique up to constant factor w.r.t. the given ordering) Groebner bases
    873 RETURN:  list 
     873RETURN:  list
    874874ASSUME:  L is the output of control/autonomy procedures
    875875EXAMPLE:  example canonize; shows an example
     
    896896  "EXAMPLE:"; echo = 2;
    897897  ring r=(0,m1,m2,M,g,L),Dt,dp;
    898   module RR = 
    899     [m1*L*Dt^2, m2*L*Dt^2, -1, (M+m1+m2)*Dt^2], 
     898  module RR =
     899    [m1*L*Dt^2, m2*L*Dt^2, -1, (M+m1+m2)*Dt^2],
    900900    [m1*L^2*Dt^2-m1*L*g, 0, 0, m1*L*Dt^2],
    901901    [0, m2*L^2*Dt^2-m2*L*g, 0, m2*L*Dt^2];
     
    914914    {
    915915      if(v[j]==i)
    916         {
    917           b=1;
    918           return (b);
    919         }
     916        {
     917          b=1;
     918          return (b);
     919        }
    920920    }
    921921  return (b);
     
    923923//-----------------------------------------------------------------
    924924proc iostruct(module R)
    925 "USAGE: iostruct( R ); R a module 
     925"USAGE: iostruct( R ); R a module
    926926RETURN:  list L with entries: string s, intvec v, module P and module Q
    927927PURPOSE:  if R is the kernel-representation-matrix of some system, then we output a input-ouput representation Py=Qu of the system, the components that have been chosen as outputs(intvec v) and a comment s
     
    941941  module Q;
    942942  int n=0;
    943  
     943
    944944  while(b==1)               //sort v through bubblesort
    945945    {
    946946      b=0;
    947947      for(i=1;i<NRows;i++)
    948         {
    949           if(v[i]>v[i+1])
    950           {
    951             temp=v[i];
    952             v[i]=v[i+1];
    953             v[i+1]=temp;
    954             b=1;
    955           }
    956         }
    957     }
    958   P=R[v];                     //generate P 
     948        {
     949          if(v[i]>v[i+1])
     950          {
     951            temp=v[i];
     952            v[i]=v[i+1];
     953            v[i+1]=temp;
     954            b=1;
     955          }
     956        }
     957    }
     958  P=R[v];                     //generate P
    959959  for(i=1;i<=NCols;i++)       //generate Q
    960960    {
    961961      if(elementof(i,v)==1)
    962         {
    963           i++;
    964           continue;
    965         }
     962        {
     963          i++;
     964          continue;
     965        }
    966966      Q=Q,R[i];
    967967    }
     
    975975 ring r = (0, K1, K2, Te, Kp, Kc),(Dt, delta), (c,dp);
    976976 module RR;
    977  RR = 
     977 RR =
    978978   [Dt, -K1, 0, 0, 0, 0, 0, 0, 0],
    979979   [0, Dt+K2/Te, 0, 0, 0, 0, -Kp/Te*delta, -Kc/Te*delta, -Kc/Te*delta],
     
    984984 module R = transpose(RR);
    985985 view(iostruct(R));
    986 };     
     986};
    987987
    988988//---------------------------------------------------------------
    989 static proc smdeg(matrix N) 
    990 "USAGE: smdeg( N ); N a matrix 
     989static proc smdeg(matrix N)
     990"USAGE: smdeg( N ); N a matrix
    991991RETURN:  intvec
    992992PURPOSE: returns an intvec of length 2 with the index of an element of N with smallest degree
     
    999999  int i,j;            // counter
    10001000
    1001   if (N==0) 
     1001  if (N==0)
    10021002  {
    10031003    v = 1,1;
    10041004    return(v);
    1005   } 
    1006  
    1007   for (i=1; i<=n; i++) 
     1005  }
     1006
     1007  for (i=1; i<=n; i++)
    10081008// hier wird ein Element ausgewaehlt(!=0) und mit dessen Grad gestartet
    10091009  {
     
    10121012      if( deg(N[i,j])!=-1 )
    10131013      {
    1014         d=deg(N[i,j]);
    1015         break;
     1014        d=deg(N[i,j]);
     1015        break;
    10161016      }
    10171017    }
     
    10191019    {
    10201020      break;
    1021     } 
     1021    }
    10221022  }
    10231023  for(i=1; i<=n; i++)
     
    10281028      if ( (d_temp < d) && (N[i,j]!=0) )
    10291029      {
    1030         d=d_temp;
     1030        d=d_temp;
    10311031      }
    10321032    }
     
    10381038      if ( (deg(N[i,j]) == d) && (N[i,j]!=0) )
    10391039      {
    1040         v = i,j;
    1041         return(v);
     1040        v = i,j;
     1041        return(v);
    10421042      }
    10431043    }
     
    10761076    J = p,q; // J = N[k-1,k-1],N[k,k]; //J is of type ideal
    10771077    L[1] = liftstd(J,T);  //T is of type matrix
    1078     if(J[1]==p) //this is just for the case the SINGULAR swaps the 
     1078    if(J[1]==p) //this is just for the case the SINGULAR swaps the
    10791079    //      two elements due to ordering
    1080     { 
    1081       L[2] = T[1,1]; 
    1082       L[3] = T[2,1]; 
     1080    {
     1081      L[2] = T[1,1];
     1082      L[3] = T[2,1];
    10831083    }
    10841084    else
    1085     { 
    1086       L[2] = T[2,1]; 
    1087       L[3] = T[1,1]; 
     1085    {
     1086      L[2] = T[2,1];
     1087      L[3] = T[1,1];
    10881088    }
    10891089  }
    10901090  else
    10911091  {
    1092     L=extgcd(p,q); 
    1093     //    L=extgcd(N[k-1,k-1],N[k,k]); 
     1092    L=extgcd(p,q);
     1093    //    L=extgcd(N[k-1,k-1],N[k,k]);
    10941094    //one can use this line if extgcd-bug is fixed
    10951095  }
     
    11001100PURPOSE: normalizes N and divides the columns of Q through the leading coefficients of the columns of N
    11011101RETURN: normalized matrix N and altered Q(according to the scheme mentioned in purpose). If number of columns of N and Q do not coincide, N and Q are returned unchanged
    1102 NOTE: number of columns of N and Q must coincide. 
     1102NOTE: number of columns of N and Q must coincide.
    11031103"
    11041104{
     
    11061106    {
    11071107      return (N,Q);
    1108     }   
     1108    }
    11091109  module M = module(N);
    11101110  module S = module(Q);
     
    11231123   Q = matrix(S);
    11241124   return (N,Q);
    1125 }               
    1126        
     1125}
     1126
    11271127//---------------------------------------------------------------
    11281128proc smith( module M )
     
    11301130PURPOSE: computes the Smith form of a matrix
    11311131RETURN: a list of length 4 with the following entries:
    1132 @*      [1]: The Smith-Form S of M, 
    1133 @*      [2]: the rank of M, 
     1132@*      [1]: The Smith-Form S of M,
     1133@*      [2]: the rank of M,
    11341134@*      [3]: a unimodular matrix U,
    1135 @*      [4]: a unimodular matrix V, 
    1136 such that U*M*V=S. An warning is returned when no Smith Form exists. 
     1135@*      [4]: a unimodular matrix V,
     1136such that U*M*V=S. An warning is returned when no Smith Form exists.
    11371137NOTE: The Smith form only exists over PIDs (principal ideal domains). Use global ordering for computations!
    11381138"
     
    11571157  matrix mu[1][m];             //to save leadcoefficients
    11581158  int ii;                       //counter
    1159  
    1160   while ((k!=n) && (k!=m) )   
     1159
     1160  while ((k!=n) && (k!=m) )
    11611161  {
    11621162    k++;
     
    11651165      while(k<=m )        //inner while-loop for row-operations
    11661166      {
    1167         if( (n>m) && (k < n) && (k<m))
    1168         {     
    1169           if( simplify((ideal(submat(N,k+1..n,k+1..m))),2)== 0)
    1170           {
    1171             return(N,k-1,P,Q);
    1172           }
    1173         }
     1167        if( (n>m) && (k < n) && (k<m))
     1168        {
     1169          if( simplify((ideal(submat(N,k+1..n,k+1..m))),2)== 0)
     1170          {
     1171            return(N,k-1,P,Q);
     1172          }
     1173        }
    11741174        i,j = smdeg(submat(N,k..n,k..m)); //choose smallest degree in the remaining submatrix
    11751175        i=i+(k-1);                        //indices adjusted to the whole matrix
    1176         j=j+(k-1);
    1177         if(i!=k)                    //take the element with smallest degree in the first position
     1176        j=j+(k-1);
     1177        if(i!=k)                    //take the element with smallest degree in the first position
    11781178        {
    11791179          N=permrow(N,i,k);
     
    11931193        for(ii=k+1;ii<=n;ii++)
    11941194        {
    1195           lambda[1,ii]=leadcoef(N[ii,k])/tmp;     
     1195          lambda[1,ii]=leadcoef(N[ii,k])/tmp;
    11961196          f[1,ii]=deg(N[ii,k])-deg_temp;
    11971197        }
    11981198        for(ii=k+1;ii<=n;ii++)
    11991199        {
    1200           N = addrow(N,k,-lambda[1,ii]*var(1)^f[1,ii],ii);               
     1200          N = addrow(N,k,-lambda[1,ii]*var(1)^f[1,ii],ii);
    12011201          P = addrow(P,k,-lambda[1,ii]*var(1)^f[1,ii],ii);
    1202           N,Q=normalize_Our(N,Q);
    1203         }
     1202          N,Q=normalize_Our(N,Q);
     1203        }
    12041204      }
    12051205      if (k>n)
    12061206      {
    1207         break;
     1207        break;
    12081208      }
    12091209      if(NoNon0Pol(transpose(N)[k])==1)
     
    12131213      tmp=leadcoef(N[k,k]);
    12141214      deg_temp=ord(N[k,k]); //ord outputs the leading degree of N[k][k]
    1215      
     1215
    12161216      for(ii=k+1;ii<=m;ii++)
    12171217      {
    1218         mu[1,ii]=leadcoef(N[k,ii])/tmp;     
     1218        mu[1,ii]=leadcoef(N[k,ii])/tmp;
    12191219        g[1,ii]=deg(N[k,ii])-deg_temp;
    12201220      }
     
    12231223        N=addcol(N,k,-mu[1,ii]*var(1)^g[1,ii],ii);
    12241224        Q=addcol(Q,k,-mu[1,ii]*var(1)^g[1,ii],ii);
    1225         N,Q=normalize_Our(N,Q);
     1225        N,Q=normalize_Our(N,Q);
    12261226      }
    12271227    }
    12281228    if( (k!=1) && (k<n) && (k<m) )
    12291229    {
    1230       L = extgcd_Our(N[k-1,k-1],N[k,k]);     
     1230      L = extgcd_Our(N[k-1,k-1],N[k,k]);
    12311231      if ( N[k-1,k-1]!=L[1] )  //means that N[k-1,k-1] is not a divisor of N[k,k]
    12321232      {
    1233         N=addrow(N,k-1,L[2],k);
    1234         P=addrow(P,k-1,L[2],k);
    1235         N,Q=normalize_Our(N,Q); 
    1236        
     1233        N=addrow(N,k-1,L[2],k);
     1234        P=addrow(P,k-1,L[2],k);
     1235        N,Q=normalize_Our(N,Q);
     1236
    12371237        N=addcol(N,k,-L[3],k-1);
    1238         Q=addcol(Q,k,-L[3],k-1);
    1239         N,Q=normalize_Our(N,Q);
    1240         k=k-2;
     1238        Q=addcol(Q,k,-L[3],k-1);
     1239        N,Q=normalize_Our(N,Q);
     1240        k=k-2;
    12411241      }
    12421242    }
    1243   } 
     1243  }
    12441244  if( (k<=n) && (k<=m) )
    12451245  {
     
    12761276static proc list_tex(L, string name,link l,int nr_loop)
    12771277"USAGE: list_tex(L,name,l), where L is a list, name a string, l a link
    1278         writes the content of list L in a tex-file 'name'
     1278        writes the content of list L in a tex-file 'name'
    12791279RETURN: nothing
    12801280"
     
    12841284    texobj(name,L);
    12851285  }
    1286   if(size(L)==0) 
     1286  if(size(L)==0)
    12871287  {
    12881288  }
     
    12941294      while(1)
    12951295      {
    1296         if(typeof(L[i])=="string")  //Fehler hier fuer normalen output->nur wenn string in liste dann verbatim
    1297         {
    1298           t=L[i];
    1299           if(nr_loop==1)
    1300           {
    1301             write(l,"\\begin\{center\}");
    1302             write(l,"\\begin\{verbatim\}");
    1303           }
    1304           write(l,t);
    1305           if(nr_loop==0)
    1306           {
    1307             write(l,"\\par");
    1308           }
    1309           if(nr_loop==1)
    1310           {
    1311             write(l,"\\end\{verbatim\}");
    1312             write(l,"\\end\{center\}");
    1313           }
    1314           break;
    1315         }
    1316         if(typeof(L[i])=="module")
    1317         {
    1318           texobj(name,matrix(L[i]));
    1319           break;
    1320         }
    1321         if(typeof(L[i])=="list")
    1322         {
    1323           list_tex(L[i],name,l,1);
    1324           break;
    1325         }
    1326         write(l,"\\begin\{center\}");
    1327         texobj(name,L[i]);
    1328         write(l,"\\end\{center\}");
    1329         write(l,"\\par");
    1330         break;
     1296        if(typeof(L[i])=="string")  //Fehler hier fuer normalen output->nur wenn string in liste dann verbatim
     1297        {
     1298          t=L[i];
     1299          if(nr_loop==1)
     1300          {
     1301            write(l,"\\begin\{center\}");
     1302            write(l,"\\begin\{verbatim\}");
     1303          }
     1304          write(l,t);
     1305          if(nr_loop==0)
     1306          {
     1307            write(l,"\\par");
     1308          }
     1309          if(nr_loop==1)
     1310          {
     1311            write(l,"\\end\{verbatim\}");
     1312            write(l,"\\end\{center\}");
     1313          }
     1314          break;
     1315        }
     1316        if(typeof(L[i])=="module")
     1317        {
     1318          texobj(name,matrix(L[i]));
     1319          break;
     1320        }
     1321        if(typeof(L[i])=="list")
     1322        {
     1323          list_tex(L[i],name,l,1);
     1324          break;
     1325        }
     1326        write(l,"\\begin\{center\}");
     1327        texobj(name,L[i]);
     1328        write(l,"\\end\{center\}");
     1329        write(l,"\\par");
     1330        break;
    13311331      }
    13321332    }
     
    13411341"USAGE: verbatim_tex(s,l), where s is a string and l a link
    13421342PURPOSE: writes the content of s in verbatim-environment in the file
    1343         specified by link
     1343        specified by link
    13441344RETURN: nothing
    13451345"
     
    14051405@* To use ab example, one has to do the following. Suppose one calls the ring, where the example will be activated, A. Then, by executing
    14061406@*  @code{def A = ControlExample(\"Antenna\");} and @code{setring A;},
    1407 @* A will become a basering from the example \"Antenna\" with 
     1407@* A will become a basering from the example \"Antenna\" with
    14081408the predefined system module R (transposed).
    1409 After that one can just execute @code{control(R);} respectively 
     1409After that one can just execute @code{control(R);} respectively
    14101410@code{autonom(R);} to perform the control resp. autonomy analysis of R.
    14111411EXAMPLE: example ControlExample; shows an example
     
    14691469  R=transpose(R);
    14701470  export R;
    1471   return(@r);       
     1471  return(@r);
    14721472};
    14731473//----------------------------------------------------------
     
    14771477  module R= [s1,-s2],
    14781478            [s2, s1],
    1479             [s3,-s4],
    1480             [s4, s3];       
     1479            [s3,-s4],
     1480            [s4, s3];
    14811481  R=transpose(R);
    14821482  export R;
    1483   return(@r);       
    1484 }; 
     1483  return(@r);
     1484};
    14851485//----------------------------------------------------------
    14861486static proc exZerz1()
    1487 { 
     1487{
    14881488  ring @r=0,(d1,d2),dp;
    14891489  module R=[d1^2-d2],
     
    14911491  R=transpose(R);
    14921492  export R;
    1493   return(@r);       
    1494 }; 
     1493  return(@r);
     1494};
    14951495//----------------------------------------------------------
    14961496//control
     
    15011501  module R=[0,-s3,s2],
    15021502           [s3,0,-s1];
    1503   R=transpose(R);         
     1503  R=transpose(R);
    15041504  export R;
    15051505  return(@r);
     
    15071507//----------------------------------------------------------
    15081508static proc exControl2()
    1509 { 
     1509{
    15101510  ring @r=0,(s1,s2,s3),dp;
    15111511  module R=[0,-s3,s2],
    15121512           [s3,0,-s1],
    15131513           [-s2,s1,0];
    1514   R=transpose(R);         
     1514  R=transpose(R);
    15151515  export R;
    1516   return(@r); 
     1516  return(@r);
    15171517};
    15181518//----------------------------------------------------------
     
    15301530  R=transpose(R);
    15311531  export R;
    1532   return(@r); 
     1532  return(@r);
    15331533};
    15341534
     
    15401540  module R =
    15411541  [D(2)^2+D(3)^2-D(4)^2, D(1)^2, D(1)^2, -D(1)^2, -2*D(1)*D(2), 0, 0, -2*D(1)*D(3), 0, 2*D(1)*D(4)],
    1542   [D(2)^2, D(1)^2+D(3)^2-D(4)^2, D(2)^2, -D(2)^2, -2*D(1)*D(2), -2*D(2)*D(3), 0, 0, 2*D(2)*D(4), 0], 
     1542  [D(2)^2, D(1)^2+D(3)^2-D(4)^2, D(2)^2, -D(2)^2, -2*D(1)*D(2), -2*D(2)*D(3), 0, 0, 2*D(2)*D(4), 0],
    15431543  [D(3)^2, D(3)^2, D(1)^2+D(2)^2-D(4)^2, -D(3)^2, 0, -2*D(2)*D(3), 2*D(3)*D(4), -2*D(1)*D(3), 0, 0],
    15441544  [D(4)^2, D(4)^2, D(4)^2, D(1)^2+D(2)^2+D(3)^2, 0, 0, -2*D(3)*D(4), 0, -2*D(2)*D(4), -2*D(1)*D(4)],
     
    15471547  [D(3)*D(4), D(3)*D(4), 0, 0, 0, -D(2)*D(4), D(1)^2+D(2)^2, -D(1)*D(4), -D(2)*D(3), -D(1)*D(3)],
    15481548  [0, D(1)*D(3), 0, -D(1)*D(3), -D(2)*D(3), -D(1)*D(2), D(1)*D(4), D(2)^2-D(4)^2, 0, D(3)*D(4)],
    1549   [D(2)*D(4), 0, D(2)*D(4), 0, -D(1)*D(4), -D(3)*D(4), -D(2)*D(3), 0, D(1)^2+D(3)^2, -D(1)*D(2)], 
     1549  [D(2)*D(4), 0, D(2)*D(4), 0, -D(1)*D(4), -D(3)*D(4), -D(2)*D(3), 0, D(1)^2+D(3)^2, -D(1)*D(2)],
    15501550  [0, D(1)*D(4), D(1)*D(4), 0, -D(2)*D(4), 0, -D(1)*D(3), -D(3)*D(4), -D(1)*D(2), D(2)^2+D(3)^2];
    15511551
    15521552  R=transpose(R);
    15531553  export R;
    1554   return(@r); 
     1554  return(@r);
    15551555};
    15561556
     
    15611561  module R;
    15621562  R = [D1, -D1*delta, -1], [2*D1*delta, -D1-D1*delta^2, 0];
    1563  
     1563
    15641564  R=transpose(R);
    15651565  export R;
    1566   return(@r); 
     1566  return(@r);
    15671567};
    15681568
    15691569//----------------------------------------------------------
    15701570static proc exTwoPendula()
    1571 { 
     1571{
    15721572  ring @r=(0,m1,m2,M,g,L1,L2),Dt,dp;
    1573   module R = [m1*L1*Dt^2, m2*L2*Dt^2, -1, (M+m1+m2)*Dt^2], 
     1573  module R = [m1*L1*Dt^2, m2*L2*Dt^2, -1, (M+m1+m2)*Dt^2],
    15741574             [m1*L1^2*Dt^2-m1*L1*g, 0, 0, m1*L1*Dt^2],
    15751575             [0, m2*L2^2*Dt^2-m2*L2*g, 0, m2*L2*Dt^2];
     
    15771577  R=transpose(R);
    15781578  export R;
    1579   return(@r); 
     1579  return(@r);
    15801580};
    15811581//----------------------------------------------------------
    15821582static proc exWindTunnel()
    1583 { 
     1583{
    15841584  ring @r = (0,a, omega, zeta, k),(D1, delta),dp;
    15851585  module R = [D1+a, -k*a*delta, 0, 0],
     
    15891589  R=transpose(R);
    15901590  export R;
    1591   return(@r); 
     1591  return(@r);
    15921592};
    15931593
     
    15961596proc declare(string NameOfRing, string Variables, list #)
    15971597"USAGE: declare(NameOfRing, Variables,[Parameters, Ordering]);  where
    1598 @*         NameOfRing is string with name of ring, 
     1598@*         NameOfRing is string with name of ring,
    15991599@*         Variables is a string with names of variables separated by commas (e.g. \"x,y,z\"),
    1600 @*          Parameters is string of parameters in the ring separated by commas (e.g. \"a,b,c\"),
    1601 @*          Ordering is   string with name of ordering (by default, the ordering (dp,C) is used).
     1600@*            Parameters is string of parameters in the ring separated by commas (e.g. \"a,b,c\"),
     1601@*            Ordering is   string with name of ordering (by default, the ordering (dp,C) is used).
    16021602PURPOSE: define the ring easily
    16031603RETURN:  no return value
    1604 EXAMPLE:  example declare; shows an example 
     1604EXAMPLE:  example declare; shows an example
    16051605"
    16061606{
     
    16161616     }
    16171617     else
    1618      { 
     1618     {
    16191619       if( (size(#[1])!=0)&&(#[1]!=" ") )
    16201620       {
     
    16231623       else
    16241624       {
    1625          execute( "ring " + NameOfRing + "=0,("+Variables+"),("+#[2]+");" ); 
     1625         execute( "ring " + NameOfRing + "=0,("+Variables+"),("+#[2]+");" );
    16261626       };
    16271627     };
     
    16581658// maybe reasonable to add this in declare
    16591659//
    1660 //  print("Please enter your representation matrix in the following form: 
     1660//  print("Please enter your representation matrix in the following form:
    16611661//  module R=[1st row],[2nd row],...");
    16621662//  print("Type the command: R=transpose(R)");
  • Singular/LIB/deform.lib

    re6fb531 r3c4dcc  
    1 // $Id: deform.lib,v 1.34 2005-04-28 15:12:24 Singular Exp $
     1// $Id: deform.lib,v 1.35 2005-05-06 14:38:14 hannes Exp $
    22// author: Bernd Martin email: martin@math.tu-cottbus.de
    33//(bm, last modified 4/98)
    44///////////////////////////////////////////////////////////////////////////////
    5 version="$Id: deform.lib,v 1.34 2005-04-28 15:12:24 Singular Exp $";
     5version="$Id: deform.lib,v 1.35 2005-05-06 14:38:14 hannes Exp $";
    66category="Singularities";
    77info="
     
    2828RETURN: list L of 4 rings:
    2929         L[1] extending the basering Po by new variables given by
    30           \"A,B,..\" (deformation parameters); the new variables precede 
     30          \"A,B,..\" (deformation parameters); the new variables precede
    3131         the old ones, the ordering is the product of \"ls\" and \"ord(Po)\" @*
    3232         L[2] = L[1]/Fo extending Qo=Po/Fo, @*
     
    4040      If d is defined (!=0), it computes up to degree d.
    4141      @*If 'any' is defined and any[1] is no string, interactive version.
    42       @*Otherwise 'any' is interpreted as a list of predefined strings: 
     42      @*Otherwise 'any' is interpreted as a list of predefined strings:
    4343      \"my\",\"param\",\"order\",\"out\": @*
    44       (\"my\" internal prefix, \"param\" is a letter (e.g. \"A\") for the 
    45       name of the first parameter or (e.g. \"A(\") for index parameter 
    46       variables, \"order\" ordering string for ring extension), \"out\" name 
    47       of output file). 
     44      (\"my\" internal prefix, \"param\" is a letter (e.g. \"A\") for the
     45      name of the first parameter or (e.g. \"A(\") for index parameter
     46      variables, \"order\" ordering string for ring extension), \"out\" name
     47      of output file).
    4848NOTE:   printlevel < 0        no additional output,
    4949        printlevel >=0,1,2,.. informs you, what is going on;
     
    291291   list L=versal(Fo);
    292292   L;
    293    def Px=L[1]; 
     293   def Px=L[1];
    294294   setring Px;
    295295   // ___ Equations of miniversal base space ___:
     
    305305RETURN:  list L of 4 rings:
    306306         L[1] extending the basering Po by new variables given by
    307           \"A,B,..\" (deformation parameters); the new variables precede 
     307          \"A,B,..\" (deformation parameters); the new variables precede
    308308         the old ones, the ordering is the product of \"ls\" and \"ord(Po)\" @*
    309309         L[2] = L[1]/Io extending Qo, @*
     
    313313         @*Js  = giving the versal base space (obstructions),
    314314         @*Fs  = giving the versal family of Mo,
    315          @*Rs  = giving the lifting of syzygies Lo=syz(Mo).   
     315         @*Rs  = giving the lifting of syzygies Lo=syz(Mo).
    316316      If d is defined (!=0), it computes up to degree d.
    317317      @*If 'any' is defined and any[1] is no string, interactive version.
    318       @*Otherwise 'any' is interpreted as a list of predefined strings: 
     318      @*Otherwise 'any' is interpreted as a list of predefined strings:
    319319      \"my\",\"param\",\"order\",\"out\": @*
    320       (\"my\" internal prefix, \"param\" is a letter (e.g. \"A\") for the 
    321       name of the first parameter or (e.g. \"A(\") for index parameter 
    322       variables, \"order\" ordering string for ring extension), \"out\" name 
    323       of output file). 
     320      (\"my\" internal prefix, \"param\" is a letter (e.g. \"A\") for the
     321      name of the first parameter or (e.g. \"A(\") for index parameter
     322      variables, \"order\" ordering string for ring extension), \"out\" name
     323      of output file).
    324324NOTE:   printlevel < 0        no additional output,
    325325        printlevel >=0,1,2,.. informs you, what is going on,
     
    662662   def my_Px=extendring(e1,my_var,my_ord);
    663663   setring my_Px;
    664    ideal Io  = imap(Po,Io);         
     664   ideal Io  = imap(Po,Io);
    665665   attrib(Io,"isSB",1);
    666666   qring my_Qx = Io;
     
    841841    t1=size(vvvv);
    842842// ==========================================================
    843    
     843
    844844    int l,l1;
    845845    for (l=1;l<=t1;l=l+1)
     
    927927    if (size(tv)>1)
    928928    { k = tv[2];
    929       tv = tv[2..size(tv)]; 
     929      tv = tv[2..size(tv)];
    930930      tv = tv -k;
    931931      if (tv==0) { @nv = @nv+string(-k)+",";}
  • Singular/LIB/digimult.lib

    re6fb531 r3c4dcc  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: digimult.lib,v 1.1 2005-05-04 15:41:12 bricken Exp $";
     2version="$Id: digimult.lib,v 1.2 2005-05-06 14:38:17 hannes Exp $";
    33category="Logic";
    44info="
     
    77
    88OVERVIEW:
    9         Various algorithms for verifiying digital circuits, including SAT-Solvers
     9        Various algorithms for verifiying digital circuits, including SAT-Solvers
    1010
    1111PROCEDURES:
     
    4040    return(poly_cancel_mod_number(f-l,n));
    4141  }
    42  
     42
    4343  return(l+poly_cancel_mod_number(f-l,n));
    4444}
     
    7474    for(j=1;j<=size(l);j++){
    7575      if(i!=j){
    76         summand=summand*(var(1)-l[j][1]);
    77        
     76        summand=summand*(var(1)-l[j][1]);
    7877      }
    7978    }
     
    163162  j=simplify(j,2);
    164163  j=simplify(j,8);
    165  
     164
    166165  poly v=var(var_order[1]);
    167166  var_order=delete(var_order,1);
     
    177176    return(simple_gps(j0,var_order, step));
    178177  }
    179  
     178
    180179}
  • Singular/LIB/equising.lib

    re6fb531 r3c4dcc  
    1 version="$Id: equising.lib,v 1.11 2005-04-25 10:13:06 Singular Exp $";
     1version="$Id: equising.lib,v 1.12 2005-05-06 14:38:17 hannes Exp $";
    22category="Singularities";
    33info="
    44LIBRARY:  equising.lib  Equisingularity Stratum of a Family of Plane Curves
    5 AUTHOR:   Christoph Lossen, lossen@mathematik.uni-kl.de 
     5AUTHOR:   Christoph Lossen, lossen@mathematik.uni-kl.de
    66          Andrea Mindnich, mindnich@mathematik.uni-kl.de
    77
    88MAIN PROCEDURES:
    99 tau_es(f);             codim of mu-const stratum in semi-universal def. base
    10  esIdeal(f);            (Wahl's) equisingularity ideal of f 
     10 esIdeal(f);            (Wahl's) equisingularity ideal of f
    1111 esStratum(F[,m,L]);    equisingularity stratum of a family F
    1212 isEquising(F[,m,L]);   tests if a given deformation is equisingular
     
    5555static proc m_Jet(poly F,int m);
    5656{
    57   intvec w=xyVector(); 
    58   poly Fd=jet(F,m,w); 
     57  intvec w=xyVector();
     58  poly Fd=jet(F,m,w);
    5959  return(Fd);
    6060}
     
    6363////////////////////////////////////////////////////////////////////////////////
    6464// computes the 4 control matrices (input is multsequence(L))
    65 proc control_Matrix(list M); 
     65proc control_Matrix(list M);
    6666"USAGE:   control_Matrix(L); L list
    6767ASSUME:  L is the output of multsequence(hnexpansion(f)).
    6868RETURN:  list M of 4 intmat's:
    6969@format
    70   M[1] contains the multiplicities at the respective infinitely near points 
    71        p[i,j] (i=step of blowup+1, j=branch) -- if branches j=k,...,k+m pass 
    72        through the same p[i,j] then the multiplicity is stored in M[1][k,j], 
    73        while M[1][k+1]=...=M[1][k+m]=0.   
    74   M[2] contains the number of branches meeting at p[i,j] (again, the information 
    75        is stored according to the above rule)   
    76   M[3] contains the information about the splitting of M[1][i,j] with respect to 
    77        different tangents of branches at p[i,j] (information is stored only for 
    78        minimal j>=k corresponding to a new tangent direction). 
    79        The entries are the sum of multiplicities of all branches with the 
     70  M[1] contains the multiplicities at the respective infinitely near points
     71       p[i,j] (i=step of blowup+1, j=branch) -- if branches j=k,...,k+m pass
     72       through the same p[i,j] then the multiplicity is stored in M[1][k,j],
     73       while M[1][k+1]=...=M[1][k+m]=0.
     74  M[2] contains the number of branches meeting at p[i,j] (again, the information
     75       is stored according to the above rule)
     76  M[3] contains the information about the splitting of M[1][i,j] with respect to
     77       different tangents of branches at p[i,j] (information is stored only for
     78       minimal j>=k corresponding to a new tangent direction).
     79       The entries are the sum of multiplicities of all branches with the
    8080       respective tangent.
    81   M[4] contains the maximal sum of higher multiplicities for a branch passing 
    82        through p[i,j] ( = degree Bound for blowing up) 
     81  M[4] contains the maximal sum of higher multiplicities for a branch passing
     82       through p[i,j] ( = degree Bound for blowing up)
    8383@end format
    84 NOTE:    the branches are ordered in such a way that only consecutive branches 
     84NOTE:    the branches are ordered in such a way that only consecutive branches
    8585         can meet at an infinitely near point. @*
    86          the final rows of the matrices M[1],...,M[3] is (1,1,1,...,1), and 
    87          correspond to infinitely near points such that the strict transforms 
    88          of the branches are smooth and intersect the exceptional divisor 
     86         the final rows of the matrices M[1],...,M[3] is (1,1,1,...,1), and
     87         correspond to infinitely near points such that the strict transforms
     88         of the branches are smooth and intersect the exceptional divisor
    8989         transversally.
    9090SEE ALSO: multsequence
     
    9696  dummy=0;
    9797  for (j=1;j<=ncols(M[2]);j++)
    98   { 
     98  {
    9999    dummy=dummy+M[1][nrows(M[1])-1,j]-M[1][nrows(M[1]),j];
    100100  }
     
    103103  intmat U[nrows(M[1])+dummy][ncols(M[1])];
    104104  intmat maxDeg[nrows(M[1])+dummy][ncols(M[1])];
    105  
     105
    106106  for (i=1;i<=nrows(M[2]);i++)
    107107  {
     
    110110    {
    111111      for (k=dummy;k<dummy+M[2][i,j];k++)
    112       { 
    113         T[i,dummy]=T[i,dummy]+1; 
    114         S[i,dummy]=S[i,dummy]+M[1][i,k]; 
     112      {
     113        T[i,dummy]=T[i,dummy]+1;
     114        S[i,dummy]=S[i,dummy]+M[1][i,k];
    115115        if (i>1)
    116116        {
     
    127127  {
    128128    for (j=1;j<=ncols(M[2]);j++)
    129     { 
    130       S[i,j]=1; 
    131       T[i,j]=1; 
     129    {
     130      S[i,j]=1;
     131      T[i,j]=1;
    132132      U[i,j]=1;
    133133    }
    134134  }
    135  
     135
    136136  // Computing the degree Bounds to be stored in M[4]:
    137137  for (i=1;i<=nrows(S);i++)
     
    141141    {
    142142      for (k=dummy;k<dummy+T[i,j];k++)
    143       { 
     143      {
    144144        maxDeg[i,k]=S[i,dummy];  // multiplicity at i-th blowup
    145145      }
     
    147147    }
    148148  }
    149   // adding up multiplicities 
    150   for (i=nrows(S);i>=2;i--) 
     149  // adding up multiplicities
     150  for (i=nrows(S);i>=2;i--)
    151151  {
    152152    for (j=1;j<=ncols(S);j++)
     
    155155    }
    156156  }
    157  
     157
    158158  list L=S,T,U,maxDeg;
    159159  return(L);
     
    165165//  returns list: 1) tangent directions
    166166//                2) swapping information (x <--> y)
    167 static proc inf_Tangents(list L,int s); // L aus hnexpansion, 
     167static proc inf_Tangents(list L,int s); // L aus hnexpansion,
    168168{
    169169  int nv=nvars(basering);
     
    178178    V[k]=L[k][3];  // switch: 0 --> tangent 2nd parameter
    179179                   //         1 --> tangent 1st parameter
    180     e=0;   
     180    e=0;
    181181    M=L[k][1];
    182182    counter=1;
    183183    B[counter,k]=M[1,1];
    184    
     184
    185185    for (i=1;i<=nrows(M);i++)
    186186    {
     
    193193          {
    194194            B[counter,k]=M[i,j];
    195             j=ncols(M)+1; // goto new row of HNmatrix... 
     195            j=ncols(M)+1; // goto new row of HNmatrix...
    196196            if (counter<>s)
    197             { 
     197            {
    198198              if (counter+1<=nrows(Mult))
    199199              {
     
    206206            }
    207207          }
    208           else 
     208          else
    209209          {
    210210            B[counter,k]=0;
    211             j=ncols(M)+1; // goto new row of HNmatrix... 
     211            j=ncols(M)+1; // goto new row of HNmatrix...
    212212          }
    213213        }
     
    215215        {
    216216          if (e<=0)
    217           { 
     217          {
    218218            B[counter,k]=M[i,j];
    219219          }
     
    231231          }
    232232        }
    233        
    234         if (counter==s) // given number of points determined 
     233
     234        if (counter==s) // given number of points determined
    235235        {
    236             j=ncols(M)+1; 
     236            j=ncols(M)+1;
    237237            i=nrows(M)+1;
    238238            // leave procedure
     
    247247////////////////////////////////////////////////////////////////////////////////
    248248// compute "good" upper bound for needed number of help variables
    249 // 
     249//
    250250static proc Determine_no_b(intmat U,matrix B)
    251251// U is assumed to be 3rd output of control_Matrix
     
    265265        }
    266266      }
    267      
     267
    268268    }
    269269  }
     
    273273
    274274////////////////////////////////////////////////////////////////////////////////
    275 // compute number of infinitely near free points corresponding to non-zero 
     275// compute number of infinitely near free points corresponding to non-zero
    276276// entries in control_Matrix[1] (except first row)
    277 // 
     277//
    278278static proc no_freePoints(intmat Mult,matrix B)
    279279// Mult is assumed to be 1st output of control_Matrix
     
    330330
    331331///////////////////////////////////////////////////////////////////////////////
    332 // 
     332//
    333333// DEFINES: A new basering, "myRing",
    334334//          with new names for the parameters and variables.
     
    337337//          The ring ordering is ordStr.
    338338// NOTE:    This proc uses 'execute'.
    339 static proc createMyRing_new(poly p_F, string ordStr, 
    340                                 string minPolyStr, int no_b) 
     339static proc createMyRing_new(poly p_F, string ordStr,
     340                                string minPolyStr, int no_b)
    341341{
    342342  def r_old = basering;
     
    393393  export p_F,mIdeal;
    394394
    395   // Extension by no_b auxiliary variables 
     395  // Extension by no_b auxiliary variables
    396396  if (no_b>0)
    397397  {
     
    401401      helpStr = "ring myRing ="
    402402                + string(chara)+ ", (b(1..no_b), t(1..nDefParams), x, y),"
    403                 + ordStr +";"; 
     403                + ordStr +";";
    404404      execute(helpStr);
    405405    }
     
    419419
    420420          helpStr = "minpoly =" + minPolyStr + ";";
    421           execute (helpStr); 
     421          execute (helpStr);
    422422        }
    423423        else // no minpoly given
    424         { 
     424        {
    425425          ordStr = "(dp(" + string(no_b) + ")," + ordStr + ")";
    426426          helpStr = "ring myRing =
     
    441441    }
    442442    ideal qIdeal = imap(myRing1, qIdeal);
    443  
     443
    444444    if(qIdeal != 0)
    445445    {
     
    455455    kill myRing1;
    456456  }
    457   else 
    458   { 
     457  else
     458  {
    459459    if(qIdeal != 0)
    460460    {
     
    471471      def myRing=myRing1;
    472472    }
    473     kill myRing1;   
    474   }
    475  
     473    kill myRing1;
     474  }
     475
    476476  setring r_old;
    477477  return(myRing);
     
    479479
    480480////////////////////////////////////////////////////////////////////////////////
    481 // returns list of coef, leadmonomial 
     481// returns list of coef, leadmonomial
    482482//
    483483static proc determine_coef (poly Fm)
     
    532532  kill myRing1;
    533533  def M=coef(Fm,xy);
    534  
     534
    535535  for (i=1; i<=ncols(M); i++)
    536536  {
     
    578578
    579579////////////////////////////////////////////////////////////////////////////////
    580 static proc make_ring_small(ideal J) 
    581 // returns varstr for new ring, the map and the number of vars 
     580static proc make_ring_small(ideal J)
     581// returns varstr for new ring, the map and the number of vars
    582582{
    583583  attrib(J,"isSB",1);
    584   int counter=0; 
     584  int counter=0;
    585585  ideal newmap;
    586586  string newvar="";
     
    590590    {
    591591      newmap[i]=var(i);
    592      
     592
    593593      if (newvar=="")
    594594      {
    595595        newvar=newvar+string(var(i));
    596         counter=counter+1;       
     596        counter=counter+1;
    597597      }
    598598      else
    599599      {
    600600        newvar=newvar+","+string(var(i));
    601         counter=counter+1;       
    602       }
    603     }
    604     else 
     601        counter=counter+1;
     602      }
     603    }
     604    else
    605605    {
    606606      newmap[i]=0;
    607     } 
     607    }
    608608  }
    609609  list L=newvar,newmap,counter;
     
    626626  int auxVar=1;
    627627  int nVars;
    628  
     628
    629629  intvec upper_bound, upper_bound_old, fertig, soll;
    630630  list blowup_string;
     
    643643    {
    644644      option(set,ov);
    645       return(1); 
     645      return(1);
    646646    }
    647647    else
     
    658658      def artin_bd=#[1];  // compute modulo maxideal(artin_bd)
    659659      if (artin_bd <= 1)
    660       { 
     660      {
    661661        print("Do you really want to compute over Basering/maxideal("
    662662              +string(artin_bd)+") ?");
     
    665665        {
    666666          option(set,ov);
    667           return(1); 
     667          return(1);
    668668        }
    669669        else
     
    674674      }
    675675      if (size(#)>1)
    676       { 
     676      {
    677677        if (typeof(#[2])=="list")
    678678        {
    679679          def @L=#[2];  // is assumed to be the Hamburger-Noether matrix
    680680        }
    681       }     
     681      }
    682682    }
    683683    else
     
    710710    poly f=phi(p_F);
    711711
    712     // Heuristics: if x,y are transversal parameters then computation of HNE 
    713     // can be much faster when exchanging variables...! 
     712    // Heuristics: if x,y are transversal parameters then computation of HNE
     713    // can be much faster when exchanging variables...!
    714714    if (2*size(coeffs(f,x))<size(coeffs(f,y)))
    715715    {
     
    717717      f=swapXY(f);
    718718    }
    719    
     719
    720720    int error=checkPoly(f);
    721721    if (error)
     
    726726        print("Return value (=0) has no meaning!");
    727727        option(set,ov);
    728         return(0); 
     728        return(0);
    729729      }
    730730      else
    731       { 
     731      {
    732732        option(set,ov);
    733733        return(list( ideal(0),error));
    734734      }
    735735    }
    736    
     736
    737737    dbprint(i_print,"// ");
    738738    dbprint(i_print,"// Compute HN expansion");
     
    740740    i=printlevel;
    741741    printlevel=printlevel-5;
    742     list LLL=hnexpansion(f); 
     742    list LLL=hnexpansion(f);
    743743
    744744    if (size(LLL)==0) { // empty list returned by hnexpansion
    745745      setring old_ring;
    746       print(i_print,"Unable to compute HN expansion !");     
     746      print(i_print,"Unable to compute HN expansion !");
    747747      if (typ==1) //isEquising
    748748      {
    749749        print("Return value (=0) has no meaning!");
    750750        option(set,ov);
    751         return(0); 
     751        return(0);
    752752      }
    753753      else
     
    762762    {
    763763      if (typeof(LLL[1])=="ring") {
    764         def HNering = LLL[1]; 
    765         setring HNering; 
     764        def HNering = LLL[1];
     765        setring HNering;
    766766        def @L=stripHNE(hne);
    767767      }
     
    776776  def HNEring=basering;
    777777  list M=multsequence(@L);
    778   M=control_Matrix(M);     // this returns the 4 control matrices 
     778  M=control_Matrix(M);     // this returns the 4 control matrices
    779779  def maxDeg=M[4];
    780780
     
    792792
    793793  // Determine maximal number of needed auxiliary parameters (free tangents):
    794   no_b=Determine_no_b(M[3],B); 
     794  no_b=Determine_no_b(M[3],B);
    795795
    796796  // test whether HNexpansion needed field extension....
     
    817817  number_of_branches=ncols(M[1]);
    818818  for (i=1;i<=number_of_branches;i++)
    819   { 
     819  {
    820820    poly F(i);
    821     ideal bl_Map(i); 
     821    ideal bl_Map(i);
    822822  }
    823823  upper_bound[number_of_branches]=0;
     
    829829  // Hole:  B = matrix of blowup points
    830830  if (ring_is_changed==0) { matrix B=hole(B); }
    831   else                    { matrix B=imap(HNEring,B); } 
     831  else                    { matrix B=imap(HNEring,B); }
    832832  m=M[1][blowup,branch];    // multiplicity at 0
    833    
     833
    834834  // now, we start by checking equimultiplicity along trivial section
    835835  poly Fm=m_Jet(p_F,m-1);