Changeset d5f9d98 in git


Ignore:
Timestamp:
Feb 25, 2005, 11:45:27 AM (19 years ago)
Author:
Viktor Levandovskyy <levandov@…>
Branches:
(u'spielwiese', 'ec94ef7a30b928574c0c3daf41f6804dff5f6b69')
Children:
dc6b576eab156ea960b83a3ed8a822d14adab0b7
Parents:
cbea7991f06987b6fda55b7d0836fa40b140110d
Message:
*levandov: docu rewritten, tex functions by Markus added, revised examples, RightInverse etc


git-svn-id: file:///usr/local/Singular/svn/trunk@7765 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/control.lib

    rcbea799 rd5f9d98  
    1 version="$Id: control.lib,v 1.21 2005-02-18 17:38:45 levandov Exp $";
     1version="$Id: control.lib,v 1.22 2005-02-25 10:45:27 levandov Exp $";
    22category="Applications";
    33info="
     
    1313
    1414PROCEDURES:
    15 control(module R);            analysis of controllability-related properties of R,
    16 autonom(module R);            analysis of autonomy-related properties of R (using Ext modules),
    17 autonom2(module R);           analysis of autonomy-related properties of R (using dimension),
    18 
    19 LeftKernel(module R);         a left kernel of R,
    20 RightKernel(module R);        a right kernel of R,
    21 LeftInverse(module R)         a left inverse of matrix (module),
    22 
    23 smith(module M);              a Smith form of a module M,
    24 
    25 genericity(module M);         analysis of the genericity of parameters,
    26 
    27 canonize(list L);             Groebnerification for modules in the output of control/autonomy procs.
     15control  (R);           analysis of controllability-related properties of R,
     16autonom  (R);           analysis of autonomy-related properties of R (using Ext modules),
     17autonom2 (R);           analysis of autonomy-related properties of R (using dimension),
     18LeftKernel  (R);        a left kernel of R,
     19RightKernel (R);        a right kernel of R,
     20LeftInverse (R)         a left inverse of R,
     21smith (M);              a Smith form of a module M,
     22genericity (M);         analysis of the genericity of parameters,
     23canonize (L);           Groebnerification for modules in the output of control/autonomy procs.
    2824
    2925AUXILIARY PROCEDURES:
    30 declare(string NameOfRing, Variables[,string  Parameters, Ordering]);     defines the ring, optional parametes are strings of parameters and ordering,
    31 view();                      Well-formatted output of lists, modules and matrices
     26declare(NameOfRing,Variables [,Parameters, Ordering]);    define the ring easily
     27view();                      well-formatted output of lists, modules and matrices
    3228
    3329NOTE (EXAMPLES): In order to use examples below, execute the commands
    3430@* def A = exAntenna(); setring A;
    35 @* Thus A will become a basering from the example with the predefined module R (transposed), corresponding to the system.
    36 After that you can just type in
     31@* Thus A will become a basering from the example with the predefined module R (transposed), corresponding to the system. After that you can just type in
    3732@* control(R); //respectively autonom(R);
    3833and check the result.
     
    4035
    4136EXAMPLES (AUTONOMY):
    42 
    4337exCauchy();                  example of 1-dimensional Cauchy equation,
    4438exCauchy2();                 example of 2-dimensional Cauchy equation,
     
    4640
    4741EXAMPLES (CONTROLLABILITY):
    48 
    4942ex1();                       example of noncontrollable system,   
    5043ex2();                       example of controllable system ,
     
    5245exEinstein();                Einstein equations,
    5346exFlexibleRod();             Flexible Rod,
    54 exTwoPendula();              Two Pendula,
     47exTwoPendula();              Two Pendula mounted on a cart,
    5548exWindTunnel();              Wind Tunnel.
    5649";
     
    8881proc declare(string NameOfRing, string Variables, list #)
    8982"USAGE: declare(NameOfRing, Variables,[Parameters, Ordering]);
    90           NameOfRing:  string with name of ring,
    91           Variables:   string with names of variables separated by commas(e.g. "x,y,z"),
    92           [Parameters, Ordering]: optional, strings:
    93             Parameters: string of parameters in the ring separated by commas(e.g. "a,b,c"),
    94             Ordering:   string with name of ordering(by default the ordering "dp,C" is used)
     83@*          NameOfRing:  string with name of ring,
     84@*          Variables:   string with names of variables separated by commas(e.g. \"x,y,z\"),
     85@*          Parameters: string of parameters in the ring separated by commas(e.g. \"a,b,c\"),
     86@*          Ordering:   string with name of ordering (by default, the ordering \"dp,C\" is used)
     87PURPOSE: define the ring easily
    9588RETURN:  no return value
    9689EXAMPLE:  example declare; shows an example
     
    183176"
    184177{
     178  // to be replaced with something more feasible
    185179  if ( (typeof(M)=="module")||(typeof(M)=="matrix") )
    186180  {
     
    254248proc RightKernel(matrix M)
    255249"USAGE:  RightKernel(M);   M a matrix
    256 RETURN:  right kernel of matrix M, i.e., the module of all elements v such that Mv=0
     250PURPOSE: computes the right kernel of matrix M (a module of all elements v such that Mv=0)
     251RETURN:  module
    257252NOTE:    in the noncommutative case RightKernel is a right module
    258 EXAMPLE:  example RightKernel; shows an example
     253EXAMPLE: example RightKernel; shows an example
    259254"
    260255{
     
    274269proc LeftKernel(matrix M)
    275270"USAGE:  LeftKernel(M);   M a matrix
    276 RETURN:  left kernel of matrix M, i.e. the module of all elements v such that vM=0
     271PURPOSE: computes left kernel of matrix M (a module of all elements v such that vM=0)
     272RETURN:  module
    277273EXAMPLE:  example LeftKernel; shows an example
    278274"
     
    293289proc LeftInverse(module M)
    294290"USAGE:  LeftInverse(M);  M a module
    295 RETURN:  matrix L such that LM == Id;
     291PURPOSE: computes such a matrix L, that LM == Id;
     292RETURN:  module
    296293EXAMPLE: example LeftInverse; shows an example
    297294NOTE: exists only in the case when Id \subseteq M!
     
    350347//-----------------------------------------------------------------------
    351348proc RightInverse(module R)
     349"USAGE:  RightInverse(M);  M a module
     350PURPOSE: computes such a matrix L, that ML == Id;
     351RETURN:  module
     352EXAMPLE: example RightInverse; shows an example
     353NOTE: exists only in the case when Id \subseteq M!
     354"
    352355{
    353356  return(transpose(LeftInverse(transpose(R))));
    354357}
     358example
     359{ // trivial example:
     360"EXAMPLE:";echo =2;
     361  ring r = 0,(x,z),dp;
     362  matrix M[1][2] = 1,x2+z;
     363  print(M);
     364  print( RightInverse(M) ); 
     365  kill r;
     366  // derived from the exTwoPendula
     367  ring r=(0,m1,m2,M,g,L1,L2),Dt,dp;
     368  matrix U[1][3];
     369  U[1,1]=(-L2)*Dt^4+(g)*Dt^2;
     370  U[1,2]=(-L1)*Dt^4+(g)*Dt^2;
     371  U[1,3]=(L1*L2)*Dt^4+(-g*L1-g*L2)*Dt^2+(g^2);
     372  module M = module(U);
     373  module L = RightInverse(M);
     374  print(L);
     375};
    355376//-----------------------------------------------------------------------
    356377static proc dim_Our(module R)
     
    420441"USAGE:  control_output(i, NVars, R, Ext_1), where
    421442           i:  integer, number of first nonzero Ext or
    422                just number of variables in a base ring + 1 in case that all the Exts are zero,
     443             just a number of variables in a base ring + 1 in case that all the Exts are zero,
    423444           NVars:  integer, number of variables in a base ring,
    424445           R:  module R (cokernel representation),
     
    503524
    504525proc control(module R)
    505 "USAGE:  control(R); R a module (R is the matrix of the system of equations which is to be investigated)
    506 RETURN:  list of all the properties concerning controllability of the system (behavior) represented by the  matrix R
     526"USAGE:  control(R);  R a module (R is the matrix of the system of equations to be investigated)
     527PURPOSE: compute the list of all the properties concerning controllability of the system (behavior), represented by the matrix R
     528RETURN:  list
    507529EXAMPLE:  example control; shows an example
    508530"
     
    546568//------------------------------------------------------------------------------------------
    547569proc control2(module R)
    548 "USAGE:  control2(R); R a module (R is the matrix of the system of equations which is to be investigated)
    549 RETURN:  list of all the properties concerning controllability of the system (behavior) represented by the  matrix R
     570"USAGE:  control2(R); R a module (R is the matrix of the system of equations to be investigated)
     571PURPOSE: computes list of all the properties concerning controllability of the system (behavior), represented by the  matrix R
     572RETURN: list
    550573EXAMPLE:  example control; shows an example
    551574NOTE: same as control(R); but using dimensions
     
    657680proc autonom2(module R)
    658681"USAGE:  autonom2(R);   R a module (R is a matrix of the system of equations which is to be investigated)
    659 RETURN:  list of all the properties concerning autonomy of the system (behavior) represented by the matrix R
    660 NOTE:  this procedure is an analogue to 'autonom' using dimension calculations
     682PURPOSE: computes the list of all the properties concerning autonomy of the system (behavior), represented by the matrix R
     683RETURN: list
     684NOTE:  this procedure is analogous to 'autonom' but uses dimension calculations
    661685EXAMPLE:  example autonom2; shows an example
    662686"
     
    872896proc genericity(matrix M)
    873897"USAGE:  genericity(M), M is a module/matrix
    874 RETURN:  list of strings with expressions, which have been assumed to be non-zero in the process of computing the Groebner basis
     898PURPOSE: determine parametric expressions which have been assumed to be non-zero in the process of computing the Groebner basis
     899RETURN:  list (of strings)
    875900NOTE: we strongly recommend to switch on the redSB and redTail options;
    876 the procedure is effective with the lift procedure for modules with parameters
     901@*    the procedure is effective with the lift procedure for modules with parameters
    877902EXAMPLE:  example genericity; shows an example
    878903"
    879904{
     905  // returns nothing, if there are no parameters!
     906  if (npars(basering)==0)
     907  {
     908    return("");
     909  }
     910  int plevel = printlevel-voice+2;
    880911  // M is a matrix over a ring with params and vars;
    881912  ideal I = ideal(M); // a list of entries
     
    890921  intvec ZeroVec; ZeroVec[nvars(basering)] = 0;
    891922  intvec W;
     923  ideal Numero, Denomiro;
     924  int cNu=0; int cDe=0;
    892925  for (i=1; i<=s; i++)
    893926  {
     
    898931    {
    899932      num    = denominator(leadcoef(p)); // from poly.lib
    900       p      = p*num;
    901       NM[cl] = p;
     933      NM[cl] = numerator(leadcoef(p));
     934      dbprint(p,"numerator:");
     935      dbprint(p, string(NM[cl]));
     936      cNu++; Numero[cNu]= NM[cl];
    902937      cl++;
    903       NM[cl] = num;
     938      NM[cl] = num; // denominator
     939      dbprint(p,"denominator:");
     940      dbprint(p, string(NM[cl]));
     941      cDe++; Denomiro[cDe]= NM[cl];
    904942      cl++;
    905943      p = p - lead(p); // for the next cycle
     
    910948      p   = p/num;
    911949      NM[cl] = denominator(num);
     950      dbprint(p,"content denominator:");
     951      dbprint(p, string(NM[cl]));
     952      cNu++; Numero[cNu]= NM[cl];
    912953      cl++;
    913954      NM[cl] = numerator(num);
     955      dbprint(p,"content numerator:");
     956      dbprint(p, string(NM[cl]));
     957      cDe++; Denomiro[cDe]= NM[cl];
    914958      cl++;
    915959    }
     960    // it seems that the next elements will not have real influence
    916961    while( p != 0)
    917962    {
    918       NM[cl] = leadcoef(p); // should be all integer
     963      NM[cl] = leadcoef(p); // should be all integer, i.e. non-rational
     964      dbprint(p,"coef:");
     965      dbprint(p, string(NM[cl]));
    919966      cl++;
    920967      p = p - lead(p);
     
    944991      cf = 1;
    945992      // factorize every polynomial
    946       // throw away every non-monomial
     993      // throw away every monomial from factorization (also constants from above ring)
    947994      for (j=1; j<=size(F);j++)
    948995      {
     
    9571004  }
    9581005  // return the result [in string-format]
    959   @L = simplify(@L,2+4); // skip zeroes and double entries
     1006  @L = simplify(@L,2+4+8); // skip zeroes, doubled and entries, diff. by a constant
    9601007  list SL;
    9611008  for (j=1; j<=size(@L);j++)
     
    9891036proc canonize(list L)
    9901037"USAGE:  canonize(L), L a list
     1038PURPOSE: modules in the list are canonized by computing their reduced minimal (= unique in the given ordering) Groebner bases
     1039RETURN:  list
    9911040ASSUME:  L is the output of control/autonomy procedures
    992 RETURN:  a canonized list, where modules are canonized by computing
    993 their reduced minimal (= unique in the given ordering) Groebner bases
    9941041EXAMPLE:  example canonize; shows an example
    9951042"
     
    10831130  }
    10841131}
    1085 
     1132//---------------------------------------------------------------
    10861133static proc NoNon0Pol(vector v)
    10871134// returns 1, if there is only one non-zero element in v and 0 else
     
    11021149  return(i);
    11031150}
    1104 
    1105 
     1151//---------------------------------------------------------------
    11061152proc smith( module M )
    11071153"USAGE: smith(M), M a module or a matrix,
     1154PURPOSE: computes the Smith form of a matrix
    11081155RETURN: a list of length 4 with the following entries:
    1109 [1]: The Smith-Form S of M,
    1110 [2]: the rank of M,
    1111 [3]: a unimodular matrix U,
    1112 [4]: a unimodular matrix V,
     1156@*      [1]: The Smith-Form S of M,
     1157@*      [2]: the rank of M,
     1158@*      [3]: a unimodular matrix U,
     1159@*      [4]: a unimodular matrix V,
    11131160such that U*M*V=S. An empty list is returned when no Smith Form exists.
    11141161NOTE: The Smith form only exists over PIDs (principal ideal domains).
     
    12561303  print(B2);
    12571304}
     1305//---------------------------------------------------------------
     1306proc list_tex(list L, string name, link l)
     1307"USAGE: control_tex(l), where l is a list
     1308PURPOSE:        writes the content of list L in a tex-file 'name'
     1309RETURN: nothing
     1310"
     1311{
     1312  if(size(L)==0)
     1313    {
     1314    }
     1315  else
     1316    {
     1317      string t;
     1318      for (int i=1;i<=size(L);i++)
     1319        {
     1320          while(1)
     1321            {
     1322              if(typeof(L[i])=="string")
     1323                {
     1324                  t=L[i];
     1325                  write(l,t,"\\par");
     1326                  break;
     1327                }
     1328              if(typeof(L[i])=="module")
     1329                {
     1330                  texobj(s,matrix(L[i]));
     1331                  break;
     1332                }
     1333              texobj(s,L[i]);
     1334              write(l,"\\par");
     1335              break;
     1336            }
     1337        }
     1338    }
     1339}
     1340//---------------------------------------------------------------
     1341proc verbatim_tex(string s, link l)
     1342"USAGE: verbatim_tex(s,l), where s is a string and l a link
     1343PURPOSE: writes the content of s in verbatim-environment in the file
     1344         specified by link
     1345RETURN: nothing
     1346"
     1347{
     1348  write(l,"\\begin{verbatim}");
     1349  write(l,s);
     1350  write(l,"\\end{verbatim}");
     1351  write(l,"\\par");
     1352}
Note: See TracChangeset for help on using the changeset viewer.