Changeset 6e9d48a in git for Singular/LIB/control.lib


Ignore:
Timestamp:
Apr 3, 2005, 10:31:37 PM (19 years ago)
Author:
Viktor Levandovskyy <levandov@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
Children:
f52515c83a11c2bf5c2744c7a7775df92a8eb725
Parents:
0582696e2e59bf0b8bc20c14d1424a96c802fec2
Message:
*levandov: iostruct and other improvements by Markus added, smith form corrected


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/control.lib

    r058269 r6e9d48a  
    1 version="$Id: control.lib,v 1.26 2005-03-17 18:42:48 levandov Exp $";
     1version="$Id: control.lib,v 1.27 2005-04-03 20:31:37 plural Exp $";
    22category="Applications";
    33info="
     
    1313
    1414PROCEDURES:
    15 control (R);           analysis of controllability-related properties of R (using Ext modules),
    16 control2 (R);          analysis of controllability-related properties of R (using dimension),
    17 autonom (R);           analysis of autonomy-related properties of R (using Ext modules),
    18 autonom2 (R);          analysis of autonomy-related properties of R (using dimension),
    19 LeftKernel (R);        a left kernel of R,
    20 RightKernel (R);       a right kernel of R,
    21 LeftInverse (R);       a left inverse of R,
    22 RightInverse (R);      a right inverse of R,
    23 smith (M);             a Smith form of a module M,
    24 rank (M);              a column rank of M as of matrix,
    25 genericity (M);        analysis of the genericity of parameters,
    26 canonize (L);          Groebnerification for modules in the output of control/autonomy procs,
    27 FindTorsion (R, I);    generators of the submodule of a module R, annihilated by the ideal I.
     15control (R);            analysis of controllability-related properties of R (using Ext modules),
     16control2 (R);           analysis of controllability-related properties of R (using dimension),
     17autonom (R);            analysis of autonomy-related properties of R (using Ext modules),
     18autonom2 (R);           analysis of autonomy-related properties of R (using dimension),
     19LeftKernel (R);         a left kernel of R,
     20RightKernel (R);        a right kernel of R,
     21LeftInverse (R);        a left inverse of R,
     22RightInverse (R);       a right inverse of R,
     23smith (M);              a Smith form of a module M,
     24colrank (M);            a column rank of M as of matrix,
     25genericity (M);         analysis of the genericity of parameters,
     26canonize (L);           Groebnerification for modules in the output of control/autonomy procs,
     27iostruct (R);           computes an I/O-structure of behavior given by a module R
     28FindTorsion (R, I);     generators of the submodule of a module R, annihilated by the ideal I.
    2829
    2930
     
    6061// static control_output();      Generating the output for the procedure 'control'
    6162// static autonom_output();      Generating the output for the procedure 'autonom' and 'autonom2'
     63// static extgcd_Our(poly p, poly q)  Computes extgcd of p and q. for versions ealier than 2006 extgcd has a bug and is therefore not used
     64// static normalize_Our(matrix N, matrix Q) normalizes the columns of N and divides the columns of Q through the leading coefficients of the columns of N
    6265
    6366LIB "homolog.lib";
     
    539542"
    540543{
    541   if( nrows(R) != rank(transpose(R)) )
     544  if( nrows(R) != colrank(transpose(R)) )
    542545  {
    543546    return ("control2 cannot be applied, since R does not have full row rank");
    544547  } 
    545   intvec v=option(get);
     548  intvec v=Opt_Our();
    546549  module R_std=std(R);
    547550  int d=dim_Our(R_std);
    548551  int NVars=nvars(basering);
    549552  int i=NVars-d;
    550   module Ext_1;
    551 
    552   if(i==1)
    553     {
    554       Ext_1=std(Ext_Our(1,R_std));
    555     }
     553  module Ext_1=std(Ext_Our(1,R_std));
    556554  matrix T=lift(R,R_std);
    557555  list l=genericity(T);
     
    572570};
    573571//------------------------------------------------------------------------
    574 proc rank(module M)
    575 "USAGE: proc rank(M), M a matrix/module
     572proc colrank(module M)
     573"USAGE: proc colrank(M), M a matrix/module
    576574PURPOSE: compute the column rank of M as of matrix
    577575RETURN: int
    578 NOTE: this procedure uses bareiss-algorithm which might not terminate
     576NOTE: this procedure uses bareiss-algorithm which might not terminate in some cases
    579577"
    580578{
     
    592590    [-D(2),D(1),0];
    593591  R=transpose(R);
    594   rank(R);
     592  colrank(R);
    595593};
    596594 
     
    602600           NVars:  integer, number of variables in a base ring 
    603601           RC: module, kernel-representation of controllable part of the system
    604            R_rank: integer, rank of the representation matrix
     602           R_rank: integer, column rank of the representation matrix
    605603PURPOSE: compute all the autonomy properties of the system which is to be returned in 'autonom' procedure
    606604RETURN:  list
     
    618616                   "kernel representation for controllable part",
    619617                   RC,
    620                    "column-rank of the matrix",
     618                   "column rank of the matrix",
    621619                   R_rank,
    622620                   DofS,
     
    692690    {
    693691      RC=LeftKernel(RightKernel(R));
    694       R_rank=rank(R);
     692      R_rank=colrank(R);
    695693    }
    696694  return( autonom_output(i,NVars,RC,R_rank) );
     
    731729  {
    732730    RC=LeftKernel(RightKernel(R));
    733     R_rank=rank(R);
     731    R_rank=colrank(R);
    734732  }
    735733  return(autonom_output(i,NVars,RC,R_rank));
     
    11431141  view(CC);
    11441142}
     1143
     1144//----------------------------------------------------------------
     1145
     1146static proc elementof (int i, intvec v)
     1147{
     1148  int b=0;
     1149  for(int j=1;j<=nrows(v);j++)
     1150    {
     1151      if(v[j]==i)
     1152        {
     1153          b=1;
     1154          return (b);
     1155        }
     1156    }
     1157  return (b);
     1158}
     1159//-----------------------------------------------------------------
     1160proc iostruct(module R)
     1161"USAGE: iostruct( R ); R a module
     1162RETURN:  list L with entries: string s, intvec v, module P and module Q
     1163PURPOSE:  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
     1164NOTE:  the procedure uses Bareiss algorithm which might not terminate in some cases
     1165EXAMPLE:  example iostruct; shows an example
     1166"
     1167{
     1168  list L = bareiss(R);
     1169  int R_rank = ncols(L[1]);
     1170  int NCols=ncols(R);
     1171  intvec v=L[2];
     1172  int temp;
     1173  int NRows=nrows(v);
     1174  int i,j;
     1175  int b=1;
     1176  module P;
     1177  module Q;
     1178  int n=0;
     1179 
     1180  while(b==1)               //sort v through bubblesort
     1181    {
     1182      b=0;
     1183      for(i=1;i<NRows;i++)
     1184        {
     1185          if(v[i]>v[i+1])
     1186          {
     1187            temp=v[i];
     1188            v[i]=v[i+1];
     1189            v[i+1]=temp;
     1190            b=1;
     1191          }
     1192        }
     1193    }
     1194  P=R[v];                     //generate P
     1195  for(i=1;i<=NCols;i++)       //generate Q
     1196    {
     1197      if(elementof(i,v)==1)
     1198        {
     1199          i++;
     1200          continue;
     1201        }
     1202      Q=Q,R[i];
     1203    }
     1204  Q=simplify(Q,2);
     1205  string s="The following components have been chosen as outputs: ";
     1206  return (list(s,v,P,Q));
     1207}
     1208example
     1209{"EXAMPLE:";echo = 2;
     1210 //Example Antenna
     1211 ring r = (0, K1, K2, Te, Kp, Kc),(Dt, delta), (c,dp);
     1212 
     1213 module RR;
     1214 RR = [Dt, -K1, 0, 0, 0, 0, 0, 0, 0],
     1215   [0, Dt+K2/Te, 0, 0, 0, 0, -Kp/Te*delta, -Kc/Te*delta, -Kc/Te*delta],
     1216   [0, 0, Dt, -K1, 0, 0, 0, 0, 0],
     1217   [0, 0, 0, Dt+K2/Te, 0, 0, -Kc/Te*delta, -Kp/Te*delta, -Kc/Te*delta],
     1218   [0, 0, 0, 0, Dt, -K1, 0, 0, 0],
     1219   [0, 0, 0, 0, 0, Dt+K2/Te, -Kc/Te*delta, -Kc/Te*delta, -Kp/Te*delta];
     1220 module R = transpose(RR);
     1221 view(R);
     1222 view(iostruct(R));
     1223};     
     1224
    11451225//---------------------------------------------------------------
    11461226static proc smdeg(matrix N) 
     
    12181298}
    12191299//---------------------------------------------------------------
    1220 static proc Our_extgcd(poly p, poly q)
     1300static proc extgcd_Our(poly p, poly q)
    12211301{
    12221302  ideal J;   //for extgcd-computations
     
    12481328  return(L);
    12491329}
     1330static proc normalize_Our(matrix N, matrix Q)
     1331"USAGE: normalize_Our(N,Q), N, Q are two matrices
     1332PURPOSE: normalizes N and divides the columns of Q through the leading coefficients of the columns of N
     1333RETURN: 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
     1334NOTE: number of columns of N and Q must coincide.
     1335"
     1336{
     1337  if(ncols(N) != ncols(Q))
     1338    {
     1339      return (N,Q);
     1340    }   
     1341  module M = module(N);
     1342  module S = module(Q);
     1343  int NCols = ncols(N);
     1344  number n;
     1345  for(int i=1;i<=NCols;i++)
     1346    {
     1347      n = leadcoef(M[i]);
     1348      if( n != 0 )
     1349        {
     1350          M[i]=M[i]/n;
     1351          S[i]=S[i]/n;
     1352        }
     1353     }
     1354   N = matrix(M);
     1355   Q = matrix(S);
     1356   return (N,Q);
     1357}               
     1358       
    12501359//---------------------------------------------------------------
    12511360proc smith( module M )
     
    12571366@*      [3]: a unimodular matrix U,
    12581367@*      [4]: a unimodular matrix V,
    1259 such that U*M*V=S. An empty list is returned when no Smith Form exists.
    1260 NOTE: The Smith form only exists over PIDs (principal ideal domains).
     1368such that U*M*V=S. An warning is returned when no Smith Form exists.
     1369NOTE: The Smith form only exists over PIDs (principal ideal domains). Use global ordering for computations!
    12611370"
    12621371{
    12631372  if (nvars(basering)>1) //if more than one variable, return empty list
    12641373  {
    1265     list @L;
    1266     return (@L);
     1374    string s="The Smith-Form only exists for principal ideal domains";
     1375    return (s);
    12671376  }
    12681377  matrix N = matrix(M);         //Typecasting
     
    13211430        for(ii=k+1;ii<=n;ii++)
    13221431        {
    1323           N = addrow(N,k,-lambda[1,ii]*var(1)^f[1,ii],ii);
    1324           N = normalize(N);
     1432          N = addrow(N,k,-lambda[1,ii]*var(1)^f[1,ii],ii);               
    13251433          P = addrow(P,k,-lambda[1,ii]*var(1)^f[1,ii],ii);
     1434          N,Q=normalize_Our(N,Q);
    13261435        }
    13271436      }
     
    13451454      {
    13461455        N=addcol(N,k,-mu[1,ii]*var(1)^g[1,ii],ii);
    1347         N=normalize(N);
    13481456        Q=addcol(Q,k,-mu[1,ii]*var(1)^g[1,ii],ii);
     1457        N,Q=normalize_Our(N,Q);
    13491458      }
    13501459    }
    13511460    if( (k!=1) && (k<n) && (k<m) )
    13521461    {
    1353       L = Our_extgcd(N[k-1,k-1],N[k,k]);     
     1462      L = extgcd_Our(N[k-1,k-1],N[k,k]);     
    13541463      if ( N[k-1,k-1]!=L[1] )  //means that N[k-1,k-1] is not a divisor of N[k,k]
    13551464      {
    13561465        N=addrow(N,k-1,L[2],k);
    1357         normalize(N);
    13581466        P=addrow(P,k-1,L[2],k);
     1467        N,Q=normalize_Our(N,Q);
    13591468       
    1360         N=addcol(N,k,-L[3],k-1);
    1361         N=normalize(N);
     1469        N=addcol(N,k,-L[3],k-1);
    13621470        Q=addcol(Q,k,-L[3],k-1);
     1471        N,Q=normalize_Our(N,Q);
    13631472        k=k-2;
    13641473      }
     
    13871496  matrix N=matrix(M);
    13881497  matrix B=L[3]*N*L[4];
    1389   B=normalize(std(B));
    13901498  print(B);
    13911499  //------- and yet another example --------------
     
    13961504  matrix N2=matrix(M2);
    13971505  matrix B2=P[3]*N2*P[4];
    1398   print(B2);
    1399   B2=normalize(std(B2));
    14001506  print(B2);
    14011507}
     
    14771583"USAGE:  FindTorsion(R, I);   R an ideal/matrix/module, I an ideal
    14781584PURPOSE: computes the Groebner basis of the submodule of R, annihilated by I
    1479 RETURN:  module
     1585ETURN:  module
    14801586NOTE: especially helpful, when I is the annihilator of the t(R) - the torsion submodule of R. In this case, the result is the explicit presentation of t(R) as
    14811587the submodule of R
Note: See TracChangeset for help on using the changeset viewer.