Changeset 6f2edc in git
- Timestamp:
- Apr 28, 1997, 9:27:25 PM (26 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 8c5a578cc8481c8a133a58030c4c4c8227d82bb1
- Parents:
- 6d09c564c80f079b501f7187cf6984d040603849
- Location:
- Singular/LIB
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/deform.lib
r6d09c56 r6f2edc 1 // $Id: deform.lib,v 1. 1.1.1 1997-04-25 15:13:25 obachman Exp $2 //(BM +GMG)1 // $Id: deform.lib,v 1.2 1997-04-28 19:27:15 obachman Exp $ 2 //(BM/GMG, last modified 22.06.96) 3 3 /////////////////////////////////////////////////////////////////////////////// 4 4 LIBRARY: deform.lib PROCEDURES FOR COMPUTING MINIVERSAL DEFORMATION 5 5 6 6 miniversal(id[,deg]); miniversal deformation of an isolated singularity id 7 7 8 8 SUB-PROCEDURES used by main procedure: 9 9 apply_col(A,B); put A into col-nf and apply same col-operations to B … … 15 15 LIB "inout.lib"; 16 16 LIB "general.lib"; 17 LIB "sing.lib"; 17 LIB "sing.lib"; 18 18 LIB "matrix.lib"; 19 19 /////////////////////////////////////////////////////////////////////////////// 20 20 21 21 proc miniversal (ideal id,list #) 22 USAGE: miniversal(id[,d,na,va,o,iv]); id=ideal, d=integer, 22 USAGE: miniversal(id[,d,na,va,o,iv]); id=ideal, d=integer, 23 23 na,va,o=strings, iv=intvec of positive integers 24 24 COMUPTE: miniversal deformation of id up to degree d (default d=100) … … 26 26 the basering by new variables given by va (deformation parameters). 27 27 -- The new vars come before the old vars 28 -- The characteristic of `na` is the characteristic of the basering.29 -- The new vars are derived from va. If va is a single letter, say 30 va="T", and if n<=26 then T and the following n-1 letters from 31 T..Z..T (resp. T(1..n) if n>26) are taken as additional variables. 32 If va is a single letter followed by (, say va="x(", the new 28 -- The characteristic of `na` is the characteristic of the basering. 29 -- The new vars are derived from va. If va is a single letter, say 30 va="T", and if n<=26 then T and the following n-1 letters from 31 T..Z..T (resp. T(1..n) if n>26) are taken as additional variables. 32 If va is a single letter followed by (, say va="x(", the new 33 33 variables are x(1),...,x(n) (default va="A"). 34 34 -- The ordering is the product ordering between the ordering of r and 35 an ordering derived from `o`, which has to be local!! (default: 36 o="ds") [and iv (a weight vector)]. 35 an ordering derived from `o`, which has to be local!! (default: 36 o="ds") [and iv (a weight vector)]. 37 37 Type 'help extendring' for a more detailed explanation of the 38 ordering 39 -- Even if na,va,o are given, d and/or iv may be ommited. Then the 38 ordering 39 -- Even if na,va,o are given, d and/or iv may be ommited. Then the 40 40 default values d=100, iv=0 (i.e. all weights = 1) are used. 41 41 The procedure creates also two ideals: 42 42 ideal jetJ - defining the miniversal base space (in `na`) 43 43 ideal jetF - defining miniversal total space (in `na`) 44 NOTE: int printlevel=2; shows what is going on 45 int printlevel=3; shows also memory usage 46 This proc uses 'execute' or calls a procedure using 'execute'. 47 If you use it in your own proc, let the local names of your proc 44 NOTE: printlevel >=0: display dimT1,T2 and explain created objects (default) 45 printlevel >=1: show partial + final result during computation 46 printlevel >=2: show also memory and time usage 47 printlevel >=3: test and show obstructions 48 printlevel >=4: create a file 'minbaseout' and (over) write part of 49 ideal of miniversal base up to current degree into it 50 This proc uses 'execute' or calls a procedure using 'execute'. 51 If you use it in your own proc, let the local names of your proc 48 52 start with @ (see the file HelpForProc) 49 EXAMPLE: example miniversal; shows an example 53 EXAMPLE: example miniversal; shows an example 50 54 { 51 55 //------- initialisation ------------------------------------------------------ 52 int @d,@deg,@t1,@t2,@colR,@noObstr; 56 int @d,@deg,@t1,@t2,@colR,@noObstr,@j; 57 int p = printlevel-voice+3; // p=printlevel+1 (default: p=1) 53 58 intvec @iv,@jv; 54 59 string @na,@va,@o; … … 60 65 if( size(#)==4 ) { @deg=#[1]; @na=#[2]; @va=#[3]; @o=#[4];} 61 66 if( size(#)==5 ) { @deg=#[1]; @na=#[2]; @va=#[3]; @o=#[4]; @iv=#[5]; } 62 if( find(@o,"s")==0 ) 67 if( find(@o,"s")==0 ) 63 68 { "// ordering must be an s-ordering, please change!"; return();} 64 65 def @Pn = basering; 66 string @ords = ordstr(@Pn); 69 70 def @Pn = basering; 71 string @ords = ordstr(@Pn); 67 72 id = simplify(id,10); 68 73 int @rowR = size(id); 69 74 if( @rowR<=1 ) 70 { 75 { 71 76 "// hypersurface, use proc deform from sing.lib"; 72 77 return(); 73 } 78 } 74 79 //------- change ordering if not correct -------------------------------------- 75 80 @t1=1; 76 for( @d=1;@d<=nvars(@Pn);@d ++) { @t1=@t1*(lead(1+var(@d))==var(@d)); }81 for( @d=1;@d<=nvars(@Pn);@d=@d+1 ) { @t1=@t1*(lead(1+var(@d))==var(@d)); } 77 82 if( @t1==0 ) 78 83 { 79 if( @ords[size(@ords)]!="c" and @ords[size(@ords)]!="C" ) 80 { 84 if( @ords[size(@ords)]!="c" and @ords[size(@ords)]!="C" ) 85 { 81 86 if( @ords[1]=="c" ) { @ords=@ords[3,size(@ords)-2]+",c"; @t1=1;} 82 87 if( @ords[1]=="C" ) { @ords=@ords[3,size(@ords)-2]+",C"; @t1=1;} 83 88 } 84 if( @t1==1 ) 85 { 89 if( @t1==1 ) 90 { 86 91 changeord("@On",@ords,@Pn); 87 92 ideal id = imap(@Pn,id); … … 90 95 if( defined(@On)==0 ) { def @On=@Pn; setring @On; } 91 96 //------- reproduce T12 ------------------------------------------------------- 92 list Ls = T12(id,1); 93 matrix Ro = Ls[ 4]; //syz(i)94 matrix InfD = Ls[ 3]; //matrix of inf. deformations95 matrix PreO = Ls[ 5]; //present. mat of Syz/Kos^*96 module PreT = Ls[ 2]; //present. module of modT297 @t1 = Ls[ 8]; //vdim of T198 @t2 = Ls[ 9]; //vdim of T297 list Ls = T12(id,1); 98 matrix Ro = Ls[6]; //syz(i) 99 matrix InfD = Ls[5]; //matrix of inf. deformations 100 matrix PreO = Ls[7]; //present. mat of Syz/Kos^* 101 module PreT = Ls[9]; //present. module of modT2 102 @t1 = Ls[3]; //vdim of T1 103 @t2 = Ls[4]; //vdim of T2 99 104 kill Ls; 100 dbpri (2,"","// ___ matrix of infinitesimal deformations:",InfD);101 @colR = ncols(Ro); 105 dbprint(p-1,"","// ___ matrix of infinitesimal deformations:",InfD); 106 @colR = ncols(Ro); 102 107 ideal i0 = std(id); 103 108 qring @Ox = i0; //ring of singularity to deform 104 matrix Cup,lCup; module PreT;109 matrix Cup,lCup; 105 110 ideal testid; 106 111 matrix Ro = fetch(@On,Ro); 107 112 matrix PreO = fetch(@On,PreO); 113 module PreT = fetch(@On,PreT); 108 114 //---- create new ring with @t1=dim T1 additional variables and initialize ---- 109 115 … … 116 122 export jetF; 117 123 matrix Fo = matrix(jetF); //initial equations 118 matrix Rs = imap(@On,Ro); //deformed syzygies 124 matrix Ro = imap(@On,Ro); 125 matrix Rs = imap(@On,Ro); //deformed syzygies 119 126 ideal jetJ; //(jet)ideal of minversal defor 120 127 export jetJ; … … 132 139 jetF= Fs; 133 140 F_R = Fs*Rs; 134 if (@t2<=0) { @d=0; } //finished, if "T2=0" 141 if (@t2<=0) { @d=0; } //finished, if "T2=0" 135 142 //------- start the loop ------------------------------------------------------ 136 for (@d=1;@d<=@deg;@d ++)137 { 138 dbpri (2,"","// ___ start computation in degree "+string(@d)+":");139 dbpri (3,"memory="+string(kmemory())+"k");143 for (@d=1;@d<=@deg;@d=@d+1) 144 { 145 dbprint(p-1,"","// ___ start computation in degree "+string(@d)+":"); 146 dbprint(p-2,"// memory = "+string(kmemory())+"k"); 140 147 //------- lift relation to next degree ---------------------------------------- 141 F_r = reduce_s(F_R,Jo,@d+1); 148 F_r = reduce_s(F_R,Jo,@d+1); 142 149 Cup = matrix(jet(F_r,@d,@jv),1,@colR); 143 150 Rn = (-1)*lift(Fo,Cup); 144 151 Rs = Rs + Rn; 145 F_R = F_R + Fs*Rn; 152 F_R = F_R + Fs*Rn; 146 153 //------- test: already finished? --------------------------------------------- 147 154 testid = simplify(reduce(ideal(F_R),Jo),10); 148 155 if (testid[1]==0) 149 { 150 "// computation finished in degree "+string(@d); 151 if( @d==@deg ) 152 {"// degree bound reached, result may not yet be complete!";} 156 { dbprint(p,"// ___ computation finished in degree "+string(@d)); 157 if( @d==@deg ) 158 { dbprint(p,"// ___ degree bound reached, result may not yet be complete!");} 153 159 break; 154 160 } 155 161 //------- compute obstruction-matrix ----------------------------------------- 156 F_r = reduce_s(F_R,Jo,@d+1); 157 Cup = matrix(jet(F_r,@d+1,@jv),1,@colR); 162 F_r = reduce_s(F_R,Jo,@d+1); 163 Cup = matrix(jet(F_r,@d+1,@jv),1,@colR); 158 164 Test= Cup; 159 dbpri (2,"","// ___ obstruction vector:",ideal(Cup));165 dbprint(p-3,"","// ___ obstruction vector:",ideal(Cup)); 160 166 Cup,Mon = coef_ideal(Cup,@t1); 161 167 //------- express obstructions in kbase of T2 -------------------------------- … … 163 169 Cup = imap(`@na`,Cup); 164 170 lCup = lift(PreO,Cup); 165 PreT = fetch(@On,PreT);166 171 lCup = lift_kbase(lCup,PreT); 167 172 @t2 = nrows(lCup); 168 dbpri (2,"","// ___ obstructions in kbase of T2:",lCup);169 testid = simplify(ideal(lCup),10); // test no obstructions173 dbprint(p-3,"","// ___ obstructions in kbase of T2:",lCup); 174 testid = simplify(ideal(lCup),10); // test no obstructions 170 175 if (testid[1]==0) 171 { @noObstr=1; } else { @noObstr=0; } 172 //------- compute ideal of minversal(its k-jet) ------------------------------- 176 { @noObstr=1;dbprint(p-3,"// ___ no obstruction"); } else { @noObstr=0; } 177 @j=size(module(gauss_col(lCup))); // test:full obstruction 178 if (@j==ncols(lCup)) 179 { dbprint(p,"","// nothing to lift!", 180 "// ___ miniversal base, defined by jetJ, is a fat point!"); 181 break; 182 } 183 //------- compute ideal of minversal base (its k-jet) ------------------------- 173 184 setring `@na`; 174 if (@noObstr==0) //case of non-zero obstr. 185 if (@noObstr==0) //case of non-zero obstr. 175 186 { 176 187 lCup = imap(@Ox,lCup); 177 188 Jo = lCup*transpose(Mon); 178 jetJ = matrix(jetJ,1,@t2)+matrix(Jo,1,@t2); 179 dbpri(2,"","// ___ degree-"+string(@d+1)+"-part of ideal of miniversal base"+":",Jo); 189 jetJ = matrix(jetJ,1,@t2)+matrix(Jo,1,@t2); 190 dbprint(p-1,"","// ___ degree-"+string(@d+1)+"-part of ideal of miniversal base"+":",Jo); 191 if( p-1>=4 ) 192 { write (">minbaseout","// part of ideal of miniversal base up to degree <= "+string(@d+1)+":",jetJ); } 180 193 Jo = std(jetJ); 181 //------- choose a defining system -------------------------------------------- 182 @iv,Cup = defining_system(lCup,Cup); 183 dbpri(2,"","// ___ number of cols of defining system:",@iv); 184 //------- lift the equations -------------------------------------------------- 185 if (sum(@iv)==0) 186 { 187 "// nothing to lift!"; 188 "// miniversal base, defined by jetJ, is a fat point!";break; 189 } 190 setring @Ox; 191 Cup = imap(`@na`,Cup); 192 Cup = submat(Cup,1..nrows(Cup),@iv); 193 dbpri(2,"","// ___ matrix of defining system:",Cup); 194 } 195 else // case of zero obstructions 196 { 197 setring @Ox; 198 Cup = imap(`@na`,Cup); 199 } 200 Cup = lift(transpose(Ro),module(Cup)); 201 setring `@na`; 202 Cup = imap(@Ox,Cup); 203 if (@noObstr==0) 204 { Mon = submat(Mon,1..nrows(Mon),@iv); } 205 Fn = (-1)*transpose(Cup*transpose(Mon)); 194 } 195 F_r = reduce_s(F_R,Jo,@d+1); 196 Cup = matrix(jet(F_r,@d+1,@jv),1,@colR); 197 //---------------- repeat test: jetJ ok in deg d+1? -------------------------- 198 if( (p-1>=3) && (@noObstr==0) ) 199 { 200 lCup,Mon = coef_ideal(Cup,@t1); 201 setring @Ox; 202 Cup = imap(`@na`,Cup); 203 lCup = lift(PreO,Cup); 204 lCup = lift_kbase(lCup,PreT); 205 dbprint(p-3,"","// ____ test: jetJ ok iff all entries are 0",lCup); 206 setring `@na`; 207 } 208 //---------------- lift equations F ----------------------------------------- 209 if (defined(Qrg)) {kill Qrg;} 210 qring Qrg = std(ideal(Fo)); 211 def Ro=fetch(`@na`,Ro); 212 def Cup=fetch(`@na`,Cup); 213 def Fn = lift(transpose(Ro),transpose(Cup)); 214 Fn=(-1)*transpose(Fn); 215 setring `@na`; 216 Fn = fetch(Qrg,Fn); 206 217 Fs = Fs+Fn; 207 F_R = F_R+Fn*Rs; 218 F_R = F_R+Fn*Rs; 208 219 jetF = matrix(Fs); 209 dbpri (2,"","// ___ degree-"+string(@d+1)+"-part of deformed equations:",Fn);210 } 220 dbprint(p-1,"","// ___ degree-"+string(@d+1)+"-part of deformed equations:",Fn); 221 } 211 222 //--------- end loop and final output --------------------------------------- 212 ""; 213 "// ___ Equations of miniversal base space ___";jetJ; "";214 "// ___ Equations of miniversal total space ___";jetF; ""; 215 "// Result belongs to ring",@na,"(total space of miniversal deformation).";216 "// Make",@na,"the basering and list objects defined in",@na,"by typing:";217 " setring",@na,"; show("+@na+");";218 " listvar(ideal);";219 kill @On; 223 dbprint(p-1,"","// ___ Equations of miniversal base space ___",jetJ, 224 "","// ___ Equations of miniversal total space ___",jetF); 225 dbprint(p,"","// Result belongs to ring "+@na+".", 226 "// Equations of total space of miniversal deformation are ", 227 "// given by jetF, equations of miniversal base space by jetJ.", 228 "// Make "+@na+" the basering and list objects defined in "+@na+" by typing:", 229 " setring "+@na+"; show("+@na+");"," listvar(ideal);"); 230 kill @On; 220 231 return(); 221 232 } 222 example 233 example 223 234 { "EXAMPLE:"; echo = 2; 224 ring r1=0,(x,y,z,u,v),ds; 225 matrix m[2][4]=x,y,z,u,y,z,u,v; 226 ideal i=minor(m,2); //cone over rational normal curve of degree 4 235 int p = printlevel; 236 ring r1 = 0,(x,y,z,u,v),ds; 237 matrix m[2][4] = x,y,z,u,y,z,u,v; 238 ideal i = minor(m,2); //cone over rational normal curve of degree 4 227 239 miniversal(i,"R","T("); 228 // hit return-key to continue; 229 // pause; 230 ring r = 0,(x,y,z),ds; 231 ideal i = x2,xy,yz,zx; 232 printlevel = 2; 233 miniversal(i);""; 234 kill printlevel; 235 // NOTE: rings R and Ont are still alive! 236 } 237 /////////////////////////////////////////////////////////////////////////////// 238 239 proc apply_col (matrix A, matrix B) 240 setring R;""; 241 // ___ Equations of miniversal base space ___: 242 jetJ;""; 243 // ___ Equations of miniversal total space ___: 244 jetF;""; 245 ring r = 0,(x,y,z),ds; 246 ideal i = x2,xy,yz,zx; 247 printlevel = 3; 248 miniversal(i);""; 249 printlevel = p; 250 // NOTE: rings R and Ont are still alive! 251 } 252 /////////////////////////////////////////////////////////////////////////////// 253 254 proc apply_col (matrix A, matrix B) 240 255 USAGE: apply_col(A,B); A,B=matrices 241 ASSUME: A = constant matrix in row-reduced (upper triangular) normal form, 256 ASSUME: A = constant matrix in row-reduced (upper triangular) normal form, 242 257 B = matrix of same size 243 258 COMUPTE: apply to B those col-operations which reduce A into col-reduced nf 244 259 RETURN: two transformed matrices: col-reduced A, transformed B 245 EXAMPLE: example apply_col; shows an example 260 EXAMPLE: example apply_col; shows an example 246 261 { 247 262 int i,j,k; … … 251 266 matrix C = concat(transpose(A),transpose(B)); 252 267 module mC = transpose(C); 253 for( k=1;k<=r;k ++)268 for( k=1;k<=r;k=k+1 ) 254 269 { 255 270 j=1; 256 while( C[j,k]==0 && j<c ) { j ++; }257 for( i=j+1;i<=c;i ++)271 while( C[j,k]==0 && j<c ) { j=j+1; } 272 for( i=j+1;i<=c;i=i+1 ) 258 273 { 259 274 m = C[i,k]; 260 mC[i] = mC[i]-m*mC[j]; 275 mC[i] = mC[i]-m*mC[j]; 261 276 } 262 277 } … … 266 281 return(transpose(a),transpose(b)); 267 282 } 268 example 283 example 269 284 { "EXAMPLE:"; echo = 2; 270 285 ring R=0,(x,y,z),dp; … … 279 294 /////////////////////////////////////////////////////////////////////////////// 280 295 281 proc defining_system (matrix A,matrix B) 296 proc defining_system (matrix A,matrix B) 282 297 USAGE: defining_system(A,B); A,B=matrices 283 298 ASSUME: A a constant matrix … … 287 302 RETURN: two objects: intvec iv, matrix M (the transformed matrix B) 288 303 The columns of M with index from iv are a defining sytem 289 EXAMPLE: example defining_system; shows an example 304 EXAMPLE: example defining_system; shows an example 290 305 { 291 306 int k,l; … … 295 310 int rg = ncols(A); 296 311 A,B = apply_col(A,B); // special columne-reduction 297 for( k=1;k<=rg;k ++) // collect zero-cols of B298 { 299 if( A[k]==0) {l ++;iv[l]=k;} // test if kth column is 0312 for( k=1;k<=rg;k=k+1 ) // collect zero-cols of B 313 { 314 if( A[k]==0) {l=l+1;iv[l]=k;} // test if kth column is 0 300 315 } // collect indices of 0-columns in iv 301 316 return(iv,B); 302 317 } 303 example 318 example 304 319 { "EXAMPLE:"; echo = 2; 305 320 ring R=0,(x,y,z),dp; … … 323 338 int d,k; 324 339 ideal j0 = std(j); 325 for (k=1;k<=m;k ++)340 for (k=1;k<=m;k=k+1) 326 341 { 327 342 if (deg(i[k])>=0) … … 333 348 return(i); 334 349 } 335 example 350 example 336 351 { "EXAMPLE:"; echo = 2; 337 352 ring r = 0,(x,y),ds; 338 353 poly f = x7+y7+(x-y)^2*x^2*y^2; 339 354 ideal j = jacob(f); 340 reduce_s(f,j,10); 355 reduce_s(f,j,10); 341 356 } 342 357 /////////////////////////////////////////////////////////////////////////////// … … 344 359 proc lift_kbase (N, M) 345 360 USAGE: lift_kbase(N,M); N,M=poly/ideal/vector/module 346 RETURN: matrix A, coefficient matrix expressing N as linear combination of 347 k-basis of M. Let the k-basis have k elements and A c columns.361 RETURN: matrix A, coefficient matrix expressing N as linear combination of 362 k-basis of M. Let the k-basis have k elements and size(N)=c columns. 348 363 Then A satisfies: 349 364 matrix(reduce(N,std(M)),k,c) = matrix(kbase(std(M)))*A 350 ASSUME: dim(M)=0 and the monomial ordering is a well ordering or the last 365 ASSUME: dim(M)=0 and the monomial ordering is a well ordering or the last 351 366 block of the ordering is c or C 352 367 EXAMPLE: example lift_kbase; shows an example … … 360 375 //------- check wether ordering is correct ------------------------------------ 361 376 k=1; 362 for( l=1;l<=nvars(basering);l ++) { k=k*(lead(1+var(l))==var(l)); }377 for( l=1;l<=nvars(basering);l=l+1 ) { k=k*(lead(1+var(l))==var(l)); } 363 378 if( k==0 ) 364 379 { 365 if( ords[size(ords)]!="c" and ords[size(ords)]!="C" ) 366 { 380 if( ords[size(ords)]!="c" and ords[size(ords)]!="C" ) 381 { 367 382 "// change ordering!"; 368 "// ordering "+ordstr(basering)+" not implemented for this proc"; 369 return(); 383 "// ordering "+ordstr(basering)+" not implemented for this proc"; 384 return(); 370 385 } 371 386 } … … 377 392 if( d<1 ) 378 393 { "// second argument in `lift_kbase` has vdim",d; return(); } 379 //---------- compute kbase and reduce(N,M) ----------------------------------- 394 //---------- compute kbase and reduce(N,M) ----------------------------------- 380 395 kb = kbase(M); 381 396 col = ncols(N); 382 397 N = reduce(N,M); 398 N = matrix(N,nrows(N),col); 383 399 //---------- collecting coefficients of reduce(N,M) -------------------------- 384 400 matrix result[d][col]; … … 389 405 { 390 406 for( k=1;k<=d;k=k+1 ) 391 { 407 { 392 408 p = kb[k]; 393 q = lead(v); 409 q = lead(v); 394 410 if( size(p-q)<2 ) 395 411 { … … 399 415 else { k=0; } 400 416 } 401 } 417 } 402 418 } 403 419 } 404 420 //--------- final test ------------------------------------------------------- 405 421 testm = matrix(N,nrows(kb),ncols(result))- matrix(kb)*result; 406 if( size(module(testm))!=0 ) 407 { 422 if( size(module(testm))!=0 ) 423 { 408 424 "// proc `lift_kbase` did'nt work correctly!"; 409 425 "// Please inform tthe authors"; … … 413 429 } 414 430 example 415 { 416 "EXAMPLE:"; echo=2; 431 {"EXAMPLE:"; echo=2; 417 432 ring R=0,(x,y),ds; 418 433 module M=[x2,xy],[y2,xy],[0,xx],[0,yy]; … … 432 447 ASSUME: M=matrix with only one row and without any constant term 433 448 COMPUTE: coef_matrices with respect to first s variables 434 RETURN: 2 matrices: 449 RETURN: 2 matrices: 435 450 matrix of coefficients (each column is formed by the coefficients 436 of M with respect to some monomial) 437 row-matrix of corresponding monomials 451 of M with respect to some monomial) 452 row-matrix of corresponding monomials 438 453 EXAMPLE: example coef_ideal; shows an example 439 454 { 440 455 int k,l,n,z; 441 456 int cM = ncols(M); 442 ideal flatM = M; 457 ideal flatM = M; 443 458 ideal monId,flat; 444 459 poly mon = product(maxideal(1),1..s); 445 460 //--------- collect all monomials (!=1) --------------------------------------- 446 for (k=1;k<=cM;k ++)461 for (k=1;k<=cM;k=k+1) 447 462 { 448 463 matrix mci(k) = coef(flatM[k],mon); … … 450 465 if (flat[1]!=1) 451 466 { monId = monId,flat;} 452 } 467 } 453 468 monId = monId+ideal(0); 454 469 k=size(monId); 455 470 matrix BIG[cM][k]; 456 471 //--------- create coef_matrices -------------------------------------------- 457 for (n=1;n<=k;n ++)472 for (n=1;n<=k;n=n+1) 458 473 { 459 for (l=1;l<=cM;l ++)474 for (l=1;l<=cM;l=l+1) 460 475 { 461 for (z=1;z<=ncols(mci(l));z ++)476 for (z=1;z<=ncols(mci(l));z=z+1) 462 477 { 463 478 if(mci(l)[1,z]==monId[n]) 464 479 { BIG[l,n] = mci(l)[2,z];} 465 } 480 } 466 481 } 467 } 482 } 468 483 return(BIG,matrix(monId)); 469 } 470 example 484 } 485 example 471 486 { "EXAMPLE:"; echo = 2; 472 487 ring Z = 0,(A,B,C,x,y,z),ds; 473 int s = 3; 488 int s = 3; 474 489 matrix M[1][4]=A+yB,2C,3AA,4BB+5CC; 475 490 print(M); … … 480 495 } 481 496 /////////////////////////////////////////////////////////////////////////////// 482 ----------483 484 "example in r1: i=cone rational normal curve d=4";485 int d=4;486 ring r1=0,(x,y,z,u,v),ds;487 matrix m[2][4]=x,y,z,u,y,z,u,v;488 ideal i=minor(m,2);489 i=minbase(i);490 i;pause;491 int t=timer;miniversal(i);timer-t;492 ----------493 494 "example: in r4 i=cone rational normal curve d=5";495 int d=5;496 ring s=0,(x,y,z,u,v,w),ds;497 matrix m[2][5]=x,y,z,u,v,y,z,u,v,w;498 ideal i=minor(m,2);499 i=minbase(i);500 i;pause;501 502 ----------503 504 "Example: in r5 i=L_n^n, n=4;";505 ring r5=0,(x,y,z,u),ds;506 ideal i;507 i=xy,xz,xu,yz,yu,zu;508 i;pause;509 510 ----------511 512 "Example 1 : cyclic quotient in ws513 (type setring r1;sud(i);)";514 ring r1=0,(x,y,z,u,v),ws(4,3,2,3,4);515 ideal i=xz-y2,yz2-xu,xv-yzu,yu-z3,z2u-yv,zv-u2;516 i;517 518 "Example 2: same in wp519 (ringr r2)";520 ring r2=0,(x,y,z,u,v),wp(4,3,2,3,4);521 ideal i=xz-y2,yz2-xu,xv-yzu,yu-z3,z2u-yv,zv-u2;522 i;523 524 "Example 3: same in ls";525 ring r3=0,(x,y,z,u,v),ls;526 ideal i=xz-y2,yz2-xu,xv-yzu,yu-z3,z2u-yv,zv-u2;527 i;528 529 "Example 4: by chance for testing";530 ring r4=0,(x,y,z),ds;531 ideal i=xy,yz,xz+y3,x2+y2+z3;532 i;533 -
Singular/LIB/elim.lib
r6d09c56 r6f2edc 1 // $Id: elim.lib,v 1. 1.1.1 1997-04-25 15:13:25obachman Exp $2 // system("random",787422842);3 // (GMG)1 // $Id: elim.lib,v 1.2 1997-04-28 19:27:16 obachman Exp $ 2 // system("random",787422842); 3 // (GMG, last modified 22.06.96) 4 4 /////////////////////////////////////////////////////////////////////////////// 5 5 6 6 LIBRARY: elim.lib PROCEDURES FOR ELIMINATIOM, SATURATION AND BLOWING UP 7 7 8 blowup0(j[,s1,s2]); create presentation of blownup ring of ideal j 8 blowup0(j[,s1,s2]); create presentation of blownup ring of ideal j 9 9 elim(id,n,m); variable n..m eliminated from id (ideal/module) 10 elim1(id,p); p=product of vars to be eliminated from id 10 elim1(id,p); p=product of vars to be eliminated from id 11 11 nselect(id,n[,m]); select generators not containing nth [..mth] variable 12 sat(id,j); saturated quotient of ideal/module id by ideal j 12 sat(id,j); saturated quotient of ideal/module id by ideal j 13 13 select(id,n[,m]); select generators containing nth [..mth] variable 14 14 (parameters in square brackets [] are optional) … … 20 20 21 21 proc blowup0 (ideal j,list #) 22 USAGE: blowup0(j[,s1,s2]); j ideal, s1,s2 nonempty strings 23 CREATE: Create a presentation of the blowup ring of j 22 USAGE: blowup0(j[,s1,s2]); j ideal, s1,s2 nonempty strings 23 CREATE: Create a presentation of the blowup ring of j 24 24 RETURN: no return value 25 25 NOTE: s1 and s2 are used to give names to the blownup ring and the blownup 26 26 ideal (default: s1="j", s2="A") 27 27 Assume R = char,x(1..n),ord is the basering of j, and s1="j", s2="A" 28 then the procedure creates a new basering with name Bl_jR28 then the procedure creates a new ring with name Bl_jR 29 29 (equal to R[A,B,...]) 30 Bl_jR = char,(A,B,...,x(1..n)),(dp(k),ord) 31 with k=ncols(j) new variables A,B,... and ordering wp(d1..dk) if j is 30 Bl_jR = char,(A,B,...,x(1..n)),(dp(k),ord) 31 with k=ncols(j) new variables A,B,... and ordering wp(d1..dk) if j is 32 32 homogeneous with deg(j[i])=di resp. dp otherwise for these vars. 33 If k>26 or size(s2)>1, say s2="A()", the new vars are A(1),...,A(k). 33 If k>26 or size(s2)>1, say s2="A()", the new vars are A(1),...,A(k). 34 34 Let j_ be the kernel of the ring map Bl_jR -> R defined by A(i)->j[i], 35 35 x(i)->x(i), then the quotient ring Bl_jR/j_ is the blowup ring of j 36 36 in R (being isomorphic to R+j+j^2+...). Moreover the procedure creates 37 a std basis of j_ with name j_ and Bl_jR as basering. 38 EXAMPLE: example blowup0; shows an example 37 a std basis of j_ with name j_ in Bl_jR. 38 This proc uses 'execute' or calls a procedure using 'execute'. 39 DISPLAY: printlevel >=0: explain created objects (default) 40 EXAMPLE: example blowup0; shows examples 39 41 { 40 42 string bsr = nameof(basering); 41 43 def br = basering; 42 string cr, vr, o = charstr(br), varstr(br),ordstr(br);43 int n, k = nvars(br), ncols(j);44 int i;44 string cr,vr,o = charstr(br),varstr(br),ordstr(br); 45 int n,k,i = nvars(br),ncols(j),0; 46 int p = printlevel-voice+3; // p=printlevel+1 (default: p=1) 45 47 //---------------- create coordinate ring of blown up space ------------------- 46 48 if( size(#)==0 ) { #[1] = "j"; #[2] = "A"; } … … 48 50 if( k<=26 and size(#[2])==1 ) { string nv = A_Z(#[2],k)+","; } 49 51 else { string nv = (#[2])[1]+"(1.."+string(k)+"),"; } 50 if( is homog(j) )51 { 52 if( is_homog(j) ) 53 { 52 54 intvec v=1; 53 for( i=1; i<=k; i ++) { v[i+1]=deg(j[i]); }55 for( i=1; i<=k; i=i+1) { v[i+1]=deg(j[i]); } 54 56 string nor = "),(wp(v),"; 55 57 } … … 58 60 //---------- map to new ring, eliminate and create blown up ideal ------------- 59 61 ideal j=imap(br,j); 60 for( i=1; i<=k; i ++) { j[i]=var(1+i)-t*j[i]; }62 for( i=1; i<=k; i=i+1) { j[i]=var(1+i)-t*j[i]; } 61 63 j=eliminate(j,t); 62 64 v=v[2..size(v)]; … … 65 67 export basering; 66 68 export `#[1]+"_"`; 67 keepring basering; 69 //keepring basering; 70 setring br; 68 71 //------------------- some comments about usage and names -------------------- 69 if( voice ==2 ) 70 { 71 "// NOTE:"; 72 "// basering is now Bl_"+#[1]+bsr+" (equal to "+bsr+"["+nv[1,size(nv)-1]+"])"; 73 "// it contains the ideal "+#[1]+"_ , such that"; 74 "// Bl_"+#[1]+bsr+"/"+#[1]+"_ is the blowup ring"; 75 "// For blowing-up another ideal in "+bsr+" type first:"; 76 "// setring "+bsr+";"; 77 } 72 dbprint(p,"", 73 "// The proc created the ring Bl_"+#[1]+bsr+" (equal to "+bsr+"["+nv[1,size(nv)-1]+"])", 74 "// it contains the ideal "+#[1]+"_ , such that", 75 "// Bl_"+#[1]+bsr+"/"+#[1]+"_ is the blowup ring", 76 "// show(Bl_"+#[1]+bsr+"); shows this ring.", 77 "// Make Bl_"+#[1]+bsr+" the basering and see "+#[1]+"_ by typing:", 78 " setring Bl_"+#[1]+bsr+";"," "+#[1]+"_;"); 78 79 return(); 79 80 } 80 example 81 example 81 82 { "EXAMPLE:"; echo = 2; 82 83 ring R=0,(x,y),dp; 83 poly f=y2+x3; ideal j=jacob(f); 84 poly f=y2+x3; ideal j=jacob(f); 84 85 blowup0(j); 85 type basering; ""; 86 // NOTE: 87 // basering is now Bl_jR (equal to R[A,B]) 88 // it contains the ideal j_ , such that 89 // Bl_jR/j_ is the blowup ring 90 // For blowing-up another ideal in R type first: 91 // setring R; 92 type j_; ""; 86 show(Bl_jR); 87 setring Bl_jR; 88 j_;""; 93 89 ring r=32003,(x,y,z),ds; 94 90 blowup0(maxideal(1),"m","T()"); 95 type basering; ""; 96 // NOTE: 97 // basering is now Bl_mr (equal to r[T(1..3)]) 98 // it contains the ideal m_ , such that 99 // Bl_mr/m_ is the blowup ring 100 // For blowing-up another ideal in r type first: 101 // setring r; 91 show(Bl_mr); 92 setring Bl_mr; 102 93 m_; 103 kill Bl_jR, Bl_mr; 94 kill Bl_jR, Bl_mr; 104 95 } 105 96 /////////////////////////////////////////////////////////////////////////////// 106 97 107 98 proc elim (id, int n, int m) 108 USAGE: elim(id,n,m); id ideal/module, n,m integers 109 RETURNS: ideal/module obtained from id by eliminating variables n..m 110 NOTE: no special monomial ordering is required, result is a SB with 111 respect to ordering dp (resp. ls) if the first var not to be 112 eliminated belongs to a -p (resp. -s) blockordering 113 EXAMPLE: example elim; shows an example 99 USAGE: elim(id,n,m); id ideal/module, n,m integers 100 RETURNS: ideal/module obtained from id by eliminating variables n..m 101 NOTE: no special monomial ordering is required, result is a SB with 102 respect to ordering dp (resp. ls) if the first var not to be 103 eliminated belongs to a -p (resp. -s) blockordering 104 This proc uses 'execute' or calls a procedure using 'execute'. 105 EXAMPLE: example elim; shows examples 114 106 { 115 107 //---- get variables to be eliminated and create string for new ordering ------ 116 108 int ii; poly vars=1; 117 for( ii=n; ii<=m; ii=ii+1 ) { vars=vars*var(ii); } 109 for( ii=n; ii<=m; ii=ii+1 ) { vars=vars*var(ii); } 118 110 if( n>1 ) { poly p = 1+var(1); } 119 111 else { poly p = 1+var(m+1); } … … 122 114 //-------------- create new ring and map objects to new ring ------------------ 123 115 def br = basering; 124 string str = "ring newr = ("+charstr(br)+"),("+varstr(br)+ordering;116 string str = "ring @newr = ("+charstr(br)+"),("+varstr(br)+ordering; 125 117 execute(str); 126 118 def i = imap(br,id); … … 129 121 i = eliminate(i,vars); 130 122 setring br; 131 return(imap( newr,i));132 } 133 example 123 return(imap(@newr,i)); 124 } 125 example 134 126 { "EXAMPLE:"; echo = 2; 135 127 ring r=0,(x,y,u,v,w),dp; 136 128 ideal i=x-u,y-u2,w-u3,v-x+y3; 137 elim(i,3,4); 129 elim(i,3,4); 138 130 module m=i*gen(1)+i*gen(2); 139 m=elim(m,3,4);show(m); 140 } 141 /////////////////////////////////////////////////////////////////////////////// 131 m=elim(m,3,4);show(m); 132 } 133 /////////////////////////////////////////////////////////////////////////////// 142 134 143 135 proc elim1 (id, poly vars) … … 147 139 respect to ordering dp (resp. ls) if the first var not to be 148 140 eliminated belongs to a -p (resp. -s) blockordering 149 EXAMPLE: example elim1; shows an example 141 This proc uses 'execute' or calls a procedure using 'execute'. 142 EXAMPLE: example elim1; shows examples 150 143 { 151 144 //---- get variables to be eliminated and create string for new ordering ------ 152 int ii; 153 for( ii=1; ii<=nvars(basering); ii++ ) 154 { 155 if( vars/var(ii)==0 ) { poly p = 1+var(ii); } 156 break; 145 int ii; 146 for( ii=1; ii<=nvars(basering); ii=ii+1 ) 147 { 148 if( vars/var(ii)==0 ) { poly p = 1+var(ii); break;} 157 149 } 158 150 if( ord(p)==0 ) { string ordering = "),ls;"; } … … 160 152 //-------------- create new ring and map objects to new ring ------------------ 161 153 def br = basering; 162 string str = "ring newr = "+charstr(br)+",("+varstr(br)+ordering;154 string str = "ring @newr = ("+charstr(br)+"),("+varstr(br)+ordering; 163 155 execute(str); 164 156 def id = fetch(br,id); … … 167 159 id = eliminate(id,vars); 168 160 setring br; 169 return(imap( newr,id));170 } 171 example 161 return(imap(@newr,id)); 162 } 163 example 172 164 { "EXAMPLE:"; echo = 2; 173 165 ring r=0,(x,y,t,s,z),dp; 174 166 ideal i=x-t,y-t2,z-t3,s-x+y3; 175 elim1(i,ts); 167 elim1(i,ts); 176 168 module m=i*gen(1)+i*gen(2); 177 m=elim1(m,st); show(m); 178 } 179 /////////////////////////////////////////////////////////////////////////////// 169 m=elim1(m,st); show(m); 170 } 171 /////////////////////////////////////////////////////////////////////////////// 180 172 181 173 proc nselect (id, int n, list#) 182 174 USAGE: nselect(id,n[,m]); id a module or ideal, n, m integers 183 175 RETURN: generators of id not containing the variable n [up to m] 184 EXAMPLE: example nselect; shows an example 185 { 176 EXAMPLE: example nselect; shows examples 177 { 178 int j,k; 186 179 if( size(#)==0 ) { #[1]=n; } 187 int j,k; 188 for( k=1; k<=ncols(id); k++ ) 189 { 190 for( j=n; j<=#[1]; j++ ) 191 { 192 if( size(id[k]/var(j))!=0) { id[k]=0; break; } 180 for( k=1; k<=ncols(id); k=k+1 ) 181 { for( j=n; j<=#[1]; j=j+1 ) 182 { if( size(id[k]/var(j))!=0) { id[k]=0; break; } 193 183 } 194 184 } 195 185 return(simplify(id,2)); 196 186 } 197 example 187 example 198 188 { "EXAMPLE:"; echo = 2; 199 189 ring r=0,(x,y,t,s,z),(c,dp); 200 190 ideal i=x-y,y-z2,z-t3,s-x+y3; 201 191 nselect(i,3); 202 module m=i*(gen(1)+gen(2)); 192 module m=i*(gen(1)+gen(2)); 203 193 show(m); 204 194 show(nselect(m,3,4)); … … 207 197 208 198 proc sat (id, ideal j) 209 USAGE: sat(id,j); id ideal or module, j ideal 210 RETURN: saturation of id with respect to j (= union_(k=1...) of id:j^k) 211 NOTE: result is a std basis in the basering 199 USAGE: sat(id,j); id=ideal/module, j=ideal 200 RETURN: list of an ideal/module [1] and an integer [2]: 201 [1] = saturation of id with respect to j (= union_(k=1...) of id:j^k) 202 [2] = saturation exponent (= min( k | id:j^k = id:j^(k+1) )) 203 NOTE: [1] is a standard basis in the basering 204 DISPLAY: saturation exponent during computation if printlevel >=1 212 205 EXAMPLE: example sat; shows an example 213 206 { 214 207 int ii,kk; 215 def i=id; id=std(id); 208 def i=id; 209 id=std(id); 210 int p = printlevel-voice+3; // p=printlevel+1 (default: p=1) 216 211 while( ii<=size(i) ) 217 { 218 if( voice==2 ) 219 {"// start quotient:",kk+1;} 212 { 213 dbprint(p-1,"// compute quotient "+string(kk+1)); 220 214 i=quotient(id,j); 221 for( ii=1; ii<=size(i); ii ++)215 for( ii=1; ii<=size(i); ii=ii+1 ) 222 216 { 223 217 if( reduce(i[ii],id)!=0 ) break; … … 225 219 id=std(i); kk=kk+1; 226 220 } 227 if( voice==2 ) 228 {"// saturation becomes stable after",kk-1,"iteration(s)";"";} 229 return (id); 230 } 231 example 232 { "EXAMPLE:"; echo = 2; 233 ring r=2,(x,y,z),dp; 234 poly F=x5+y5+(x-y)^2*xyz; 235 ideal j= jacob(F); 236 sat(j,maxideal(1)); 221 dbprint(p-1,"// saturation becomes stable after "+string(kk-1)+" iteration(s)",""); 222 list L = id,kk-1; 223 return (L); 224 } 225 example 226 { "EXAMPLE:"; echo = 2; 227 int p = printlevel; 228 ring r = 2,(x,y,z),dp; 229 poly F = x5+y5+(x-y)^2*xyz; 230 ideal j = jacob(F); 231 sat(j,maxideal(1)); 232 printlevel = 2; 233 sat(j,maxideal(2)); 234 printlevel = p; 237 235 } 238 236 /////////////////////////////////////////////////////////////////////////////// … … 241 239 USAGE: select(id,n[,m]); id ideal/module, n, m integers 242 240 RETURN: generators of id containing the variable n [up to m] 243 EXAMPLE: example select; shows an example241 EXAMPLE: example select; shows examples 244 242 { 245 243 if( size(#)==0 ) { #[1]=n; } 246 244 int j,k; 247 for( k=1; k<=ncols(id); k++ ) 248 { 249 for( j=n; j<=#[1]; j++ ) 250 { 251 if( size(id[k]/var(j))==0) { id[k]=0; break; } 245 for( k=1; k<=ncols(id); k=k+1 ) 246 { for( j=n; j<=#[1]; j=j+1 ) 247 { if( size(id[k]/var(j))==0) { id[k]=0; break; } 252 248 } 253 249 } 254 return( id+id);255 } 256 example 250 return(simplify(id,2)); 251 } 252 example 257 253 { "EXAMPLE:"; echo = 2; 258 254 ring r=0,(x,y,t,s,z),(c,dp); 259 255 ideal i=x-y,y-z2,z-t3,s-x+y3; 260 256 ideal j=select(i,1); 261 module m=i*(gen(1)+gen(2)); show(m); 262 show(select(m,1,2)); 263 } 264 /////////////////////////////////////////////////////////////////////////////// 265 257 j; 258 module m=i*(gen(1)+gen(2)); 259 m; 260 select(m,1,2); 261 } 262 /////////////////////////////////////////////////////////////////////////////// -
Singular/LIB/factor.lib
r6d09c56 r6f2edc 1 // $Id: factor.lib,v 1. 1.1.1 1997-04-25 15:13:26obachman Exp $1 // $Id: factor.lib,v 1.2 1997-04-28 19:27:17 obachman Exp $ 2 2 //(RS) 3 3 /////////////////////////////////////////////////////////////////////////////// -
Singular/LIB/general.lib
r6d09c56 r6f2edc 1 // $Id: general.lib,v 1. 1.1.1 1997-04-25 15:13:26obachman Exp $1 // $Id: general.lib,v 1.2 1997-04-28 19:27:17 obachman Exp $ 2 2 //system("random",787422842); 3 3 //(GMG, last modified 22.06.96) … … 20 20 sum(vector/id/..[,v]); add components of vector/ideal/...[with indices v] 21 21 (parameters in square brackets [] are optional) 22 22 wich(command); searches for command and returns absolute 23 path, if found 23 24 LIB "inout.lib"; 24 25 /////////////////////////////////////////////////////////////////////////////// … … 187 188 proc killall 188 189 USAGE: killall(); (no parameter) 189 killall("proc"); 190 killall("type_name"); 191 killall("not", "type_name"); 190 192 COMPUTE: killall(); kills all user-defined variables but not loaded procedures 191 killall("proc"); kills all loaded procedures 193 killall("type_name"); kills all user-defined variables, of type "type_name" 194 killall("not", "type_name"); kills all user-defined 195 variables, except those of type "type_name" and except loaded procedures 192 196 RETURN: no return value 193 197 NOTE: killall should never be used inside a procedure … … 201 205 if( L[joni]!="LIB" and typeof(`L[joni]`)!="proc" ) { kill `L[joni]`; } 202 206 } 203 return(); 204 } 205 if( #[1] == "proc" ) 206 { 207 for ( joni=size(L); joni>0; joni-- ) 208 { 209 if( L[joni]=="LIB" or typeof(`L[joni]`)=="proc" ) { kill `L[joni]`; } 210 } 211 } 212 } 213 example 214 { "EXAMPLE:"; echo = 2; 215 ring rtest; ideal i=x,y,z; number n=37; string str="hi"; 216 export rtest,i,n,str; //this makes the local variables global 207 } 208 else 209 { 210 if( size(#)==1 ) 211 { 212 if( #[1] == "proc" ) 213 { 214 for ( joni=size(L); joni>0; joni-- ) 215 { 216 if( L[joni]=="LIB" or typeof(`L[joni]`)=="proc" ) 217 { kill `L[joni]`; } 218 } 219 } 220 else 221 { 222 for ( ; joni>2; joni-- ) 223 { 224 if(typeof(`L[joni]`)==#[1] and L[joni]!="LIB" and typeof(`L[joni]`)!="proc") { kill `L[joni]`; } 225 } 226 } 227 } 228 else 229 { 230 for ( ; joni>2; joni-- ) 231 { 232 if(typeof(`L[joni]`)!=#[2] and L[joni]!="LIB" and typeof(`L[joni]`)!="proc") { kill `L[joni]`; } 233 } 234 } 235 } 236 return(); 237 } 238 example 239 { "EXAMPLE:"; echo = 2; 240 ring rtest; ideal i=x,y,z; number n=37; string str="hi"; int j = 3; 241 export rtest,i,n,str,j; //this makes the local variables global 217 242 listvar(all); 218 killall(); 243 killall("string"); // kills all string variables 244 listvar(all); 245 killall("not", "int"); // kills all variables except int's (and procs) 246 listvar(all); 247 killall(); // kills all vars except loaded procs 219 248 listvar(all); 220 249 } … … 590 619 } 591 620 /////////////////////////////////////////////////////////////////////////////// 621 622 proc which (command) 623 USAGE: which(command); command = string expression 624 RETURN: Absolute pathname of command, if found in search path. 625 Empty string, otherwise. 626 NOTE: Based on the Unix command 'which'. 627 EXAMPLE: example which; shows an example 628 { 629 int rs; 630 int i; 631 string fn = "/tmp/which_" + string(system("pid")); 632 string pn; 633 if( typeof(command) != "string") 634 { 635 return pn; 636 } 637 i = system("sh", "which " + command + " > " + fn); 638 pn = read(fn); 639 pn[size(pn)] = ""; 640 i = 1; 641 while ((pn[i] != " ") and (pn[i] != "")) 642 { 643 i = i+1; 644 } 645 if (pn[i] == " ") {pn[i] = "";} 646 rs = system("sh", "ls " + pn + " > " + fn + " 2>&1 "); 647 i = system("sh", "rm " + fn); 648 if (rs == 0) {return (pn);} 649 else 650 { 651 print (command + " not found "); 652 return (""); 653 } 654 } 655 example 656 { "EXAMPLE:"; echo = 2; 657 which("Singular"); 658 } 659 /////////////////////////////////////////////////////////////////////////////// -
Singular/LIB/homog.lib
r6d09c56 r6f2edc 1 // $Id: homog.lib,v 1. 1.1.1 1997-04-25 15:13:26obachman Exp $1 // $Id: homog.lib,v 1.2 1997-04-28 19:27:18 obachman Exp $ 2 2 //(BM 11/95) 3 3 /////////////////////////////////////////////////////////////////////////////// 4 LIBRARY: homog.lib homological algebra porcedures 4 LIBRARY: homog.lib homological algebra porcedures 5 5 ext(<int>,<ideal>); Ext^k(R/I,R), I - ideal in basering R 6 6 Ext(<int>,<mod>,<mod>); Ext^k(M,N), M,N modules … … 328 328 example 329 329 { 330 "EXAMPLE"; echo=2; intprintlevel=2;330 "EXAMPLE"; echo=2; printlevel=2; 331 331 ring r = 0,(x,y),(dp,C); 332 332 ideal i = x2-y3; -
Singular/LIB/homolog.lib
r6d09c56 r6f2edc 1 // $Id: homolog.lib,v 1. 1.1.1 1997-04-25 15:13:26obachman Exp $2 //(BM 11/95)1 // $Id: homolog.lib,v 1.2 1997-04-28 19:27:19 obachman Exp $ 2 //(BM/GMG, last modified 22.06.96) 3 3 /////////////////////////////////////////////////////////////////////////////// 4 4 5 LIBRARY: homolog.lib PROCEDURES FOR HOMOLOGICAL ALGEBRA 6 7 Ext_R(k,id); Ext^k(R/id,R), id = ideal 8 Ext(k,M,N); Ext^k(M,N), M,N = modules 9 Hom(M,N); Hom(M,N), M,N = modules 10 kohom(A,k); Hom(R^k,A), A = matrix 11 kontrahom(A,k); Hom(A,R^k), A = matrix 12 5 LIBRARY: homolog.lib PROCEDURES FOR HOMOLOGICAL ALGEBRA 6 7 cup(M); cup: Ext^1(M',M') x Ext^1() --> Ext^2() 8 cupproduct(M,N,P,p,q); cup: Ext^p(M',N') x Ext^q(N',P') --> Ext^p+q(M',P') 9 Ext_R(k,M); Ext^k(M',R), M module, R basering, M'=coker(M) 10 Ext(k,M,N); Ext^k(M',N'), M,N modules, M'=coker(M), N'=coker(N) 11 Hom(M,N); Hom(M',N'), M,N modules, M'=coker(M), N'=coker(N) 12 homology(A,B,M,N) ker(B)/im(A), homology of complex R^k--A->M'--B->N' 13 kernel(A,M,N); ker(M'--A->N') M,N modules, A matrix 14 kohom(A,k); Hom(R^k,A), A matrix over basering R 15 kontrahom(A,k); Hom(A,R^k), A matrix over basering R 16 17 LIB "general.lib"; 18 LIB "deform.lib"; 13 19 LIB "matrix.lib"; 20 LIB "poly.lib"; 14 21 /////////////////////////////////////////////////////////////////////////////// 15 22 16 proc Ext_R (int k, ideal I, list #) 17 USAGE: Ext_R(k,id[,any]); k=integer, id=ideal 18 DISPLAY: degree of Ext^k(P/id,P) 19 RETURN: Ext^k(P/id,P), presentation as a quotient of a free module. 20 If a third argument is given (of any type) return a list of two 21 modules: 22 [1] = module Ext^k(P/id,P) 23 [2] = SB of Ext^k(P/id,P) 24 EXAMPLE: example Ext_R; shows an example 23 proc cup (module M,list #) 24 USAGE: cup(M,[,any,any]); M=module 25 COMPUTE: cup-product Ext^1(M',M') x Ext^1(M',M') ---> Ext^2(M',M'), 26 where M':=R^m/M, if M in R^m, R basering (i.e. M':=coker(matrix(M))) 27 in case of a second argument: symmetrized cup-product 28 ASSUME: all Ext's are finite dimensional 29 RETURN: matrix of the associated linear map, 30 i.e. the columns of <matrix> present the coordinates of b_i & b_j 31 (resp. (1/2)(b_i & b_j + b_j & b_i) in the symmetric version) 32 with respect to a kbase of Ext^2, 33 (where b_1,b_2,... is a kbase of Ext^1 and & denotes cup product) 34 in case of a third argument return a list: 35 L[1] = matrix see above (and symmetric case) 36 L[2] = matrix of kbase of Ext^1 37 L[3] = matrix of kbase of Ext^2 38 NOTE: printlevel >=1; shows what is going on 39 printlevel >=2; shows result in another representation 40 For computing cupproduct of M itself, apply proc to syz(M)! 41 EXAMPLE: example cup; shows examples 25 42 { 26 module m1,m2,ret,ret0; 27 //------------------ compute resolution of P/I -------------------------------- 28 mres(I,k+1,resI); 29 //----------------- apply Hom(_,P) at k-th place ----------------------------- 30 m2 = transpose(resI(k+1)); 31 m1 = transpose(resI(k)); 32 //----------------- ker(m2)/im(m1) ------------------------------------------- 33 m2 = simplify(m2,10); 34 if (m2[1]==0) { ret = m1; } 35 else { ret = modulo(syz(m2),m1); } 36 ret0 = std(ret); 37 "// degree of Ext^"+string(k)+"(P/I,P):";degree(ret0); 38 if (size(#)>0) { return(ret,ret0); } 39 return(ret); 43 //---------- initialization --------------------------------------------------- 44 int i,j,k,f0,f1,f2,f3,e1,e2; 45 module M1,M2,A,B,C,ker,ima,ext1,ext2,ext10,ext20; 46 matrix cup[1][0]; 47 matrix kb1,lift1,kb2,mA,mB,mC; 48 ideal tes1,tes2,null; 49 int p = printlevel-voice+3; // p=printlevel+1 (default: p=1) 50 //----------------------------------------------------------------------------- 51 //take a resolution of M<--F(0)<--- ... <---F(3) 52 //apply Hom(-,M) and compute the Ext's 53 //----------------------------------------------------------------------------- 54 list resM = res(M,3); 55 M1 = resM[2]; 56 M2 = resM[3]; 57 f0 = nrows(M); 58 f1 = ncols(M); 59 f2 = ncols(M1); 60 f3 = ncols(M2); 61 tes1 = simplify(ideal(M),10); 62 tes2=simplify(ideal(M1),10); 63 if ((tes1[1]*tes2[1]==0) or (tes1[1]==1) or (tes2[1]==1)) 64 { 65 dbprint(p,"// Ext == 0 , hence 'cup' is the zero-map"); 66 return(@cup); 67 } 68 //------ compute Ext^1 -------------------------------------------------------- 69 B = kohom(M,f2); 70 A = kontrahom(M1,f0); 71 C = intersect(A,B); 72 C = reduce(C,std(null));C = simplify(C,10); 73 ker = lift(A,C)+syz(A); 74 ima = kohom(M,f1); 75 ima = ima + kontrahom(M,f0); 76 ext1 = modulo(ker,ima); 77 ext10 = std(ext1); 78 e1 = vdim(ext10); 79 dbprint(p-1,"// vdim (Ext^1) = "+string(e1)); 80 if (e1 < 0) 81 { 82 "// Ext^1 not of finite dimension"; 83 return(cup); 84 } 85 kb1 = kbase(ext10); 86 kb1 = matrix(ker)*kb1; 87 dbprint(p-1,"// kbase of Ext^1(M,M)", 88 "// - the columns present the kbase elements in Hom(F(1),F(0))", 89 "// - F(*) a free resolution of M",kb1); 90 91 //------ compute the liftings of Ext^1 ---------------------------------------- 92 mC = matrix(A)*kb1; 93 lift1 =lift(B,mC); 94 dbprint(p-1,"// lift kbase of Ext^1:", 95 "// - the columns present liftings of kbase elements into Hom(F(2),F(1))", 96 "// - F(*) a free resolution of M ",lift1); 97 98 //------ compute Ext^2 ------------------------------------------------------- 99 B = kohom(M,f3); 100 A = kontrahom(M2,f0); 101 C = intersect(A,B); 102 C = reduce(C,std(null));C = simplify(C,10); 103 ker = lift(A,C)+syz(A); 104 ima = kohom(M,f2); 105 ima = ima + kontrahom(M1,f0); 106 ext2 = modulo(ker,ima); 107 ext20= std(ext2); 108 e2 = vdim(ext20); 109 if (e2<0) 110 { 111 "// Ext^2 not of finite dimension"; 112 return(cup); 113 } 114 dbprint(p-1,"// vdim (Ext^2) = "+string(e2)); 115 kb2 = kbase(ext20); 116 kb2 = matrix(ker)*kb2; 117 dbprint(p-1,"// kbase of Ext^2(M,M)", 118 "// - the columns present the kbase elements in Hom(F(2),F(0))", 119 "// - F(*) is a a free resolution of M ",kb2); 120 //------- compute: cup-products of base-elements ----------------------------- 121 for (i=1;i<=e1;i=i+1) 122 { 123 for (j=1;j<=e1;j=j+1) 124 { 125 mA = matrix(ideal(lift1[j]),f1,f2); 126 mB = matrix(ideal(kb1[i]),f0,f1); 127 mC = mB*mA; 128 if (size(#)==0) 129 { //non symmestric 130 mC = matrix(ideal(mC),f0*f2,1); 131 cup= concat(cup,mC); 132 } 133 else //symmetric version 134 { 135 if (j>=i) 136 { 137 if (j>i) 138 { 139 mA = matrix(ideal(lift1[i]),f1,f2); 140 mB = matrix(ideal(kb1[j]),f0,f1); 141 mC = mC+mB*mA;mC=(1/2)*mC; 142 } 143 mC = matrix(ideal(mC),f0*f2,1); 144 cup= concat(cup,mC); 145 } 146 } 147 } 148 } 149 dbprint(p-1,"// matrix of cup-products (in Ext^2)",cup,"////// end level 2 //////"); 150 //------- comptute: presentation of base-elements ----------------------------- 151 cup = lift(ker,cup); 152 cup = lift_kbase(cup,ext20); 153 if( p>2 ) 154 { 155 "// the associated matrices of the bilinear mapping 'cup' "; 156 "// corresponding to the kbase elements of Ext^2(M,M) are shown,"; 157 "// i.e. the rows of the final matrix are written as matrix of"; 158 "// a bilinear form on Ext^1 x Ext^1"; 159 matrix BL[e1][e1]; 160 for (k=1;k<=e2;k=k+1) 161 { 162 "//_____"+string(k)+". component:"; 163 for (i=1;i<=e1;i=i+1) 164 { 165 for (j=1;j<=e1;j=j+1) 166 { 167 if (size(#)==0) { BL[i,j]=cup[k,j+e1*(i-1)]; } 168 else 169 { 170 if (i<=j) 171 { 172 BL[i,j]=cup[k,j+e1*(i-1)-binomial(i,2)]; 173 BL[j,i]=BL[i,j]; 174 } 175 } 176 } 177 } 178 print(BL); 179 } 180 "////// end level 3 //////"; 181 } 182 if (size(#)>2) { return(cup,kb1,kb2);} 183 else {return(cup);} 40 184 } 41 185 example 42 { "EXAMPLE:"; echo=2; 43 ring r=0,(x,y,z),dp; 44 ideal i = x2y,y2z,z3x; 45 module E = Ext_R(1,i);""; 46 E = Ext_R(2,i); 47 show(E);""; 48 list LE = Ext_R(3,i,""); 49 kbase(LE[2]);""; 50 E = Ext_R(4,i); 186 {"EXAMPLE"; echo=2; 187 int p = printlevel; 188 ring rr = 32003,(x,y,z),(dp,C); 189 ideal I = x4+y3+z2; 190 qring o = std(I); 191 module M = [x,y,0,z],[y2,-x3,z,0],[z,0,-y,-x3],[0,z,x,-y2]; 192 print(cup(M)); 193 print(cup(M,1)); 194 // 2nd EXAMPLE (shows what is going on) 195 printlevel = 3; 196 ring r = 0,(x,y),(dp,C); 197 ideal i = x2-y3; 198 qring q = std(i); 199 module M = [-x,y],[-y2,x]; 200 print(cup(M)); 201 printlevel = p; 51 202 } 52 203 /////////////////////////////////////////////////////////////////////////////// 53 204 54 proc Ext (int k, module M, module N, list #) 55 USAGE: Ext(k,M,N[,any]); k=integer, M,N=modules 56 DISPLAY: degree of Ext^k(M,N) 57 RETURN: Ext^k(M,N), presentation as a quotient of a free module. 58 If a third argument is given (of any type) return a list of two 59 modules: 60 [1] = module Ext^k(M,N) 61 [2] = SB of Ext^k(M,N) 62 EXAMPLE: example Ext; shows an example 205 proc cupproduct (module M,N,P,int p,q,list #) 206 USAGE: cupproduct(M,N,P,p,q[,any]); M,N,P modules, p,q integers 207 COMPUTE: cup-product Ext^p(M',N') x Ext^q(N',P') ---> Ext^p+q(M',P') 208 where M':=R^m/M, if M in R^m, R basering (i.e. M':=coker(matrix(M))) 209 ASSUME: all Ext's are of finite dimension 210 RETURN: matrix of the associated linear map Ext^p(tensor)Ext^q-->Ext^p+q 211 i.e. the columnes of <matrix> present the coordinates of 212 the cup products (b_i & c_j) with respect to a kbase of Ext^p+q 213 (b_i resp. c_j are choosen bases of Ext^p resp. Ext^q) 214 in case of a 6th argument: 215 return a list 216 L[1] = matrix (see above) 217 L[2] = matrix of kbase of Ext^p(M',N') 218 L[3] = matrix of kbase of Ext^q(N',P') 219 L[4] = matrix of kbase of Ext^p+q(N',P') 220 NOTE: printlevel >=1; shows what is going on 221 printlevel >=2; shows result in another representation 222 For computing cupproduct of M,N itself, apply proc to syz(M),syz(N)! 223 EXAMPLE: example cupproduct; shows examples 63 224 { 64 module A,B,C,M1,M2,ker,imag,extMN,extMN0; 65 ideal test1,test2; 66 //---------- resolution of M and N ------------------------------------------ 67 if (k>0) 68 { 69 mres(M,k+1,resM); 70 M1 = resM(k); 71 M2 = resM(k+1); 72 test1 = simplify(ideal(M1),10); 73 test2 = simplify(ideal(N),10); 74 if ((test1[1]==0) or (test2[1]==0)) 75 { "//Ext(M,N)=0";return(extMN); } 76 else 77 { 78 test1 = simplify(ideal(M2),10); 79 if (test1[1]==0) //Ker(Hom(m2,N)) 80 { ker = freemodule(ncols(M1)*nrows(N));} 81 else 82 { 83 A = kontrahom(M2,nrows(N)); 84 B = kohom(N,ncols(M2)); 85 C = intersect(A,B); 86 C = reduce(C,std(ideal(0)));C=simplify(C,10); 87 ker = lift(A,C)+syz(A); 88 } 89 imag = kohom(N,ncols(M1)); 90 A = kontrahom(M1,nrows(N)); 91 imag = imag+A; //im(Hom(m1,M)) 92 extMN = modulo(ker,imag); 93 extMN0= std(extMN); 94 "// degree of Ext^"+string(k)+"(M,N):";degree(extMN0); 225 //---------- initialization --------------------------------------------------- 226 int e1,e2,e3,i,j,k,f0,f1,f2; 227 module M1,M2,N1,N2,P1,P2,A,B,C,ker,ima,extMN,extMN0,extMP, 228 extMP0,extNP,extNP0; 229 matrix cup[1][0]; 230 matrix kbMN,kbMP,kbNP,lift1,mA,mB,mC; 231 ideal test1,test2,null; 232 int pp = printlevel-voice+3; // pp=printlevel+1 (default: p=1) 233 //----------------------------------------------------------------------------- 234 //compute resolutions of M and N 235 // M<--F(0)<--- ... <---F(p+q+1) 236 // N<--G(0)<--- ... <---G(q+1) 237 //----------------------------------------------------------------------------- 238 list resM = res(M,p+q+1); 239 M1 = resM[p]; 240 M2 = resM[p+1]; 241 list resN = res(N,q+1); 242 N1 = resN[q]; 243 N2 = resN[q+1]; 244 P1 = resM[p+q]; 245 P2 = resM[p+q+1]; 246 //-------test: Ext==0?--------------------------------------------------------- 247 test1 = simplify(ideal(M1),10); 248 test2 = simplify(ideal(N),10); 249 if (test1[1]==0) { dbprint(pp,"//Ext(M,N)=0");return(cup); } 250 test1 = simplify(ideal(N1),10); 251 test2 = simplify(ideal(P),10); 252 if (test1[1]==0) { dbprint(pp,"//Ext(N,P)=0");return(cup); } 253 test1 = simplify(ideal(P1),10); 254 if (test1[1]==0) { dbprint(pp,"//Ext(M,P)=0");return(cup); } 255 //------ compute kbases of Ext's --------------------------------------------- 256 //------ Ext(M,N) 257 test1 = simplify(ideal(M2),10); 258 if (test1[1]==0) { ker = freemodule(ncols(M1)*nrows(N));} 259 else 260 { 261 A = kontrahom(M2,nrows(N)); 262 B = kohom(N,ncols(M2)); 263 C = intersect(A,B); 264 C = reduce(C,std(ideal(0)));C=simplify(C,10); 265 ker = lift(A,C)+syz(A); 266 } 267 ima = kohom(N,ncols(M1)); 268 A = kontrahom(M1,nrows(N)); 269 ima = ima+A; 270 extMN = modulo(ker,ima); 271 extMN0= std(extMN); 272 e1 = vdim(extMN0); 273 dbprint(pp-1,"// vdim Ext(M,N) = "+string(e1)); 274 if (e1 < 0) 275 { 276 "// Ext(M,N) not of finite dimension"; 277 return(cup); 278 } 279 kbMN = kbase(extMN0); 280 kbMN = matrix(ker)*kbMN; 281 dbprint(pp-1,"// kbase of Ext^p(M,N)", 282 "// - the columns present the kbase elements in Hom(F(p),G(0))", 283 "// - F(*),G(*) are free resolutions of M and N",kbMN); 284 //------- Ext(N,P) 285 test1 = simplify(ideal(N2),10); 286 if (test1[1]==0) { ker = freemodule(ncols(N1)*nrows(P)); } 287 else 288 { 289 A = kontrahom(N2,nrows(P)); 290 B = kohom(P,ncols(N2)); 291 C = intersect(A,B); 292 C = reduce(C,std(ideal(0)));C=simplify(C,10); 293 ker = lift(A,C)+syz(A); 294 } 295 ima = kohom(P,ncols(N1)); 296 A = kontrahom(N1,nrows(P)); 297 ima = ima+A; 298 extNP = modulo(ker,ima); 299 extNP0= std(extNP); 300 e2 = vdim(extNP0); 301 dbprint(pp-1,"// vdim Ext(N,P) = "+string(e2)); 302 if (e2 < 0) 303 { 304 "// Ext(N,P) not of finite dimension"; 305 return(cup); 306 } 307 kbNP = kbase(extNP0); 308 kbNP = matrix(ker)*kbNP; 309 dbprint(pp-1,"// kbase of Ext(N,P):",kbNP, 310 "// kbase of Ext^q(N,P)", 311 "// - the columns present the kbase elements in Hom(G(q),H(0))", 312 "// - G(*),H(*) are free resolutions of N and P",kbNP); 313 314 //------ Ext(M,P) 315 test1 = simplify(ideal(P2),10); 316 if (test1[1]==0) { ker = freemodule(ncols(P1)*nrows(P)); } 317 else 318 { 319 A = kontrahom(P2,nrows(P)); 320 B = kohom(P,ncols(P2)); 321 C = intersect(A,B); 322 C = reduce(C,std(ideal(0)));C=simplify(C,10); 323 ker = lift(A,C)+syz(A); 324 } 325 ima = kohom(P,ncols(P1)); 326 A = kontrahom(P1,nrows(P)); 327 ima = ima+A; 328 extMP = modulo(ker,ima); 329 extMP0= std(extMP); 330 e3 = vdim(extMP0); 331 dbprint(pp-1,"// vdim Ext(M,P) = "+string(e3)); 332 if (e3 < 0) 333 { 334 "// Ext(M,P) not of finite dimension"; 335 return(cup); 336 } 337 kbMP = kbase(extMP0); 338 kbMP = matrix(ker)*kbMP; 339 dbprint(pp-1,"// kbase of Ext^p+q(M,P)", 340 "// - the columns present the kbase elements in Hom(F(p+q),H(0))", 341 "// - F(*),H(*) are free resolutions of M and P",kbMP); 342 //----- lift kbase of Ext(M,N) ------------------------------------------------ 343 lift1 = kbMN; 344 for (i=1;i<=q;i=i+1) 345 { 346 mA = kontrahom(resM[p+i],nrows(resN[i])); 347 mB = kohom(resN[i],ncols(resM[p+i])); 348 lift1 = lift(mB,mA*lift1); 349 } 350 dbprint(pp-1,"// lifting of kbase of Ext^p(M,N)", 351 "// - the columns present the lifting of kbase elements in Hom(F(p+q),G(q))",lift1); 352 //------- compute: cup-products of base-elements ----------------------------- 353 f0 = nrows(P); 354 f1 = ncols(N1); 355 f2 = ncols(resM[p+q]); 356 for (i=1;i<=e1;i=i+1) 357 { 358 for (j=1;j<=e2;j=j+1) 359 { 360 mA = matrix(ideal(lift1[j]),f1,f2); 361 mB = matrix(ideal(kbMP[i]),f0,f1); 362 mC = mB*mA; 363 mC = matrix(ideal(mC),f0*f2,1); 364 cup= concat(cup,mC); 95 365 } 96 } 97 else { extMN,extMN0 = Hom(M,N,1); } 98 if (size(#)>0) { return(extMN,extMN0); } 99 return(extMN ); 366 } 367 dbprint(pp-1,"// matrix of cup-products (in Ext^p+q)",cup,"////// end level 2 //////"); 368 //------- comptute: presentation of base-elements ----------------------------- 369 cup = lift(ker,cup); 370 cup = lift_kbase(cup,extMP0); 371 //------- special output ------------------------------------------------------ 372 if (pp>2) 373 { 374 "// the associated matrices of the bilinear mapping 'cup' "; 375 "// corresponding to the kbase elements of Ext^p+q(M,P) are shown,"; 376 "// i.e. the rows of the final matrix are written as matrix of"; 377 "// a bilinear form on Ext^p x Ext^q"; 378 matrix BL[e1][e2]; 379 for (k=1;k<=e3;k=k+1) 380 { 381 "//----"+string(k)+". component:"; 382 for (i=1;i<=e1;i=i+1) 383 { 384 for (j=1;j<=e2;j=j+1) 385 { 386 BL[i,j]=cup[k,j+e1*(i-1)]; 387 } 388 } 389 print(BL); 390 } 391 "////// end level 3 //////"; 392 } 393 if (size(#)) { return(cup,kbMN,kbNP,kbMP);} 394 else { return(cup); } 100 395 } 101 396 example 102 { "EXAMPLE:"; echo=2; 103 ring r=0,(x,y),(c,dp); 104 ideal i=x2-y3; 105 qring qr=std(i); 106 module M=[-x,y],[-y2,x]; 107 list EXT1=Ext(1,M,M,""); 108 kbase(EXT1[2]); 109 } 110 //////////////////////////////////////////////////////////////////////////////// 111 112 proc Hom (module M, module N, list #) 113 USAGE: Hom(M,N); M,N=modules 114 DISPLAY: degree of Hom(M,N); 115 RETURN: Hom(M,N), presentation as a quotient of a free module. 116 If a third argument is given (of any type) return a list of two 117 modules: 118 [1] = module Hom(M,N) 119 [2] = SB of Hom(M,N) 120 EXAMPLE: example Hom; shows an example 397 {"EXAMPLE"; echo=2; 398 int p = printlevel; 399 ring rr = 32003,(x,y,z),(dp,C); 400 ideal I = x4+y3+z2; 401 qring o = std(I); 402 module M = [x,y,0,z],[y2,-x3,z,0],[z,0,-y,-x3],[0,z,x,-y2]; 403 print(cupproduct(M,M,M,1,3)); 404 printlevel = 3; 405 list l = (cupproduct(M,M,M,1,3,"any")); 406 show(l[1]);show(l[2]); 407 printlevel = p; 408 } 409 /////////////////////////////////////////////////////////////////////////////// 410 411 proc Ext_R (intvec v, module M, list #) 412 USAGE: Ext_R(v,M[,p]); v=int/intvec , M=module, p=int 413 COMPUTE: A presentation of Ext^k(M',R); for k=v[1],v[2],..., M'=coker(M). 414 Let ...--> F2 --> F1 --M-> F0-->M'-->0 be a free resolution of M'. If 415 0 <-- F0* <-A1-- F1* <-A2-- F2* <-A3--... denotes the dual sequence, 416 Fi*=Hom(Fi,R), then Ext^k = ker(Ak)/im(Ak+1) is presented as in the 417 following exact sequences: 418 Fk-1* <-Ak-- Fk* <-syz(Ak)-- R^p 419 Fk*/im(Ak+1) <-syz(Ak)-- R^p <-Ext^k-- R^q 420 Hence Ext^k=modulo(syz(Ak),Ak+1) presents Ext^k(M',R); 421 RETURN: Ext^k, of type module, a presentation of Ext^k(M',R) if v is of type 422 int, resp. a list of Ext^k (k=v[1],v[2],...) if v is of type intvec. 423 In case of a third argument of type int return a list: 424 [1] = module Ext^k/list of Ext^k 425 [2] = SB of Ext^k/list of SB of Ext^k 426 [3] = matrix/list of matrices, each representing kbase of Ext^k 427 (if finite dimensional) 428 DISPLAY: printlevel >=0: degree of Ext^k for each k (default) 429 printlevel >=1: Ak, Ak+1 and kbase of Ext^k in Fk* 430 NOTE: In order to compute Ext^k(M,R) use the command Ext_R(k,syz(M)); 431 or the 2 commands: list L=mres(M,2); Ext_R(k,L[2]); 432 EXAMPLE: example Ext_R; shows examples 433 { 434 435 //Bemerkung (nur fuer internen Gebrauch): Ext_R(v,M[,"sres",p]); bewirkt folgendes: 436 // Es wird der input mit sres statt mres aufgeloest. Bei den bisherigen Versuchen 437 // ist dies insgesamt langsamer, da sres zu gro§e Objekte zurueckliefert. 438 // Der Versuch, auch spaeter sres statt mres zu verwenden, ist ganz aufgegeben, 439 // da mit sres spaeter syz und modulo viel laenger dauern! 440 // In case M is known to be a SB, set attrib(M,"isSB",1); in order to 441 // avoid unnecessary SB computations 442 443 //------------ initialisation ------------------------------------------------- 444 module m1,m2,ret,ret0; 445 matrix ker,kb; 446 list L1,L2,L3,L,resl,K; 447 int k,max,ii,t1,t2; 448 int s = size(v); 449 intvec v1 = sort(v)[1]; 450 max = v1[s]; // the maximum integer occuring in intvec v 451 int p = printlevel-voice+3; // p=printlevel+1 (default: p=1) 452 // --------------- Variante mit sres 453 for( ii=1; ii<=size(#); ii++ ) 454 { 455 t2=1; // return a list if t2=1 456 if( typeof(#[ii])=="string" ) 457 { 458 if ( #[ii]=="sres" ) { t1=1; t2=0; } // use sres instead of mres if t1=1 459 } 460 } 461 //----------------- compute resolution of coker(M) ---------------------------- 462 if( max<0 ) { dbprint(p,"// Ext^i=0 for i<0!"); return([1]); } 463 if( t1==1 ) 464 { 465 if( attrib(M,"isSB")==0 ) { M=std(M); } 466 resl = sres(M,max+1); 467 } 468 else { resl = mres(M,max+1); } 469 for( ii=1; ii<=s; ii++ ) 470 { 471 //----------------- apply Hom(_,R) at k-th place ----------------------------- 472 k=v[ii]; 473 if( k<0 ) // Ext^k=0 for negative k 474 { 475 dbprint(p-1,"// Ext^i=0 for i<0!"); 476 ret = gen(1); 477 ret0 = std(ret); 478 L1[ii] = ret; 479 L2[ii] = ret0; 480 L3[ii] = matrix(kbase(ret0)); 481 dbprint(p,"// degree of Ext^"+string(k)+":"); 482 if( p>=0 ) { degree(ret0);"";} 483 } 484 else 485 { 486 m2 = transpose(resl[k+1]); 487 if( k==0 ) { m1=0*gen(nrows(m2)); } 488 else { m1 = transpose(resl[k]); } 489 //----------------- presentation of ker(m2)/im(m1) ---------------------------- 490 ker = syz(m2); 491 ret = modulo(ker,m1); 492 dbprint(p-1,"// Computing Ext^"+string(k)+":", 493 "// Let 0<--coker(M)<--F0<--F1<--F2<--... be a resolution of M,", 494 "// then F"+string(k)+"*-->F"+string(k+1)+"* is given by:",m2, 495 "// and F"+string(k-1)+"*-->F"+string(k)+"* is given by:",m1,""); 496 ret0 = std(ret); 497 dbprint(p,"// degree of Ext^"+string(k)+":"); 498 if( p>0 ) { degree(ret0);"";} 499 if( t2 ) 500 { 501 if( vdim(ret0)>=0 ) 502 { 503 kb = kbase(ret0); 504 if ( size(ker)!=0 ) { kb = matrix(ker)*kb; } 505 dbprint(p-1, 506 "// columns of matrix are kbase of Ext^"+string(k)+" in F"+string(k)+"*:",kb,""); 507 L3[ii] = kb; 508 } 509 L2[ii] = ret0; 510 } 511 L1[ii] = ret; 512 } 513 } 514 if( t2 ) 515 { 516 if( s>1 ) { L = L1,L2,L3; return(L); } 517 else { L = ret,ret0,kb; return(L); } 518 } 519 else 520 { 521 if( s>1 ) { return(L1); } 522 else { return(ret); } 523 } 524 } 525 example 526 {"EXAMPLE:"; echo=2; 527 int p = printlevel; 528 printlevel = 1; 529 ring r = 0,(x,y,z),dp; 530 ideal i = x2y,y2z,z3x; 531 module E = Ext_R(1,i); //computes Ext^1(r/i,r) 532 is_zero(E); 533 module m = [x],[0,y]; 534 list L = Ext_R(2..3,m); //computes Ext^i(r^2/m,r), i=2,3 535 show(L);""; 536 qring R = std(x2+yz); 537 intvec v = 0,2,4; 538 printlevel = 2; //shows what is going on 539 ideal i = x,y,z; //computes Ext^i(r/(x,y,z),r/(x2+yz)), i=0,2,4 540 list L = Ext_R(v,i,1); //over the qring R=r/(x2+yz), std and kbase 541 printlevel = p; 542 } 543 /////////////////////////////////////////////////////////////////////////////// 544 545 proc Ext (intvec v, module M, module N, list #) 546 USAGE: Ext(v,M,N[,any]); v=int/intvec, M,N=modules 547 COMPUTE: A presentation of Ext^k(M',N'); for k=v[1],v[2],... where 548 M'=coker(M) and N'=coker(N). Let 549 0<--M'<-- F0 <-M-- F1 <-- F2 <--... resp. 0<--N'<-- G0 <--N- G1 be 550 a free resolution of M' resp. a presentations of N'. Consider 551 0 0 0 552 |^ |^ |^ 553 --> Hom(Fk-1,N') -Ak-> Hom(Fk,N') -Ak+1-> Hom(Fk+1,N') 554 |^ |^ |^ 555 --> Hom(Fk-1,G0) -Ak-> Hom(Fk,G0) -Ak+1-> Hom(Fk+1,G0) 556 |^ |^ 557 |C |B 558 Hom(Fk,G1) -----> Hom(Fk+1,G1) 559 (Ak,Ak+1 induced by M and B,C induced by N). 560 Let K=modulo(Ak+1,B), J=module(Ak)+module(C) and Ext=modulo(K,J), 561 then we have exact sequences 562 R^p --K-> Hom(Fk,G0) --Ak+1-> Hom(Fk+1,G0)/im(B) 563 R^q -Ext-> R^p --K->Hom(Fk,G0)/im(Ak)+im(C) --Ak+1->Hom(Fk+1,G0)/im(B) 564 Hence Ext presents Ext^k(M',N') 565 RETURN: Ext, of type module, a presentation of Ext^k(M',N') if v is of type 566 int, resp. a list of Ext^k (k=v[1],v[2],...) if v is of type intvec. 567 In case of a third argument of any type return a list: 568 [1] = module Ext/list of Ext^k 569 [2] = SB of Ext/list of SB of Ext^k 570 [3] = matrix/list of matrices, each representing a kbase of Ext^k 571 (if finite dimensional) 572 DISPLAY: printlevel >=0: degree of Ext^k for each k (default) 573 printlevel >=1: Ak, Ak+1 and kbase of Ext^k in Hom(Fk,G0) 574 (if finite dimensional) 575 NOTE: In order to compute Ext^k(M,N) use the command Ext(k,syz(M),syz(N)); 576 or: list P=mres(M,2); list Q=mres(N,2); Ext(k,P[2],Q[2]); 577 EXAMPLE: example Ext; shows examples 121 578 { 122 579 //---------- initialisation --------------------------------------------------- 123 module A,B,C,ker,imag,homMN,homMN0; 124 ideal tes; 125 tes = simplify(ideal(M),10); 126 if (tes[1]==0) 127 { 128 "// Hom(ring,N)=N"; 129 if (size(#)>0) { return(N,std(N)); } 130 return(N); 131 } 132 tes = simplify(ideal(N),10); 133 if (tes[1]==0) 134 { 135 "// Hom(M,ring)=M^*"; 136 homMN = transpose(M); 137 if (size(#)>0) { return(homMN,std(homMN));} 138 return(homMN); 139 } 140 B = kohom(N,ncols(M)); 141 A = kontrahom(M,nrows(N)); 142 C = intersect(A,B); 143 C = reduce(C,std(ideal(0)));C=simplify(C,10); 144 ker = lift(A,C)+syz(A); //ker(Hom(m,N)) 145 imag = kohom(N,ncols(M)); //im(Hom(M,n)) 146 homMN = modulo(ker,imag); 147 homMN0= std(homMN); 148 "// degree of Hom(M,N):";degree(homMN0); 149 if (size(#)>0) { return(homMN,homMN0); } 150 return(homMN); 580 int k,max,ii,l,row,col; 581 module A,B,C,D,M1,M2,N1,ker,imag,extMN,extMN0; 582 matrix kb; 583 list L1,L2,L3,L,resM,K; 584 ideal test1; 585 intmat Be; 586 int s = size(v); 587 intvec v1 = sort(v)[1]; 588 max = v1[s]; // the maximum integer occuring in intvec v 589 int p = printlevel-voice+3; // p=printlevel+1 (default: p=1) 590 //---------- test: coker(N)=basering, coker(N)=0 ? ---------------------------- 591 if( max<0 ) { dbprint(p,"// Ext^i=0 for i<0!"); return([1]); } 592 N1 = std(N); 593 if( size(N1)==0 ) //coker(N)=basering, in this case proc Ext_R is faster 594 { printlevel=printlevel+1; 595 if( size(#)==0 ) 596 { def E = Ext_R(v,M); 597 printlevel=printlevel-1; 598 return(E); 599 } 600 else 601 { def E = Ext_R(v,M,#[1]); 602 printlevel=printlevel-1; 603 return(E); 604 } 605 } 606 if( dim(N1)==-1 ) //coker(N)=0, all Ext-groups are 0 607 { dbprint(p-1,"2nd module presents 0, hence Ext^k=0, for all k"); 608 for( ii=1; ii<=s; ii++ ) 609 { k=v[ii]; 610 extMN = gen(1); 611 extMN0 = std(extMN); 612 L1[ii] = extMN; 613 L2[ii] = extMN0; 614 L3[ii] = matrix(kbase(extMN0)); 615 if( p>0 ) { "// degree of Ext^"+string(k)+":"; degree(extMN0);""; } 616 } 617 } 618 else 619 { 620 if( size(N1) < size(N) ) { N=N1;} 621 row = nrows(N); 622 //---------- resolution of M ------------------------------------------------- 623 resM = mres(M,max+1); 624 for( ii=1; ii<=s; ii++ ) 625 { k=v[ii]; 626 if( k<0 ) // Ext^k is 0 for negative k 627 { dbprint(p-1,"// Ext^k=0 for k<0!"); 628 extMN = gen(1); 629 extMN0 = std(extMN); 630 L1[ii] = extMN; 631 L2[ii] = extMN0; 632 L3[ii] = matrix(kbase(extMN0)); 633 if( p>0 ) { "// degree of Ext^"+string(k)+":"; degree(extMN0);""; } 634 } 635 else 636 { M2 = resM[k+1]; 637 if( k==0 ) { M1=0*gen(nrows(M2)); } 638 else { M1 = resM[k]; } 639 col = ncols(M1); 640 D = kohom(N,col); 641 //---------- computing homology ---------------------------------------------- 642 imag = kontrahom(M1,row); 643 A = kontrahom(M2,row); 644 B = kohom(N,ncols(M2)); 645 ker = modulo(A,B); 646 imag = imag,D; 647 extMN = modulo(ker,imag); 648 dbprint(p-1,"// Computing Ext^"+string(k)+":", 649 "// Let 0<--coker(M)<--F0<--F1<--F2<--... be a resolution of coker(M),", 650 "// and 0<--coker(N)<--G0<--G1 a presentation of coker(N),", 651 "// then Hom(F"+string(k)+",G0)-->Hom(F"+string(k+1)+",G0) is given by:",A, 652 "// and Hom(F"+string(k-1)+",G0) + Hom(F"+string(k)+",G1)-->Hom(F"+string(k)+",G0) is given by:",imag,""); 653 extMN0 = std(extMN); 654 if( p>0 ) { "// degree of Ext^"+string(k)+":"; degree(extMN0);""; } 655 //---------- more information ------------------------------------------------- 656 if( size(#)>0 ) 657 { if( vdim(extMN0) >= 0 ) 658 { kb = kbase(extMN0); 659 if ( size(ker)!=0) { kb = matrix(ker)*kb; } 660 dbpri(p-1,"// columns of matrix are kbase of Ext^"+ 661 string(k)+" in Hom(F"+string(k)+",G0)",kb,""); 662 if( p>0 ) 663 { for (l=1;l<=ncols(kb);l=l+1) 664 { 665 "// element",l,"of kbase of Ext^"+string(k)+" in Hom(F"+string(k)+",G0)"; 666 "// as matrix: F"+string(k)+"-->G0"; 667 print(matrix(ideal(kb[l]),row,col)); 668 } 669 ""; 670 } 671 L3[ii] = matrix(kb); 672 } 673 L2[ii] = extMN0; 674 } 675 L1[ii] = extMN; 676 } 677 } 678 } 679 if( size(#) ) 680 { if( s>1 ) { L = L1,L2,L3; return(L); } 681 else { L = extMN,extMN0,matrix(kb); return(L); } 682 } 683 else 684 { if( s>1 ) { return(L1); } 685 else { return(extMN); } 686 } 151 687 } 152 688 example 153 { "EXAMPLE:"; echo = 2; 154 ring r=0,(x,y),(c,dp); 155 ideal i=x2-y3; 156 qring q=std(i); 157 module M=[-x,y],[-y2,x]; 158 module hom=Hom(M,M); 159 print(hom); newline; 160 ring s=3,(x,y,z),(c,dp); 161 ideal i=x2+y5+z4;i=jacob(i); 162 qring rq=std(i); 163 matrix M[2][2]=xy,x3,5y,z2,x2; 164 matrix N[4][4]=x,y,z,x2,xyx2y,y3,xz2,x2z,z3; 165 print(M); 166 print(N); 167 print(Hom(M,N)); 689 {"EXAMPLE:"; echo=2; 690 int p = printlevel; 691 printlevel = 1; 692 ring r = 0,(x,y),dp; 693 ideal i = x2-y3; 694 ideal j = x2-y5; 695 list E = Ext(0..2,i,j); // Ext^k(r/i,r/j) for k=0,1,2 over r 696 qring R = std(i); 697 ideal j = fetch(r,j); 698 module M = [-x,y],[-y2,x]; 699 printlevel = 2; 700 module E1 = Ext(1,M,j); // Ext^1(R^2/M,R/j) over R=r/i 701 list l = Ext(4,M,M,1); // Ext^4(R^2/M,R^2/M) over R=r/i 702 printlevel = p; 168 703 } 169 704 //////////////////////////////////////////////////////////////////////////////// 170 705 171 proc qmod (module M, module N) 172 USAGE: qmod(M,N); M,N=modules, N a submodule of M 173 COMPUTE: presentation S of M/N, i.e. M/N<<--F<--[S], F free of rank = size(M) 174 RETURN: module S 175 { 176 return(lift(M,N)+syz(M)); 706 proc Hom (module M, module N, list #) 707 USAGE: Hom(M,N,[any]); M,N=modules 708 COMPUTE: A presentation of Hom(M',N'), M'=coker(M), N'=coker(N) as follows: 709 Let ...-->F1 --M-> F0-->M'-->0 and ...-->G1 --N-> G0-->N'-->0 be 710 presentations of M' and N'. Consider 711 0 0 712 |^ |^ 713 0 --> Hom(M',N') ----> Hom(F0,N') ----> Hom(F1,N') 714 |^ |^ 715 (A: induced by M) Hom(F0,G0) --A-> Hom(F1,G0) 716 |^ |^ 717 (B,C:induced by N) |C |B 718 Hom(F0,G1) ----> Hom(F1,G1) 719 720 Let D=modulo(A,B) and Hom=modulo(D,C), then we have exact sequences 721 R^p --D-> Hom(F0,G0) --A-> Hom(F1,G0)/im(B) 722 R^q -Hom-> R^p --D-> Hom(F0,G0)/im(C) --A-> Hom(F1,G0)/im(B). 723 Hence Hom presents Hom(M',N') 724 RETURN: Hom, of type module, presentation of Hom(M',N') or, 725 in case of 3 arguments, a list: 726 [1] = Hom 727 [2] = SB of Hom 728 [3] = kbase of coker(Hom) (if finite dimensional), represented by 729 elements in Hom(F0,G0) via mapping D 730 DISPLAY: printlevel >=0: degree of Hom (default) 731 printlevel >=1: D and C and kbase of coker(Hom) in Hom(F0,G0) 732 printlevel >=2: elements of kbase of coker(Hom) as matrix :F0-->G0 733 NOTE: DISPLAY is as described only for a direct call of 'Hom'. Calling 'Hom' 734 from another proc has the same effect as decreasing printlevel by 1. 735 EXAMPLE: example Hom; shows examples 736 { 737 //---------- initialisation --------------------------------------------------- 738 int l,p; 739 matrix kb; 740 module A,B,C,D,homMN,homMN0; 741 list L; 742 //---------- computation of Hom ----------------------------------------------- 743 B = kohom(N,ncols(M)); 744 A = kontrahom(M,nrows(N)); 745 C = kohom(N,nrows(M)); 746 D = modulo(A,B); 747 homMN = modulo(D,C); 748 homMN0= std(homMN); 749 p = printlevel-voice+3; // p=printlevel+1 (default: p=1) 750 if( p>=0 ) { "// degree of Hom:"; degree(homMN0); ""; } 751 dbprint(p-1,"// given ...--> F1 --M-> F0 -->M'--> 0 and ...--> G1 --N-> G0 -->N'--> 0,", 752 "// show D=ker(Hom(F0,G0) --> Hom(F1,G0)/im(Hom(F1,G1) --> Hom(F1,G0)))",D, 753 "// show C=im(Hom(F0,G1) --> Hom(F0,G0))",C,""); 754 //---------- extra output if size(#)>0 ---------------------------------------- 755 if( size(#)>0 ) 756 { if( vdim(homMN0)>0 ) 757 { kb = kbase(homMN0); 758 kb = matrix(D)*kb; 759 if( p>2 ) 760 { for (l=1;l<=ncols(kb);l=l+1) 761 { 762 "// element",l,"of kbase of Hom in Hom(F0,G0) as matrix: F0-->G0:"; 763 print(matrix(ideal(kb[l]),nrows(N),nrows(M))); 764 } 765 } 766 else 767 { dbprint(p-1,"// columns of matrix are kbase of Hom in Hom(F0,G0)",kb); } 768 L=homMN,homMN0,kb; return(L); 769 } 770 L=homMN,homMN0; return(L); 771 } 772 return(homMN); 773 } 774 example 775 {"EXAMPLE:"; echo = 2; 776 int p = printlevel; 777 printlevel= 1; //in 'example proc' printlevel has to be increased by 1 778 ring r = 0,(x,y),dp; 779 ideal i = x2-y3,xy; 780 qring q = std(i); 781 ideal i = fetch(r,i); 782 module M = [-x,y],[-y2,x],[x3]; 783 module H = Hom(M,i); 784 print(H); 785 printlevel= 2; 786 list L = Hom(M,i,1);""; 787 ring s = 3,(x,y,z),(c,dp); 788 ideal i = jacob(ideal(x2+y5+z4)); 789 qring rq=std(i); 790 matrix M[2][2]=xy,x3,5y,4z,x2; 791 matrix N[3][2]=x2,x,y3,3xz,x2z,z; 792 print(M); 793 print(N); 794 list l=Hom(M,N,1); 795 printlevel = p; 796 } 797 //////////////////////////////////////////////////////////////////////////////// 798 799 proc homology (matrix A,matrix B,module M,module N,list #) 800 USAGE: homology(A,B,M,N); 801 COMPUTE: Let M and N be submodules of R^m and R^n presenting M'=R^m/M, N'=R^n/N 802 (R=basering) and let A,B matrices inducing maps R^k--A-->R^m--B-->R^n. 803 Compute a presentation R^q --H-> R^m of the module 804 ker(B)/im(A) := ker(M'/im(A) --B--> N'/im(BM)+im(BA)). 805 If B induces a map M'--B-->N' (i.e BM=0) and if R^k--A-->M'--B-->N' is 806 a complex (i.e. BA=0) then ker(B)/im(A) is the homology of this complex 807 RETURN: module H, a presentation of ker(B)/im(A) 808 NOTE: homology returns a free module of rank m if ker(B)=im(A) 809 EXAMPLE: example homology; shows examples 810 { 811 module ker,ima; 812 ker = modulo(B,N); 813 ima = A,M; 814 return(modulo(ker,ima)); 815 } 816 example 817 {"EXAMPLE"; echo=2; 818 ring r; 819 ideal id=maxideal(4); 820 qring qr=std(id); 821 module N=maxideal(3)*freemodule(2); 822 module M=maxideal(2)*freemodule(2); 823 module B=[2x,0],[x,y],[z2,y]; 824 module A=M; 825 degree(std(homology(A,B,M,N)));""; 826 ring s=0,x,ds; 827 qring qs=std(x4); 828 module A=[x];module B=A; 829 module M=[x3];module N=M; 830 homology(A,B,M,N); 177 831 } 178 832 ////////////////////////////////////////////////////////////////////////////// 179 833 834 proc kernel (matrix A,module M,module N) 835 USAGE: kernel(A,M,N); 836 COMPUTE: Let M and N be submodules of R^m and R^n presenting M'=R^m/M, N'=R^n/N 837 (R=basering) and let A:R^m-->R^n a matrix inducing a map A':M'-->N'. 838 Compute a presentation K of ker(A') as in the commutative diagram: 839 ker(A') ---> M' --A'--> N' 840 |^ |^ |^ 841 | | | 842 R^r ---> R^m --A--> R^n 843 |^ |^ |^ 844 |K |M |N 845 | | | 846 R^s ---> R^p -----> R^q 847 RETURN: module K, a presentation of ker(A') 848 EXAMPLE: example kernel; shows examples 849 { 850 module M1 = modulo(A,N); 851 return(modulo(M1,M)); 852 } 853 example 854 {"EXAMPLE"; echo=2; 855 ring r; 856 module N=[2x,x],[0,y]; 857 module M=maxideal(1)*freemodule(2); 858 matrix A[2][2]=2x,0,x,y,z2,y; 859 module K=kernel(A,M,N); 860 degree(std(K)); 861 print(K); 862 } 863 //////////////////////////////////////////////////////////////////////////////// 864 865 proc kohom (matrix M, int j) 866 USAGE: kohom(A,k); A=matrix, k=integer 867 RETURN: matrix Hom(R^k,A) i.e. let A be a matrix defining a map: F1 --> F2 of 868 free R-modules, the matrix of Hom(R^k,F1)-->Hom(R^k,F2) is computed 869 EXAMPLE: example kohom; shows an example 870 { 871 if (j==1) 872 { return(M);} 873 if (j>1) 874 { return(outer(M,diag(1,j))); } 875 else { return(0);} 876 } 877 example 878 {"EXAMPLE:"; echo=2; 879 ring r; 880 matrix n[2][3]=x,y,5,z,77,33; 881 print(kohom(n,3)); 882 } 883 ///////////////////////////////////////////////////////////////////////////////// 884 180 885 proc kontrahom (matrix M, int j) 181 USAGE: qmod(M,N); M,N=modules, N a submodule of M182 886 USAGE: kontrahom(A,k); A=matrix, k=integer 183 RETURN: Hom(A,P^k), i.e. let A be a matrix defining a map: F1 --> F2 of free184 P-modules, the matrix of Hom(F2,P^k)-->Hom(F1,P^k) is computed887 RETURN: matrix Hom(A,R^k), i.e. let A be a matrix defining a map: F1 --> F2 of 888 free R-modules, the matrix of Hom(F2,R^k)-->Hom(F1,R^k) is computed 185 889 EXAMPLE: example kontrahom; shows an example 186 890 { 187 return(transpose(outer(diag(1,j),M))); 891 if (j==1) 892 { return(transpose(M));} 893 if (j>1) 894 { return(transpose(outer(diag(1,j),M)));} 895 else { return(0);} 188 896 } 189 897 example 190 { 191 192 193 898 {"EXAMPLE:"; echo=2; 899 ring r; 900 matrix n[2][3]=x,y,5,z,77,33; 901 print(kontrahom(n,3)); 194 902 } 195 903 /////////////////////////////////////////////////////////////////////////////// 196 197 proc kohom (matrix M, int j)198 USAGE: kohom(A,k); A=matrix, k=integer199 RETURN: Hom(P^k,A) i.e. let A be a matrix defining a map: F1 --> F2 of free200 P-modules, the matrix of Hom(P^k,F1)-->Hom(P^k,F2) is computed201 EXAMPLE: example kohom; shows an example202 {203 return(outer(M,diag(1,j)));204 }205 example206 { "EXAMPLE:"; echo=2;207 ring r;208 matrix n[2][3]=x,y,5,z,77,33;209 print(kohom(n,3));210 }211 ///////////////////////////////////////////////////////////////////////////////212 -
Singular/LIB/inout.lib
r6d09c56 r6f2edc 1 // $Id: inout.lib,v 1. 1.1.1 1997-04-25 15:13:26obachman Exp $2 // system("random",787422842);3 // (GMG,BM)4 /////////////////////////////////////////////////////////////////////////////// 5 6 LIBRARY: inout.lib PROCEDURES FOR MANIPULATING IN- AND OUTPUT 1 // $Id: inout.lib,v 1.2 1997-04-28 19:27:20 obachman Exp $ 2 // system("random",787422842); 3 // (GMG/BM, last modified 22.06.96) 4 /////////////////////////////////////////////////////////////////////////////// 5 6 LIBRARY: inout.lib PROCEDURES FOR MANIPULATING IN- AND OUTPUT 7 7 8 8 allprint(list); print list if ALLprint is defined, with pause if >0 … … 19 19 /////////////////////////////////////////////////////////////////////////////// 20 20 21 proc allprint (list #) 21 proc allprint (list #) 22 22 USAGE: allprint(L); L list 23 23 CREATE: display L[1], L[2], ... if an integer with name ALLprint is defined, 24 makes "pause", if ALLprint > 0 24 makes "pause", if ALLprint > 0 25 25 listvar(matrix), if ALLprint = 2 26 26 RETURN: no return value … … 30 30 { 31 31 int i; 32 for( i=1; i<=size(#); i ++) { print(#[i]); }32 for( i=1; i<=size(#); i=i+1 ) { print(#[i]); } 33 33 if( ALLprint==2 ) { pause; listvar(matrix); } 34 34 if( ALLprint >0 ) { pause; } 35 } 35 } 36 36 return(); 37 } 37 } 38 38 example 39 39 { "EXAMPLE:"; echo = 2; … … 43 43 allprint("M =",M); 44 44 kill ALLprint; 45 } 45 } 46 46 /////////////////////////////////////////////////////////////////////////////// 47 47 … … 52 52 RETURN: no return value 53 53 NOTE: this is uesful to control the printing of comments or partial results 54 in a procedure, e.g. for debugging a procedure. 54 in a procedure, e.g. for debugging a procedure. 55 55 It is similair but not the same as the internal function dbprint 56 56 EXAMPLE: example dbpri; shows an example 57 57 { 58 int i; 58 int i; 59 59 if( defined(printlevel)==0 ) { int printlevel; export printlevel; } 60 60 if( n<=printlevel ) 61 61 { 62 for( i=1; i<=size(#); i ++) { print(#[i]); }62 for( i=1; i<=size(#); i=i+1 ) { print(#[i]); } 63 63 } 64 64 return(); 65 } 65 } 66 66 example 67 67 { "EXAMPLE:"; echo = 2; 68 68 ring s; 69 module M=freemodule(3); 69 module M=freemodule(3); 70 70 dbpri(0,"M =",M); 71 71 } 72 72 /////////////////////////////////////////////////////////////////////////////// 73 73 74 proc lprint 74 proc lprint 75 75 USAGE: lprint(id[,n]); id poly/ideal/vector/module/matrix, n integer 76 RETURN: string of id in a format fitting into lines of size n; if only one 77 argument is present, n = pagewidth 76 RETURN: string of id in a format fitting into lines of size n; if only one 77 argument is present, n = pagewidth 78 78 NOTE: id is printed columnwise, each column separated by a blank line; 79 79 hence lprint(transpose(id)); displays a matrix id in a format which … … 85 85 matrix M = matrix(#[1]); 86 86 poly p,h,L; string s1,s,S; int jj,ii,a; 87 for (jj=1; jj<=ncols(M); jj ++)88 { 89 for (ii=1; ii<=nrows(M); ii ++)87 for (jj=1; jj<=ncols(M); jj=jj+1) 88 { 89 for (ii=1; ii<=nrows(M); ii=ii+1) 90 90 { 91 91 a=2; … … 96 96 while (p != 0) 97 97 { 98 if (a+size(string(h+L)) > n) 99 { 98 if (a+size(string(h+L)) > n) 99 { 100 100 s = string(h); 101 101 if (a != 0) { s = " "+s; } … … 109 109 } 110 110 if (ii != nrows(M)) { s = s+","; S=S+newline+s; } 111 else 111 else 112 112 { 113 113 if (jj != ncols(M)) { s = s+","; S=S+newline+s+newline;} … … 132 132 // above) as input in order to reproduce m (by defining m1): 133 133 execute("matrix M[2][3]="+s+";"); 134 module m1 = transpose(M); 134 module m1 = transpose(M); 135 135 m-m1; 136 136 } … … 142 142 if n is given, only the first n characters of each colum are shown 143 143 RETURN: no return value 144 EXAMPLE: example pmat; shows an example 144 EXAMPLE: example pmat; shows an example 145 145 { 146 146 //------------- main case: input is a matrix, no second argument--------------- 147 147 if ( size(#)==0) 148 { 148 { 149 149 int elems,mlen,slen,c,r; 150 150 //-------------- count maximal size of each column, and sum up ------------- 151 for ( c=1; c<=ncols(m); c ++)151 for ( c=1; c<=ncols(m); c=c+1) 152 152 { int len(c); 153 for (r=1; r<=nrows(m); r ++)153 for (r=1; r<=nrows(m); r=r+1) 154 154 { 155 155 elems = elems+1; … … 163 163 string aus; string sep = " "; 164 164 if (mlen >= pagewidth) { sep = newline; } 165 for (r=1; r<nrows(m); r ++)165 for (r=1; r<nrows(m); r=r+1) 166 166 { elems = r; aus = ""; 167 for (c=1; c<=ncols(m); c ++)167 for (c=1; c<=ncols(m); c=c+1) 168 168 { 169 169 aus = aus + s(elems)[1,len(c)] + sep; … … 174 174 //--------------- print last row (no comma after last entry) --------------- 175 175 aus = ""; elems = nrows(m); 176 for (c=1; c<ncols(m); c ++)176 for (c=1; c<ncols(m); c=c+1) 177 177 { 178 178 aus = aus + s(elems)[1,len(c)] + sep; … … 185 185 if ( typeof(#[1])=="int" ) 186 186 { string aus,tmp; int ll,c,r; 187 for ( r=1; r<=nrows(m); r ++)187 for ( r=1; r<=nrows(m); r=r+1) 188 188 { aus = ""; 189 for (c=1; c<=ncols(m); c ++)190 { 191 tmp=string(m[r,c]); 192 aus=aus+tmp[1,#[1]]+" "; 189 for (c=1; c<=ncols(m); c=c+1) 190 { 191 tmp=string(m[r,c]); 192 aus=aus+tmp[1,#[1]]+" "; 193 193 } 194 194 aus; … … 207 207 /////////////////////////////////////////////////////////////////////////////// 208 208 209 proc rMacaulay 209 proc rMacaulay 210 210 USAGE: rMacaulay(s[,n]); s string, n integer 211 211 RETURN: a string which should be readable by Singular if s is a string read 212 212 by Singular from a file which was produced by Macaulay_1 (='Macaulay 213 classic'). If a second argument is present the first n lines of the 214 file are deleted (which is useful if the file was prodeuced e.g. by 215 the putstd command of Macaulay) 213 classic'). If a second argument is present the first n lines of the 214 file are deleted (which is useful if the file was prodeuced e.g. by 215 the putstd command of Macaulay) 216 216 NOTE: This does not always work with 'cut and paste' since, coming 217 from the screen, the character \ is treated differently 218 EXAMPLE: example rMacaulay; shows an example 217 from the screen, the character \ is treated differently 218 EXAMPLE: example rMacaulay; shows an example 219 219 { 220 220 int n; … … 223 223 //------------------------ delete first n=#[2] lines -------------------------- 224 224 int ii=find(s0,newline); int jj; 225 for ( jj=1; jj<=n; jj ++)225 for ( jj=1; jj<=n; jj=jj+1) 226 226 { 227 227 s0 = s0[ii+1,size(s0)-ii]; … … 243 243 ii = find(s0,newline); 244 244 } 245 jj=jj+1; 245 jj=jj+1; 246 246 string s(jj) = s0; 247 247 //------------ delete blanks and \ at end of each string and add , ------------ … … 261 261 s1 = ""; s2 = s(ii); 262 262 kk = find(s(ii)," "); ll=kk+1; 263 while( kk!=0 ) 263 while( kk!=0 ) 264 264 { 265 265 while( s2[ll]==" ") { ll=ll+1; } … … 299 299 example 300 300 { "EXAMPLE:"; echo = 2; 301 // Assume there exists a file 'Macid' with the following ideal in Macaulay 301 // Assume there exists a file 'Macid' with the following ideal in Macaulay 302 302 // format:" 303 // x[0]3-101/74x[0]2x[1]+7371x[0]x[1]2-13/83x[1]3-x[0]2x[2] \ 303 // x[0]3-101/74x[0]2x[1]+7371x[0]x[1]2-13/83x[1]3-x[0]2x[2] \ 304 304 // -4/71x[0]x[1]x[2]-65/64x[1]2x[2]-49/111x[0]x[2]2-x[1]x[2]2 \ 305 // -747x[2]3+6072x[0]2x[3] 306 // You can read this file into Singular and assign it to the string s1 by: 305 // -747x[2]3+6072x[0]2x[3] 306 // You can read this file into Singular and assign it to the string s1 by: 307 307 // string s1 = read("Macid"); 308 308 // This is equivalent to"; … … 314 314 // You may wish to assign s1 to a Singular ideal id: 315 315 string sid = "ideal id =",rMacaulay(s1),";"; 316 ring r = 0,x(0..3),dp; 316 ring r = 0,x(0..3),dp; 317 317 execute sid; 318 318 id; ""; … … 330 330 /////////////////////////////////////////////////////////////////////////////// 331 331 332 proc show 332 proc show (id, list #) 333 333 USAGE: show(id); id any object of basering or of type ring/qring 334 show(R,s); R=ring, s=string ( `s`= name of an object belonging to R)335 CREATE: display id resp.`s`in a compact format together with some information334 show(R,s); R=ring, s=string (s = name of an object belonging to R) 335 CREATE: display id/s in a compact format together with some information 336 336 RETURN: no return value 337 337 NOTE: objects of type string, int, intvec, intmat belong to any ring. 338 id may be a ring or a qring. In this case the minimal polynomial is 339 displayed, and, for a qring, also the defining ideal .340 id m ust not be of type list341 CAUTION: show(R,s) does not work inside a procedure 338 id may be a ring or a qring. In this case the minimal polynomial is 339 displayed, and, for a qring, also the defining ideal 340 id may be of type list but the list must not contain a ring 341 CAUTION: show(R,s) does not work inside a procedure 342 342 EXAMPLE: example show; shows an example 343 { 343 { 344 344 //------------- use funny names in order to avoid name conflicts -------------- 345 int @li@, @ii; 346 string @s@,@@s; 345 347 int @short@=short; short=1; 346 string @s@;347 348 //----------------------------- check syntax ---------------------------------- 348 if( size(#)==1 ) 349 { 350 def @id@ = #[1]; 351 } 352 if( size(#)==2 ) 353 { 354 if( typeof(#[1])=="ring" or typeof(#[1])=="qring") 355 { 356 def @R@ = #[1]; 357 setring @R@; 358 def @id@=`#[2]`; 359 } 360 } 361 if( defined(@id@)!=voice ) { "// wrong syntax, type help show;"; return(); } 349 if( size(#)!= 0 ) 350 { 351 if( typeof(#[1])=="int" ) { @li@=#[1]; } 352 } 353 if ( typeof(id)!="list" ) 354 { 355 if( size(#)==0 ) 356 { 357 def @id@ = id; 358 } 359 if( size(#)==1 ) 360 { 361 if( typeof(#[1])=="int" ) 362 { 363 def @id@ = id; 364 } 365 if( typeof(#[1])=="string" ) 366 { 367 if( typeof(id)=="ring" or typeof(id)=="qring") 368 { 369 def @R@ = id; 370 setring @R@; 371 def @id@=`#[1]`; 372 } 373 } 374 } 375 } 376 //----------------------- case: id is of type list ---------------------------- 377 if ( typeof(id)=="list" ) 378 { 379 @@s = tab(@li@)+"// list, "+string(size(id))+" element(s):"; 380 @@s; 381 for ( @ii=1; @ii<=size(id); @ii++ ) 382 { 383 if( typeof(id[@ii])!="none" ) 384 { 385 def @id(@ii) = id[@ii]; 386 show(@id(@ii),@li@+3); 387 } 388 else { tab(@li@+2),"//",id[@ii]; } 389 } 390 short=@short@; return(); 391 } 392 if( defined(@id@)!=voice ) { "// wrong syntax, type help show;"; return(); } 362 393 //-------------------- case: @id@ belongs to any ring ------------------------- 363 394 if( typeof(@id@)=="string" or typeof(@id@)=="int" or typeof(@id@)=="intvec" 364 or typeof(@id@)=="intmat" or typeof(@id@)=="list" ) 365 { 366 "//", typeof(@id@); 395 or typeof(@id@)=="intmat" or typeof(@id@)=="list" ) 396 { 397 if( typeof(@id@)!="intmat" ) 398 { 399 @@s = tab(@li@)+"// "+typeof(@id@)+", size "+string(size(@id@)); 400 @@s; 401 } 402 if( typeof(@id@)=="intmat" ) 403 { 404 @@s = tab(@li@)+"// "+typeof(@id@)+", "+string(nrows(@id@))+" rows, " 405 + string(ncols(@id@))+" columns"; 406 @@s; 407 } 367 408 @id@; 368 short=@short@; return(); 409 short=@short@; return(); 369 410 } 370 411 //-------------------- case: @id@ belongs to basering ------------------------- 371 412 if( typeof(@id@)=="poly" or typeof(@id@)=="ideal" or typeof(@id@)=="matrix" ) 372 413 { 373 if( typeof(@id@)=="ideal" ) { @s@=", "+string(ncols(@id@))+" generators";} 374 if( typeof(@id@)=="matrix") { @s@=", "+string(nrows(@id@))+"x"+string(ncols(@id@));} 375 "// "+ typeof(@id@)+ @s@; 376 print(matrix(@id@)); short=@short@; return(); 414 if( typeof(@id@)=="ideal" ) 415 { 416 @s@=", "+string(ncols(@id@))+" generator(s)"; 417 } 418 if( typeof(@id@)=="matrix") 419 { 420 @s@=", "+string(nrows(@id@))+"x"+string(ncols(@id@)); 421 } 422 @@s = tab(@li@)+"// "+ typeof(@id@)+ @s@; 423 @@s; 424 print(matrix(@id@)); 425 short=@short@; return(); 377 426 } 378 427 if( typeof(@id@)=="vector" ) 379 428 { 380 "//", typeof(@id@); 381 print(@id@); short=@short@; return(); 429 @@s = tab(@li@)+"// "+typeof(@id@); 430 @@s; 431 print(@id@); 432 short=@short@; return(); 382 433 } 383 434 if( typeof(@id@)=="module" ) 384 435 { 385 @s@=", "+string(ncols(@id@))+" generators"; 386 "// "+ typeof(@id@)+ @s@; 436 @s@=", "+string(ncols(@id@))+" generator(s)"; 437 @@s = tab(@li@)+"// "+ typeof(@id@)+ @s@; 438 @@s; 387 439 int @n@; 388 for( @n@=1; @n@<=ncols(@id@); @n@ ++) { print(@id@[@n@]); }440 for( @n@=1; @n@<=ncols(@id@); @n@=@n@+1 ) { print(@id@[@n@]); } 389 441 short=@short@; return(); 390 442 } 391 if( typeof(@id@)=="number" ) { "//", typeof(@id@); @id@; short=@short@; return(); } 392 if( typeof(@id@)=="map" ) 393 { 443 if( typeof(@id@)=="number" ) 444 { 445 @@s = tab(@li@)+"//", typeof(@id@); 446 @@s; 447 @id@; short=@short@; return(); 448 } 449 if( typeof(@id@)=="map" ) 450 { 394 451 def @map = @id@; 395 "// nth variable of preimage ring is mapped to nth component of map"; 396 if( size(#)==1 ) { type @map; } 397 if( size(#)==2 ) { type `#[2]`; } 452 @@s = tab(@li@)+"// i-th variable of preimage ring is mapped to @map[i]"; 453 @@s; 454 if( size(#)==0 ) { type @map; } 455 if( size(#)==1 ) 456 { 457 if( typeof(#[1])=="int" ) { type @map; } 458 if( typeof(#[1])=="string" ) { type `#[1]`; } 459 } 398 460 short=@short@; return(); 399 461 } 400 462 //---------------------- case: @id@ is a ring/qring --------------------------- 401 if( typeof(@id@)=="ring" or typeof(@id@)=="qring" ) 402 { 463 if( typeof(@id@)=="ring" or typeof(@id@)=="qring" ) 464 { 403 465 setring @id@; 404 466 string s="("+charstr(@id@)+"),("+varstr(@id@)+"),("+ordstr(@id@)+");"; 405 if( typeof(@id@)=="ring" ) 406 { 407 "// ring:",s;408 "// minpoly =",minpoly;467 if( typeof(@id@)=="ring" ) 468 { 469 @@s = tab(@li@)+"// ring:"; @@s,s; 470 @@s = tab(@li@)+"// minpoly ="; @@s,minpoly; 409 471 } 410 472 if( typeof(@id@)=="qring" ) 411 { 412 "// qring:",s; 413 "// minpoly =", minpoly; 414 "// quotient ring from ideal:"; ideal(@id@); 415 } 416 short=@short@; return(); 473 { 474 @@s = tab(@li@)+"// qring:"; @@s,s; 475 @@s = tab(@li@)+"// minpoly ="; @@s, minpoly; 476 @@s = tab(@li@)+"// quotient ring from ideal:"; @@s; 477 ideal(@id@); 478 } 479 short=@short@; //return(); 417 480 } 418 481 } … … 422 485 show(r); 423 486 ideal i=x^3+y^5-6*z^3,xy,x3-y2; 424 show(i );487 show(i,3); 425 488 vector v=x*gen(1)+y*gen(3); 426 show(v);427 module m=v,2*v+gen(4);428 show( m);429 ring S=(0,T),(a,b,c,d),ws(1,2,3,4); 430 minpoly = T 2+1;431 ideal i=a2+b,c2+T 2*d2; i=std(i);432 qring Q=i; 433 show(Q); 489 module m=v,2*v+gen(4); 490 list L = i,v,m; 491 show(L); 492 ring S=(0,T),(a,b,c,d),ws(1,2,3,4); 493 minpoly = T^2+1; 494 ideal i=a2+b,c2+T^2*d2; i=std(i); 495 qring Q=i; 496 show(Q); 434 497 map F=r,a2,b^2,3*c3; 435 498 show(F); … … 444 507 (default: n=pagewidth) 445 508 NOTE: may be used in connection with lprint 446 EXAMPLE: example split; shows an example 509 EXAMPLE: example split; shows an example 447 510 { 448 511 string line,re; int p,l; 449 if( size(#)==0 ) { int n=pagewidth; } 512 if( size(#)==0 ) { int n=pagewidth; } 450 513 else { int n=#[1]; } 451 514 if( s[size(s),1] != newline ) { s=s+newline; } … … 461 524 } 462 525 re=re+line[p,l-1]+"\\"+newline; 463 l=size(line); 526 l=size(line); 464 527 if( l>=size(s) ) break; 465 528 s=s[l+1,size(s)-l]; … … 494 557 495 558 proc writelist (string fil, string nam, list L) 496 USAGE: writelist(fil,nam,L); fil,nam=strings (file name, listname), L=list559 USAGE: writelist(fil,nam,L); fil,nam=strings (file-name, list-name), L=list 497 560 CREATE: a file with name `fil`, write the content of the list L into it and 498 561 call the list `nam`. 499 562 RETURN: no return value 500 NOTE: The syntax of writelist uses and is similar to the thesyntax of the563 NOTE: The syntax of writelist uses and is similar to the syntax of the 501 564 write command of Singular which does not manage lists properly. 502 If, say, (fil,nam) = ("listfile","L1"), writelist creates (resp. 503 appends if listfile exists) a file with name listfile and stores 504 there the list L under the name L1. The Singular command 505 execute(read("listfile")); assignes the content of L (stored in 565 If, say, (fil,nam) = ("listfile","L1"), writelist creates (resp. 566 appends if listfile exists) a file with name listfile and stores 567 there the list L under the name L1. The Singular command 568 execute(read("listfile")); assignes the content of L (stored in 506 569 listfile) to a list L1. 507 On a UNIX system, overwrite an existing file if fil=">...", resp. 570 On a UNIX system, overwrite an existing file if fil=">...", resp. 508 571 append if fil=">>...". 509 572 EXAMPLE: example writelist; shows an example 510 573 { 511 574 int i; 512 write fil,"list "+nam+";";575 write(fil,"list "+nam+";"); 513 576 if( fil[1]==">" ) { fil=fil[2..size(fil)]; } 514 577 if( fil[1]==">" ) { fil=fil[2..size(fil)]; } 515 for( i=1;i<=size(L);i ++)516 { 517 write fil," "+nam+"["+string(i)+"]=",string(L[i])+";";578 for( i=1;i<=size(L);i=i+1 ) 579 { 580 write(fil," "+nam+"["+string(i)+"]=",string(L[i])+";"); 518 581 } 519 582 return(); … … 529 592 writelist("L","L",L); 530 593 read("L"); 531 // You might wish to remove the just created files `zumSpass` and `L`! 532 } 533 /////////////////////////////////////////////////////////////////////////////// 594 system("sh","/bin/rm L zumSpass"); 595 // Under UNIX, this removes the files 'L' and 'zumSpass' 596 // Type help system; to get more information about the shell escape 597 // If your operating system does not accept the shell escape, you 598 // have to remove the just created files 'zumSpass' and 'L' directly 599 } 600 /////////////////////////////////////////////////////////////////////////////// -
Singular/LIB/matrix.lib
r6d09c56 r6f2edc 1 // $Id: matrix.lib,v 1. 1.1.1 1997-04-25 15:13:26obachman Exp $2 // (GMG+BM)1 // $Id: matrix.lib,v 1.2 1997-04-28 19:27:22 obachman Exp $ 2 // (GMG/BM, last modified 22.06.96) 3 3 /////////////////////////////////////////////////////////////////////////////// 4 LIBRARY: matrix.lib PROCEDURES FOR MATRIX OPERATIONS 4 LIBRARY: matrix.lib PROCEDURES FOR MATRIX OPERATIONS 5 5 6 6 compress(A); matrix, zero columns from A deleted … … 9 9 dsum(A1,A2,..); matrix, direct sum of matrices A1,A2,... 10 10 flatten(A); ideal, generated by entries of matrix A 11 genericmat(n,m[,id]); generic nxm matrix [entries from id] 11 12 is_complex(c); 1 if list c is a complex, 0 if not 12 13 outer(A,B); matrix, outer product of matrices A and B 13 14 skewmat(n[,id]); generic skew-symmetric nxn matrix [entries from id] 14 submat(A,r,c); submatrix of A with rows/cols specified by intvec r/c 15 submat(A,r,c); submatrix of A with rows/cols specified by intvec r/c 15 16 symmat(n[,id]); generic symmetric nxn matrix [entries from id] 16 17 tensor(A,B); matrix, tensor product of matrices A nd B … … 32 33 33 34 proc compress (A) 34 USAGE: compress(A); A matrix/intmat/ideal/module 35 RETURN: matrix/intmat/ideal/module, zero columns/generators from A deleted 35 USAGE: compress(A); A matrix/ideal/module/intmat/intvec 36 RETURN: same type, zero columns/generators from A deleted 37 (in an intvec zero elements are deleted) 36 38 EXAMPLE: example compress; shows an example 37 39 { 38 if( typeof(A)=="matrix" ) { return(matrix(simplify(A,2))); } 39 if( typeof(A)=="intmat" )40 if( typeof(A)=="matrix" ) { return(matrix(simplify(A,2))); } 41 if( typeof(A)=="intmat" or typeof(A)=="intvec" ) 40 42 { 41 43 ring r=0,x,lp; 42 module m=module(matrix(A));43 int c= size(m);44 intmat B[nrows(A)][ c];44 if( typeof(A)=="intvec" ) { intmat C=transpose(A); kill A; intmat A=C; } 45 module m = matrix(A); 46 intmat B[nrows(A)][size(m)]; 45 47 int i,j; 46 for( i=1; i<=ncols(A); i ++ )47 { 48 if( m[i]!=[0] ) 49 { 48 for( i=1; i<=ncols(A); i=i+1 ) 49 { 50 if( m[i]!=[0] ) 51 { 50 52 j=j+1; 51 53 B[1..nrows(A),j]=A[1..nrows(A),i]; 52 54 } 53 55 } 56 if( defined(C) ) { return(intvec(B)); } 54 57 return(B); 55 58 } … … 66 69 intmat B[3][4]=1,0,3,0,4,0,5,0,6,0,7,0; 67 70 compress(B); 71 intvec C=0,0,1,2,0,3; 72 compress(C); 68 73 } 69 74 //////////////////////////////////////////////////////////////////////////////// 70 75 proc concat (list #) 71 USAGE: concat(A1,A2,..); A1,A2,... matrices 72 RETURN: matrix, concatenation of A1,A2,... . Number of rows of result matrix is 76 USAGE: concat(A1,A2,..); A1,A2,... matrices 77 RETURN: matrix, concatenation of A1,A2,... . Number of rows of result matrix is 73 78 max(nrows(A1),nrows(A2),...) 74 79 EXAMPLE: example concat; shows an example … … 76 81 int i; 77 82 module B=module(#[1]); 78 for( i=2; i<=size(#); i ++) { B=B,module(#[i]); }83 for( i=2; i<=size(#); i=i+1 ) { B=B,module(#[i]); } 79 84 return(matrix(B)); 80 85 } … … 92 97 93 98 proc diag (list #) 94 USAGE: diag(p,n); p poly, n integer 99 USAGE: diag(p,n); p poly, n integer 95 100 diag(A); A matrix 96 101 RETURN: diag(p,n): diagonal matrix, p times unitmatrix of size n 97 diag(A) : n*mxn*m diagonal matrix with entries all the entries of 102 diag(A) : n*mxn*m diagonal matrix with entries all the entries of the 98 103 nxm matrix A, taken from the 1st row, 2nd row etc of A 99 104 EXAMPLE: example diag; shows an example … … 104 109 int i; ideal id=#[1]; 105 110 int n=ncols(id); matrix A[n][n]; 106 for( i=1; i<=n; i ++) { A[i,i]=id[i]; }111 for( i=1; i<=n; i=i+1 ) { A[i,i]=id[i]; } 107 112 } 108 113 return(A); … … 118 123 //////////////////////////////////////////////////////////////////////////////// 119 124 120 proc flatten (matrix A)121 USAGE: flatten(A); A matrix122 RETURN: ideal, generated by all entries from A123 EXAMPLE: example flatten; shows an example124 {125 return(ideal(A));126 }127 example128 { "EXAMPLE:"; echo = 2;129 ring r=0,(x,y,z),ds;130 matrix A[3][3]=1,2,3,x,y,z,7,8,9;131 print(A);132 flatten(A);133 }134 ////////////////////////////////////////////////////////////////////////////////135 136 125 proc dsum (list #) 137 USAGE: dsum(A1,A2,..); A1,A2,... matrices 126 USAGE: dsum(A1,A2,..); A1,A2,... matrices 138 127 RETURN: matrix, direct sum of A1,A2,... 139 128 EXAMPLE: example dsum; shows an example … … 141 130 int i,N,a; 142 131 list L; 143 for( i=1; i<=size(#); i ++) { N=N+nrows(#[i]); }144 for( i=1; i<=size(#); i ++ )145 { 146 matrix B[N][ncols(#[i])]; 132 for( i=1; i<=size(#); i=i+1 ) { N=N+nrows(#[i]); } 133 for( i=1; i<=size(#); i=i+1 ) 134 { 135 matrix B[N][ncols(#[i])]; 147 136 B[a+1..a+nrows(#[i]),1..ncols(#[i])]=#[i]; 148 137 a=a+nrows(#[i]); … … 162 151 print(dsum(A,B,C)); 163 152 } 153 //////////////////////////////////////////////////////////////////////////////// 154 155 proc flatten (matrix A) 156 USAGE: flatten(A); A matrix 157 RETURN: ideal, generated by all entries from A 158 EXAMPLE: example flatten; shows an example 159 { 160 return(ideal(A)); 161 } 162 example 163 { "EXAMPLE:"; echo = 2; 164 ring r=0,(x,y,z),ds; 165 matrix A[3][3]=1,2,3,x,y,z,7,8,9; 166 print(A); 167 flatten(A); 168 } 169 //////////////////////////////////////////////////////////////////////////////// 170 171 proc genericmat (int n,int m,list #) 172 USAGE: genericmat(n,m[,id]); n,m=integers, id=ideal 173 RETURN: nxm matrix, with entries from id (default: id=maxideal(1)) 174 NOTE: if id has less than nxm elements, the matrix is filled with 0's, 175 genericmat(n,m); creates the generic nxm matrix 176 EXAMPLE: example genericmat; shows an example 177 { 178 if( size(#)==0 ) { ideal id=maxideal(1); } 179 if( size(#)==1 ) { ideal id=#[1]; } 180 if( size(#)>=2 ) { "// give 3 arguments, 3-rd argument must be an ideal"; } 181 matrix B[n][m]=id; 182 return(B); 183 } 184 example 185 { "EXAMPLE:"; echo = 2; 186 ring R=0,x(1..16),lp; 187 print(genericmat(4,4)); // the generic 4x4 matrix 188 changevar("R1",A_Z("a",4),R); 189 matrix A=genericmat(4,5,maxideal(1)^3); 190 print(A); 191 int n,m=4,3; 192 ideal i = ideal(randommat(1,n*m,maxideal(1),9)); 193 print(genericmat(n,m,i)); // matrix of generic linear forms 194 kill R1; 195 } 164 196 /////////////////////////////////////////////////////////////////////////////// 165 197 166 198 proc is_complex (list c) 167 199 USAGE: is_complex(c); c = list of size-compatible modules or matrices 168 RETURN: 1 if c[i]*c[i+1]=0 for all i, 0 if not. 200 RETURN: 1 if c[i]*c[i+1]=0 for all i, 0 if not. 169 201 NOTE: Ideals are treated internally as 1-line matrices 170 202 EXAMPLE: example is_complex; shows an example … … 186 218 } 187 219 example 188 { "EXAMPLE:"; echo = 2; 189 ring r=32003,(x,y,z),ds; 190 ideal i=x4+y5+z6,xyz,yx2+xz2+zy7; 220 { "EXAMPLE:"; echo = 2; 221 ring r=32003,(x,y,z),ds; 222 ideal i=x4+y5+z6,xyz,yx2+xz2+zy7; 191 223 list L=res(i,0); 192 224 is_complex(L); … … 202 234 { 203 235 int i,j; list L; 204 int N=nrows(A)*nrows(B); 205 matrix C[N][ncols(B)]; 206 for( i=1; i<=ncols(A); i++ ) 207 { 208 for( j=1; j<=nrows(A); j++ ) 209 { 210 C[(j-1)*nrows(B)+1..j*nrows(B),1..ncols(B)]=A[j,i]*B; 211 } 212 L[i]=C; 213 } 214 return(concat(L)); 236 int triv = nrows(B)*ncols(B); 237 if( triv==1 ) 238 { 239 return(B[1,1]*A); 240 } 241 else 242 { 243 int N = nrows(A)*nrows(B); 244 matrix C[N][ncols(B)]; 245 for( i=1; i<=ncols(A); i=i+1 ) 246 { 247 for( j=1; j<=nrows(A); j=j+1 ) 248 { 249 C[(j-1)*nrows(B)+1..j*nrows(B),1..ncols(B)]=A[j,i]*B; 250 } 251 L[i]=C; 252 } 253 return(concat(L)); 254 } 215 255 } 216 256 example … … 227 267 proc skewmat (int n, list #) 228 268 USAGE: skewmat(n[,id]); n integer, id ideal 229 RETURN: skew-symmetric nxn matrix, with entries from id 269 RETURN: skew-symmetric nxn matrix, with entries from id 230 270 (default: id=maxideal(1)) 231 271 NOTE: if id has less than n*(n-1)/2 elements, the matrix is filled with 0's, … … 238 278 id = id,B[1..n,1..n]; 239 279 int i,j; 240 for( i=0; i<=n-2; i ++)241 { 242 B[i+1,i+2..n]=id[j+1..j+n-i-1]; 243 j=j+n-i-1; 280 for( i=0; i<=n-2; i=i+1 ) 281 { 282 B[i+1,i+2..n]=id[j+1..j+n-i-1]; 283 j=j+n-i-1; 244 284 } 245 285 matrix A=transpose(B); … … 263 303 proc submat (matrix A, intvec r, intvec c) 264 304 USAGE: submat(A,r,c); A=matrix, r,c=intvec 265 RETURN: matrix, submatrix of A with rows specified by intvec r and columns 305 RETURN: matrix, submatrix of A with rows specified by intvec r and columns 266 306 specified by intvec c 267 307 EXAMPLE: example submat; shows an example … … 293 333 id = id,B[1..n,1..n]; 294 334 int i,j; 295 for( i=0; i<=n-1; i ++)296 { 297 B[i+1,i+1..n]=id[j+1..j+n-i]; 298 j=j+n-i; 335 for( i=0; i<=n-1; i=i+1 ) 336 { 337 B[i+1,i+1..n]=id[j+1..j+n-i]; 338 j=j+n-i; 299 339 } 300 340 matrix A=transpose(B); 301 for( i=1; i<=n; i ++) { A[i,i]=0; }341 for( i=1; i<=n; i=i+1 ) { A[i,i]=0; } 302 342 B=A+B; 303 343 return(B); … … 306 346 { "EXAMPLE:"; echo = 2; 307 347 ring R=0,x(1..10),lp; 308 print(symmat(4)); // the generic symmetric matrix 348 print(symmat(4)); // the generic symmetric matrix 309 349 changevar("R1",A_Z("a",5),R); 310 350 matrix A=symmat(5,maxideal(1)^2); … … 324 364 int i,j; 325 365 matrix C=B; 326 for( i=2; i<=nrows(A); i ++) { C=dsum(C,B); }366 for( i=2; i<=nrows(A); i=i+1 ) { C=dsum(C,B); } 327 367 matrix D[nrows(C)][ncols(A)*nrows(B)]; 328 for( j=1; j<=nrows(B); j ++)329 { 330 for( i=1; i<=nrows(A); i ++)368 for( j=1; j<=nrows(B); j=j+1 ) 369 { 370 for( i=1; i<=nrows(A); i=i+1 ) 331 371 { 332 372 D[(i-1)*nrows(B)+j,(j-1)*ncols(A)+1..j*ncols(A)]=A[i,1..ncols(A)]; … … 362 402 /////////////////////////////////////////////////////////////////////////////// 363 403 364 proc gauss_col (matrix m)404 proc gauss_col (matrix A) 365 405 USAGE: gauss_col(A); A=matrix with constant coefficients 366 RETURN: matrix = col-reduced normal form of A 406 RETURN: matrix = col-reduced lower-triagonal normal form of A 407 NOTE: the procedure sets the global option-command: option(noredSB); 367 408 EXAMPLE: example gauss_col; shows an example 368 409 { 369 410 def R=basering; 370 changeord("@R","ds,c",R); 411 changeord("@R","ds,c",R); 371 412 option(redSB); option(nointStrategy); 372 matrix m = imap(R,m);373 m = matrix(std(m),nrows(m),ncols(m));374 setring R; 375 m=imap(@R,m);413 matrix A = imap(R,A); 414 A = matrix(std(A),nrows(A),ncols(A)); 415 setring R; 416 A=imap(@R,A); 376 417 option(noredSB); 377 418 kill @R; 378 return(m); 379 } 380 example 381 { "EXAMPLE:"; echo = 2; 382 ring S; 383 matrix M[3][4] = 1,3,2,4,2,6,4,8,1,3,4,4; 384 print(M); 385 print(gauss_col(M)); 419 return(A); 420 } 421 example 422 { "EXAMPLE:"; echo = 2; 423 ring S=0,x,dp; 424 matrix A[5][4] = 3, 1,1,-1, 425 13, 8,6,-7, 426 14,10,6,-7, 427 7, 4,3,-3, 428 2, 1,0, 3; 429 print(gauss_col(A)); 386 430 } 387 431 /////////////////////////////////////////////////////////////////////////////// 388 432 389 proc gauss_row (matrix m)433 proc gauss_row (matrix A) 390 434 USAGE: gauss_row(A); A=matrix with constant coefficients 391 RETURN: matrix = row-reduced normal form of A 435 RETURN: matrix = row-reduced upper-triangular normal form of A 436 NOTE: may be used to solve a system of linear equations 437 see proc 'linearsolve' from 'solve.lib' for a different method 438 the procedure sets the global option-command: option(noredSB); 392 439 EXAMPLE: example gauss_row; shows an example 393 440 { 394 m = gauss_col(transpose(m)); 395 return(transpose(m)); 396 } 397 example 398 { "EXAMPLE:"; echo = 2; 399 ring S; 400 matrix M[3][4] = 1,3,2,4,2,6,4,8,1,3,4,4; 401 print(M); 402 print(gauss_row(M)); 441 A = gauss_col(transpose(A)); 442 return(transpose(A)); 443 } 444 example 445 { "EXAMPLE:"; echo = 2; 446 ring S=0,x,dp; 447 matrix A[4][5] = 3, 1,1,-1,2, 448 13, 8,6,-7,1, 449 14,10,6,-7,1, 450 7, 4,3,-3,3; 451 print(gauss_row(A)); 403 452 } 404 453 //////////////////////////////////////////////////////////////////////////////// -
Singular/LIB/poly.lib
r6d09c56 r6f2edc 1 // $Id: poly.lib,v 1. 1.1.1 1997-04-25 15:13:26obachman Exp $1 // $Id: poly.lib,v 1.2 1997-04-28 19:27:22 obachman Exp $ 2 2 //system("random",787422842); 3 //(GMG) 4 /////////////////////////////////////////////////////////////////////////////// 5 6 LIBRARY: poly.lib PROCEDURES FOR MANIPULATING POLYS AND IDEALS 7 8 ishomog(poly/...); int, =1 resp. =0 if input is homogeneous resp. not 9 maxcoef(poly/...); maximal length of coefficient occuring in poly/... 3 //(GMG, last modified 22.06.96) 4 /////////////////////////////////////////////////////////////////////////////// 5 6 LIBRARY: poly.lib PROCEDURES FOR MANIPULATING POLYS, IDEALS, MODULES 7 8 cyclic(int); ideal of cyclic n-roots 9 freerank(poly/...) rank of coker(input) if coker is free else -1 10 is_homog(poly/...); int, =1 resp. =0 if input is homogeneous resp. not 11 is_zero(poly/...); int, =1 resp. =0 if coker(input) is 0 resp. not 12 maxcoef(poly/...); maximal length of coefficient occuring in poly/... 10 13 maxdeg(poly/...); int/intmat = degree/s of terms of maximal order 14 maxdeg1(poly/...); int = [weighted] maximal degree of input 11 15 mindeg(poly/...); int/intmat = degree/s of terms of minimal order 16 mindeg1(poly/...); int = [weighted] minimal degree of input 12 17 normalize(poly/...); normalize poly/... such that leading coefficient is 1 13 18 (parameters in square brackets [] are optional) … … 16 21 /////////////////////////////////////////////////////////////////////////////// 17 22 18 proc ishomog (id) 19 USAGE: ishomog(id); id poly/ideal/vector/module/matrix 23 proc cyclic (int n) 24 USAGE: cyclic(n); n integer 25 RETURN: ideal of cyclic n-roots from 1-st n variables of basering 26 EXAMPLE: example cyclic; shows examples 27 { 28 //----------------------------- procedure body -------------------------------- 29 ideal m = maxideal(1); 30 m = m[1..n],m[1..n]; 31 int i,j; 32 ideal s; poly t; 33 for ( j=0; j<=n-2; j=j+1 ) 34 { 35 t=0; 36 for( i=1;i<=n;i=i+1 ) { t=t+product(m,i..i+j); } 37 s=s+t; 38 } 39 s=s,product(m,1..n)-1; 40 return (s); 41 } 42 //-------------------------------- examples ----------------------------------- 43 example 44 { "EXAMPLE:"; echo = 2; 45 ring r=0,(u,v,w,x,y,z),lp; 46 cyclic(nvars(basering)); 47 homog(cyclic(5),z); 48 } 49 /////////////////////////////////////////////////////////////////////////////// 50 51 proc freerank 52 USAGE: freerank(M[,any]); M=poly/ideal/vector/module/matrix 53 COMPUTE: rank of module presented by M in case it is free. By definition this 54 is vdim(coker(M)/m*coker(M)) if coker(M) is free, where m = maximal 55 ideal of basering and M is considered as matrix (the 0-module is 56 free of rank 0) 57 RETURN: rank of coker(M) if coker(M) is free and -1 else; 58 in case of a second argument return a list: 59 L[1] = rank of coker(M) or -1 60 L[2] = minbase(M) 61 NOTE: freerank(syz(M)); computes the rank of M if M is free (and -1 else) 62 //* Zur Zeit noch ein Bug, da erste Bettizahl falsch berechnet wird: 63 //betti(0) ist -1 statt 0 64 EXAMPLE: example freerank; shows examples 65 { 66 int rk; 67 def M = simplify(#[1],10); 68 list mre = mres(M,2); 69 intmat B = betti(mre); 70 if ( ncols(B)>1 ) { rk = -1; } 71 else { rk = sum(B[1..nrows(B),1]); } 72 if (size(#) == 2) { list L=rk,mre[1]; return(L);} 73 return(rk); 74 } 75 example 76 {"EXAMPLE"; echo=2; 77 ring r; 78 ideal i=x; 79 module M=[x,0,1],[-x,0,-1]; 80 freerank(M); // should be -1, coker(M) is not free 81 // [1] should be 1, coker(syz(M))=M is free of rank 1 82 freerank(syz (M),""); // [2] should be gen(2)+gen(1) (minimal relation of M) 83 freerank(i); 84 freerank(syz(i)); //* bug, should be 1, coker(syz(i))=i is free of rank 1 85 } 86 /////////////////////////////////////////////////////////////////////////////// 87 88 proc is_homog (id) 89 USAGE: is_homog(id); id poly/ideal/vector/module/matrix 20 90 RETURN: integer which is 1 if input is homogeneous (resp. weighted homogeneous 21 91 if the monomial ordering consists of one block of type ws,Ws,wp or Wp, … … 24 94 degree, a module/matrix is homogeneous if all column vectors are 25 95 homogeneous 26 //*** ergaenzen, wenn Matrizen Spalten Gewichte haben 27 EXAMPLE: example ishomog; shows an example 28 { 96 //*** ergaenzen, wenn Matrizen-Spalten Gewichte haben 97 EXAMPLE: example is_homog; shows examples 98 { 99 //----------------------------- procedure body -------------------------------- 29 100 module M = module(matrix(id)); 30 101 M = simplify(M,2); // remove 0-columns 31 102 intvec v = ringweights(basering); 32 103 int i,j=1,1; 33 for (i=1; i<=ncols(M); i ++)104 for (i=1; i<=ncols(M); i=i+1) 34 105 { 35 106 if( M[i]!=jet(M[i],deg(lead(M[i])),v)-jet(M[i],deg(lead(M[i]))-1,v)) … … 38 109 return(1); 39 110 } 111 //-------------------------------- examples ----------------------------------- 40 112 example 41 113 { "EXAMPLE:"; echo = 2; 42 114 ring r = 0,(x,y,z),wp(1,2,3); 43 is homog(x5-yz+y3);115 is_homog(x5-yz+y3); 44 116 ideal i = x6+y3+z2, x9-z3; 45 is homog(i);117 is_homog(i); 46 118 ring s = 0,(a,b,c),ds; 47 119 vector v = [a2,0,ac+bc]; 48 120 vector w = [a3,b3,c4]; 49 ishomog(v); 50 ishomog(w); 51 } 52 /////////////////////////////////////////////////////////////////////////////// 121 is_homog(v); 122 is_homog(w); 123 } 124 /////////////////////////////////////////////////////////////////////////////// 125 126 proc is_zero 127 USAGE: is_zero(M[,any]); M=poly/ideal/vector/module/matrix 128 RETURN: integer, 1 if coker(M)=0 resp. 0 if coker(M)!=0, where M is considered 129 as matrix 130 if a second argument is given, return a list: 131 L[1] = 1 if coker(M)=0 resp. 0 if coker(M)!=0 132 L[2] = dim(M) 133 EXAMPLE: example is_zero; shows examples 134 { 135 int d=dim(std(#[1])); 136 int a = ( d==-1 ); 137 if( size(#) >1 ) { list L=a,d; return(L); } 138 return(a); 139 } 140 example 141 { "EXAMPLE:"; echo=2; 142 ring r; 143 module m = [x],[y],[1,z]; 144 is_zero(m,1); 145 qring q = std(ideal(x2+y3+z2)); 146 ideal j = x2+y3+z2-37; 147 is_zero(j); 148 } 149 //////////////////////////////////////////////////////////////////////////////// 53 150 54 151 proc maxcoef (f) 55 152 USAGE: maxcoef(f); f poly/ideal/vector/module/matrix 56 RETURN: maximal length of coefficient of f of type int (by counting the 153 RETURN: maximal length of coefficient of f of type int (by counting the 57 154 length of the string of each coefficient) 58 EXAMPLE: example maxcoef; shows an example 59 { 155 EXAMPLE: example maxcoef; shows examples 156 { 157 //----------------------------- procedure body -------------------------------- 60 158 int max,s,ii,jj; string t; 61 159 ideal i = ideal(matrix(f)); 62 i = simplify(i,6); //*delete 0's and keep first of equal elements160 i = simplify(i,6); // delete 0's and keep first of equal elements 63 161 poly m = var(1); matrix C; 64 for (ii=2;ii<=nvars(basering);ii ++) { m = m*var(ii); }65 for (ii=1; ii<=size(i); ii ++)162 for (ii=2;ii<=nvars(basering);ii=ii+1) { m = m*var(ii); } 163 for (ii=1; ii<=size(i); ii=ii+1) 66 164 { 67 165 C = coef(i[ii],m); 68 for (jj=1; jj<=ncols(C); jj ++)166 for (jj=1; jj<=ncols(C); jj=jj+1) 69 167 { 70 168 t = string(C[2,jj]); s = size(t); … … 75 173 return(max); 76 174 } 175 //-------------------------------- examples ----------------------------------- 77 176 example 78 177 { "EXAMPLE:"; echo = 2; … … 80 179 poly g = 345x2-1234567890y+7/4z; 81 180 maxcoef(g); 82 ideal i = g,10/1234567890; 83 maxcoef(i); 84 // since i[2]=1/123456789 85 } 86 /////////////////////////////////////////////////////////////////////////////// 87 88 proc maxdeg (id) 181 ideal i = g,10/1234567890; 182 maxcoef(i); 183 // since i[2]=1/123456789 184 } 185 /////////////////////////////////////////////////////////////////////////////// 186 187 proc maxdeg (id) 89 188 USAGE: maxdeg(id); id poly/ideal/vector/module/matrix 90 RETURN: maximal degree/s of monomials of id independent of ring ordering 91 (maxdeg of each variable is 1) 189 RETURN: int/intmat, each component equals maximal degree of monomials in the 190 corresponding component of id, independent of ring ordering 191 (maxdeg of each var is 1) 92 192 of type int if id is of type poly, of type intmat else 93 EXAMPLE: example maxdeg; shows an example 94 { 95 //------------------- find maximal degree of given component ------------------ 193 NOTE: proc maxdeg1 returns 1 integer, the absolut maximum; moreover, it has 194 an option for computing weighted degrees 195 EXAMPLE: example maxdeg; shows examples 196 { 197 //-------- subprocedure to find maximal degree of given component ---------- 96 198 proc findmaxdeg 97 199 { … … 117 219 int r,c = nrows(M), ncols(M); int i,j; 118 220 intmat m[r][c]; 119 for (i=r; i>0; i --)120 { 121 for (j=c; j>0; j --) { m[i,j] = findmaxdeg(M[i,j]); }122 } 123 if ( typeof(id)=="poly") { return(m[1,1]); }221 for (i=r; i>0; i=i-1) 222 { 223 for (j=c; j>0; j=j-1) { m[i,j] = findmaxdeg(M[i,j]); } 224 } 225 if (typeof(id)=="poly") { return(m[1,1]); } 124 226 return(m); 125 227 } 228 //-------------------------------- examples ----------------------------------- 126 229 example 127 230 { "EXAMPLE:"; echo = 2; 128 231 ring r = 0,(x,y,z),wp(-1,-2,-3); 129 232 poly f = x+y2+z3; 130 deg(f); //deg returns weighted degree (in case of 1 block)!233 deg(f); //deg; returns weighted degree (in case of 1 block)! 131 234 maxdeg(f); 132 235 matrix m[2][2]=f+x10,1,0,f^2; … … 135 238 /////////////////////////////////////////////////////////////////////////////// 136 239 240 proc maxdeg1 (id,list #) 241 USAGE: maxdeg1(id[,v]); id=poly/ideal/vector/module/matrix, v=intvec 242 RETURN: integer, maximal [weighted] degree of monomials of id independent of 243 ring ordering, maxdeg1 of i-th variable is v[i] (default: v=1..1). 244 NOTE: This proc returns one integer while maxdeg returns, in general, 245 a matrix of integers. For one polynomial and if no intvec v is given 246 maxdeg is faster 247 EXAMPLE: example maxdeg1; shows examples 248 { 249 //-------- subprocedure to find maximal degree of given component ---------- 250 proc findmaxdeg 251 { 252 poly c = #[1]; 253 if (c==0) { return(-1); } 254 intvec v = #[2]; 255 //--- guess upper 'o' and lower 'u' bound, in case of negative weights ----- 256 int d = (deg(c)>=0)*deg(c)-(deg(c)<0)*deg(c); 257 int i = d; 258 if ( c == jet(c,-1,v)) //case: maxdeg is negative 259 { 260 i = -d; 261 while ( c == jet(c,i,v) ) { i = 2*(i-1); } 262 int o = (d != -i)*((i/ 2)+2) - 1; 263 int u = i+1; 264 int e = -1; 265 } 266 else //case: maxdeg is nonnegative 267 { 268 while ( c != jet(c,i,v) ) { i = 2*(i+1); } 269 int o = i-1; 270 int u = (d != i)*((i/ 2)-1); 271 int e = 1; 272 } 273 //----------------------- "quick search" for maxdeg ------------------------ 274 while ( ( c==jet(c,i,v) )*( c!=jet(c,i-1,v) ) == 0 ) 275 { 276 i = (o+e+u)/ 2; 277 if ( c!=jet(c,i,v) ) { u = i+1; } 278 else { o = i-1; } 279 } 280 return(i); 281 } 282 //------------------------------ main program --------------------------------- 283 ideal M = simplify(ideal(matrix(id)),8); //delete scalar multiples from id 284 int c = ncols(M); 285 int i,n; 286 if( size(#)==0 ) 287 { 288 int m = maxdeg(M[c]); 289 for (i=c-1; i>0; i=i-1) 290 { 291 n = maxdeg(M[i]); 292 m = (m>=n)*m + (m<n)*n; //let m be the maximum of m and n 293 } 294 } 295 else 296 { 297 intvec v=#[1]; //weight vector for the variables 298 int m = findmaxdeg(M[c],v); 299 for (i=c-1; i>0; i--) 300 { 301 n = findmaxdeg(M[i],v); 302 if( n>m ) { m=n; } 303 } 304 } 305 return(m); 306 } 307 //-------------------------------- examples ----------------------------------- 308 example 309 { "EXAMPLE:"; echo = 2; 310 ring r = 0,(x,y,z),wp(-1,-2,-3); 311 poly f = x+y2+z3; 312 deg(f); //deg returns weighted degree (in case of 1 block)! 313 maxdeg1(f); 314 intvec v = ringweights(r); 315 maxdeg1(f,v); //weighted maximal degree 316 matrix m[2][2]=f+x10,1,0,f^2; 317 maxdeg1(m,v); //absolut weighted maximal degree 318 } 319 /////////////////////////////////////////////////////////////////////////////// 320 137 321 proc mindeg (id) 138 322 USAGE: mindeg(id); id poly/ideal/vector/module/matrix 139 RETURN: minimal degree/s of monomials of id independent of ring ordering 140 (mindeg of each variable is 1) 141 of type int if id is of type poly, of type intmat else 142 EXAMPLE: example mindeg; shows an example 143 { 144 //------------------- find minimal degree of given component ------------------ 323 RETURN: minimal degree/s of monomials of id, independent of ring ordering 324 (mindeg of each variable is 1) of type int if id of type poly, else 325 of type intmat. 326 NOTE: proc mindeg1 returns one integer, the absolut minimum; moreover it 327 has an option for computing weighted degrees. 328 EXAMPLE: example mindeg; shows examples 329 { 330 //--------- subprocedure to find minimal degree of given component --------- 145 331 proc findmindeg 146 332 { … … 153 339 int o = i-1; 154 340 int u = (d != i)*((i/ 2)-1); 155 //----------------------- "quick search" for mindeg --------------------------341 //----------------------- "quick search" for mindeg ------------------------ 156 342 while ( (jet(c,u)==0)*(jet(c,o)!=0) ) 157 343 { … … 167 353 int r,c = nrows(M), ncols(M); int i,j; 168 354 intmat m[r][c]; 169 for (i=r; i>0; i --)170 { 171 for (j=c; j>0; j --) { m[i,j] = findmindeg(M[i,j]); }355 for (i=r; i>0; i=i-1) 356 { 357 for (j=c; j>0; j=j-1) { m[i,j] = findmindeg(M[i,j]); } 172 358 } 173 359 if (typeof(id)=="poly") { return(m[1,1]); } 174 360 return(m); 175 361 } 362 //-------------------------------- examples ----------------------------------- 176 363 example 177 364 { "EXAMPLE:"; echo = 2; 178 365 ring r = 0,(x,y,z),ls; 179 366 poly f = x5+y2+z3; 180 ord(f); // ord returns weighted order of leading term!181 mindeg(f); 367 ord(f); // ord returns weighted order of leading term! 368 mindeg(f); // computes minimal degree 182 369 matrix m[2][2]=x10,1,0,f^2; 183 mindeg(m); 370 mindeg(m); // computes matrix of minimum degrees 371 } 372 /////////////////////////////////////////////////////////////////////////////// 373 374 proc mindeg1 (id, list #) 375 USAGE: mindeg1(id[,v]); id=poly/ideal/vector/module/matrix, v=intvec 376 RETURN: integer, minimal [weighted] degree of monomials of id independent of 377 ring ordering, mindeg1 of i-th variable is v[i] (default v=1..1). 378 NOTE: This proc returns one integer while mindeg returns, in general, 379 a matrix of integers. For one polynomial and if no intvec v is given 380 mindeg is faster. 381 EXAMPLE: example mindeg1; shows examples 382 { 383 //--------- subprocedure to find minimal degree of given component --------- 384 proc findmindeg 385 { 386 poly c = #[1]; 387 intvec v = #[2]; 388 if (c==0) { return(-1); } 389 //--- guess upper 'o' and lower 'u' bound, in case of negative weights ----- 390 int d = (ord(c)>=0)*ord(c)-(ord(c)<0)*ord(c); 391 int i = d; 392 if ( jet(c,-1,v) !=0 ) //case: mindeg is negative 393 { 394 i = -d; 395 while ( jet(c,i,v) != 0 ) { i = 2*(i-1); } 396 int o = (d != -i)*((i/ 2)+2) - 1; 397 int u = i+1; 398 int e = -1; i=u; 399 } 400 else //case: inded is nonnegative 401 { 402 while ( jet(c,i,v) == 0 ) { i = 2*(i+1); } 403 int o = i-1; 404 int u = (d != i)*((i/ 2)-1); 405 int e = 1; i=u; 406 } 407 //----------------------- "quick search" for mindeg ------------------------ 408 while ( (jet(c,i-1,v)==0)*(jet(c,i,v)!=0) == 0 ) 409 { 410 i = (o+e+u)/ 2; 411 if (jet(c,i,v)==0) { u = i+1; } 412 else { o = i-1; } 413 } 414 return(i); 415 } 416 //------------------------------ main program --------------------------------- 417 ideal M = simplify(ideal(matrix(id)),8); //delete scalar multiples from id 418 int c = ncols(M); 419 int i,n; 420 if( size(#)==0 ) 421 { 422 int m = mindeg(M[c]); 423 for (i=c-1; i>0; i=i-1) 424 { 425 n = mindeg(M[i]); 426 m = (m<=n)*m + (m>n)*n; //let m be the maximum of m and n 427 } 428 } 429 else 430 { 431 intvec v=#[1]; //weight vector for the variables 432 int m = findmindeg(M[c],v); 433 for (i=c-1; i>0; i=i-1) 434 { 435 n = findmindeg(M[i],v); 436 m = (m<=n)*m + (m>n)*n; //let m be the maximum of m and n 437 } 438 } 439 return(m); 440 } 441 //-------------------------------- examples ----------------------------------- 442 example 443 { "EXAMPLE:"; echo = 2; 444 ring r = 0,(x,y,z),ls; 445 poly f = x5+y2+z3; 446 ord(f); // ord returns weighted order of leading term! 447 intvec v = 1,-3,2; 448 mindeg1(f,v); // computes minimal weighted degree 449 matrix m[2][2]=x10,1,0,f^2; 450 mindeg1(m,1..3); // computes absolut minimum of weighted degrees 184 451 } 185 452 /////////////////////////////////////////////////////////////////////////////// … … 189 456 RETURN: object of same type with leading coefficient equal to 1 190 457 EXAMPLE: example normalize; shows an example 191 { 458 { 192 459 return(simplify(id,1)); 193 460 } 461 //-------------------------------- examples ----------------------------------- 194 462 example 195 463 { "EXAMPLE:"; echo = 2; … … 202 470 module m=[9xy,0,3z3],[4z,6y,2x]; 203 471 normalize(m); 204 normalize(matrix(m)); // by automatic type conversion to module! 205 } 206 /////////////////////////////////////////////////////////////////////////////// 472 normalize(matrix(m)); // by automatic type conversion to module! 473 } 474 /////////////////////////////////////////////////////////////////////////////// 475 -
Singular/LIB/random.lib
r6d09c56 r6f2edc 1 // $Id: random.lib,v 1. 1.1.1 1997-04-25 15:13:26obachman Exp $1 // $Id: random.lib,v 1.2 1997-04-28 19:27:23 obachman Exp $ 2 2 //system("random",787422842); 3 //(GMG +BM)3 //(GMG/BM, last modified 22.06.96) 4 4 /////////////////////////////////////////////////////////////////////////////// 5 5 … … 20 20 21 21 proc genericid (id, list #) 22 USAGE: genericid(id,[,p,b]); id ideal/module, p,b integers23 RETURN: system of generators of id which are generic, sparse, tri gonal linear22 USAGE: genericid(id,[,p,b]); id ideal/module, k,p,b integers 23 RETURN: system of generators of id which are generic, sparse, triagonal linear 24 24 combinations of given generators with coefficients in [1,b] and 25 25 sparsety p percent, bigger p being sparser (default: p=75, b=30000) … … 32 32 if( size(#)==0 ) { int p=75; int b=30000; } 33 33 //---------------- use sparsetriag for creation of genericid ------------------ 34 def i = simplify(id,10); 34 def i = simplify(id,10); 35 35 i = i*sparsetriag(ncols(i),ncols(i),p,b); 36 36 return(i); 37 } 38 example 39 { "EXAMPLE:"; echo = 2; 40 ring r=0,(t,x,y,z),ds; 41 ideal i= x3+y4,z4+yx,t+x+y+z; 42 genericid(i,0,10); 43 module m=[x,0,0,0],[0,y2,0,0],[0,0,z3,0],[0,0,0,t4]; 37 } 38 example 39 { "EXAMPLE:"; echo = 2; 40 ring r=0,(t,x,y,z),ds; 41 ideal i= x3+y4,z4+yx,t+x+y+z; 42 genericid(i,0,10); 43 module m=[x,0,0,0],[0,y2,0,0],[0,0,z3,0],[0,0,0,t4]; 44 44 print(genericid(m)); 45 45 } … … 59 59 if( size(#)==0 ) { int k=size(id); int b=30000; } 60 60 //--------------------------- create randomid --------------------------------- 61 def i = id; 61 def i = id; 62 62 i = matrix(id)*random(b,ncols(id),k); 63 63 return(i); 64 } 65 example 66 { "EXAMPLE:"; echo = 2; 67 ring r=0,(x,y,z),dp; 68 randomid(maxideal(2),2,9); 69 module m=[x,0,1],[0,y2,0],[y,0,z3]; 64 } 65 example 66 { "EXAMPLE:"; echo = 2; 67 ring r=0,(x,y,z),dp; 68 randomid(maxideal(2),2,9); 69 module m=[x,0,1],[0,y2,0],[y,0,z3]; 70 70 show(randomid(m)); 71 71 } … … 88 88 int g=ncols(id); 89 89 matrix rand[n][m]; matrix ra[1][m]; 90 for (int k=1; k<=n; k ++)90 for (int k=1; k<=n; k=k+1) 91 91 { 92 92 ra = id*random(b,g,m); … … 102 102 A=randommat(2,3); 103 103 print(A); 104 } 104 } 105 105 /////////////////////////////////////////////////////////////////////////////// 106 106 107 107 proc sparseid (int k, int u, list #) 108 108 USAGE: sparseid(k,u[,o,p,b]); k,u,o,p,b integers 109 RETURN: ideal having k generators in each degree d, u<=d<=o, p percent of 110 terms in degree d are 0, the remaining have random coefficients 109 RETURN: ideal having k generators in each degree d, u<=d<=o, p percent of 110 terms in degree d are 0, the remaining have random coefficients 111 111 in the interval [1,b], (default: o=u=d, p=75, b=30000) 112 112 EXAMPLE: example sparseid; shows an example … … 119 119 //------------------ use sparsemat for creation of sparseid ------------------- 120 120 int ii; ideal i; intmat m; 121 for ( ii=u; ii<=o; ii ++)122 { 121 for ( ii=u; ii<=o; ii=ii+1) 122 { 123 123 m = sparsemat(size(maxideal(ii)),k,p,b); 124 124 i = i+ideal(matrix(maxideal(ii))*m); … … 131 131 sparseid(3,4);""; 132 132 sparseid(2,2,5,90,9); 133 } 133 } 134 134 /////////////////////////////////////////////////////////////////////////////// 135 135 … … 153 153 if( p<40 ) 154 154 { 155 for( ii=1; ii<=t; ii ++)155 for( ii=1; ii<=t; ii=ii+1 ) 156 156 { r=( random(1,100)>p ); v[1,ii]=r*random(1,b); h=h+r; } 157 157 } … … 173 173 example 174 174 { "EXAMPLE:"; echo = 2; 175 sparsemat(5,5); 176 sparsemat(5,5,95); 177 sparsemat(5,5,5); 175 sparsemat(5,5);""; 176 sparsemat(5,5,95);""; 177 sparsemat(5,5,5);""; 178 178 sparsemat(5,5,50,100); 179 } 179 } 180 180 /////////////////////////////////////////////////////////////////////////////// 181 181 … … 183 183 USAGE: sparsepoly(u[,o,p,b]); u,o,p,b integers 184 184 RETURN: poly having only terms in degree d, u<=d<=o, p percent of the terms 185 in degree d are 0, the remaining have random coefficients in [1,b), 185 in degree d are 0, the remaining have random coefficients in [1,b), 186 186 (defaults: o=u=d, p=75, b=30000) 187 187 EXAMPLE: example sparsepoly; shows an example … … 194 194 int ii; poly f; 195 195 //----------------- use sparseid for creation of sparsepoly ------------------- 196 for( ii=u; ii<=o; ii ++) { f=f+sparseid(1,ii,ii,p,b)[1]; }196 for( ii=u; ii<=o; ii=ii+1 ) { f=f+sparseid(1,ii,ii,p,b)[1]; } 197 197 return(f); 198 198 } … … 202 202 sparsepoly(5);""; 203 203 sparsepoly(3,5,90,9); 204 } 204 } 205 205 /////////////////////////////////////////////////////////////////////////////// 206 206 … … 222 222 if( n<=m ) { min=n-1; M[n,n]=1; } 223 223 else { min=m; } 224 for( ii=1; ii<=min; ii ++)224 for( ii=1; ii<=min; ii=ii+1 ) 225 225 { 226 226 l=r+1; r=r+n-ii; … … 231 231 example 232 232 { "EXAMPLE:"; echo = 2; 233 sparsetriag(5,7); 234 sparsetriag(7,5,90); 235 sparsetriag(5,5,0); 233 sparsetriag(5,7);""; 234 sparsetriag(7,5,90);""; 235 sparsetriag(5,5,0);""; 236 236 sparsetriag(5,5,50,100); 237 } 238 /////////////////////////////////////////////////////////////////////////////// 237 } 238 /////////////////////////////////////////////////////////////////////////////// -
Singular/LIB/redfac.lib
r6d09c56 r6f2edc 1 // $Id: redfac.lib,v 1. 1.1.1 1997-04-25 15:13:26obachman Exp $1 // $Id: redfac.lib,v 1.2 1997-04-28 19:27:24 obachman Exp $ 2 2 //(RS) 3 3 /////////////////////////////////////////////////////////////////////////////// -
Singular/LIB/ring.lib
r6d09c56 r6f2edc 1 // $Id: ring.lib,v 1. 1.1.1 1997-04-25 15:13:27obachman Exp $2 //(GMG, 95/11/3)3 /////////////////////////////////////////////////////////////////////////////// 4 5 LIBRARY: ring.lib PROCEDURES FOR MANIPULATING RINGS AND MAPS 1 // $Id: ring.lib,v 1.2 1997-04-28 19:27:25 obachman Exp $ 2 //(GMG, last modified 03.11.95) 3 /////////////////////////////////////////////////////////////////////////////// 4 5 LIBRARY: ring.lib PROCEDURES FOR MANIPULATING RINGS AND MAPS 6 6 7 7 changechar("R",c[,r]); make a copy R of basering [ring r] with new char c … … 25 25 USAGE: changechar(newr,c[,r]); newr,c=strings, r=ring 26 26 CREATE: create a new ring with name `newr` and make it the basering if r is 27 an existing ring [default: r=basering]. 27 an existing ring [default: r=basering]. 28 28 The new ring differs from the old ring only in the characteristic. 29 If, say, (newr,c) = ("R","0,A") and the ring r exists, the new 29 If, say, (newr,c) = ("R","0,A") and the ring r exists, the new 30 30 basering will have name R characteristic 0 and one parameter A. 31 31 RETURN: No return value 32 32 NOTE: Works for qrings if map from old_char to new_char is implemented 33 This proc uses 'execute' or calls a procedure using 'execute'. 34 If you use it in your own proc, let the local names of your proc 33 This proc uses 'execute' or calls a procedure using 'execute'. 34 If you use it in your own proc, let the local names of your proc 35 35 start with @ (see the file HelpForProc) 36 36 EXAMPLE: example changechar; shows an example … … 40 40 setring @r; 41 41 ideal i = ideal(@r); int @q = size(i); 42 if( @q!=0 ) 42 if( @q!=0 ) 43 43 { string @s = "@newr1"; } 44 else 44 else 45 45 { string @s = newr; } 46 46 string @newring = @s+"=("+c+"),("+varstr(@r)+"),("+ordstr(@r)+");"; … … 51 51 ideal i = phi(i); 52 52 attrib(i,"isSB",1); //*** attrib funktioniert ? 53 execute("qring "+newr+"=i;"); 53 execute("qring "+newr+"=i;"); 54 54 } 55 55 export(`newr`); … … 70 70 USAGE: changeord(newr,o[,r]); newr,o=strings, r=ring/qring 71 71 CREATE: create a new ring with name `newr` and make it the basering if r is 72 an existing ring/qring [default: r=basering]. 72 an existing ring/qring [default: r=basering]. 73 73 The new ring differs from the old ring only in the ordering. If, say, 74 (newr,o) = ("R","wp(2,3),dp") and the ring r exists and has >=3 74 (newr,o) = ("R","wp(2,3),dp") and the ring r exists and has >=3 75 75 variables, the new basering will have name R and ordering wp(2,3),dp. 76 76 RETURN: No return value 77 NOTE: This proc uses 'execute' or calls a procedure using 'execute'. 78 If you use it in your own proc, let the local names of your proc 77 NOTE: This proc uses 'execute' or calls a procedure using 'execute'. 78 If you use it in your own proc, let the local names of your proc 79 79 start with @ (see the file HelpForProc) 80 80 EXAMPLE: example changeord; shows an example … … 84 84 setring @r; 85 85 ideal i = ideal(@r); int @q = size(i); 86 if( @q!=0 ) 86 if( @q!=0 ) 87 87 { string @s = "@newr1"; } 88 else 88 else 89 89 { string @s = newr; } 90 90 string @newring = @s+"=("+charstr(@r)+"),("+varstr(@r)+"),("+o+");"; … … 95 95 ideal i = phi(i); 96 96 attrib(i,"isSB",1); //*** attrib funktioniert ? 97 execute("qring "+newr+"=i;"); 97 execute("qring "+newr+"=i;"); 98 98 } 99 99 export(`newr`); … … 116 116 USAGE: changevar(newr,vars[,r]); newr,vars=strings, r=ring/qring 117 117 CREATE: creates a new ring with name `newr` and makes it the basering if r 118 is an existing ring/qring [default: r=basering]. 118 is an existing ring/qring [default: r=basering]. 119 119 The new ring differs from the old ring only in the variables. If, 120 say, (newr,vars) = ("R","t()") and the ring r exists and has n 121 variables, the new basering will have name R and variables 120 say, (newr,vars) = ("R","t()") and the ring r exists and has n 121 variables, the new basering will have name R and variables 122 122 t(1),...,t(n). 123 If vars = "a,b,c,d", the new ring will have the variables a,b,c,d. 123 If vars = "a,b,c,d", the new ring will have the variables a,b,c,d. 124 124 RETURN: No return value 125 125 NOTE: This procedure is useful in connection with the procedure ringtensor, 126 126 when a conflict between variable names must be avoided. 127 This proc uses 'execute' or calls a procedure using 'execute'. 128 If you use it in your own proc, let the local names of your proc 127 This proc uses 'execute' or calls a procedure using 'execute'. 128 If you use it in your own proc, let the local names of your proc 129 129 start with @ (see the file HelpForProc) 130 130 EXAMPLE: example changevar; shows an example … … 134 134 setring @r; 135 135 ideal i = ideal(@r); int @q = size(i); 136 if( @q!=0 ) 136 if( @q!=0 ) 137 137 { string @s = "@newr1"; } 138 else 138 else 139 139 { string @s = newr; } 140 140 string @newring = @s+"=("+charstr(@r)+"),("; 141 141 if( vars[size(vars)-1]=="(" and vars[size(vars)]==")" ) 142 { 143 @newring = @newring+vars[1,size(vars)-2]+"(1.."+string(nvars(@r))+")"; 142 { 143 @newring = @newring+vars[1,size(vars)-2]+"(1.."+string(nvars(@r))+")"; 144 144 } 145 145 else { @newring = @newring+vars; } … … 151 151 ideal i = phi(i); 152 152 attrib(i,"isSB",1); //*** attrib funktioniert ? 153 execute("qring "+newr+"=i;"); 153 execute("qring "+newr+"=i;"); 154 154 } 155 155 export(`newr`); … … 174 174 CREATE: Define a ring with name 's1', characteristic 's2', ordering 's4' and 175 175 n variables with names derived from s3 and make it the basering. 176 If s3 is a single letter, say s3="a", and if n<=26 then a and the 177 following n-1 letters from the alphabeth (cyclic order) are taken as 178 variables. If n>26 or if s3 is a single letter followed by (, say 179 s3="T(", the variables are T(1),...,T(n). 176 If s3 is a single letter, say s3="a", and if n<=26 then a and the 177 following n-1 letters from the alphabeth (cyclic order) are taken as 178 variables. If n>26 or if s3 is a single letter followed by (, say 179 s3="T(", the variables are T(1),...,T(n). 180 180 RETURN: No return value 181 181 NOTE: This proc is useful for defining a ring in a procedure. 182 This proc uses 'execute' or calls a procedure using 'execute'. 183 If you use it in your own proc, let the local names of your proc 182 This proc uses 'execute' or calls a procedure using 'execute'. 183 If you use it in your own proc, let the local names of your proc 184 184 start with @ (see the file HelpForProc) 185 185 EXAMPLE: example defring; shows an example … … 258 258 execute("keepring P"+string(n)+";"); 259 259 //the next comment is only shown if defringp is not called by another proc 260 if (voice==2) { "// basering is now:",s; } 261 } 260 if (voice==2) { "// basering is now:",s; } 261 } 262 262 example 263 263 { "EXAMPLE:"; echo = 2; … … 269 269 270 270 proc extendring (string na, int n, string va, string o, list #) 271 USAGE: extendring(na,n,va,o[iv,i,r]); na,va,o=strings, 271 USAGE: extendring(na,n,va,o[iv,i,r]); na,va,o=strings, 272 272 n,i=integers, r=ring, iv=intvec of positive integers or iv=0 273 273 CREATE: Define a ring with name `na` which extends the ring r by adding n new … … 275 275 the basering [default: (i,r)=(0,basering)] 276 276 -- The characteristic is the characteristic of r 277 -- The new vars are derived from va. If va is a single letter, say 278 va="T", and if n<=26 then T and the following n-1 letters from 279 T..Z..T (resp. T(1..n) if n>26) are taken as additional variables. 280 If va is a single letter followed by (, say va="x(", the new 277 -- The new vars are derived from va. If va is a single letter, say 278 va="T", and if n<=26 then T and the following n-1 letters from 279 T..Z..T (resp. T(1..n) if n>26) are taken as additional variables. 280 If va is a single letter followed by (, say va="x(", the new 281 281 variables are x(1),...,x(n) 282 282 -- The ordering is the product ordering between the ordering of r and 283 283 an ordering derived from `o` [and iv] 284 - If o contains a 'c' or a 'C' in front resp. at the end this is 284 - If o contains a 'c' or a 'C' in front resp. at the end this is 285 285 taken for the whole ordering in front resp. at the end. If o does 286 286 not contain a 'c' or a 'C' the same rule applies to ordstr(r). 287 287 - If no intvec iv is given, or if iv=0, o may be any allowed ordstr, 288 288 like "ds" or "dp(2),wp(1,2,3),Ds(2)" or "ds(a),dp(b),ls" if a and b 289 are globally (!) defined integers and if a+b+1<=n 290 If, however, a and b are local to a proc calling extendring, the 291 intvec iv must be used to let extendring know the values of a and b 289 are globally (!) defined integers and if a+b+1<=n 290 If, however, a and b are local to a proc calling extendring, the 291 intvec iv must be used to let extendring know the values of a and b 292 292 - If an intvec iv !=0 is given, iv[1],iv[2],... is taken for the 1st, 293 2nd,... block of o, if o contains no substring "w" or "W" i.e. no 294 weighted ordering (in the above case o="ds,dp,ls" and iv=a,b). 295 If o contains a weighted ordering (only one (!) weighted block is 296 allowed) iv[1] is taken as size for the weight-vector, the next 293 2nd,... block of o, if o contains no substring "w" or "W" i.e. no 294 weighted ordering (in the above case o="ds,dp,ls" and iv=a,b). 295 If o contains a weighted ordering (only one (!) weighted block is 296 allowed) iv[1] is taken as size for the weight-vector, the next 297 297 iv[1] values of iv are taken as weights and the remaining values of 298 iv as block-size for the remaining non-weighted blocks. 299 e.g. o="dp,ws,Dp,ds", iv=3,2,3,4,2,5 creates the ordering 298 iv as block-size for the remaining non-weighted blocks. 299 e.g. o="dp,ws,Dp,ds", iv=3,2,3,4,2,5 creates the ordering 300 300 dp(2),ws(2,3,4),Dp(5),ds 301 301 RETURN: No return value 302 302 NOTE: This proc is useful for adding deformation parameters. 303 This proc uses 'execute' or calls a procedure using 'execute'. 304 If you use it in your own proc, let the local names of your proc 303 This proc uses 'execute' or calls a procedure using 'execute'. 304 If you use it in your own proc, let the local names of your proc 305 305 start with @ (see the file HelpForProc) 306 306 EXAMPLE: example extendring; shows an example 307 307 { 308 308 //--------------- initialization and place c/C of ordering properly ----------- 309 string @o1,@o2,@ro,@wstr,@v,@newring; 309 string @o1,@o2,@ro,@wstr,@v,@newring; 310 310 int @i,@w,@ii,@k; 311 311 intvec @iv,@iw; … … 331 331 } 332 332 @ro=ordstr(@r); 333 if( @ro[1]=="c" or @ro[1]=="C" ) 333 if( @ro[1]=="c" or @ro[1]=="C" ) 334 334 { @v=@ro[1,2]; @ro=@ro[3..size(@ro)]; } 335 else 335 else 336 336 { @wstr=@ro[size(@ro)-1,2]; @ro=@ro[1..size(@ro)-2]; } 337 337 if( @k==0) { @o1=@v; @o2=@wstr; } … … 341 341 @k=n; //@k counts no of vars not yet ordered 342 342 @w=find(o,"w")+find(o,"W");o=o+" "; 343 if( @w!=0 ) 344 { 345 @wstr=o[@w..@w+1]; 343 if( @w!=0 ) 344 { 345 @wstr=o[@w..@w+1]; 346 346 o=o[1,@w-1]+"@"+o[@w+2,size(o)]; 347 347 @iw=@iv[2..@iv[1]+1]; 348 348 @wstr=@wstr+"("+string(@iw)+")"; 349 @k=@k-@iv[1]; 349 @k=@k-@iv[1]; 350 350 @iv=@iv[@iv[1]+2..size(@iv)]; 351 351 @w=0; 352 352 } 353 for( @ii=1; @ii<=size(@iv); @ii ++)353 for( @ii=1; @ii<=size(@iv); @ii=@ii+1 ) 354 354 { 355 355 if( find(o,",",@w+1)!=0 ) … … 357 357 @w=find(o,",",@w+1); 358 358 if( o[@w-1]!="@" ) 359 { 360 o=o[1,@w-1]+"("+string(@iv[@ii])+")"+o[@w,size(o)]; 359 { 360 o=o[1,@w-1]+"("+string(@iv[@ii])+")"+o[@w,size(o)]; 361 361 @w=find(o,",",@w+1); 362 362 @k=@k-@iv[@ii]; … … 373 373 if( n>26 or va[2]=="(" ) { @v = va[1]+"(1.."+string(n)+")"; } 374 374 else { @v = A_Z(va,n); } 375 if( @i==0 ) 376 { 377 @v=@v+","+varstr(@r); 378 o=@o1+o+","+@ro+@o2; 379 } 380 else 381 { 382 @v=varstr(@r)+","+@v; 383 o=@o1+@ro+","+o+@o2; 375 if( @i==0 ) 376 { 377 @v=@v+","+varstr(@r); 378 o=@o1+o+","+@ro+@o2; 379 } 380 else 381 { 382 @v=varstr(@r)+","+@v; 383 o=@o1+@ro+","+o+@o2; 384 384 } 385 385 @newring=@newring+@v+"),("+o+");"; … … 394 394 { "EXAMPLE:"; echo = 2; 395 395 ring r=0,(x,y,z),ds; 396 show(r);""; 396 show(r);""; 397 397 //no intvec given, no blocksize given: blocksize is derived from no of vars 398 int t=5; 398 int t=5; 399 399 extendring("R1",t,"a","dp"); //t global: "dp" -> "dp(5)" 400 400 show(R1); ""; … … 411 411 //the remaining variables, if intvec has too many components, the last 412 412 //ones are ignored 413 intvec v=3,2,3,4,1,3; 414 extendring("R4",10,"A","ds,ws,Dp,dp",v,0,r); 415 //v covers 3 blocks: v[1] (=3) : no of components of ws 413 intvec v=3,2,3,4,1,3; 414 extendring("R4",10,"A","ds,ws,Dp,dp",v,0,r); 415 //v covers 3 blocks: v[1] (=3) : no of components of ws 416 416 //next v[1] values (=v[2..4]) give weights 417 417 //remaining components of v are used for the remaining blocks … … 421 421 /////////////////////////////////////////////////////////////////////////////// 422 422 423 proc fetchall (R, list #) 423 proc fetchall (R, list #) 424 424 USAGE: fetchall(R[,s]); R=ring/qring, s=string 425 425 CREATE: fetch all objects of ring R (of type poly/ideal/vector/module/number/ … … 427 427 If no 3rd argument is present, the names are the same as in R. If, 428 428 say, f is a poly in R and the 3rd argument is the string "R", then f 429 is maped to f_R etc. 429 is maped to f_R etc. 430 430 RETURN: no return value 431 431 NOTE: As fetch, this procedure maps the 1st, 2nd, ... variable of R to the 432 1st, 2nd, ... variable of the basering. 432 1st, 2nd, ... variable of the basering. 433 433 The 3rd argument is useful in order to avoid conflicts of names, the 434 434 empty string is allowed 435 435 CAUTION: fetchall does not work inside a procedure 436 //***at the moment it does not work if R contains a map 436 //***at the moment it does not work if R contains a map 437 437 EXAMPLE: example fetchall; shows an example 438 { 438 { 439 439 list @L@=names(R); 440 440 int @ii@; string @s@; 441 441 if( size(#) > 0 ) { @s@=@s@+"_"+#[1]; } 442 for( @ii@=size(@L@); @ii@>0; @ii@ --)443 { 442 for( @ii@=size(@L@); @ii@>0; @ii@=@ii@-1 ) 443 { 444 444 execute("def "+@L@[@ii@]+@s@+"=fetch(R,`@L@[@ii@]`);"); 445 445 execute("export "+@L@[@ii@]+@s@+";"); … … 465 465 /////////////////////////////////////////////////////////////////////////////// 466 466 467 proc imapall (R, list #) 467 proc imapall (R, list #) 468 468 USAGE: imapall(R[,s]); R=ring/qring, s=string 469 469 CREATE: map all objects of ring R (of type poly/ideal/vector/module/number/ … … 471 471 If no 3rd argument is present, the names are the same as in R. If, 472 472 say, f is a poly in R and the 3rd argument is the string "R", then f 473 is maped to f_R etc. 473 is maped to f_R etc. 474 474 RETURN: no return value 475 475 NOTE: As imap, this procedure maps the variables of R to the variables with … … 478 478 empty string is allowed 479 479 CAUTION: imapall does not work inside a procedure 480 //***at the moment it does not work if R contains a map 480 //***at the moment it does not work if R contains a map 481 481 EXAMPLE: example imapall; shows an example 482 { 482 { 483 483 list @L@=names(R); 484 484 int @ii@; string @s@; 485 485 if( size(#) > 0 ) { @s@=@s@+"_"+#[1]; } 486 for( @ii@=size(@L@); @ii@>0; @ii@ --)487 { 486 for( @ii@=size(@L@); @ii@>0; @ii@=@ii@-1 ) 487 { 488 488 execute("def "+@L@[@ii@]+@s@+"=imap(R,`@L@[@ii@]`);"); 489 489 execute("export "+@L@[@ii@]+@s@+";"); … … 509 509 /////////////////////////////////////////////////////////////////////////////// 510 510 511 proc mapall (R, ideal i, list #) 511 proc mapall (R, ideal i, list #) 512 512 USAGE: mapall(R,i[,s]); R=ring/qring, i=ideal of basering, s=string 513 CREATE: map all objects of ring R (of type poly/ideal/vector/module/number/ 513 CREATE: map all objects of ring R (of type poly/ideal/vector/module/number/ 514 514 matrix, map) into the basering, by mapping the jth variable of R to 515 515 the jth generator of the ideal i. If no 3rd argument is present, the 516 names are the same as in R. If, say, f is a poly in R and the 3rd 517 argument is the string "R", then f is maped to f_R etc. 516 names are the same as in R. If, say, f is a poly in R and the 3rd 517 argument is the string "R", then f is maped to f_R etc. 518 518 RETURN: no return value 519 519 NOTE: This procedure has the same effect as defining a map, say psi, by 520 520 map psi=R,i; and then applying psi to all objects of R. In particular, 521 521 maps from R to some ring S are composed with psi, creating thus a map 522 from the basering to S. 522 from the basering to S. 523 523 mapall may be combined with copyring to change vars for all objects. 524 524 The 3rd argument is useful in order to avoid conflicts of names, the 525 525 empty string is allowed 526 CAUTION: mapall does not work inside a procedure 526 CAUTION: mapall does not work inside a procedure 527 527 EXAMPLE: example mapall; shows an example 528 { 528 { 529 529 list @L@=names(R); map @psi@ = R,i; 530 530 int @ii@; string @s@; 531 531 if( size(#) > 0 ) { @s@=@s@+"_"+#[1]; } 532 for( @ii@=size(@L@); @ii@>0; @ii@ --)533 { 532 for( @ii@=size(@L@); @ii@>0; @ii@=@ii@-1 ) 533 { 534 534 execute("def "+@L@[@ii@]+@s@+"=@psi@(`@L@[@ii@]`);"); 535 535 execute("export "+@L@[@ii@]+@s@+";"); … … 544 544 " ideal j=x,y,z;"; 545 545 " matrix M[2][3]=1,2,3,x,y,z;"; 546 " map phi=R,x2,y2,z2; "; 546 " map phi=R,x2,y2,z2; "; 547 547 " ring S=0,(a,b,c),ds;"; 548 548 " ideal i=c,a,b;"; … … 565 565 USAGE: ringtensor(s,r1,r2,...); s=string, r1,r2,...=rings 566 566 CREATE: A new base ring with name `s` if r1,r2,... are existing rings. 567 If, say, s = "R" and the rings r1,r2,... exist, the new ring will 568 have name R, variables from all rings r1,r2,... and as monomial 567 If, say, s = "R" and the rings r1,r2,... exist, the new ring will 568 have name R, variables from all rings r1,r2,... and as monomial 569 569 ordering the block (product) ordering of r1,r2,... . Hence, R 570 570 is the tensor product of the rings r1,r2,... with ordering matrix … … 576 576 variable with name x in r1, there is no access to x in r2). 577 577 The procedure works also for quotient rings ri, if the characteristic 578 of ri is compatible with the characteristic of r1 (i.e. if imap from 578 of ri is compatible with the characteristic of r1 (i.e. if imap from 579 579 ri to r1 is implemented) 580 This proc uses 'execute' or calls a procedure using 'execute'. 581 If you use it in your own proc, let the local names of your proc 580 This proc uses 'execute' or calls a procedure using 'execute'. 581 If you use it in your own proc, let the local names of your proc 582 582 start with @ (see the file HelpForProc) 583 583 EXAMPLE: example ringtensor; shows an example … … 587 587 string @vars,@order,@oi,@s1; 588 588 //---- gather variables, orderings and ideals (of qrings) from given rings ---- 589 for(@ii=1; @ii<=@n; @ii ++)590 { 591 if( ordstr(#[@ii])[1]=="C" or ordstr(#[@ii])[1]=="c" ) 589 for(@ii=1; @ii<=@n; @ii=@ii+1) 590 { 591 if( ordstr(#[@ii])[1]=="C" or ordstr(#[@ii])[1]=="c" ) 592 592 { @oi=ordstr(#[@ii])[3,size(ordstr(#[@ii]))-2]; } 593 593 else { @oi=ordstr(#[@ii])[1,size(ordstr(#[@ii]))-2]; } … … 596 596 def @r(@ii)=#[@ii]; 597 597 setring @r(@ii); 598 ideal i(@ii)=ideal(@r(@ii)); 598 ideal i(@ii)=ideal(@r(@ii)); 599 599 int @q(@ii)=size(i(@ii)); 600 600 @q=@q+@q(@ii); … … 610 610 { 611 611 ideal i; 612 for(@ii=1; @ii<=@n; @ii ++)612 for(@ii=1; @ii<=@n; @ii=@ii+1) 613 613 { 614 614 if( @q(@ii)!=0 ) … … 618 618 } 619 619 i=std(i); 620 execute("qring "+s+"=i;"); 620 execute("qring "+s+"=i;"); 621 621 } 622 622 //----------------------- export and keep created ring ------------------------ … … 626 626 return(); 627 627 } 628 example 628 example 629 629 { "EXAMPLE:"; echo = 2; 630 630 ring r=32003,(x,y,u,v),dp; 631 631 ring s=0,(a,b,c),wp(1,2,3); 632 632 ring t=0,x(1..5),(c,ls); 633 ringtensor("R",r,s,t); 633 ringtensor("R",r,s,t); 634 634 type R;""; 635 635 setring s; … … 639 639 changevar("T","d,e,f,g,h",t); //set T (change vars of t to d..h) the basering 640 640 qring qT=std(d2+e2-f3); //create qring of T mod d2+e2-f3 641 ringtensor("Q",s,qS,t,qT); 641 ringtensor("Q",s,qS,t,qT); 642 642 type Q; 643 643 kill R,Q,S,T; -
Singular/LIB/sing.lib
r6d09c56 r6f2edc 1 // $Id: sing.lib,v 1. 1.1.1 1997-04-25 15:13:27obachman Exp $1 // $Id: sing.lib,v 1.2 1997-04-28 19:27:25 obachman Exp $ 2 2 //system("random",787422842); 3 //(GMG +BM)4 /////////////////////////////////////////////////////////////////////////////// 5 6 LIBRARY: sing.lib PROCEDURES FOR SINGULARITIES 3 //(GMG/BM, last modified 26.06.96) 4 /////////////////////////////////////////////////////////////////////////////// 5 6 LIBRARY: sing.lib PROCEDURES FOR SINGULARITIES 7 7 8 8 deform(i); infinitesimal deformations of ideal i … … 22 22 T12(i); T1- and T2-module of ideal i 23 23 24 LIB "inout.lib"; 24 LIB "inout.lib"; 25 25 LIB "random.lib"; 26 26 /////////////////////////////////////////////////////////////////////////////// 27 27 28 28 proc deform (ideal id) 29 USAGE: deform(id); id =ideal or poly29 USAGE: deform(id); id=ideal or poly 30 30 RETURN: matrix, columns are kbase of infinitesimal deformations 31 EXAMPLE: example deform; shows an example 32 { 31 EXAMPLE: example deform; shows an example 32 { 33 33 list L=T1(id,""); 34 return(L[2]*kbase(std(L[1]))); 35 } 36 example 37 { "EXAMPLE:"; echo = 2; 38 ring r=32003,(x,y,z),ds; 39 ideal i=xy,xz,yz; 40 matrix T=deform(i);print(T); 41 print(deform(x3+y5+z2)); 34 def K=L[1]; attrib(K,"isSB",1); 35 return(L[2]*kbase(K)); 36 } 37 example 38 { "EXAMPLE:"; echo = 2; 39 ring r = 32003,(x,y,z),ds; 40 ideal i = xy,xz,yz; 41 matrix T = deform(i); 42 print(T); 43 print(deform(x3+y5+z2)); 42 44 } 43 45 /////////////////////////////////////////////////////////////////////////////// … … 52 54 example 53 55 { "EXAMPLE:"; echo = 2; 54 ring r =32003,(x,y,z),ds;55 ideal i = x5+y6+z6,x2+2y2+3z2;56 ring r = 32003,(x,y,z),ds; 57 ideal i = x5+y6+z6,x2+2y2+3z2; 56 58 dim_slocus(i); 57 59 } … … 59 61 60 62 proc is_active (poly f, id) 61 USAGE: is_active(f,id); f poly, id ideal or module 63 USAGE: is_active(f,id); f poly, id ideal or module 62 64 RETURN: 1 if f is an active element modulo id (i.e. dim(id)=dim(id+f*R^n)+1, 63 65 if id is a submodule of R^n) resp. 0 if f is not active. 64 The basering may be a quotient ring 66 The basering may be a quotient ring 65 67 NOTE: regular parameters are active but not vice versa (id may have embedded 66 68 components). proc is_reg tests whether f is a regular parameter 67 69 EXAMPLE: example is_active; shows an example 68 70 { 69 if( size(id)==0 ) { return(1); } 71 if( size(id)==0 ) { return(1); } 70 72 if( typeof(id)=="ideal" ) { ideal m=f; } 71 if( typeof(id)=="module" ) { module m=f*freemodule( rank(id)); }73 if( typeof(id)=="module" ) { module m=f*freemodule(nrows(id)); } 72 74 return(dim(std(id))-dim(std(id+m))); 73 75 } 74 76 example 75 77 { "EXAMPLE:"; echo = 2; 76 ring r =32003,(x,y,z),ds;77 ideal i =yx3+y,yz3+y3z;78 poly f =x;78 ring r =32003,(x,y,z),ds; 79 ideal i = yx3+y,yz3+y3z; 80 poly f = x; 79 81 is_active(f,i); 80 qring q = std(x4y5);81 poly f =x;82 module m =[yx3+x,yx3+y3x];82 qring q = std(x4y5); 83 poly f = x; 84 module m = [yx3+x,yx3+y3x]; 83 85 is_active(f,m); 84 86 } … … 88 90 USAGE: is_ci(i); i ideal 89 91 RETURN: intvec = sequence of dimensions of ideals (j[1],...,j[k]), for 90 k=1,...,size(j), where j is minimal base of i. i is a complete 91 intersection if last number equals nvars-size(i) 92 NOTE: dim(0-ideal) = -1. You may first apply simplify(i,10); in order to 93 delete zeroes and multiples from set of generators 92 k=1,...,size(j), where j is minimal base of i. i is a complete 93 intersection if last number equals nvars-size(i) 94 NOTE: dim(0-ideal) = -1. You may first apply simplify(i,10); in order to 95 delete zeroes and multiples from set of generators 96 printlevel >=0: display comments (default) 94 97 EXAMPLE: example is_ci; shows an example 95 98 { … … 97 100 i=minbase(i); 98 101 int s = ncols(i); 102 int p = printlevel-voice+3; // p=printlevel+1 (default: p=1) 99 103 //--------------------------- compute dimensions ------------------------------ 100 for( n=1; n<=s; n ++ )101 { 104 for( n=1; n<=s; n=n+1 ) 105 { 102 106 id = i[1..n]; 103 107 dimvec[n] = dim(std(id)); 104 108 } 105 109 n = dimvec[s]; 106 //--------------------------- output ------------------------------------------ 107 if( defined(printlevel) ) 108 { 109 if( n+s !=nvars(basering) ) 110 { dbprint(printlevel,"// no complete intersection"); } 111 if( n+s ==nvars(basering) ) 112 { dbprint(printlevel,"// complete intersection of dim "+string(n)); } 113 dbprint(printlevel,"// dim-sequence:"); 114 } 115 if( voice==2 ) 116 { 117 if( n+s !=nvars(basering)) {"// no complete intersection"; } 118 if( n+s ==nvars(basering)) {"// complete intersection of dim",n;} 119 "// dim-sequence:"; 120 } 110 //--------------------------- output ------------------------------------------ 111 if( n+s != nvars(basering) ) 112 { dbprint(p,"// no complete intersection"); } 113 if( n+s == nvars(basering) ) 114 { dbprint(p,"// complete intersection of dim "+string(n)); } 115 dbprint(p,"// dim-sequence:"); 121 116 return(dimvec); 122 117 } 123 118 example 124 { "EXAMPLE:"; echo = 2;125 int p rintlevel=2; // this forces the proc to display comments126 export printlevel;127 ring r =32003,(x,y,z),ds;128 ideal i =x4+y5+z6,xyz,yx2+xz2+zy7;119 { "EXAMPLE:"; echo = 2; 120 int p = printlevel; 121 printlevel = 1; // display comments 122 ring r = 32003,(x,y,z),ds; 123 ideal i = x4+y5+z6,xyz,yx2+xz2+zy7; 129 124 is_ci(i); 130 i =xy,yz;131 is_ci(i); 132 kill printlevel;125 i = xy,yz; 126 is_ci(i); 127 printlevel = p; 133 128 } 134 129 /////////////////////////////////////////////////////////////////////////////// … … 139 134 generated by id[1]..id[i], k = 1..size(id); dim(0-ideal) = -1; 140 135 id defines an isolated singularity if last number is 0 136 NOTE: printlevel >=0: display comments (default) 141 137 EXAMPLE: example is_is; shows an example 142 138 { 143 139 int l; intvec dims; ideal j; 140 int p = printlevel-voice+3; // p=printlevel+1 (default: p=1) 144 141 //--------------------------- compute dimensions ------------------------------ 145 for( l=1; l<=ncols(i); l ++)146 { 147 j = i[1..l]; 142 for( l=1; l<=ncols(i); l=l+1 ) 143 { 144 j = i[1..l]; 148 145 dims[l] = dim(std(slocus(j))); 149 146 } 150 if( voice==2 ) {"// dim of singular locus =",dims[size(dims)],"dim-sequence:";151 "// isolated singularity if last number is 0"; }147 dbprint(p,"// dim of singular locus = "+string(dims[size(dims)]), 148 "// isolated singularity if last number is 0 in dim-sequence:"); 152 149 return(dims); 153 150 } 154 151 example 155 152 { "EXAMPLE:"; echo = 2; 156 ring r=32003,(x,y,z),ds; 157 ideal i=x2y,x4+y5+z6,yx2+xz2+zy7; 153 int p = printlevel; 154 printlevel = 1; 155 ring r = 32003,(x,y,z),ds; 156 ideal i = x2y,x4+y5+z6,yx2+xz2+zy7; 158 157 is_is(i); 159 // isolated singularity if last number is 0 160 poly f=xy+yz; 158 poly f = xy+yz; 161 159 is_is(f); 162 // isolated singularity if last number is 0 160 printlevel = p; 163 161 } 164 162 /////////////////////////////////////////////////////////////////////////////// … … 177 175 id=std(id); 178 176 d=size(q); 179 for( ii=1; ii<=d; ii ++)177 for( ii=1; ii<=d; ii=ii+1 ) 180 178 { 181 179 if( reduce(q[ii],id)!=0 ) … … 184 182 return(1); 185 183 } 186 example 187 { "EXAMPLE:"; echo = 2; 188 ring r=32003,(x,y),ds; 189 ideal i=x8,y8;ideal j=(x+y)^4; 190 i=intersect(i,j); poly f=xy; 184 example 185 { "EXAMPLE:"; echo = 2; 186 ring r = 32003,(x,y),ds; 187 ideal i = x8,y8; 188 ideal j = (x+y)^4; 189 i = intersect(i,j); 190 poly f = xy; 191 191 is_reg(f,i); 192 192 } … … 198 198 NOTE: let R be the basering and id a submodule of R^n. The procedure checks 199 199 injectivity of multiplication with i[k] on R^n/id+i[1..k-1]. 200 The basering may be a quotient ring 200 The basering may be a quotient ring 201 printlevel >=0: display comments (default) 202 printlevel >=1: display comments during computation 201 203 EXAMPLE: example is_regs; shows an example 202 204 { 205 int d,ii,r; 206 int p = printlevel-voice+3; // p=printlevel+1 (default: p=1) 203 207 if( size(#)==0 ) { ideal id; } 204 208 else { def id=#[1]; } 205 209 if( size(i)==0 ) { return(0); } 206 int d,ii,r; 207 d=size(i); 210 d=size(i); 208 211 if( typeof(id)=="ideal" ) { ideal m=1; } 209 if( typeof(id)=="module" ) { module m=freemodule( rank(id)); }210 for( ii=1; ii<=d; ii ++)211 { 212 if( voice==2 )212 if( typeof(id)=="module" ) { module m=freemodule(nrows(id)); } 213 for( ii=1; ii<=d; ii=ii+1 ) 214 { 215 if( p>=2 ) 213 216 { "// checking whether element",ii,"is regular mod 1 ..",ii-1; } 214 if( is_reg(i[ii],id)==0 ) 215 { 216 if( voice==2 ) 217 { 218 "// elements 1 ..",ii-1,"are regular,", 219 ii,"is not regular mod 1 ..",ii-1; 220 } 221 return(0); 217 if( is_reg(i[ii],id)==0 ) 218 { 219 dbprint(p,"// elements 1.."+string(ii-1)+" are regular, " + 220 string(ii)+" is not regular mod 1.."+string(ii-1)); 221 return(0); 222 222 } 223 id=id+i[ii]*m; 224 } 225 if( voice==2) { "// elements are a regular sequence of length",d; }223 id=id+i[ii]*m; 224 } 225 if( p>=1 ) { "// elements are a regular sequence of length",d; } 226 226 return(1); 227 227 } 228 example 229 { "EXAMPLE:"; echo = 2; 230 ring r1=32003,(x,y,z),ds; 231 ideal i=x8,y8,(x+y)^4; 228 example 229 { "EXAMPLE:"; echo = 2; 230 int p = printlevel; 231 printlevel = 1; 232 ring r1 = 32003,(x,y,z),ds; 233 ideal i = x8,y8,(x+y)^4; 232 234 is_regs(i); 233 module m =[x,0,y];234 i =x8,(x+z)^4;;235 module m = [x,0,y]; 236 i = x8,(x+z)^4;; 235 237 is_regs(i,m); 238 printlevel = p; 236 239 } 237 240 /////////////////////////////////////////////////////////////////////////////// … … 240 243 USAGE: milnor(i); i ideal or poly 241 244 RETURN: Milnor number of i, if i is ICIS (isolated complete intersection 242 singularity) in generic form, resp. -1 if not 245 singularity) in generic form, resp. -1 if not 243 246 NOTE: use proc nf_icis to put generators in generic form 247 printlevel >=0: display comments (default) 244 248 EXAMPLE: example milnor; shows an example 245 { 246 i = simplify(i,10); //delete zeroes and multiples from set of generators 249 { 250 i = simplify(i,10); //delete zeroes and multiples from set of generators 247 251 int n = size(i); 248 252 int l,q,m_nr; ideal t; intvec disc; 249 //---------------------------- hypersurface case ------------------------------ 250 if( n==1 ) 253 int p = printlevel-voice+3; // p=printlevel+1 (default: p=1) 254 //---------------------------- hypersurface case ------------------------------ 255 if( n==1 ) 251 256 { 252 257 i = std(jacob(i[1])); 253 m_nr = vdim(i); 254 if( m_nr<0 and voice==2) { "// no isolated singularity"; }255 return(m_nr); 258 m_nr = vdim(i); 259 if( m_nr<0 and p>=1 ) { "// no isolated singularity"; } 260 return(m_nr); 256 261 } 257 262 //------------ isolated complete intersection singularity (ICIS) -------------- 258 263 for( l=n; l>0; l=l-1) 259 { 260 t = minor(jacob(i),l); 261 i[l] = 0; 264 { t = minor(jacob(i),l); 265 i[l] = 0; 262 266 q = vdim(std(i+t)); 263 267 disc[l]= q; 264 268 if( q ==-1 ) 265 { 266 if( voice==2 ) 269 { if( p>=1 ) 267 270 { "// not in generic form or no ICIS; use proc nf_icis to put"; 268 "// generators in generic form and then try milnor again!"; } 271 "// generators in generic form and then try milnor again!"; } 269 272 return(q); 270 273 } 271 m_nr = q-m_nr; 274 m_nr = q-m_nr; 272 275 } 273 //---------------------------- change sign ------------------------------------ 274 if (m_nr < 0) { m_nr=-m_nr; } 275 if( voice==2) { "//sequence of discriminant numbers:",disc; }276 //---------------------------- change sign ------------------------------------ 277 if (m_nr < 0) { m_nr=-m_nr; } 278 if( p>=1 ) { "//sequence of discriminant numbers:",disc; } 276 279 return(m_nr); 277 280 } 278 281 example 279 282 { "EXAMPLE:"; echo = 2; 280 ring r=32003,(x,y,z),ds; 281 ideal j=x5+y6+z6,x2+2y2+3z2,xyz+yx; 283 int p = printlevel; 284 printlevel = 1; 285 ring r = 32003,(x,y,z),ds; 286 ideal j = x5+y6+z6,x2+2y2+3z2,xyz+yx; 282 287 milnor(j); 283 poly f=x7+y7+(x-y)^2*x2y2+z2; 284 milnor(f); 288 poly f = x7+y7+(x-y)^2*x2y2+z2; 289 milnor(f); 290 printlevel = p; 285 291 } 286 292 /////////////////////////////////////////////////////////////////////////////// … … 291 297 (isolated complete intersection singularity), return i if not 292 298 NOTE: this proc is useful in connection with proc milnor 299 printlevel >=0: display comments (default) 293 300 EXAMPLE: example nf_icis; shows an example 294 301 { 295 302 i = simplify(i,10); //delete zeroes and multiples from set of generators 296 int p,b = 100,0; 303 int p,b = 100,0; 297 304 int n = size(i); 298 305 matrix mat=freemodule(n); 299 //---------------------------- test: complete intersection? ------------------- 306 int P = printlevel-voice+3; // P=printlevel+1 (default: P=1) 307 //---------------------------- test: complete intersection? ------------------- 300 308 intvec sl = is_ci(i); 301 if( n+sl[n] != nvars(basering) ) 302 { 303 if( voice==2 ) { "// no complete intersection"; }304 return(i);305 } 306 //--------------- test: isolated singularity in generic form? ----------------- 309 if( n+sl[n] != nvars(basering) ) 310 { 311 dbprint(P,"// no complete intersection"); 312 return(i); 313 } 314 //--------------- test: isolated singularity in generic form? ----------------- 307 315 sl = is_is(i); 308 316 if ( sl[n] != 0 ) 309 317 { 310 if( voice==2 ) { "// no isolated singularity"; }318 dbprint(P,"// no isolated singularity"); 311 319 return(i); 312 320 } 313 //------------ produce generic linear combinations of generators -------------- 321 //------------ produce generic linear combinations of generators -------------- 314 322 int prob; 315 while ( sum(sl) != 0 ) 323 while ( sum(sl) != 0 ) 316 324 { prob=prob+1; 317 p=p-25; b=b+10; 325 p=p-25; b=b+10; 318 326 i = genericid(i,p,b); // proc genericid from random.lib 319 327 sl = is_is(i); 320 328 } 321 if( voice==2 ) { "// ICIS in generic form after",prob,"genericity loop(s)";} 322 return(i); 323 } 324 example 325 { "EXAMPLE:"; echo = 2; 326 ring r=32003,(x,y,z),ds; 327 ideal i=x3+y4,z4+yx; 328 nf_icis(i); 329 ideal j=x3+y4,xy,yz; 329 dbprint(P,"// ICIS in generic form after "+string(prob)+" genericity loop(s)"); 330 return(i); 331 } 332 example 333 { "EXAMPLE:"; echo = 2; 334 int p = printlevel; 335 printlevel = 1; 336 ring r = 32003,(x,y,z),ds; 337 ideal i = x3+y4,z4+yx; 338 nf_icis(i); 339 ideal j = x3+y4,xy,yz; 330 340 nf_icis(j); 341 printlevel = p; 331 342 } 332 343 /////////////////////////////////////////////////////////////////////////////// … … 340 351 int cod = nvars(basering)-dim(std(i)); 341 352 i = i+minor(jacob(i),cod); 342 return(i); 343 } 344 example 345 { "EXAMPLE:"; echo = 2; 346 ring r =32003,(x,y,z),ds;347 ideal i = x5+y6+z6,x2+2y2+3z2;353 return(i); 354 } 355 example 356 { "EXAMPLE:"; echo = 2; 357 ring r = 32003,(x,y,z),ds; 358 ideal i = x5+y6+z6,x2+2y2+3z2; 348 359 dim(std(slocus(i))); 349 360 } … … 351 362 352 363 proc Tjurina (id, list #) 353 USAGE: Tjurina(id[,<any>]); id ideal or poly (assume: id=ICIS) 354 RETURN: Tjurina(id): standard basis of Tjurina-module of id, displays Tjurina 355 number 356 Tjurina(id,...): If a second argument is present (of any type) return 357 a list of 4 objects: [1]=Tjurina number (int), [2]=basis of miniversal 358 deformation (module), [3]=SB of Tjurina module (module), [4]=Tjurina 359 module (module) 360 NOTE: if id is a poly the output will be of type ideal rather than module 361 EXAMPLE: example Tjurina; shows an example 364 USAGE: Tjurina(id[,<any>]); id=ideal or poly 365 ASSUME: id=ICIS (isolated complete intersection singularity) 366 RETURN: standard basis of Tjurina-module of id, 367 of type module if id=ideal, resp. of type ideal if id=poly. 368 If a second argument is present (of any type) return a list: 369 [1] = Tjurina number, 370 [2] = k-basis of miniversal deformation, 371 [3] = SB of Tjurina module, 372 [4] = Tjurina module 373 DISPLAY: Tjurina number if printlevel >= 0 (default) 374 NOTE: Tjurina number = -1 implies that id is not an ICIS 375 EXAMPLE: example Tjurina; shows examples 362 376 { 363 377 //---------------------------- initialisation --------------------------------- 364 def i = simplify(id,10); 378 def i = simplify(id,10); 365 379 int tau,n = 0,size(i); 366 380 if( size(ideal(i))==1 ) { def m=i; } // hypersurface case … … 370 384 def st1 = std(t1); // SB of Tjurina module/ideal 371 385 tau = vdim(st1); // Tjurina number 372 def kB = kbase(st1); // basis of miniversal deformation 373 if( voice==2 ) { "// Tjurina number =",tau; } 374 if( size(#)>0 ) { return(tau,kB,st1,t1); } 386 dbprint(printlevel-voice+3,"// Tjurina number = "+string(tau)); 387 if( size(#)>0 ) 388 { 389 def kB = kbase(st1); // basis of miniversal deformation 390 return(tau,kB,st1,t1); 391 } 375 392 return(st1); 376 393 } 377 394 example 378 395 { "EXAMPLE:"; echo = 2; 379 ring r=0,(x,y,z),ds; 380 poly f = x5+y6+z7+xyz; // singularity T[5,6,7] 381 list T = Tjurina(f,""); 382 show(T[1]); // Tjurina number, should be 16 383 show(T[2]); // basis of miniversal deformation 384 show(T[3]); // SB of Tjurina ideal 385 show(T[4]); ""; // Tjurina ideal 386 ideal j=x2+y2+z2,x2+2y2+3z2; 387 show(kbase(Tjurina(j))); // basis of miniversal deformation 388 hilb(Tjurina(j)); // Hilbert series of Tjurina module 396 int p = printlevel; 397 printlevel = 1; 398 ring r = 0,(x,y,z),ds; 399 poly f = x5+y6+z7+xyz; // singularity T[5,6,7] 400 list T = Tjurina(f,""); 401 show(T[1]); // Tjurina number, should be 16 402 show(T[2]); // basis of miniversal deformation 403 show(T[3]); // SB of Tjurina ideal 404 show(T[4]); ""; // Tjurina ideal 405 ideal j = x2+y2+z2,x2+2y2+3z2; 406 show(kbase(Tjurina(j))); // basis of miniversal deformation 407 hilb(Tjurina(j)); // Hilbert series of Tjurina module 408 printlevel = p; 389 409 } 390 410 /////////////////////////////////////////////////////////////////////////////// 391 411 392 412 proc tjurina (ideal i) 393 USAGE: tjurina(id); id ideal or poly (assume: id=ICIS) 413 USAGE: tjurina(id); id=ideal or poly 414 ASSUME: id=ICIS (isolated complete intersection singularity) 394 415 RETURN: int = Tjurina number of id 416 NOTE: Tjurina number = -1 implies that id is not an ICIS 395 417 EXAMPLE: example tjurina; shows an example 396 418 { 397 return(vdim(Tjurina(i))); 419 return(vdim(Tjurina(i))); 398 420 } 399 421 example … … 401 423 ring r=32003,(x,y,z),(c,ds); 402 424 ideal j=x2+y2+z2,x2+2y2+3z2; 403 tjurina(j); 425 tjurina(j); 404 426 } 405 427 /////////////////////////////////////////////////////////////////////////////// … … 407 429 proc T1 (ideal id, list #) 408 430 USAGE: T1(id[,<any>]); id = ideal or poly 409 RETURN: T1(id): T1-module of id or T1-ideal if id is a poly. This is a 431 RETURN: T1(id): of type module/ideal if id is of type ideal/poly. 432 We call T1(id) the T1-module of id. It is a std basis of the 410 433 presentation of 1st order deformations of P/id, if P is the basering. 411 T1(id,...): If a second argument is present (of any type) return a412 list of3 modules:413 [1]= presentation of infinitesimal deformations of id (=T1(id))434 If a second argument is present (of any type) return a list of 435 3 modules: 436 [1]= T1(id) 414 437 [2]= generators of normal bundle of id, lifted to P 415 [3]= module of relations of [2], lifted to P ([2]*[3]=0 mod id) 416 The list contains all non-easy objects which must be computed anyway 438 [3]= module of relations of [2], lifted to P 439 (note: transpose[3]*[2]=0 mod id) 440 The list contains all non-easy objects which must be computed 417 441 to get T1(id). 418 The situation is described in detail in the procedure T1_expl 419 from library explain.lib 420 NOTE: T1(id) itself is usually of minor importance, nevertheless, from it 421 all relevant information can be obtained. Since no standard basis is 422 computed, the user has first to compute a standard basis before 423 applying vdim or hilb etc.. For example, matrix([2])*(kbase(std([1]))) 424 represents a basis of 1st order semiuniversal deformation of id 425 (use proc 'deform', to get this in a direct and convenient way). 426 If the input is weighted homogeneous with weights w1,...,wn, use 427 ordering wp(w1..wn), even in the local case, which is equivalent but 428 faster than ws(w1..wn). 442 DISPLAY: k-dimension of T1(id) if printlevel >= 0 (default) 443 NOTE: T1(id) itself is usually of minor importance. Nevertheless, from it 444 all relevant information can be obtained. The most important are 445 probably vdim(T1(id)); (which computes the Tjurina number), 446 hilb(T1(id)); and kbase(T1(id)); 447 If T1 is called with two argument, then matrix([2])*(kbase([1])) 448 represents a basis of 1st order semiuniversal deformation of id 449 (use proc 'deform', to get this in a direct way). 429 450 For a complete intersection the proc Tjurina is faster 430 451 EXAMPLE: example T1; shows an example … … 432 453 ideal J=simplify(id,10); 433 454 //--------------------------- hypersurface case ------------------------------- 434 if( size(J)<2 ) 435 { 436 ideal t1=J[1],jacob(J[1]); module nb=[1]; module pnb; 455 if( size(J)<2 ) 456 { 457 ideal t1 = std(J+jacob(J[1])); 458 module nb = [1]; module pnb; 459 dbprint(printlevel-voice+3,"// dim T1 = "+string(vdim(t1))); 437 460 if( size(#)>0 ) { return(t1*gen(1),nb,pnb); } 438 461 return(t1); … … 440 463 //--------------------------- presentation of J ------------------------------- 441 464 int rk; 442 def P =basering;465 def P = basering; 443 466 module jac, t1; 444 jac =jacob(J); // jacobian matrix of J converted to module445 res(J,2,A); // compute presentation of J446 t1=transpose(A(2)); // transposed1st syzygy module of J467 jac = jacob(J); // jacobian matrix of J converted to module 468 res(J,2,A); // compute presentation of J 469 // A(2) = 1st syzygy module of J 447 470 //---------- go to quotient ring mod J and compute normal bundle -------------- 448 qring R =std(J);449 module jac =fetch(P,jac);450 module t1 =fetch(P,t1);451 res(t1, 3,B);// resolve t1, B(2)=(J/J^2)*=normal_bdl452 t1 =lift(B(2),jac)+B(3);// pres. of normal_bdl/trivial_deformations453 rk= rank(t1);471 qring R = std(J); 472 module jac = fetch(P,jac); 473 module t1 = transpose(fetch(P,A(2))); 474 res(t1,2,B); // resolve t1, B(2)=(J/J^2)*=normal_bdl 475 t1 = modulo(B(2),jac); // pres. of normal_bdl/trivial_deformations 476 rk=nrows(t1); 454 477 //-------------------------- pull back to basering ---------------------------- 455 478 setring P; 456 479 t1 = fetch(R,t1)+J*freemodule(rk); // T1-module, presentation of T1 457 if( size(#)>0 ) 458 { 459 module B2 = fetch(R,B(2)); // (generators of) normal bundle 460 module B3 = fetch(R,B(3)); // presentation of normal bundle 461 return(t1,B2,B3); 462 } 463 return(t1); 464 } 465 example 466 { "EXAMPLE:"; echo = 2; 467 ring r=32003,(x,y,z),(c,ds); 468 ideal i=xy,xz,yz; 469 module T=T1(i); 470 vdim(std(T)); // Tjurina number = dim_K(T1), should be 3 480 t1 = std(t1); 481 dbprint(printlevel-voice+3,"// dim T1 = "+string(vdim(t1))); 482 if( size(#)>0 ) 483 { 484 module B2 = fetch(R,B(2)); // presentation of normal bundle 485 list L = t1,B2,A(2); 486 attrib(L[1],"isSB",1); 487 return(L); 488 } 489 return(t1); 490 } 491 example 492 { "EXAMPLE:"; echo = 2; 493 int p = printlevel; 494 printlevel = 1; 495 ring r = 32003,(x,y,z),(c,ds); 496 ideal i = xy,xz,yz; 497 module T = T1(i); 498 vdim(T); // Tjurina number = dim_K(T1), should be 3 471 499 list L=T1(i,""); 472 module kB = kbase(std(L[1]));500 module kB = kbase(L[1]); 473 501 print(L[2]*kB); // basis of 1st order miniversal deformation 474 s ize(L[1]); // number of generators of T1-module475 show(L[2]); // (generators of) normal bundle476 print( L[3]); // relation matrix of normal bundle(mod i)477 print (L[2]*L[3]); // should be 0 (mod i)502 show(L[2]); // presentation of normal bundle 503 print(L[3]); // relations of i 504 print(transpose(L[3])*L[2]); // should be 0 (mod i) 505 printlevel = p; 478 506 } 479 507 /////////////////////////////////////////////////////////////////////////////// … … 481 509 proc T2 (ideal id, list #) 482 510 USAGE: T2(id[,<any>]); id = ideal 483 RETURN: T2(id): T2-module of id . This is a presentation of the module of484 485 T2(id,...): If a second argument is present (of any type) return a486 list of 6modules and 1 ideal:487 [1]= presentation of module of obstructions (=T2(id))511 RETURN: T2(id): T2-module of id . This is a std basis of a presentation of 512 the module of obstructions of R=P/id, if P is the basering. 513 If a second argument is present (of any type) return a list of 514 4 modules and 1 ideal: 515 [1]= T2(id) 488 516 [2]= standard basis of id (ideal) 489 517 [3]= module of relations of id (=1st syzygy module of id) 490 [4]= presentation of [3] (=2nd syzygy module of id) 491 [5]= lifting of Koszul relations kos, kos=module([3]*matrix([5])) 492 [6]= generators of Hom_P([3]/kos,R), lifted to P 493 [7]= relations of Hom_P([3]/kos,R), lifted to P 494 The list contains all non-easy objects which must be computed anyway 495 to get T2(id). The situation is described in detail in the procedure 496 T2_expl from library explain.lib 497 NOTE: Since no standard basis is computed, the user has first to compute a 498 standard basis before applying vdim or hilb etc.. 499 If the input is weighted homogeneous with weights w1,...,wn, use 500 ordering wp(w1..wn), even in the local case, which is equivalent but 501 faster than ws(w1..wn). 502 Use proc miniversal to get equations of miniversal deformation; 518 [4]= presentation of syz/kos 519 [5]= relations of Hom_P([3]/kos,R), lifted to P 520 The list contains all non-easy objects which must be computed 521 to get T2(id). 522 DISPLAY: k-dimension of T2(id) if printlevel >= 0 (default) 523 NOTE: The most important information is probably vdim(T2(id)). 524 Use proc miniversal to get equations of miniversal deformation. 503 525 EXAMPLE: example T2; shows an example 504 526 { 505 527 //--------------------------- initialisation ---------------------------------- 506 528 def P = basering; 507 ideal J = simplify(id,10); 508 module kos,L0,t2; 529 ideal J = id; 530 module kos,SK,B2,t2; 531 list L; 509 532 int n,rk; 510 //------------------- presentation of non-trivial syzygies -------------------- 511 res(J, 3,A); // resolve J, A(2)=syz533 //------------------- presentation of non-trivial syzygies -------------------- 534 res(J,2,A); // resolve J, A(2)=syz 512 535 kos = koszul(2,J); // module of Koszul relations 513 L0 = lift(A(2),kos); // lift Koszul relations to syz 514 t2 = L0+A(3); // presentation of syz/kos 536 SK = modulo(A(2),kos); // presentation of syz/kos 515 537 ideal J0 = std(J); // standard basis of J 516 // *** sollte bei der Berechnung von res mit anfallen, zu aendern!!538 //?*** sollte bei der Berechnung von res mit anfallen, zu aendern!! 517 539 //---------------------- fetch to quotient ring mod J ------------------------- 518 540 qring R = J0; // make P/J the basering 519 module A2' = transpose(fetch(P,A(2))); // dual of syz 520 module t2 = transpose(fetch(P, t2)); // dual of syz/kos521 res(t2, 3,B); // resolve t2522 t2 = lift(B(2),A2')+B(3);// presentation of T2523 rk = rank(t2);541 module A2' = transpose(fetch(P,A(2))); // dual of syz 542 module t2 = transpose(fetch(P,SK)); // dual of syz/kos 543 res(t2,2,B); // resolve (syz/kos)* 544 t2 = modulo(B(2),A2'); // presentation of T2 545 rk = nrows(t2); 524 546 //--------------------- fetch back to basering ------------------------------- 525 547 setring P; 526 548 t2 = fetch(R,t2)+J*freemodule(rk); 527 if( size(#)>0 ) 528 { 529 module B2 = fetch(R,B(2)); // generators of Hom_P(syz/kos,R) 530 module B3 = fetch(R,B(3)); // relations of Hom_P(syz/kos,R) 531 return(t2,J0,A(2),A(3),L0,B2,B3); 532 } 533 return(t2); 534 } 535 example 536 { "EXAMPLE:"; echo = 2; 537 ring r = 32003,(x,y),(c,dp); 538 ideal j = x6-y4,x6y6,x2y4-x5y2; 539 module T= std(T2(j)); 540 vdim(T);hilb(T); 541 ring r1=0,(x,y,z),dp; 542 ideal id=xy,xz,yz; 543 list L=T2(id,""); 544 vdim(std(L[1])); // vdim of T2 545 L[4]; // 2nd syzygy module of ideal 549 t2 = std(t2); 550 dbprint(printlevel-voice+3,"// dim T2 = "+string(vdim(t2))); 551 if( size(#)>0 ) 552 { 553 B2 = fetch(R,B(2)); // generators of Hom_P(syz/kos,R) 554 L = t2,J0,A(2),SK,B2; 555 return(L); 556 } 557 return(t2); 558 } 559 example 560 { "EXAMPLE:"; echo = 2; 561 int p = printlevel; 562 printlevel = 1; 563 ring r = 32003,(x,y),(c,dp); 564 ideal j = x6-y4,x6y6,x2y4-x5y2; 565 module T = T2(j); 566 vdim(T); 567 hilb(T);""; 568 ring r1 = 0,(x,y,z),dp; 569 ideal id = xy,xz,yz; 570 list L = T2(id,""); 571 vdim(L[1]); // vdim of T2 572 print(L[3]); // syzygy module of id 573 printlevel = p; 546 574 } 547 575 /////////////////////////////////////////////////////////////////////////////// … … 549 577 proc T12 (ideal i, list #) 550 578 USAGE: T12(i[,any]); i = ideal 551 DISPLAY: dim T1 and dim T2 of i 552 RETURN: T12(i): list of 2 modules: 553 presentation of T1-module =T1(i) , 1st order deformations554 presentation of T2-module =T2(i) , obstructions of R=P/i555 T12(i,...): If a second argument is present (of any type) return556 a list of 9 modules, matrices, integers:557 [ 1]= presentation of T1 (module)558 [ 2]= presentation of T2 (module)559 [ 3]= matrix, whose cols present infinitesimal deformations560 [ 4]= matrix, whose cols are generators of relations of i561 [ 5]= matrix, presenting Hom_P([4]/kos,R), lifted to P562 [ 6]= standard basis of T1-module563 [ 7]= standard basis of T2-module564 [ 8]= vdim of T1565 [9]= vdim of T2 579 RETURN: T12(i): list of 2 modules: 580 std basis of T1-module =T1(i), 1st order deformations 581 std basid of T2-module =T2(i), obstructions of R=P/i 582 If a second argument is present (of any type) return a list of 583 9 modules, matrices, integers: 584 [1]= standard basis of T1-module 585 [2]= standard basis of T2-module 586 [3]= vdim of T1 587 [4]= vdim of T2 588 [5]= matrix, whose cols present infinitesimal deformations 589 [6]= matrix, whose cols are generators of relations of i (=syz(i)) 590 [7]= matrix, presenting Hom_P(syz/kos,R), lifted to P 591 [8]= presentation of T1-module, no std basis 592 [9]= presentation of T2-module, no std basis 593 DISPLAY: k-dimension of T1 and T2 if printlevel >= 0 (default) 566 594 NOTE: Use proc miniversal from deform.lib to get miniversal deformation of i, 567 595 the list contains all objects used by proc miniversal … … 572 600 def P = basering; 573 601 i = simplify(i,10); 574 if (size(i)<2) 575 { 576 "// hypersurface, use proc 'Tjurina'"; 577 //return([1]); 578 } 579 module jac,t1,t2,kos,sbt1,sbt2; 580 matrix L3,L4,L5; 602 module jac,t1,t2,sbt1,sbt2; 603 matrix Kos,Syz,SK,kbT1,Sx; 604 list L; 581 605 ideal i0 = std(i); 582 606 //-------------------- presentation of non-trivial syzygies ------------------- 583 list I= res(i, 3); // resolve i584 L4 = matrix(I[2]);// syz(i)607 list I= res(i,2); // resolve i 608 Syz = matrix(I[2]); // syz(i) 585 609 jac = jacob(i); // jacobi ideal 586 t1 = transpose(I[2]); // dual of syzygies 587 kos = koszul(2,i); // koszul-relations 588 t2 = lift(I[2],kos)+I[3]; // presentation of syz/kos 610 Kos = koszul(2,i); // koszul-relations 611 SK = modulo(Syz,Kos); // presentation of syz/kos 589 612 //--------------------- fetch to quotient ring mod i ------------------------- 590 613 qring Ox = i0; // make P/i the basering 591 module jac = fetch(P,jac);592 m odule t1 = fetch(P,t1); // Hom(syz,R)593 module t2 = transpose(fetch(P,t2)); // Hom(syz/kos,R)594 list resS = res( t1,3);595 list resR = res(t2,3);596 t2 = lift(resR[2],t1)+resR[3]; // presentation of T2597 r2 = rank(t2);598 t1 = lift(resS[2],jac)+resS[3]; // presentation of T1599 r 1 = rank(t1);600 m atrix L3 = resS[2];601 matrix L5 = resR[2];614 module Jac = fetch(P,jac); 615 matrix No = transpose(fetch(P,Syz)); // ker(No) = Hom(syz,Ox) 616 module So = transpose(fetch(P,SK)); // Hom(syz/kos,R) 617 list resS = res(So,2); 618 matrix Sx = resS[2]; 619 list resN = res(No,2); 620 matrix Nx = resN[2]; 621 module T2 = modulo(Sx,No); // presentation of T2 622 r2 = nrows(T2); 623 module T1 = modulo(Nx,Jac); // presentation of T1 624 r1 = nrows(T1); 602 625 //------------------------ pull back to basering ------------------------------ 603 626 setring P; 604 t1 = fetch(Ox, t1)+i*freemodule(r1);605 t2 = fetch(Ox, t2)+i*freemodule(r2);627 t1 = fetch(Ox,T1)+i*freemodule(r1); 628 t2 = fetch(Ox,T2)+i*freemodule(r2); 606 629 sbt1 = std(t1); 607 630 d1 = vdim(sbt1); 608 sbt2 =std(t2);631 sbt2 = std(t2); 609 632 d2 = vdim(sbt2); 610 "// dim T1 = ",d1; 611 "// dim T2 = ",d2; 633 dbprint(printlevel-voice+3,"// dim T1 = "+string(d1),"// dim T2 = "+string(d2)); 612 634 if ( size(#)>0) 613 635 { 614 L3 = fetch(Ox,L3)*kbase(sbt1); 615 L5 = fetch(Ox,L5); 616 return(t1,t2,L3,L4,L5,sbt1,sbt2,d1,d2); 617 } 618 return(t1,t2); 619 } 620 example 621 { "EXAMPLE:"; echo = 2; 622 ring r=200,(x,y,z,u,v),(c,ws(4,3,2,3,4)); 623 ideal i=xz-y2,yz2-xu,xv-yzu,yu-z3,z2u-yv,zv-u2; 624 //a cyclic quotient singularity 625 list L = T12(i,1); 626 print(L[3]); 627 } 628 /////////////////////////////////////////////////////////////////////////////// 636 kbT1 = fetch(Ox,Nx)*kbase(sbt1); 637 Sx = fetch(Ox,Sx); 638 L = sbt1,sbt2,d1,d2,kbT1,Syz,Sx,t1,t2; 639 return(L); 640 } 641 L = sbt1,sbt2; 642 return(L); 643 } 644 example 645 { "EXAMPLE:"; echo = 2; 646 int p = printlevel; 647 printlevel = 1; 648 ring r = 200,(x,y,z,u,v),(c,ws(4,3,2,3,4)); 649 ideal i = xz-y2,yz2-xu,xv-yzu,yu-z3,z2u-yv,zv-u2; 650 //a cyclic quotient singularity 651 list L = T12(i,1); 652 print(L[5]); //matrix of infin. deformations 653 printlevel = p; 654 } 655 ///////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset
for help on using the changeset viewer.