Changeset dd08428 in git for Singular/LIB


Ignore:
Timestamp:
Dec 23, 1998, 2:13:09 PM (25 years ago)
Author:
Mathias Schulze <mschulze@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
66968388c61cc598cbf981f8917ef5bfcc506cfa
Parents:
7614f91f1e407b440f3a529647a08b4309a850e6
Message:
*mschulze: added procedure to compute the tranformation matrix to jordan normal form


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/jordan.lib

    r7614f91 rdd08428  
    11///////////////////////////////////////////////////////////////////////////////
    22
    3 version="$Id: jordan.lib,v 1.1 1998-12-21 16:21:05 mschulze Exp $";
     3version="$Id: jordan.lib,v 1.2 1998-12-23 13:13:09 mschulze Exp $";
    44info="
    5 LIBRARY: jordan.lib  A PROCEDURE TO COMPUTE THE JORDAN NORMAL FORM
     5LIBRARY: jordan.lib  PROCEDURES TO COMPUTE THE JORDAN NORMAL FORM
    66                     by Mathias Schulze
    77                     email: mschulze@mathematik.uni-kl.de
    88
    9  jordan(M);          jordan normal form of the constant part of the matrix M
     9 jordandata(M);      data of the jordan normal form of the constant part
     10                     of the matrix M
     11 jordanmatrix(d);    jordan matrix defined by the data d
     12 jordanform(M);      jordan normal form of the constant part of the matrix M
     13 jordanbasis(M);     basis with respect to which the constant part
     14                     of the matrix M is in jordan normal form
    1015";
    1116
     
    1318///////////////////////////////////////////////////////////////////////////////
    1419
    15 proc jordan(matrix M,list #)
    16 INPUT:   matrix M[, int i]
    17 ASSUME:  M square matrix with factorizable characteristic polynomial
     20proc jordandata(matrix M)
     21INPUT:   square matrix M with factorizable characteristic polynomial
     22         of the constant part M0
    1823OUTPUT:  nothing, if the assumptions are not fulfilled, else,
    19          if i==1,
    20            a list with first entry an ideal containing the eigenvalues
    21            of the constant part of M and second entry a list of decreasingly
    22            ordered int vectors containing the sizes of the corresponding
    23            jordan blocks,
    24          else,
    25            a jordan matrix of the constant part of M
    26 EXAMPLE: example jordan; shows an example
     24         a list with first entry an ideal containing the eigenvalues of M0
     25         in increasing order and second entry a list of increasingly ordered
     26         int vectors containing the corresponding jordan block sizes
     27EXAMPLE: example jordandata; shows an example
    2728{
    2829  int n=nrows(M);
     
    6162  kill pr;
    6263
    63   int j,k,l,m;
     64  int j;
     65  poly e;
     66  int m;
     67  for(i=size(eM);i>=2;i--)
     68  {
     69    for(j=i-1;j>=1;j--)
     70    {
     71      if(eM[i]<eM[j])
     72      {
     73        e=eM[i];
     74        eM[i]=eM[j];
     75        eM[j]=e;
     76        m=mM[i];
     77        mM[i]=mM[j];
     78        mM[j]=m;
     79      }
     80    }
     81  }
     82  kill e,m;
     83
     84  int k,l,m;
    6485  intvec bMi;
    6586  list bM;
     
    7394    m=k;
    7495    bMi=0;
     96    bMi[m]=0;
    7597    for(j=k;j>=1;j--)
    7698    {
     
    81103      Mj=Mj*Mi;
    82104      k=ncols(syz(Mj));
    83       for(l=k-m;l>=1;l--)
     105      for(l=size(bMi);l>size(bMi)+m-k;l--)
    84106      {
    85107        bMi[l]=bMi[l]+1;
     
    90112  }
    91113
    92   if(size(#)>0)
    93   {
    94     if(#[1]==1)
    95     {
    96       return(list(eM,bM));
    97     }
    98   }
    99 
    100   for(i,l,M=size(eM),1,0;i>=1;i--)
     114  return(list(eM,bM));
     115}
     116example
     117{
     118  "EXAMPLE:";
     119  echo=2;
     120  LIB "random.lib";
     121  ring r;
     122  list d=ideal(2,3),list(intvec(1,1,2,2,2),intvec(3,4,5));
     123  matrix M=jordanmatrix(d);
     124  print(M);
     125  int n=nrows(M);
     126  matrix U;
     127  while(det(U)==0)
     128  {
     129    U=randommat(n,n,ideal(1));
     130  }
     131  matrix invU=lift(U,freemodule(n));
     132  M=invU*M*U;
     133  print(M);
     134  jordandata(M);
     135}
     136///////////////////////////////////////////////////////////////////////////////
     137
     138proc jordanmatrix(list d)
     139INPUT:   list d
     140ASSUME:  first entry of d an ideal containing numbers and second entry of d
     141         a list of same length containing int vectors with positive entries
     142OUTPUT:  a jordan matrix with eigenvalues from the first entry of d
     143         and jordan block sizes from the second entry of d
     144EXAMPLE: example jordanmatrix; shows an example
     145{
     146  def eM,bM=d[1..2];
     147
     148  int i,j,n;
     149  for(i=size(bM);i>=1;i--)
    101150  {
    102151    for(j=size(bM[i]);j>=1;j--)
     152    {
     153      n=n+bM[i][j];
     154    }
     155  }
     156  matrix M[n][n];
     157
     158  int k,l;
     159  for(i,l,M=1,1,0;i<=size(eM);i++)
     160  {
     161    for(j=1;j<=size(bM[i]);j++)
    103162    {
    104163      for(k=bM[i][j];k>=2;k,l=k-1,l+1)
     
    119178  echo=2;
    120179  ring r;
     180  list d=ideal(2,3),list(intvec(1,1,2,2,2),intvec(3,4,5));
     181  d;
     182  print(jordanmatrix(d));
     183}
     184///////////////////////////////////////////////////////////////////////////////
     185
     186proc jordanform(matrix M)
     187INPUT:   square matrix M with factorizable characteristic polynomial
     188         of the constant part M0
     189OUTPUT:  nothing, if the assumptions are not fulfilled, else,
     190         a jordan matrix of M0
     191EXAMPLE: example jordanform; shows an example
     192{
     193  return(jordanmatrix(jordandata(M)));
     194}
     195example
     196{
     197  "EXAMPLE:";
     198  echo=2;
     199  LIB "random.lib";
     200  ring r;
     201  list d=ideal(2,3),list(intvec(1,1,2,2,2),intvec(3,4,5));
     202  matrix M=jordanmatrix(d);
     203  print(M);
     204  int n=nrows(M);
     205  matrix U;
     206  while(det(U)==0)
     207  {
     208    U=randommat(n,n,ideal(1));
     209  }
     210  matrix invU=lift(U,freemodule(n));
     211  M=invU*M*U;
     212  print(M);
     213  print(jordanform(M));
     214}
     215///////////////////////////////////////////////////////////////////////////////
     216
     217proc jordanbasis(matrix M)
     218INPUT:   square matrix M with factorizable characteristic polynomial
     219         of the constant part M0
     220OUTPUT:  nothing, if the assumptions are not fulfilled, else,
     221         a module containing a basis with respect to which M0 is in
     222         jordan normal form
     223EXAMPLE: example jordanbasis; shows an example
     224{
     225  int n=nrows(M);
     226  if(n!=ncols(M))
     227  {
     228    "//no square matrix";
     229    return();
     230  }
     231
     232  def br=basering;
     233  map zero=br,0;
     234  M=zero(M);
     235
     236  changeord("pr","dp");
     237  matrix M=imap(br,M);
     238
     239  list l=factorize(det(M-var(1)*freemodule(n)),2);
     240  def eM,mM=l[1..2];
     241
    121242  int i;
    122   matrix M[10][10];
    123   for(i=1;i<=4;i++) {M[i,i]=2;}
    124   for(i=1;i<=3;i++) {M[i,i+1]=1;}
    125   for(i=5;i<=10;i++) {M[i,i]=3;}
    126   for(i=5;i<=6;i++) {M[i,i+1]=1;}
    127   for(i=8;i<=8;i++) {M[i,i+1]=1;}
    128   print(M);
    129   jordan(M,1);
    130   print(jordan(M));
    131 }
    132 ///////////////////////////////////////////////////////////////////////////////
     243  for(i=size(eM);i>=1;i--)
     244  {
     245    if(deg(eM[i])>1)
     246    {
     247      kill pr;
     248      "//unable to factorize characteristic polynomial";
     249      return();
     250    }
     251  }
     252
     253  map inv=pr,-var(1);
     254  eM=simplify(inv(eM),1);
     255  setring br;
     256  map zero=pr,0;
     257  ideal eM=zero(eM);
     258  kill pr;
     259
     260  int j;
     261  poly e;
     262  int m;
     263  for(i=size(eM);i>=2;i--)
     264  {
     265    for(j=i-1;j>=1;j--)
     266    {
     267      if(eM[i]<eM[j])
     268      {
     269        e=eM[i];
     270        eM[i]=eM[j];
     271        eM[j]=e;
     272        m=mM[i];
     273        mM[i]=mM[j];
     274        mM[j]=m;
     275      }
     276    }
     277  }
     278  kill e,m;
     279
     280  int k,l;
     281  matrix Mi,Ni;
     282  matrix E=freemodule(n);
     283  module V,K1,K2,sNi;
     284  matrix v[n][1];
     285  list K;
     286  for(i=ncols(eM);i>=1;i--)
     287  {
     288    Mi=M-eM[i]*E;
     289    K=list();
     290
     291    for(Ni,sNi=Mi,0;size(sNi)<mM[i];Ni=Ni*Mi)
     292    {
     293      sNi=syz(Ni);
     294      K=K+list(sNi);
     295    }
     296    if(size(K)>1)
     297    {
     298      K1=K[1];
     299      K[1]=interred(reduce(K[1],std(module(Mi*K[2]))));
     300      for(j=2;j<=size(K)-1;j++)
     301      {
     302        K2=K[j];
     303        K[j]=interred(reduce(K[j],std(K1+module(Mi*K[j+1]))));
     304        K1=K2;
     305      }
     306      K[j]=interred(reduce(K[j],std(K1)));
     307    }
     308    for(j=size(K);j>=1;j--)
     309    {
     310      for(k=size(K[j]);k>=1;k--)
     311      {
     312        v=K[j][k];
     313        for(l=j;l>=1;l--)
     314        {
     315          V=module(v)+V;
     316          v=Mi*v;
     317        }
     318      }
     319    }
     320  }
     321  return(V);
     322}
     323example
     324{
     325  "EXAMPLE:";
     326  echo=2;
     327  LIB "random.lib";
     328  ring r;
     329  list d=ideal(2,3),list(intvec(1,1,2,2,2),intvec(3,4,5));
     330  matrix M=jordanmatrix(d);
     331  print(M);
     332  int n=nrows(M);
     333  matrix U;
     334  while(det(U)==0)
     335  {
     336    U=randommat(n,n,ideal(1));
     337  }
     338  matrix invU=lift(U,freemodule(n));
     339  M=invU*M*U;
     340  print(M);
     341  U=jordanbasis(M);
     342  invU=lift(U,freemodule(n));
     343  print(invU*M*U);
     344}
     345///////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.