Changeset dd08428 in git for Singular/LIB
- Timestamp:
- Dec 23, 1998, 2:13:09 PM (25 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 66968388c61cc598cbf981f8917ef5bfcc506cfa
- Parents:
- 7614f91f1e407b440f3a529647a08b4309a850e6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/jordan.lib
r7614f91 rdd08428 1 1 /////////////////////////////////////////////////////////////////////////////// 2 2 3 version="$Id: jordan.lib,v 1. 1 1998-12-21 16:21:05mschulze Exp $";3 version="$Id: jordan.lib,v 1.2 1998-12-23 13:13:09 mschulze Exp $"; 4 4 info=" 5 LIBRARY: jordan.lib A PROCEDURETO COMPUTE THE JORDAN NORMAL FORM5 LIBRARY: jordan.lib PROCEDURES TO COMPUTE THE JORDAN NORMAL FORM 6 6 by Mathias Schulze 7 7 email: mschulze@mathematik.uni-kl.de 8 8 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 10 15 "; 11 16 … … 13 18 /////////////////////////////////////////////////////////////////////////////// 14 19 15 proc jordan (matrix M,list #)16 INPUT: matrix M[, int i]17 ASSUME: M square matrix with factorizable characteristic polynomial 20 proc jordandata(matrix M) 21 INPUT: square matrix M with factorizable characteristic polynomial 22 of the constant part M0 18 23 OUTPUT: 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 27 EXAMPLE: example jordandata; shows an example 27 28 { 28 29 int n=nrows(M); … … 61 62 kill pr; 62 63 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; 64 85 intvec bMi; 65 86 list bM; … … 73 94 m=k; 74 95 bMi=0; 96 bMi[m]=0; 75 97 for(j=k;j>=1;j--) 76 98 { … … 81 103 Mj=Mj*Mi; 82 104 k=ncols(syz(Mj)); 83 for(l= k-m;l>=1;l--)105 for(l=size(bMi);l>size(bMi)+m-k;l--) 84 106 { 85 107 bMi[l]=bMi[l]+1; … … 90 112 } 91 113 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 } 116 example 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 138 proc jordanmatrix(list d) 139 INPUT: list d 140 ASSUME: 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 142 OUTPUT: a jordan matrix with eigenvalues from the first entry of d 143 and jordan block sizes from the second entry of d 144 EXAMPLE: 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--) 101 150 { 102 151 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++) 103 162 { 104 163 for(k=bM[i][j];k>=2;k,l=k-1,l+1) … … 119 178 echo=2; 120 179 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 186 proc jordanform(matrix M) 187 INPUT: square matrix M with factorizable characteristic polynomial 188 of the constant part M0 189 OUTPUT: nothing, if the assumptions are not fulfilled, else, 190 a jordan matrix of M0 191 EXAMPLE: example jordanform; shows an example 192 { 193 return(jordanmatrix(jordandata(M))); 194 } 195 example 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 217 proc jordanbasis(matrix M) 218 INPUT: square matrix M with factorizable characteristic polynomial 219 of the constant part M0 220 OUTPUT: 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 223 EXAMPLE: 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 121 242 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 } 323 example 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.