Changeset 7f3ad4 in git
- Timestamp:
- Jan 14, 2009, 5:07:05 PM (14 years ago)
- Branches:
- (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
- Children:
- 0721816437af5ddabc83aa203a12d9b58b42a33c
- Parents:
- 95edd5641377e851d4a1d4e986853687991d0895
- Location:
- Singular/LIB
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/bfct.lib
r95edd5 r7f3ad4 1 1 ////////////////////////////////////////////////////////////////////////////// 2 version="$Id: bfct.lib,v 1.1 0 2009-01-12 19:31:23 Singular Exp $";2 version="$Id: bfct.lib,v 1.11 2009-01-14 16:07:03 Singular Exp $"; 3 3 category="Noncommutative"; 4 4 info=" … … 35 35 AUXILIARY PROCEDURES: 36 36 37 allPositive(v); checks whether all entries of an intvec are positive 37 allPositive(v); checks whether all entries of an intvec are positive 38 38 scalarProd(v,w); computes the standard scalar product of two intvecs 39 39 vec2poly(v[,i]); constructs an univariate poly with given coefficients … … 79 79 EXAMPLE: example gradedWeyl; shows examples 80 80 NOTE: u[i] is the weight of x(i), v[i] the weight of D(i). 81 @* u+v has to be a non-negative intvec. 81 @* u+v has to be a non-negative intvec. 82 82 " 83 83 { … … 88 88 { 89 89 ERROR("weight vectors have wrong dimension"); 90 } 90 } 91 91 intvec uv,gr; 92 92 uv = u+v; … … 97 97 if (uv[i]==0) 98 98 { 99 99 gr[i] = 0; 100 100 } 101 101 else 102 102 { 103 103 gr[i] = 1; 104 104 } 105 105 } … … 114 114 for (i=1; i<=n; i++) 115 115 { 116 if (gr[i] == 1) 116 if (gr[i] == 1) 117 117 { 118 118 l2[n+i] = "xi("+string(i)+")"; … … 231 231 RETURN: ideal/list, linear reductum (over field) of f by elements from I 232 232 PURPOSE: reduce a poly only by linear reductions (no monomial multiplications) 233 NOTE: If s<>0, a list consisting of the reduced ideal and the coefficient 233 NOTE: If s<>0, a list consisting of the reduced ideal and the coefficient 234 234 @* vectors of the used reductions given as module is returned. 235 235 @* Otherwise (and by default), only the reduced ideal is returned. … … 255 255 if (typeof(#[2])=="int" || typeof(#[2])=="number") 256 256 { 257 257 redtail = #[2]; 258 258 } 259 259 } … … 273 273 for (i=1; i<=sI; i++) 274 274 { 275 276 277 278 279 280 281 282 283 284 285 275 if (I[i] == 0) 276 { 277 j++; 278 J[j] = 0; 279 ordJ[j] = -1; 280 M[j] = gen(i); 281 } 282 else 283 { 284 M[i+sZeros-j] = gen(lJ[2][i-j]+j); 285 } 286 286 } 287 287 } … … 290 290 for (i=1; i<=sZeros; i++) 291 291 { 292 293 292 J[i] = 0; 293 ordJ[i] = -1; 294 294 } 295 295 } … … 327 327 for (j=sZeros+1; j<i; j++) 328 328 { 329 330 331 332 { 333 334 335 336 337 338 339 340 341 342 343 344 345 346 329 if (lm == 0) { break; } 330 if (ordlm > maxordJ) { break; } 331 if (ordlm == ordJ[j]) 332 { 333 if (lm > maxlmJ) { break; } 334 if (lm == lmJ[j]) 335 { 336 dbprint(ppl,"reducing " + string(redpoly)); 337 dbprint(ppl," with " + string(J[j])); 338 c = leadcoef(redpoly)/leadcoef(J[j]); 339 redpoly = redpoly - c*J[j]; 340 dbprint(ppl," to " + string(redpoly)); 341 lm = leadmonom(redpoly); 342 ordlm = ord(lm); 343 if (remembercoeffs <> 0) { M[i] = M[i] - c * M[j]; } 344 reduction = 1; 345 } 346 } 347 347 } 348 348 } … … 354 354 lmJ = insertGenerator(lmJ,lm,j); 355 355 ordJ = insertGenerator(ordJ,poly(ordlm),j); 356 if (remembercoeffs <> 0) 356 if (remembercoeffs <> 0) 357 357 { 358 358 v = M[i]; … … 373 373 for (j=i+1; j<=sI; j++) 374 374 { 375 376 377 378 { 379 380 381 382 383 384 385 386 387 388 389 375 for (k=2; k<=size(J[j]); k++) // run over all terms in J[j] 376 { 377 if (ordJ[i] == ord(J[j][k])) 378 { 379 if (lm == normalize(J[j][k])) 380 { 381 c = leadcoef(J[j][k])/leadcoef(J[i]); 382 dbprint(ppl,"reducing " + string(J[j])); 383 dbprint(ppl," with " + string(J[i])); 384 J[j] = J[j] - c*J[i]; 385 dbprint(ppl," to " + string(J[j])); 386 if (remembercoeffs <> 0) { M[j] = M[j] - c * M[i]; } 387 } 388 } 389 } 390 390 } 391 391 } … … 410 410 RETURN: poly/list, linear reductum (over field) of f by elements from I 411 411 PURPOSE: reduce a poly only by linear reductions (no monomial multiplications) 412 NOTE: If s<>0, a list consisting of the reduced poly and the coefficient 412 NOTE: If s<>0, a list consisting of the reduced poly and the coefficient 413 413 @* vector of the used reductions is returned, otherwise (and by default) 414 414 @* only reduced poly is returned. … … 433 433 if (typeof(#[2])=="int" || typeof(#[2])=="number") 434 434 { 435 435 redtail = #[2]; 436 436 } 437 437 if (size(#)>2) 438 438 { 439 439 if (typeof(#[3])=="int" || typeof(#[3])=="number") 440 440 { 441 442 441 prepareideal = #[3]; 442 } 443 443 } 444 444 } … … 469 469 for (i=1; i<=sI; i++) 470 470 { 471 471 M[i] = gen(i); 472 472 } 473 473 } … … 495 495 if (ordf == ordI[i]) 496 496 { 497 498 499 500 501 502 503 504 505 506 507 497 if (lm == lmI[i]) 498 { 499 c = leadcoef(f)/lcI[i]; 500 f = f - c*I[i]; 501 lm = leadmonom(f); 502 ordf = ord(lm); 503 if (remembercoeffs <> 0) 504 { 505 v = v - c * M[i]; 506 } 507 } 508 508 } 509 509 } … … 518 518 for (j=1; j<=size(f); j++) 519 519 { 520 521 522 523 524 525 526 527 528 529 530 531 532 520 if (ord(f[j]) == ordI[i]) 521 { 522 if (normalize(f[j]) == lmI[i]) 523 { 524 c = leadcoef(f[j])/lcI[i]; 525 f = f - c*I[i]; 526 dbprint(ppl,"reducing poly to ",f); 527 if (remembercoeffs <> 0) 528 { 529 v = v - c * M[i]; 530 } 531 } 532 } 533 533 } 534 534 } … … 556 556 f = x3 + y2 + x2 + y + x; 557 557 I = x3 - y3, y3 - x2, x3 - y2, x2 - y, y2-x; 558 list l = linReduce(f, I, 1); 558 list l = linReduce(f, I, 1); 559 559 l; 560 560 module M = I; … … 601 601 if (p <> 0) 602 602 { 603 603 whichengine = 1; 604 604 } 605 605 } … … 668 668 proc pIntersect (poly s, ideal I) 669 669 "USAGE: pIntersect(f, I); f a poly, I an ideal 670 RETURN: vector, coefficient vector of the monic polynomial 670 RETURN: vector, coefficient vector of the monic polynomial 671 671 PURPOSE: compute the intersection of ideal I with the subalgebra K[f] 672 672 ASSUME: I is given as Groebner basis. … … 712 712 if (degs[j] == 0) 713 713 { 714 715 716 717 714 if (degI[i][j] <> 0) 715 { 716 break; 717 } 718 718 } 719 719 if (j == n) 720 720 { 721 722 721 k++; 722 possdegbounds[k] = Max(degI[i]); 723 723 } 724 724 } … … 749 749 if (tobracket==0) // todo bug in bracket? 750 750 { 751 751 toNF = 0; 752 752 } 753 753 else 754 754 { 755 755 toNF = bracket(tobracket,secNF); 756 756 } 757 757 newNF = NF(toNF+oldNF*secNF,I); // = NF(s^i,I) … … 802 802 v = v + m[j,1]*gen(j); 803 803 } 804 setring save; 804 setring save; 805 805 v = imap(@R,v); 806 806 kill @R; … … 864 864 if (size(#)>2) 865 865 { 866 867 868 869 866 if (typeof(#[3])=="int" || typeof(#[3])=="number") 867 { 868 modengine = int(#[3]); 869 } 870 870 } 871 871 } … … 909 909 if (tobracket!=0) 910 910 { 911 911 toNF = bracket(tobracket,NI[2]) + NI[i]*NI[2]; 912 912 } 913 913 else 914 914 { 915 915 toNF = NI[i]*NI[2]; 916 916 } 917 917 newNF = NF(toNF,I); … … 927 927 if (v!=0) // there is a modular solution 928 928 { 929 930 931 932 933 934 935 929 dbprint(ppl,"got solution in char ",solveincharp," of degree " ,i); 930 setring save; 931 v = linSyzSolve(NI,whichengine); 932 if (v==0) 933 { 934 break; 935 } 936 936 } 937 937 else // no modular solution 938 938 { 939 940 939 setring save; 940 v = 0; 941 941 } 942 942 } … … 965 965 { 966 966 dbprint(ppl,"linSyzSolve: got solution!"); 967 967 // "got solution!"; 968 968 break; 969 969 } … … 1015 1015 if (typeof(#[2])=="int" || typeof(#[2])=="number") 1016 1016 { 1017 1017 ringvar = int(#[2]); 1018 1018 } 1019 1019 } … … 1121 1121 while (b == 0) 1122 1122 { 1123 1124 1125 1123 dbprint(ppl,"number of run in the loop: "+string(i)); 1124 int q = prime(random(lb,ub)); 1125 if (findFirst(usedprimes,q)==0) // if q was not already used 1126 1126 { 1127 1128 1129 1130 1131 1132 } 1133 } 1134 else // pIntersectSyz::non-modular 1127 usedprimes = usedprimes,q; 1128 dbprint(ppl,"used prime is: "+string(q)); 1129 b = pIntersectSyz(s,J,q,whichengine,modengine); 1130 } 1131 i++; 1132 } 1133 } 1134 else // pIntersectSyz::non-modular 1135 1135 { 1136 1136 b = pIntersectSyz(s,J,0,whichengine); … … 1158 1158 RETURN: list of ideal and intvec 1159 1159 PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s) 1160 @* for the hypersurface defined by f. 1160 @* for the hypersurface defined by f. 1161 1161 ASSUME: The basering is a commutative polynomial ring in char 0. 1162 BACKGROUND: In this proc, the initial Malgrange ideal is computed according to the algorithm 1162 BACKGROUND: In this proc, the initial Malgrange ideal is computed according to the algorithm 1163 1163 @* by Masayuki Noro and then a system of linear equations is solved by linear reductions. 1164 NOTE: In the output list, the ideal contains all the roots 1164 NOTE: In the output list, the ideal contains all the roots 1165 1165 @* and the intvec their multiplicities. 1166 1166 @* If s<>0, @code{std} is used for GB computations, 1167 @* otherwise, and by default, @code{slimgb} is used. 1167 @* otherwise, and by default, @code{slimgb} is used. 1168 1168 @* If t<>0, a matrix ordering is used for Groebner basis computations, 1169 1169 @* otherwise, and by default, a block ordering is used. 1170 @* If v is a positive weight vector, v is used for homogenization computations, 1170 @* If v is a positive weight vector, v is used for homogenization computations, 1171 1171 @* otherwise and by default, no weights are used. 1172 1172 DISPLAY: If printlevel=1, progress debug messages will be printed, … … 1199 1199 if (size(#)>2) 1200 1200 { 1201 1201 if (typeof(#[3])=="intvec" && size(#[3])==n && allPositive(#[3])==1) 1202 1202 { 1203 1204 1203 u0 = #[3]; 1204 } 1205 1205 } 1206 1206 } … … 1222 1222 "USAGE: bfctSyz(f [,r,s,t,u,v]); f a poly, r,s,t,u optional ints, v an optional intvec 1223 1223 RETURN: list of ideal and intvec 1224 PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s) 1224 PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s) 1225 1225 @* for the hypersurface defined by f 1226 1226 ASSUME: The basering is a commutative polynomial ring in char 0. 1227 BACKGROUND: In this proc, the initial Malgrange ideal is computed according to the algorithm 1227 BACKGROUND: In this proc, the initial Malgrange ideal is computed according to the algorithm 1228 1228 @* by Masayuki Noro and then a system of linear equations is solved by computing syzygies. 1229 NOTE: In the output list, the ideal contains all the roots 1229 NOTE: In the output list, the ideal contains all the roots 1230 1230 @* and the intvec their multiplicities. 1231 @* If r<>0, @code{std} is used for GB computations in characteristic 0, 1232 @* otherwise, and by default, @code{slimgb} is used. 1233 @* If s<>0, a matrix ordering is used for GB computations, otherwise, 1231 @* If r<>0, @code{std} is used for GB computations in characteristic 0, 1232 @* otherwise, and by default, @code{slimgb} is used. 1233 @* If s<>0, a matrix ordering is used for GB computations, otherwise, 1234 1234 @* and by default, a block ordering is used. 1235 @* If t<>0, the computation of the intersection is solely performed over 1235 @* If t<>0, the computation of the intersection is solely performed over 1236 1236 @* charasteristic 0, otherwise and by default, a modular method is used. 1237 @* If u<>0 and by default, @code{std} is used for GB computations in 1238 @* characteristic >0, otherwise, @code{slimgb} is used. 1239 @* If v is a positive weight vector, v is used for homogenization 1237 @* If u<>0 and by default, @code{std} is used for GB computations in 1238 @* characteristic >0, otherwise, @code{slimgb} is used. 1239 @* If v is a positive weight vector, v is used for homogenization 1240 1240 @* computations, otherwise and by default, no weights are used. 1241 1241 DISPLAY: If printlevel=1, progress debug messages will be printed, … … 1275 1275 if (typeof(#[3])=="int" || typeof(#[3])=="number") 1276 1276 { 1277 1278 1279 1277 pIntersectchar = int(#[3]); 1278 } 1279 if (size(#)>3) 1280 1280 { 1281 1281 if (typeof(#[4])=="int" || typeof(#[4])=="number") 1282 1282 { 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1283 modengine = int(#[4]); 1284 } 1285 if (size(#)>4) 1286 { 1287 if (typeof(#[5])=="intvec" && size(#[5])==n && allPositive(#[5])==1) 1288 { 1289 u0 = #[5]; 1290 } 1291 } 1292 } 1293 1293 } 1294 1294 } … … 1315 1315 BACKGROUND: In this proc, the initial ideal of I is computed according to the algorithm by 1316 1316 @* Masayuki Noro and then a system of linear equations is solved by linear reductions. 1317 NOTE: In the output list, the ideal contains all the roots 1317 NOTE: In the output list, the ideal contains all the roots 1318 1318 @* and the intvec their multiplicities. 1319 1319 @* If s<>0, @code{std} is used for GB computations in characteristic 0, 1320 @* otherwise, and by default, @code{slimgb} is used. 1320 @* otherwise, and by default, @code{slimgb} is used. 1321 1321 @* If t<>0, a matrix ordering is used for GB computations, otherwise, 1322 1322 @* and by default, a block ordering is used. … … 1374 1374 "USAGE: bfctOneGB(f [,s,t]); f a poly, s,t optional ints 1375 1375 RETURN: list of ideal and intvec 1376 PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s) for the 1376 PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s) for the 1377 1377 @* hypersurface defined by f, using only one GB computation 1378 1378 ASSUME: The basering is a commutative polynomial ring in char 0. 1379 BACKGROUND: In this proc, the initial Malgrange ideal is computed based on the 1379 BACKGROUND: In this proc, the initial Malgrange ideal is computed based on the 1380 1380 @* algorithm by Masayuki Noro and combined with an elimination ordering. 1381 NOTE: In the output list, the ideal contains all the roots 1381 NOTE: In the output list, the ideal contains all the roots 1382 1382 @* and the intvec their multiplicities. 1383 1383 @* If s<>0, @code{std} is used for the GB computation, otherwise, 1384 @* and by default, @code{slimgb} is used. 1384 @* and by default, @code{slimgb} is used. 1385 1385 @* If t<>0, a matrix ordering is used for GB computations, 1386 1386 @* otherwise, and by default, a block ordering is used. … … 1492 1492 "USAGE: bfctAnn(f [,r]); f a poly, r an optional int 1493 1493 RETURN: list of ideal and intvec 1494 PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s) 1494 PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s) 1495 1495 @* for the hypersurface defined by f 1496 1496 ASSUME: The basering is a commutative polynomial ring in char 0. 1497 1497 BACKGROUND: In this proc, ann(f^s) is computed and then a system of linear 1498 1498 @* equations is solved by linear reductions. 1499 NOTE: In the output list, the ideal contains all the roots 1499 NOTE: In the output list, the ideal contains all the roots 1500 1500 @* and the intvec their multiplicities. 1501 1501 @* If r<>0, @code{std} is used for GB computations, 1502 @* otherwise, and by default, @code{slimgb} is used. 1502 @* otherwise, and by default, @code{slimgb} is used. 1503 1503 DISPLAY: If printlevel=1, progress debug messages will be printed, 1504 1504 @* if printlevel>=2, all the debug messages will be printed. -
Singular/LIB/classify.lib
r95edd5 r7f3ad4 1 1 // KK,GMG last modified: 17.12.00 2 2 /////////////////////////////////////////////////////////////////////////////// 3 version = "$Id: classify.lib,v 1.5 4 2008-12-08 14:24:41 dreyer Exp $";3 version = "$Id: classify.lib,v 1.55 2009-01-14 16:07:03 Singular Exp $"; 4 4 category="Singularities"; 5 5 info=" … … 1474 1474 1475 1475 s = s +" has 4-jet equal to zero. (F47), mu="+string(Mu); 1476 1476 1477 1477 s; // +" ("+SG_Typ+")"; 1478 1478 s = "No further classification available."; … … 2222 2222 list v; 2223 2223 2224 if(sg[1]==1 && sg[2]==0 && sg[3]==1) { 2225 v=HKclass7_teil_1(sg, SG_Typ, cnt); 2224 if(sg[1]==1 && sg[2]==0 && sg[3]==1) { 2225 v=HKclass7_teil_1(sg, SG_Typ, cnt); 2226 2226 } 2227 2227 else { -
Singular/LIB/compregb.lib
r95edd5 r7f3ad4 1 1 /////////////////////////////////////////////////////////////////////////////// 2 version="$Id: compregb.lib,v 1. 2 2007-06-20 15:39:44Singular Exp $";2 version="$Id: compregb.lib,v 1.3 2009-01-14 16:07:03 Singular Exp $"; 3 3 category="General purpose"; 4 4 info=" … … 79 79 for (j = 1; j <= size(CoefLsub); j ++) 80 80 { 81 81 if (CoefLsub[j] > 1) 82 82 { 83 84 83 CoefL = insert(CoefL, CoefLsub[j]); 84 } 85 85 } 86 86 } … … 94 94 if (Coef == CoefL[j]) 95 95 { 96 97 96 CoefL = delete(CoefL, j); 97 j --; 98 98 } 99 99 } -
Singular/LIB/decodegb.lib
r95edd5 r7f3ad4 1 1 /////////////////////////////////////////////////////////////////////////////// 2 version="$Id: decodegb.lib,v 1. 8 2008-10-22 13:31:48 bulyginExp $";2 version="$Id: decodegb.lib,v 1.9 2009-01-14 16:07:03 Singular Exp $"; 3 3 category="Coding theory"; 4 4 info=" 5 5 LIBRARY: decodegb.lib Decoding and min distance of linear codes with GB 6 AUTHOR: Stanislav Bulygin, bulygin@mathematik.uni-kl.de 6 AUTHOR: Stanislav Bulygin, bulygin@mathematik.uni-kl.de 7 7 8 8 OVERVIEW: 9 9 In this library we generate several systems used for decoding cyclic codes and 10 finding their minimum distance. Namely, we work with the Cooper's philosophy 11 and generalized Newton identities. The original method of quadratic equations 12 is worked out here as well. We also (for comparison) enable to work with the 13 system of Fitzgerald-Lax. We provide some auxiliary functions for further 14 manipulations and decoding. For an overview of the methods mentioned above @ref{Decoding codes with GB} 15 For the vanishing ideal computation the algorithm of Farr and Gao is 10 finding their minimum distance. Namely, we work with the Cooper's philosophy 11 and generalized Newton identities. The original method of quadratic equations 12 is worked out here as well. We also (for comparison) enable to work with the 13 system of Fitzgerald-Lax. We provide some auxiliary functions for further 14 manipulations and decoding. For an overview of the methods mentioned above @ref{Decoding codes with GB} 15 For the vanishing ideal computation the algorithm of Farr and Gao is 16 16 implemented. 17 17 18 MAIN PROCEDURES: 18 MAIN PROCEDURES: 19 19 sysCRHT(..); generates the CRHT-ideal as in Cooper's philosophy 20 20 sysCRHTMindist(..); CRHT-ideal to find the minimum distance in the binary case … … 29 29 genMDSMat(n,a); generates an MDS (actually an RS) matrix 30 30 mindist(check); computes the minimum distance of a code 31 decode(rec); decoding of a word using the system of quadratic equations 31 decode(rec); decoding of a word using the system of quadratic equations 32 32 decodeRandom(..); a procedure for manipulation with random codes 33 33 decodeCode(..); a procedure for manipulation with the given code … … 35 35 sysFL(..); generates the Fitzgerald-Lax system 36 36 decodeRandomFL(..); manipulation with random codes via Fitzgerald-Lax 37 38 39 KEYWORDS: Cyclic code; Linear code; Decoding; 37 38 39 KEYWORDS: Cyclic code; Linear code; Decoding; 40 40 Minimum distance; Groebner bases 41 41 "; … … 76 76 77 77 /////////////////////////////////////////////////////////////////////////////// 78 // the polynomial for Sala's restrictions 78 // the polynomial for Sala's restrictions 79 79 static proc p_poly(int n, int a, int b) 80 80 { … … 92 92 "USAGE: sysCRHT(n,defset,e,q,m,[k]); n,e,q,m,k int, defset list of int's 93 93 @format 94 - n length of the cyclic code, 94 - n length of the cyclic code, 95 95 - defset is a list representing the defining set, 96 - e the error-correcting capacity, 96 - e the error-correcting capacity, 97 97 - q field size 98 - m degree extension of the splitting field, 99 - if k>0 additional equations representing the fact that every two 98 - m degree extension of the splitting field, 99 - if k>0 additional equations representing the fact that every two 100 100 error positions are either different or at least one of them is zero 101 101 @end format 102 RETURN: the ring to work with the CRHT-ideal (with Sala's additions), 102 RETURN: the ring to work with the CRHT-ideal (with Sala's additions), 103 103 containig an ideal with name 'crht' 104 THEORY: Based on 'defset' of the given cyclic code, the procedure constructs 105 the corresponding Cooper-Reed-Heleseth-Truong ideal 'crht'. With its 104 THEORY: Based on 'defset' of the given cyclic code, the procedure constructs 105 the corresponding Cooper-Reed-Heleseth-Truong ideal 'crht'. With its 106 106 help one can solve the decoding problem. For basics of the method @ref{Cooper philosophy}. 107 107 SEE ALSO: sysNewton, sysBin … … 109 109 " 110 110 { 111 int r=size(defset); 111 int r=size(defset); 112 112 ring @crht=(q,a),(Y(e..1),Z(1..e),X(r..1)),lp; 113 113 ideal crht; … … 115 115 poly sum; 116 116 int k; 117 if ( size(#) > 0) 118 { 119 k = #[1]; 120 } 121 117 if ( size(#) > 0) 118 { 119 k = #[1]; 120 } 121 122 122 //---------------------- add check equations -------------------------- 123 123 for (i=1; i<=r; i++) … … 130 130 crht[i]=sum-X(i); 131 131 } 132 132 133 133 //--------------------- field equations on syndromes ------------------ 134 134 for (i=1; i<=r; i++) … … 136 136 crht=crht,X(i)^(q^m)-X(i); 137 137 } 138 138 139 139 //------ restrictions on error-locations: n-th roots of unity ---------- 140 140 for (i=1; i<=e; i++) … … 142 142 crht=crht,Z(i)^(n+1)-Z(i); 143 143 } 144 144 145 145 for (i=1; i<=e; i++) 146 146 { 147 147 crht=crht,Y(i)^(q-1)-1; 148 } 149 148 } 149 150 150 //--------- add Sala's additional conditions if necessary -------------- 151 151 if ( k > 0 ) 152 152 153 153 { 154 154 for (i=1; i<=e; i++) … … 159 159 } 160 160 } 161 } 162 export crht; 163 return(@crht); 164 } 161 } 162 export crht; 163 return(@crht); 164 } 165 165 example 166 166 { "EXAMPLE:"; echo=2; … … 168 168 intvec v = option(get); 169 169 170 list defset=1,3; // defining set 170 list defset=1,3; // defining set 171 171 int n=15; // length 172 172 int e=2; // error-correcting capacity … … 174 174 int m=4; // degree extension of the splitting field 175 175 int sala=1; // indicator to add additional equations 176 177 def A=sysCRHT(n,defset,e,q,m); 176 177 def A=sysCRHT(n,defset,e,q,m); 178 178 setring A; 179 179 A; // shows the ring we are working in 180 print(crht); // the CRHT-ideal 180 print(crht); // the CRHT-ideal 181 181 option(redSB); 182 182 ideal red_crht=std(crht); // reduced Groebner basis 183 183 print(red_crht); 184 184 185 185 //============================ 186 A=sysCRHT(n,defset,e,q,m,sala); 187 setring A; 186 A=sysCRHT(n,defset,e,q,m,sala); 187 setring A; 188 188 print(crht); // CRHT-ideal with additional equations from Sala 189 189 option(redSB); 190 190 ideal red_crht=std(crht); // reduced Groebner basis 191 print(red_crht); 191 print(red_crht); 192 192 red_crht[5]; // general error-locator polynomial for this code 193 193 option(set,v); … … 198 198 199 199 proc sysCRHTMindist (int n, list defset, int w) 200 "USAGE: sysCRHTMindist(n,defset,w); n,w are int, defset is list of int's 200 "USAGE: sysCRHTMindist(n,defset,w); n,w are int, defset is list of int's 201 201 @format 202 - n length of the cyclic code, 202 - n length of the cyclic code, 203 203 - defset is a list representing the defining set, 204 204 - w is a candidate for the minimum distance 205 205 @end format 206 RETURN: the ring to work with the Sala's ideal for the minimum distance 206 RETURN: the ring to work with the Sala's ideal for the minimum distance 207 207 containing the ideal with name 'crht_md' 208 THEORY: Based on 'defset' of the given cyclic code, the procedure constructs 209 the corresponding Cooper-Reed-Heleseth-Truong ideal 'crht_md'. With 210 its help one can find minimum distance of the code in the binary 208 THEORY: Based on 'defset' of the given cyclic code, the procedure constructs 209 the corresponding Cooper-Reed-Heleseth-Truong ideal 'crht_md'. With 210 its help one can find minimum distance of the code in the binary 211 211 case. For basics of the method @ref{Cooper philosophy}. 212 212 EXAMPLE: example sysCRHTMindist; shows an example 213 213 " 214 214 { 215 int r=size(defset); 215 int r=size(defset); 216 216 ring @crht_md=2,Z(1..w),lp; 217 217 ideal crht_md; 218 218 int i,j; 219 219 poly sum; 220 220 221 221 //------------ add check equations -------------- 222 222 for (i=1; i<=r; i++) … … 228 228 } 229 229 crht_md[i]=sum; 230 } 231 232 230 } 231 232 233 233 //----------- locations are n-th roots of unity ------------ 234 234 for (i=1; i<=w; i++) 235 235 { 236 236 crht_md=crht_md,Z(i)^n-1; 237 } 238 237 } 238 239 239 //------------ adding conditions on locations being different ------------ 240 240 for (i=1; i<=w; i++) … … 245 245 } 246 246 } 247 248 export crht_md; 249 return(@crht_md); 250 } 247 248 export crht_md; 249 return(@crht_md); 250 } 251 251 example 252 252 { … … 254 254 intvec v = option(get); 255 255 // binary cyclic [15,7,5] code with defining set (1,3) 256 257 list defset=1,3; // defining set 258 int n=15; // length 259 int d=5; // candidate for the minimum distance 260 261 def A=sysCRHTMindist(n,defset,d); 256 257 list defset=1,3; // defining set 258 int n=15; // length 259 int d=5; // candidate for the minimum distance 260 261 def A=sysCRHTMindist(n,defset,d); 262 262 setring A; 263 263 A; // shows the ring we are working in 264 264 print(crht_md); // the Sala's ideal for mindist 265 265 option(redSB); 266 ideal red_crht_md=std(crht_md); 266 ideal red_crht_md=std(crht_md); 267 267 print(red_crht_md); // reduced Groebner basis 268 268 269 269 option(set,v); 270 270 } … … 281 281 282 282 proc sysNewton (int n, list defset, int t, int q, int m, list #) 283 "USAGE: sysNewton (n,defset,t,q,m,[tr]); n,t,q,m,tr int, defset list int's 283 "USAGE: sysNewton (n,defset,t,q,m,[tr]); n,t,q,m,tr int, defset list int's 284 284 @format 285 - n is length, 285 - n is length, 286 286 - defset is the defining set, 287 - t is the number of errors, 288 - q is basefield size, 287 - t is the number of errors, 288 - q is basefield size, 289 289 - m is degree extension of the splitting field, 290 - if tr>0 it indicates that Newton identities in triangular 290 - if tr>0 it indicates that Newton identities in triangular 291 291 form should be constructed 292 292 @end format 293 RETURN: the ring to work with the generalized Newton identities (in 293 RETURN: the ring to work with the generalized Newton identities (in 294 294 triangular form if applicable) containing the ideal with name 'newton' 295 THEORY: Based on 'defset' of the given cyclic code, the procedure constructs 296 the corresponding ideal 'newton' with the generalized Newton 297 identities. With its help one can solve the decoding problem. For 295 THEORY: Based on 'defset' of the given cyclic code, the procedure constructs 296 the corresponding ideal 'newton' with the generalized Newton 297 identities. With its help one can solve the decoding problem. For 298 298 basics of the method @ref{Cooper philosophy}. 299 299 SEE ALSO: sysCRHT, sysBin 300 300 EXAMPLE: example sysNewton; shows an example 301 301 " 302 { 302 { 303 303 string s="ring @newton=("+string(q)+",a),("; 304 304 int i,j; 305 305 int flag; 306 306 int tr; 307 307 308 308 if (size(#)>0) 309 309 { 310 310 tr=#[1]; 311 311 } 312 312 313 313 for (i=n; i>=1; i--) 314 314 { … … 319 319 { 320 320 flag=0; 321 break; 321 break; 322 322 } 323 323 } … … 332 332 s=s+"S("+string(defset[i])+"),"; 333 333 } 334 s=s+"S("+string(defset[1])+")),lp;"; 335 334 s=s+"S("+string(defset[1])+")),lp;"; 335 336 336 execute(s); 337 338 ideal newton; 337 338 ideal newton; 339 339 poly sum; 340 341 340 341 342 342 //------------ generate generalized Newton identities ---------- 343 343 if (tr) … … 353 353 } 354 354 } else 355 { 355 { 356 356 for (i=1; i<=t; i++) 357 357 { … … 372 372 } 373 373 newton=newton,S(t+i)+sum; 374 } 375 374 } 375 376 376 //----------- add field equations on sigma's -------------- 377 377 for (i=1; i<=t; i++) … … 379 379 newton=newton,sigma(i)^(q^m)-sigma(i); 380 380 } 381 381 382 382 //----------- add conjugacy relations ------------------ 383 383 for (i=1; i<=n; i++) … … 387 387 newton=simplify(newton,2); 388 388 export newton; 389 return(@newton); 390 } 391 example 389 return(@newton); 390 } 391 example 392 392 { 393 393 "EXAMPLE:"; echo = 2; 394 // Newton identities for a binary 3-error-correcting cyclic code of 394 // Newton identities for a binary 3-error-correcting cyclic code of 395 395 //length 31 with defining set (1,5,7) 396 396 397 397 int n=31; // length 398 398 list defset=1,5,7; //defining set … … 401 401 int m=5; // degree extension of the splitting field 402 402 int tr=1; // indicator of triangular form of Newton identities 403 404 403 404 405 405 def A=sysNewton(n,defset,t,q,m); 406 406 setring A; 407 407 A; // shows the ring we are working in 408 408 print(newton); // generalized Newton identities 409 409 410 410 //=============================== 411 411 A=sysNewton(n,defset,t,q,m,tr); 412 setring A; 412 setring A; 413 413 print(newton); // generalized Newton identities in triangular form 414 414 } 415 415 416 416 /////////////////////////////////////////////////////////////////////////////// 417 // forms a list of special combinations needed for computation of Waring's 417 // forms a list of special combinations needed for computation of Waring's 418 418 //function 419 419 static proc combinations_sum (int m, int n) … … 438 438 count++; 439 439 } 440 if (flag) 440 if (flag) 441 441 { 442 442 for (j=2; j<=m; j++) … … 444 444 interm[i][j]=interm[i][j] div j; 445 445 } 446 result[size(result)+1]=interm[i]; 446 result[size(result)+1]=interm[i]; 447 447 } 448 448 } … … 470 470 "USAGE: sysBin (v,Q,n,[odd]); v,n,odd are int, Q is list of int's 471 471 @format 472 - v a number if errors, 473 - Q is a generating set of the code, 474 - n the length, 475 - odd is an additional parameter: if 476 set to 1, then the generating set is enlarged by odd elements, 472 - v a number if errors, 473 - Q is a generating set of the code, 474 - n the length, 475 - odd is an additional parameter: if 476 set to 1, then the generating set is enlarged by odd elements, 477 477 which are 2^(some power)*(some elment in the gen.set) mod n 478 478 @end format 479 479 RETURN: the ring with the resulting system called 'bin' 480 THEORY: Based on Q of the given cyclic code, the procedure constructs 481 the corresponding ideal 'bin' with the use of Waring function. 482 With its help one can solve the decoding problem. 480 THEORY: Based on Q of the given cyclic code, the procedure constructs 481 the corresponding ideal 'bin' with the use of Waring function. 482 With its help one can solve the decoding problem. 483 483 For basics of the method @ref{Generalized Newton identities}. 484 484 SEE ALSO: sysNewton, sysCRHT … … 527 527 Q_update=Q; 528 528 } 529 530 //---- form polynomials for the Bin system via Waring's function --------- 529 530 //---- form polynomials for the Bin system via Waring's function --------- 531 531 for (i=1; i<=size(Q_update); i++) 532 532 { … … 541 541 } 542 542 count1=0; 543 for (j=2; j<=upper-1; j++) 543 for (j=2; j<=upper-1; j++) 544 544 { 545 545 count1=count1+exp_count(j,2); … … 564 564 sum_=sum_+coef_*mon; 565 565 } 566 result=result,S(Q_update[i])-sum_; 566 result=result,S(Q_update[i])-sum_; 567 567 } 568 568 ideal bin=simplify(result,2); 569 569 export bin; 570 570 return(r); 571 } 572 example 571 } 572 example 573 573 { 574 574 "EXAMPLE:"; echo = 2; … … 592 592 if (ncols(x)!=nrows(g)) {print("ERRORencode2!");} 593 593 return(x*g); 594 } 595 example 594 } 595 example 596 596 { 597 597 "EXAMPLE:"; echo = 2; … … 603 603 0,0,0,1,1,1,0; 604 604 //encode x with the generator matrix g 605 print(encode(x,g)); 605 print(encode(x,g)); 606 606 } 607 607 … … 616 616 if (nrows(c)>1) {print("ERRORsyndrome1!");} 617 617 if (ncols(c)!=ncols(h)) {print("ERRORsyndrome2!");} 618 return(h*transpose(c)); 619 } 620 example 618 return(h*transpose(c)); 619 } 620 example 621 621 { 622 622 "EXAMPLE:"; echo = 2; … … 636 636 print(syndrome(check,c)); 637 637 c[1,3]=1; 638 //now c is a codeword 638 //now c is a codeword 639 639 print(syndrome(check,c)); 640 640 } … … 657 657 "USAGE: sysQE(check,y,t,[fieldeq,formal]);check,y matrix;t,fieldeq,formal int 658 658 @format 659 - check is the check matrix of the code 660 - y is a received word, 661 - t the number of errors to be corrected, 662 - if fieldeq=1, then field equations are added, 663 - if formal=0, field equations on (known) syndrome variables 664 are not added, in order to add them (note that the exponent should 659 - check is the check matrix of the code 660 - y is a received word, 661 - t the number of errors to be corrected, 662 - if fieldeq=1, then field equations are added, 663 - if formal=0, field equations on (known) syndrome variables 664 are not added, in order to add them (note that the exponent should 665 665 be as a number of elements in the INITIAL alphabet) one 666 666 needs to set formal>0 for the exponent 667 667 @end format 668 668 RETURN: the ring to work with together with the resulting system called 'qe' 669 THEORY: Based on 'check' of the given linear code, the procedure constructs 669 THEORY: Based on 'check' of the given linear code, the procedure constructs 670 670 the corresponding ideal that gives an opportunity to compute 671 671 unknown syndrome of the received word y. Further 672 one is able to solve the decoding problem. 672 one is able to solve the decoding problem. 673 673 For basics of the method @ref{Decoding method based on quadratic equations}. 674 674 SEE ALSO: sysFL … … 686 686 formal=#[2]; 687 687 } 688 689 def br=basering; 688 689 def br=basering; 690 690 list rl=ringlist(br); 691 691 692 692 int red=nrows(check); 693 693 int n=ncols(check); 694 694 int q=rl[1][1]; 695 695 696 696 if (formal==0) 697 { 697 { 698 698 ring work=(q,a),(V(1..t),U(1..n)),dp; 699 699 } else … … 701 701 ring work=(q,a),(V(1..t),U(1..n),s(1..red)),(dp(t),lp(n),dp(red)); 702 702 } 703 703 704 704 matrix check=imap(br,check); 705 705 matrix y=imap(br,y); 706 706 707 707 matrix h_full=genMDSMat(n,a); 708 708 matrix h=submat(h_full,1..red,1..n); 709 709 if (nrows(y)!=1) {print("ERROR1Pell");} 710 710 if (ncols(y)!=n) {print("ERROR2Pell");} 711 711 712 712 ideal result; 713 713 714 714 list c; 715 715 list a; … … 722 722 c[i]=tmp; 723 723 } 724 724 725 725 int tim=rtimer; 726 726 matrix transf=inverse(transpose(h_full)); 727 727 728 728 //------ expression matrix of check vectors w.r.t. the MDS basis ----------- 729 729 tim=rtimer; … … 733 733 a[i]=transf*a[i]; 734 734 } 735 735 736 736 //----------- compute the structure constants ------------------------ 737 737 tim=rtimer; 738 matrix te[n][1]; 738 matrix te[n][1]; 739 739 for (i=1; i<=n; i++) 740 740 { … … 742 742 { 743 743 if ((j<i)&&(i<=t+1)) {c[i][j]=c[j][i];} 744 else 744 else 745 745 { 746 if (i+j<=n+1) 746 if (i+j<=n+1) 747 747 { 748 748 c[i][j]=te; 749 c[i][j][i+j-1,1]=1; 749 c[i][j][i+j-1,1]=1; 750 750 } 751 751 else … … 753 753 c[i][j]=star(h_full,i,j); 754 754 c[i][j]=transf*c[i][j]; 755 } 755 } 756 756 } 757 757 } 758 758 } 759 760 761 tim=rtimer; 759 760 761 tim=rtimer; 762 762 if (formal==0) 763 763 { … … 798 798 result=result,V(j)^q-V(j); 799 799 } 800 } 801 800 } 801 802 802 //----- form the quadratic equations according to the theory ----------- 803 803 for (i=1; i<=n; i++) … … 819 819 } 820 820 result=result,sum1-sum3; 821 } 822 821 } 822 823 823 result=simplify(result,2); 824 824 825 825 ideal qe=result; 826 826 export qe; 827 return(work); 828 } 829 example 827 return(work); 828 } 829 example 830 830 { 831 831 "EXAMPLE:"; echo = 2; 832 832 intvec v = option(get); 833 833 834 834 //correct 2 errors in [7,3] 8-ary code RS code 835 835 int t=2; int q=8; int n=7; int redun=4; … … 840 840 matrix x[1][3]=0,0,1,0; 841 841 matrix y[1][7]=encode(x,g); 842 842 843 843 //disturb with 2 errors 844 matrix rec[1][7]=errorInsert(y,list(2,4),list(1,a)); 845 844 matrix rec[1][7]=errorInsert(y,list(2,4),list(1,a)); 845 846 846 //generate the system 847 847 def A=sysQE(h,rec,t); 848 848 setring A; 849 849 print(qe); 850 850 851 851 //let us decode 852 852 option(redSB); 853 853 ideal sys_qe=std(qe); 854 print(sys_qe); 855 854 print(sys_qe); 855 856 856 option(set,v); 857 857 } … … 862 862 "USAGE: errorInsert(y,pos,val); y is matrix, pos,val list of int's 863 863 @format 864 - y is a (code) word, 865 - pos = positions where errors occured, 864 - y is a (code) word, 865 - pos = positions where errors occured, 866 866 - val = their corresponding values 867 867 @end format … … 877 877 } 878 878 return(result); 879 } 880 example 879 } 880 example 881 881 { 882 882 "EXAMPLE:"; echo = 2; … … 890 890 matrix y[1][7]=encode(x,g); 891 891 print(y); 892 892 893 893 //disturb with 2 errors 894 894 matrix rec[1][7]=errorInsert(y,list(2,4),list(1,a)); … … 902 902 "USAGE: errorRand(y, num, e); y matrix, num,e int 903 903 @format 904 - y is a (code) word, 905 - num is the number of errors, 904 - y is a (code) word, 905 - num is the number of errors, 906 906 - e is an extension degree (if one wants values to be from GF(p^e)) 907 907 @end format … … 926 926 } 927 927 if (flag) {pos[i]=temp;break;} 928 } 929 } 930 928 } 929 } 930 931 931 for (i=1; i<=num; i++) 932 932 { 933 933 flag=1; 934 934 while(flag) 935 { 936 tempnum=randomvector(1,e); 937 if (tempnum!=0) {flag=0;} 938 } 939 val[i]=tempnum; 940 } 941 935 { 936 tempnum=randomvector(1,e); 937 if (tempnum!=0) {flag=0;} 938 } 939 val[i]=tempnum; 940 } 941 942 942 for (i=1; i<=size(pos); i++) 943 943 { … … 945 945 } 946 946 return(result); 947 } 948 example 947 } 948 example 949 949 { 950 950 "EXAMPLE:"; echo = 2; … … 957 957 matrix x[1][3]=0,0,1,0; 958 958 matrix y[1][7]=encode(x,g); 959 959 960 960 //disturb with 2 random errors 961 961 matrix rec[1][7]=errorRand(y,2,3); 962 962 print(rec); 963 print(rec-y); 963 print(rec-y); 964 964 } 965 965 … … 969 969 "USAGE: randomCheck(m, n, e); m,n,e are int 970 970 @format 971 - m x n are dimensions of the matrix, 971 - m x n are dimensions of the matrix, 972 972 - e is an extension degree (if one wants values to be from GF(p^e)) 973 973 @end format … … 986 986 { 987 987 rand[i,j]=temp[j,1]; 988 } 988 } 989 989 } 990 990 result=concat(rand,unitmat(m)); 991 991 return(result); 992 } 993 example 994 { 995 "EXAMPLE:"; echo = 2; 992 } 993 example 994 { 995 "EXAMPLE:"; echo = 2; 996 996 int redun=5; int n=15; 997 997 ring r=2,x,dp; 998 998 999 999 //generate random check matrix for a [15,5] binary code 1000 1000 matrix h=randomCheck(redun,n,1); 1001 1001 print(h); 1002 1002 1003 1003 //corresponding generator matrix 1004 1004 matrix g=dual_code(h); 1005 print(g); 1005 print(g); 1006 1006 } 1007 1007 … … 1011 1011 "USAGE: genMDSMat(n, a); n is int, a is number 1012 1012 @format 1013 - n x n are dimensions of the MDS matrix, 1013 - n x n are dimensions of the MDS matrix, 1014 1014 - a is a primitive element of the field. 1015 @end format 1016 NOTE: An MDS matrix is constructed in the following way. We take a to be a 1017 generator of the multiplicative group of the field. Then we construct 1015 @end format 1016 NOTE: An MDS matrix is constructed in the following way. We take a to be a 1017 generator of the multiplicative group of the field. Then we construct 1018 1018 the Vandermonde matrix with this a. 1019 ASSUME: extension field should already be defined 1019 ASSUME: extension field should already be defined 1020 1020 RETURN: a matrix with the MDS property 1021 EXAMPLE: example genMDSMat; shows an example 1021 EXAMPLE: example genMDSMat; shows an example 1022 1022 " 1023 1023 { … … 1029 1029 { 1030 1030 result[j+1,i+1]=(a^i)^j; 1031 } 1031 } 1032 1032 } 1033 1033 return(result); 1034 } 1035 example 1034 } 1035 example 1036 1036 { 1037 1037 "EXAMPLE:"; echo = 2; 1038 1038 int q=16; int n=15; 1039 1039 ring r=(q,a),x,dp; 1040 1040 1041 1041 //generate an MDS (Vandermonde) matrix 1042 1042 matrix h_full=genMDSMat(n,a); 1043 print(h_full); 1043 print(h_full); 1044 1044 } 1045 1045 … … 1050 1050 "USAGE: mindist (check, q); check matrix, q int 1051 1051 @format 1052 - check is a check matrix, 1052 - check is a check matrix, 1053 1053 - q is the field size 1054 1054 @end format 1055 RETURN: minimum distance of the code together with the time needed for its 1055 RETURN: minimum distance of the code together with the time needed for its 1056 1056 calculation 1057 EXAMPLE: example mindist; shows an example 1057 EXAMPLE: example mindist; shows an example 1058 1058 " 1059 1059 { … … 1061 1061 1062 1062 int n=ncols(check); int redun=nrows(check); int t=redun+1; 1063 1064 def br=basering; 1065 list rl=ringlist(br); 1063 1064 def br=basering; 1065 list rl=ringlist(br); 1066 1066 int q=rl[1][1]; 1067 1068 ring work=(q,a),(V(1..t),U(1..n)),dp; 1069 matrix check=imap(br,check); 1070 1067 1068 ring work=(q,a),(V(1..t),U(1..n)),dp; 1069 matrix check=imap(br,check); 1070 1071 1071 ideal temp; 1072 1072 int count=1; … … 1074 1074 int flag2; 1075 1075 int i, tim, timsolve; 1076 matrix z[1][n]; 1076 matrix z[1][n]; 1077 1077 option(redSB); 1078 1078 def A=sysQE(check,z,count); 1079 1079 1080 //proceed with solving the system w.r.t zero vector until some solutions 1080 //proceed with solving the system w.r.t zero vector until some solutions 1081 1081 //are found 1082 1082 while (flag) … … 1087 1087 tim=rtimer; 1088 1088 temp=std(temp); 1089 timsolve=timsolve+rtimer-tim; 1089 timsolve=timsolve+rtimer-tim; 1090 1090 flag2=1; 1091 1091 setring work; 1092 temp=imap(A,temp); 1092 temp=imap(A,temp); 1093 1093 for (i=1; i<=n; i++) 1094 1094 { 1095 if 1096 (temp[i]!=U(n-i+1)) 1095 if 1096 (temp[i]!=U(n-i+1)) 1097 1097 { 1098 1098 flag2=0; 1099 1099 } 1100 1100 } 1101 if (!flag2) 1101 if (!flag2) 1102 1102 { 1103 1103 flag=0; 1104 1104 } 1105 else 1105 else 1106 1106 { 1107 1107 count++; 1108 1108 } 1109 1109 } 1110 list result=list(count,timsolve); 1111 1110 list result=list(count,timsolve); 1111 1112 1112 option(set,vopt); 1113 return(result); 1114 } 1115 example 1113 return(result); 1114 } 1115 example 1116 1116 { 1117 1117 "EXAMPLE:"; echo = 2; 1118 //determine a minimum distance for a [7,3] binary code 1119 int q=8; int n=7; int redun=4; int t=redun+1; 1120 ring r=(q,a),x,dp; 1121 1118 //determine a minimum distance for a [7,3] binary code 1119 int q=8; int n=7; int redun=4; int t=redun+1; 1120 ring r=(q,a),x,dp; 1121 1122 1122 //generate random check matrix 1123 1123 matrix h=randomCheck(redun,n,1); 1124 1124 print(h); 1125 list l=mindist(h); 1126 print(l[1]); 1127 //time for the comutation in secs 1128 print(l[2]); 1125 list l=mindist(h); 1126 print(l[1]); 1127 //time for the comutation in secs 1128 print(l[2]); 1129 1129 } 1130 1130 … … 1135 1135 @format 1136 1136 - check is the check matrix of the code, 1137 - rec is a received word, 1137 - rec is a received word, 1138 1138 - t is an upper bound for the number of errors one wants to correct 1139 1139 @end format 1140 ASSUME: Errors in rec should be correctable, otherwise the output is 1140 ASSUME: Errors in rec should be correctable, otherwise the output is 1141 1141 unpredictable 1142 1142 RETURN: a codeword that is closest to rec 1143 EXAMPLE: example decode; shows an example 1143 EXAMPLE: example decode; shows an example 1144 1144 " 1145 1145 { 1146 intvec vopt = option(get); 1147 1146 intvec vopt = option(get); 1147 1148 1148 def br=basering; 1149 int n=ncols(check); 1150 1151 int count=1; 1149 int n=ncols(check); 1150 1151 int count=1; 1152 1152 def A=sysQE(check,rec,count); 1153 1153 while(1) 1154 1154 { 1155 1155 A=sysQE(check,rec,count); 1156 setring A; 1156 setring A; 1157 1157 matrix h_full=genMDSMat(n,a); 1158 1158 matrix rec=imap(br,rec); 1159 1159 option(redSB); 1160 ideal qe_red=std(qe); 1160 ideal qe_red=std(qe); 1161 1161 if (qe_red[1]!=1) 1162 1162 { 1163 1163 break; 1164 1164 } 1165 else 1165 else 1166 1166 { 1167 1167 count++; … … 1169 1169 setring br; 1170 1170 } 1171 1172 setring A; 1173 1171 1172 setring A; 1173 1174 1174 //obtain a codeword 1175 1175 //this works only if our code is indeed can correct these errors … … 1178 1178 { 1179 1179 syn[i,1]=-qe_red[n-i+1]+lead(qe_red[n-i+1]); 1180 } 1181 1182 matrix real_syn=inverse(h_full)*syn; 1180 } 1181 1182 matrix real_syn=inverse(h_full)*syn; 1183 1183 setring br; 1184 1184 matrix real_syn=imap(A,real_syn); 1185 1185 1186 1186 option(set,vopt); 1187 return(rec-transpose(real_syn)); 1188 } 1189 example 1190 { 1191 "EXAMPLE:"; echo = 2; 1192 //correct 1 error in [15,7] binary code 1187 return(rec-transpose(real_syn)); 1188 } 1189 example 1190 { 1191 "EXAMPLE:"; echo = 2; 1192 //correct 1 error in [15,7] binary code 1193 1193 int t=1; int q=16; int n=15; int redun=10; 1194 ring r=(q,a),x,dp; 1195 1194 ring r=(q,a),x,dp; 1195 1196 1196 //generate random check matrix 1197 matrix h=randomCheck(redun,n,1); 1197 matrix h=randomCheck(redun,n,1); 1198 1198 matrix g=dual_code(h); 1199 1199 matrix x[1][n-redun]=0,0,1,0,1,0,1; 1200 1200 matrix y[1][n]=encode(x,g); 1201 1201 print(y); 1202 1202 1203 1203 // find out the minimum distance of the code 1204 1204 list l=mindist(h); 1205 1205 1206 1206 //disturb with errors 1207 1207 "Correct ",(l[1]-1) div 2," errors"; 1208 1208 matrix rec[1][n]=errorRand(y,(l[1]-1) div 2,1); 1209 print(rec); 1210 1209 print(rec); 1210 1211 1211 //let us decode 1212 1212 matrix dec_word=decode(h,rec); 1213 print(dec_word); 1213 print(dec_word); 1214 1214 } 1215 1215 … … 1221 1221 @format 1222 1222 - redun is a redundabcy of a (random) code, 1223 - q is the field size, 1223 - q is the field size, 1224 1224 - ncodes is the number of random codes to be processed, 1225 1225 - ntrials is the number of received vectors per code to be corrected 1226 - If e is given it sets the correction capacity explicitly. It 1226 - If e is given it sets the correction capacity explicitly. It 1227 1227 should be used in case one expects some lower bound, 1228 otherwise the procedure tries to compute the real minimum distance 1228 otherwise the procedure tries to compute the real minimum distance 1229 1229 to find out the error-correction capacity 1230 1230 @end format 1231 RETURN: nothing; 1232 EXAMPLE: example decodeRandom; shows an example 1231 RETURN: nothing; 1232 EXAMPLE: example decodeRandom; shows an example 1233 1233 " 1234 1234 { … … 1248 1248 option(redSB); 1249 1249 def br=basering; 1250 matrix h_full=genMDSMat(n,a); 1250 matrix h_full=genMDSMat(n,a); 1251 1251 matrix z[1][ncols(h_full)]; 1252 1252 … … 1268 1268 dist=tmp[1]; 1269 1269 printf("d= %p",dist); 1270 t=(dist-1) div 2; 1271 } 1272 tim2=rtimer; 1270 t=(dist-1) div 2; 1271 } 1272 tim2=rtimer; 1273 1273 tim3=rtimer; 1274 1274 … … 1279 1279 ideal sys2,sys3; 1280 1280 matrix h=imap(br,h); 1281 matrix g=dual_code(h); 1281 matrix g=dual_code(h); 1282 1282 ideal sys=qe; 1283 1283 print("The system is generated"); 1284 timdec3=timdec3+rtimer-tim3; 1284 timdec3=timdec3+rtimer-tim3; 1285 1285 1286 1286 //------ modify the template according to every received word -------------- 1287 1287 for (j=1; j<=ntrials; j++) 1288 1288 { 1289 word=randomvector(n-redun,1); 1289 word=randomvector(n-redun,1); 1290 1290 y=encode(transpose(word),g); 1291 rec=errorRand(y,t,1); 1292 sys2=add_synd(rec,h,redun,sys); 1293 1291 rec=errorRand(y,t,1); 1292 sys2=add_synd(rec,h,redun,sys); 1293 1294 1294 tim=rtimer; 1295 sys3=std(sys2); 1296 timdec=timdec+rtimer-tim; 1297 } 1295 sys3=std(sys2); 1296 timdec=timdec+rtimer-tim; 1297 } 1298 1298 timdec2=timdec2+rtimer-tim2; 1299 1299 kill A; 1300 1300 option(set,vopt); 1301 } 1301 } 1302 1302 printf("Time for mindist: %p", timdist); 1303 1303 printf("Time for GB in mindist: %p", timdist); 1304 1304 printf("Time for decoding: %p", timdec2); 1305 1305 printf("Time for GB in decoding: %p", timdec); 1306 printf("Time for sysQE in decoding: %p", timdec3); 1307 } 1308 example 1306 printf("Time for sysQE in decoding: %p", timdec3); 1307 } 1308 example 1309 1309 { 1310 1310 "EXAMPLE:"; echo = 2; 1311 1311 int q=32; int n=25; int redun=n-11; int t=redun+1; 1312 1312 ring r=(q,a),x,dp; 1313 1313 1314 1314 // correct 2 errors in 5 random binary codes, 50 trials each 1315 decodeRandom(n,redun,5,50,2); 1315 decodeRandom(n,redun,5,50,2); 1316 1316 } 1317 1317 … … 1320 1320 1321 1321 proc decodeCode(matrix check, int ntrials, list #) 1322 "USAGE: decodeCode(check, ntrials, [e]); check matrix, ntrials,e int 1323 @format 1324 - check is a check matrix for the code, 1325 - ntrials is the number of received vectors per code to be 1322 "USAGE: decodeCode(check, ntrials, [e]); check matrix, ntrials,e int 1323 @format 1324 - check is a check matrix for the code, 1325 - ntrials is the number of received vectors per code to be 1326 1326 corrected. 1327 - If e is given it sets the correction capacity explicitly. It 1327 - If e is given it sets the correction capacity explicitly. It 1328 1328 should be used in case one expects some lower bound, 1329 otherwise the procedure tries to compute the real minimum distance 1329 otherwise the procedure tries to compute the real minimum distance 1330 1330 to find out the error-correction capacity 1331 1331 @end format 1332 RETURN: nothing; 1333 EXAMPLE: example decodeCode; shows an example 1332 RETURN: nothing; 1333 EXAMPLE: example decodeCode; shows an example 1334 1334 " 1335 1335 { … … 1351 1351 option(redSB); 1352 1352 def br=basering; 1353 matrix h_full=genMDSMat(n,a); 1353 matrix h_full=genMDSMat(n,a); 1354 1354 matrix z[1][ncols(h_full)]; 1355 1355 setring br; … … 1369 1369 dist=tmp[1]; 1370 1370 printf("d= %p",dist); 1371 t=(dist-1) div 2; 1372 } 1373 tim2=rtimer; 1371 t=(dist-1) div 2; 1372 } 1373 tim2=rtimer; 1374 1374 tim3=rtimer; 1375 1375 … … 1380 1380 ideal sys2,sys3; 1381 1381 matrix h=imap(br,h); 1382 matrix g=dual_code(h); 1382 matrix g=dual_code(h); 1383 1383 ideal sys=qe; 1384 1384 print("The system is generated"); 1385 timdec3=timdec3+rtimer-tim3; 1386 1387 //--- modify the template according to every received word --------------- 1385 timdec3=timdec3+rtimer-tim3; 1386 1387 //--- modify the template according to every received word --------------- 1388 1388 for (j=1; j<=ntrials; j++) 1389 1389 { 1390 word=randomvector(n-redun,1); 1390 word=randomvector(n-redun,1); 1391 1391 y=encode(transpose(word),g); 1392 rec=errorRand(y,t,1); 1393 sys2=add_synd(rec,h,redun,sys); 1394 1392 rec=errorRand(y,t,1); 1393 sys2=add_synd(rec,h,redun,sys); 1394 1395 1395 tim=rtimer; 1396 sys3=std(sys2); 1397 timdec=timdec+rtimer-tim; 1398 } 1399 timdec2=timdec2+rtimer-tim2; 1400 1396 sys3=std(sys2); 1397 timdec=timdec+rtimer-tim; 1398 } 1399 timdec2=timdec2+rtimer-tim2; 1400 1401 1401 printf("Time for mindist: %p", timdist); 1402 1402 printf("Time for GB in mindist: %p", timdist); 1403 1403 printf("Time for decoding: %p", timdec2); 1404 1404 printf("Time for GB in decoding: %p", timdec); 1405 printf("Time for sysQE in decoding: %p", timdec3); 1406 1405 printf("Time for sysQE in decoding: %p", timdec3); 1406 1407 1407 option(set,vopt); 1408 } 1409 example 1408 } 1409 example 1410 1410 { 1411 1411 "EXAMPLE:"; echo = 2; … … 1413 1413 ring r=(q,a),x,dp; 1414 1414 matrix check=randomCheck(redun,n,1); 1415 1416 // correct 2 errors in using the code above, 50 trials 1417 decodeCode(check,50,2); 1415 1416 // correct 2 errors in using the code above, 50 trials 1417 decodeCode(check,50,2); 1418 1418 } 1419 1419 … … 1426 1426 matrix s[redun][1]=syndrome(check,rec); 1427 1427 for (int i=1; i<=redun; i++) 1428 1429 { 1430 result[i]=result[i]-s[i,1]; 1428 1429 { 1430 result[i]=result[i]-s[i,1]; 1431 1431 } 1432 1432 return(result); … … 1448 1448 1449 1449 /////////////////////////////////////////////////////////////////////////////// 1450 // return index of an element in the ideal where it does not vanish at the 1450 // return index of an element in the ideal where it does not vanish at the 1451 1451 //given point 1452 1452 static proc find_index (ideal G, matrix p) … … 1488 1488 1489 1489 /////////////////////////////////////////////////////////////////////////////// 1490 // check whether given polynomial is divisible by some leading monomial of the 1490 // check whether given polynomial is divisible by some leading monomial of the 1491 1491 //ideal 1492 1492 static proc divisible (poly m, ideal G) … … 1494 1494 for (int i=1; i<=size(G); i++) 1495 1495 { 1496 if (m/leadmonom(G[i])!=0) {return(1);} 1496 if (m/leadmonom(G[i])!=0) {return(1);} 1497 1497 } 1498 1498 return(0); … … 1503 1503 proc vanishId (list points) 1504 1504 "USAGE: vanishId (points); point is a list of matrices 1505 'points' is a list of points for which the vanishing ideal is to be 1506 constructed 1505 'points' is a list of points for which the vanishing ideal is to be 1506 constructed 1507 1507 RETURN: Vanishing ideal corresponding to the given set of points 1508 EXAMPLE: example vanishId; shows an example 1508 EXAMPLE: example vanishId; shows an example 1509 1509 " 1510 1510 { 1511 1511 int m=size(points[1]); 1512 1512 int n=size(points); 1513 1513 1514 1514 ideal G=1; 1515 1515 int i,k,j; … … 1519 1519 //------------- proceed according to Farr-Gao algorithm ---------------- 1520 1520 for (k=1; k<=n; k++) 1521 { 1521 { 1522 1522 i=find_index(G,points[k]); 1523 cur=G[i]; 1523 cur=G[i]; 1524 1524 for(j=i+1; j<=size(G); j++) 1525 1525 { … … 1529 1529 temp=ideal2list(G); 1530 1530 temp=delete(temp,i); 1531 G=list2ideal(temp); 1531 G=list2ideal(temp); 1532 1532 for (j=1; j<=m; j++) 1533 1533 { … … 1535 1535 { 1536 1536 attrib(G,"isSB",1); 1537 h=NF((x(j)-points[k][j,1])*cur,G); 1537 h=NF((x(j)-points[k][j,1])*cur,G); 1538 1538 temp=ideal2list(G); 1539 1539 temp=insert(temp,h); 1540 1540 G=list2ideal(temp); 1541 G=sort(G)[1]; 1541 G=sort(G)[1]; 1542 1542 } 1543 1543 } … … 1545 1545 attrib(G,"isSB",1); 1546 1546 return(G); 1547 } 1548 example 1547 } 1548 example 1549 1549 { 1550 1550 "EXAMPLE:"; echo = 2; 1551 1551 ring r=3,(x(1..3)),dp; 1552 1552 1553 1553 //generate all 3-vectors over GF(3) 1554 1554 list points=pointsGen(3,1); 1555 1555 1556 1556 list points2=convPoints(points); 1557 1557 1558 1558 //grasps the first 11 points 1559 1559 list p=graspList(points2,1,11); 1560 1560 print(p); 1561 1561 1562 1562 //construct the vanishing ideal 1563 1563 ideal id=vanishId(p); … … 1566 1566 1567 1567 /////////////////////////////////////////////////////////////////////////////// 1568 // construct the list of all vectors of length m with elements in p^e, where p 1568 // construct the list of all vectors of length m with elements in p^e, where p 1569 1569 //is characteristics 1570 1570 proc pointsGen (int m, int e) … … 1588 1588 count++; 1589 1589 for (j=1; j<=charac^(e)-1; j++) 1590 { 1590 { 1591 1591 result[count][m]=a^j; 1592 1592 count++; … … 1594 1594 return(result); 1595 1595 } 1596 list prev=pointsGen(m-1,e); 1596 list prev=pointsGen(m-1,e); 1597 1597 for (i=1; i<=size(prev); i++) 1598 1598 { … … 1609 1609 return(result); 1610 1610 } 1611 1611 1612 1612 if (e==1) 1613 1613 { … … 1616 1616 int i,j; 1617 1617 list l=ringlist(basering); 1618 int charac=l[1][1]; 1618 int charac=l[1][1]; 1619 1619 list tmp; 1620 1620 for (i=1; i<=charac^m; i++) … … 1625 1625 { 1626 1626 for (j=0; j<=charac-1; j++) 1627 { 1627 { 1628 1628 result[count][m]=number(j); 1629 1629 count++; … … 1631 1631 return(result); 1632 1632 } 1633 list prev=pointsGen(m-1,e); 1633 list prev=pointsGen(m-1,e); 1634 1634 for (i=1; i<=size(prev); i++) 1635 1635 { … … 1643 1643 return(result); 1644 1644 } 1645 1645 1646 1646 } 1647 1647 … … 1688 1688 { 1689 1689 poly prod=1; 1690 list rl=ringlist(basering); 1690 list rl=ringlist(basering); 1691 1691 int charac=rl[1][1]; 1692 1692 int l; … … 1730 1730 "USAGE: sysFL (check,y,t,e,s); check,y matrix, t,e,s int 1731 1731 @format 1732 - check is a check matrix of the code, 1733 - y is a received word, 1732 - check is a check matrix of the code, 1733 - y is a received word, 1734 1734 - t the number of errors to correct, 1735 - e is the extension degree, 1735 - e is the extension degree, 1736 1736 - s is the dimension of the point for the vanishing ideal 1737 1737 @end format 1738 1738 RETURN: the system of Fitzgerald-Lax for the given decoding problem 1739 THEORY: Based on 'check' of the given linear code, the procedure constructs 1739 THEORY: Based on 'check' of the given linear code, the procedure constructs 1740 1740 the corresponding ideal constructed with a generalization of 1741 1741 Cooper's philosophy. For basics of the method @ref{Fitzgerald-Lax method}. … … 1744 1744 " 1745 1745 { 1746 list rl=ringlist(basering); 1747 int charac=rl[1][1]; 1746 list rl=ringlist(basering); 1747 int charac=rl[1][1]; 1748 1748 int n=ncols(check); 1749 int m=nrows(check); 1749 int m=nrows(check); 1750 1750 list points=pointsGen(s,e); 1751 1751 list points2=convPoints(points); 1752 list p=graspList(points2,1,n); 1753 ideal id=vanishId(p,e); 1754 ideal funcs=gener_funcs(check,p,e,id,s); 1755 1752 list p=graspList(points2,1,n); 1753 ideal id=vanishId(p,e); 1754 ideal funcs=gener_funcs(check,p,e,id,s); 1755 1756 1756 ideal result; 1757 1757 poly temp; 1758 1758 int i,j,k; 1759 1759 1760 1760 //--------------- add vanishing realtions --------------------- 1761 1761 for (i=1; i<=t; i++) 1762 { 1762 { 1763 1763 for (j=1; j<=size(id); j++) 1764 1764 { 1765 temp=id[j]; 1765 temp=id[j]; 1766 1766 for (k=1; k<=s; k++) 1767 1767 { 1768 1768 temp=subst(temp,x(k),x_var(i,k,s)); 1769 } 1769 } 1770 1770 result=result,temp; 1771 1771 } 1772 } 1773 1772 } 1773 1774 1774 //--------------- add field equations -------------------- 1775 1775 for (i=1; i<=t; i++) … … 1784 1784 result=result,e(i)^(charac^e-1)-1; 1785 1785 } 1786 1786 1787 1787 result=simplify(result,8); 1788 1788 1789 1789 //--------------- add check realtions -------------------- 1790 1790 poly sum; 1791 matrix syn[m][1]=syndrome(check,y); 1791 matrix syn[m][1]=syndrome(check,y); 1792 1792 for (i=1; i<=size(funcs); i++) 1793 { 1793 { 1794 1794 sum=0; 1795 1795 for (j=1; j<=t; j++) … … 1800 1800 temp=subst(temp,x(k),x_var(j,k,s)); 1801 1801 } 1802 sum=sum+temp*e(j); 1802 sum=sum+temp*e(j); 1803 1803 } 1804 1804 result=result,sum-syn[i,1]; 1805 1805 } 1806 1806 1807 1807 result=simplify(result,2); 1808 1808 1809 1809 points=points2; 1810 export points; 1810 export points; 1811 1811 return(result); 1812 } 1812 } 1813 1813 example 1814 1814 { 1815 1815 "EXAMPLE:"; echo = 2; 1816 1816 intvec vopt = option(get); 1817 1817 1818 1818 list l=FLpreprocess(3,1,11,2,""); 1819 1819 def r=l[1]; 1820 1820 setring r; 1821 int s_work=l[2]; 1822 1821 int s_work=l[2]; 1822 1823 1823 //the check matrix of [11,6,5] ternary code 1824 1824 matrix h[5][11]=1,0,0,0,0,1,1,1,-1,-1,0, … … 1833 1833 matrix rec[1][11]=errorInsert(y,list(2,4),list(1,-1)); 1834 1834 1835 //the Fitzgerald-Lax system 1835 //the Fitzgerald-Lax system 1836 1836 ideal sys=sysFL(h,rec,2,1,s_work); 1837 1837 print(sys); 1838 1838 option(redSB); 1839 1839 ideal red_sys=std(sys); 1840 red_sys; 1840 red_sys; 1841 1841 // read the solutions from this redGB 1842 1842 // the points are (0,0,1) and (0,1,0) with error values 1 and -1 resp. 1843 1843 // use list points to find error positions; 1844 1844 points; 1845 1845 1846 1846 option(set,vopt); 1847 1847 } … … 1856 1856 { 1857 1857 s++; 1858 } 1858 } 1859 1859 list var_ord; 1860 1860 int i,j; … … 1874 1874 count++; 1875 1875 } 1876 } 1877 1876 } 1877 1878 1878 list rl; 1879 1879 list tmp; 1880 1880 1881 1881 if (e>1) 1882 1882 { … … 1886 1886 rl[1][2][1]=string("a"); 1887 1887 rl[1][3]=tmp; 1888 rl[1][3][1]=tmp; 1888 rl[1][3][1]=tmp; 1889 1889 rl[1][3][1][1]=string("lp"); 1890 1890 rl[1][3][1][2]=1; … … 1893 1893 rl[1]=p; 1894 1894 } 1895 1895 1896 1896 rl[2]=var_ord; 1897 1897 1898 1898 rl[3]=tmp; 1899 rl[3][1]=tmp; 1899 rl[3][1]=tmp; 1900 1900 rl[3][1][1]=string("lp"); 1901 1901 intvec v=1; … … 1904 1904 v=v,1; 1905 1905 } 1906 rl[3][1][2]=v; 1906 rl[3][1][2]=v; 1907 1907 rl[3][2]=tmp; 1908 rl[3][2][1]=string("C"); 1908 rl[3][2][1]=string("C"); 1909 1909 rl[3][2][2]=intvec(0); 1910 1911 rl[4]=ideal(0); 1912 1910 1911 rl[4]=ideal(0); 1912 1913 1913 def r2=ring(rl); 1914 1914 setring r2; 1915 list l=ringlist(r2); 1915 list l=ringlist(r2); 1916 1916 if (e>1) 1917 1917 { 1918 execute(string("poly f="+minp)); 1919 ideal id=f; 1918 execute(string("poly f="+minp)); 1919 ideal id=f; 1920 1920 l[1][4]=id; 1921 1921 } 1922 1922 1923 1923 def r=ring(l); 1924 setring r; 1925 1924 setring r; 1925 1926 1926 return(list(r,s)); 1927 1927 } … … 1930 1930 // imitating two indeces 1931 1931 static proc x_var (int i, int j, int s) 1932 { 1932 { 1933 1933 return(x1(s*(i-1)+j)); 1934 1934 } … … 1937 1937 // random vector of length n with entries from p^e, p the characteristic 1938 1938 static proc randomvector(int n, int e) 1939 { 1939 { 1940 1940 int i; 1941 1941 matrix result[n][1]; … … 1944 1944 result[i,1]=asElement(random_prime_vector(e)); 1945 1945 } 1946 return(result); 1947 } 1948 1949 /////////////////////////////////////////////////////////////////////////////// 1950 // "convert" representation of an element from the field extension from vector 1946 return(result); 1947 } 1948 1949 /////////////////////////////////////////////////////////////////////////////// 1950 // "convert" representation of an element from the field extension from vector 1951 1951 //to an elelemnt 1952 1952 static proc asElement(list l) … … 1955 1955 int i; 1956 1956 number w=1; 1957 if (size(l)>1) {w=par(1);} 1957 if (size(l)>1) {w=par(1);} 1958 1958 for (i=0; i<=size(l)-1; i++) 1959 1959 { … … 1966 1966 // random vector of length n with entries from p, p the characteristic 1967 1967 static proc random_prime_vector (int n) 1968 { 1968 { 1969 1969 list rl=ringlist(basering); 1970 1970 int i, charac; … … 1972 1972 { 1973 1973 if (rl[1][1] mod i ==0) 1974 { 1974 { 1975 1975 break; 1976 1976 } 1977 1977 } 1978 charac=i; 1979 1978 charac=i; 1979 1980 1980 list l; 1981 1981 1982 1982 for (i=1; i<=n; i++) 1983 1983 { … … 1990 1990 1991 1991 proc decodeRandomFL(int n, int redun, int p, int e, int t, int ncodes, int ntrials, string minpol) 1992 "USAGE: decodeRandomFL(redun,p,e,n,t,ncodes,ntrials,minpol); 1992 "USAGE: decodeRandomFL(redun,p,e,n,t,ncodes,ntrials,minpol); 1993 1993 @format 1994 - n is length of codes generated, redun = redundancy of codes 1995 generated, 1996 - p is characteristics, 1997 - e is the extension degree, 1998 - t is the number of errors to correct, 1994 - n is length of codes generated, redun = redundancy of codes 1995 generated, 1996 - p is characteristics, 1997 - e is the extension degree, 1998 - t is the number of errors to correct, 1999 1999 - ncodes is the number of random codes to be processed, 2000 2000 - ntrials is the number of received vectors per code to be corrected, 2001 - minpol: due to some pecularities of SINGULAR one needs to provide 2001 - minpol: due to some pecularities of SINGULAR one needs to provide 2002 2002 minimal polynomial for the extension explicitly 2003 2003 @end format … … 2008 2008 intvec vopt = option(get); 2009 2009 2010 list l=FLpreprocess(p,e,n,t,minpol); 2011 2010 list l=FLpreprocess(p,e,n,t,minpol); 2011 2012 2012 def r=l[1]; 2013 int s_work=l[2]; 2013 int s_work=l[2]; 2014 2014 export(s_work); 2015 2015 setring r; 2016 2016 2017 2017 int i,j; 2018 2018 matrix h, g, word, y, rec; 2019 2019 int dist, tim, tim2, tim3, timdist, timdec, timdist2, timdec2, timdec3; 2020 2020 ideal sys, sys2, sys3; 2021 list tmp; 2022 2023 option(redSB); 2024 matrix z[1][n]; 2025 2021 list tmp; 2022 2023 option(redSB); 2024 matrix z[1][n]; 2025 2026 2026 for (i=1; i<=ncodes; i++) 2027 2027 { 2028 h=randomCheck(redun,n,e); 2028 h=randomCheck(redun,n,e); 2029 2029 g=dual_code(h); 2030 tim2=rtimer; 2030 tim2=rtimer; 2031 2031 tim3=rtimer; 2032 2032 2033 //---------------- generate the template system ----------------------- 2034 sys=sysFL(h,z,t,e,s_work); 2033 //---------------- generate the template system ----------------------- 2034 sys=sysFL(h,z,t,e,s_work); 2035 2035 timdec3=timdec3+rtimer-tim3; 2036 2036 2037 2037 //------ modifying the template according to the received word --------- 2038 2038 for (j=1; j<=ntrials; j++) … … 2041 2041 y=encode(transpose(word),g); 2042 2042 rec=errorRand(y,t,e); 2043 sys2=LF_add_synd(rec,h,sys); 2043 sys2=LF_add_synd(rec,h,sys); 2044 2044 tim=rtimer; 2045 2045 sys3=std(sys2); 2046 2046 timdec=timdec+rtimer-tim; 2047 } 2047 } 2048 2048 timdec2=timdec2+rtimer-tim2; 2049 } 2050 2049 } 2050 2051 2051 printf("Time for decoding: %p", timdec2); 2052 2052 printf("Time for GB in decoding: %p", timdec); 2053 printf("Time for generating Fitzgerald-Lax system during decoding: %p", timdec3); 2054 2053 printf("Time for generating Fitzgerald-Lax system during decoding: %p", timdec3); 2054 2055 2055 option(set,vopt); 2056 } 2056 } 2057 2057 example 2058 2058 { 2059 2059 "EXAMPLE:"; echo = 2; 2060 2061 // correcting one error for one random binary code of length 25, 2060 2061 // correcting one error for one random binary code of length 25, 2062 2062 //redundancy 14; 300 words are processed 2063 2063 decodeRandomFL(25,14,2,1,1,1,300,""); … … 2084 2084 2085 2085 "EXAMPLE:"; echo = 2; 2086 int q=128; int n=120; int redun=n-30; 2086 int q=128; int n=120; int redun=n-30; 2087 2087 ring r=(q,a),x,dp; 2088 2088 decodeRandom(n,redun,1,1,6); 2089 2089 2090 int q=128; int n=120; int redun=n-20; 2090 int q=128; int n=120; int redun=n-20; 2091 2091 ring r=(q,a),x,dp; 2092 2092 decodeRandom(n,redun,1,1,9); … … 2106 2106 2107 2107 "EXAMPLE:"; echo = 2; 2108 int q=128; int n=120; int redun=n-40; 2108 int q=128; int n=120; int redun=n-40; 2109 2109 ring r=(q,a),x,dp; 2110 2110 decodeRandom(n,redun,1,1,6); … … 2119 2119 decodeRandom(n,redun,1,1,24); 2120 2120 2121 int q=256; int n=150; int redun=n-10; 2121 int q=256; int n=150; int redun=n-10; 2122 2122 ring r=(q,a),x,dp; 2123 2123 decodeRandom(n,redun,1,1,26); … … 2156 2156 setring A; 2157 2157 print(qe); 2158 ideal red_qe=stdfglm(qe); 2158 ideal red_qe=stdfglm(qe); 2159 2159 2160 2160 */ -
Singular/LIB/discretize.lib
r95edd5 r7f3ad4 1 1 /////////////////////////////////////////////////////////////////////////////// 2 version="$Id: discretize.lib,v 1. 4 2009-01-07 16:11:35Singular Exp $";2 version="$Id: discretize.lib,v 1.5 2009-01-14 16:07:04 Singular Exp $"; 3 3 category="Applications"; 4 4 info=" … … 108 108 RETURN: string 109 109 PURPOSE: replaces in 's' all the substrings 'what' with substring 'with' 110 NOTE: 110 NOTE: 111 111 EXAMPLE: example replace; shows examples 112 112 "{ … … 419 419 if ( (sout[i]=="+") || (sout[i]=="-") ) 420 420 { 421 421 NisPoly = 1; 422 422 } 423 423 } … … 709 709 " ideal I = decoef(p,dt);"; 710 710 " difpoly2tex(I,L);"; 711 difpoly2tex(I,L); // the nodal form of the scheme in TeX 711 difpoly2tex(I,L); // the nodal form of the scheme in TeX 712 712 "* Preparations for the semi-factorized form: "; 713 713 poly pi1 = subst(I[2],B,0); -
Singular/LIB/dmod.lib
r95edd5 r7f3ad4 1 1 ////////////////////////////////////////////////////////////////////////////// 2 version="$Id: dmod.lib,v 1.3 3 2008-12-23 21:39:31 levandovExp $";2 version="$Id: dmod.lib,v 1.34 2009-01-14 16:07:04 Singular Exp $"; 3 3 category="Noncommutative"; 4 4 info=" … … 1285 1285 { 1286 1286 bs[i-1] = P[1][i]; bs[i-1] = subst(bs[i-1],s,-s-1); 1287 m[i-1] = P[2][i]; 1287 m[i-1] = P[2][i]; 1288 1288 } 1289 1289 int sP = minIntRoot(bs,1); … … 1465 1465 dbprint(ppl,"// -2-1- the ring @R3 i.e. K[s] is ready"); 1466 1466 ideal K3 = imap(@R2,K2); 1467 poly p = K3[1]; 1467 poly p = K3[1]; 1468 1468 p = s*p; // mult with the lost (s+1) factor 1469 1469 dbprint(ppl,"// -2-2- factorization"); … … 1480 1480 { 1481 1481 bs[i-1] = P[1][i]; bs[i-1] = subst(bs[i-1],s,-s-1); 1482 m[i-1] = P[2][i]; 1482 m[i-1] = P[2][i]; 1483 1483 } 1484 1484 int sP = minIntRoot(bs,1); … … 1923 1923 if ( leadmonom(K[i,2]) == 1) 1924 1924 { 1925 1926 1927 1928 1929 1925 t = K[i,1]; 1926 n = leadcoef(K[i,2]); 1927 t = t/n; 1928 // J = J, K[i][2]; 1929 break; 1930 1930 } 1931 1931 } … … 3561 3561 kill s; 3562 3562 kill NName; 3563 tmp[1] = "C"; 3563 tmp[1] = "C"; 3564 3564 Lord[2] = tmp; tmp = 0; 3565 3565 L[3] = Lord; -
Singular/LIB/dmodapp.lib
r95edd5 r7f3ad4 1 1 ////////////////////////////////////////////////////////////////////////////// 2 version="$Id: dmodapp.lib,v 1.1 5 2009-01-12 19:31:23Singular Exp $";2 version="$Id: dmodapp.lib,v 1.16 2009-01-14 16:07:04 Singular Exp $"; 3 3 category="Noncommutative"; 4 4 info=" … … 9 9 GUIDE: Let R = K[x1,..xN] and D be the Weyl algebra in variables x1,..xN,d1,..dN. 10 10 In this library there are the following procedures for algebraic D-modules: 11 @* - localization of a holonomic module D/I with respect to a mult. closed set 11 @* - localization of a holonomic module D/I with respect to a mult. closed set 12 12 of all powers of a given polynomial F from R. Our aim is to compute an ideal L 13 in D, such that D/L is a presentation of a localized module. Such L always exists, since 14 such localizations are known to be holonomic and thus cyclic modules. 13 in D, such that D/L is a presentation of a localized module. Such L always exists, since 14 such localizations are known to be holonomic and thus cyclic modules. 15 15 The procedures for the localization are DLoc, SDLoc and DLoc0. 16 16 … … 423 423 { 424 424 return(I); 425 } 425 } 426 426 int j,i,s,m; 427 427 list l; … … 442 442 else 443 443 { 444 445 446 447 448 444 if (s > m) 445 { 446 m = s; 447 g = l[i][2]; 448 } 449 449 } 450 450 } … … 587 587 588 588 589 proc appelF1() 589 proc appelF1() 590 590 "USAGE: appelF1(); 591 591 RETURN: ring … … 613 613 "EXAMPLE:"; echo = 2; 614 614 ring r = 0,x,dp; 615 def A = appelF1(); 615 def A = appelF1(); 616 616 setring A; 617 617 IAppel1; … … 643 643 "EXAMPLE:"; echo = 2; 644 644 ring r = 0,x,dp; 645 def A = appelF2(); 645 def A = appelF2(); 646 646 setring A; 647 647 IAppel2; 648 648 } 649 649 650 proc appelF4() 650 proc appelF4() 651 651 "USAGE: appelF4(); 652 652 RETURN: ring … … 673 673 "EXAMPLE:"; echo = 2; 674 674 ring r = 0,x,dp; 675 def A = appelF4(); 675 def A = appelF4(); 676 676 setring A; 677 677 IAppel4; … … 716 716 PURPOSE: check whether the ideal I is F-saturated 717 717 NOTE: 1 is returned if I is F-saturated, otherwise 0 is returned. 718 @* we check indeed that Ker(D --F--> D/I) is (0) 718 @* we check indeed that Ker(D --F--> D/I) is (0) 719 719 EXAMPLE: example isFsat; shows examples 720 720 " … … 1332 1332 LD; 1333 1333 // Now, compare with the output of Macaulay2: 1334 ideal tst = 3*x*Dx + 2*y*Dy + 1, y^3*Dy^2 - x^2*Dy^2 + 6*y^2*Dy + 6*y, 1335 9*y^2*Dx^2*Dy - 4*y*Dy^3 + 27*y*Dx^2 + 2*Dy^2, 9*y^3*Dx^2 - 4*y^2*Dy^2 + 10*y*Dy -10; 1334 ideal tst = 3*x*Dx + 2*y*Dy + 1, y^3*Dy^2 - x^2*Dy^2 + 6*y^2*Dy + 6*y, 1335 9*y^2*Dx^2*Dy - 4*y*Dy^3 + 27*y*Dx^2 + 2*Dy^2, 9*y^3*Dx^2 - 4*y^2*Dy^2 + 10*y*Dy -10; 1336 1336 option(redSB); option(redTail); 1337 1337 LD = groebner(LD); … … 1405 1405 } 1406 1406 1407 /* DIFFERENT EXAMPLES 1407 /* DIFFERENT EXAMPLES 1408 1408 1409 1409 //static proc exCusp() … … 1504 1504 */ 1505 1505 1506 proc engine(ideal I, int i) 1506 proc engine(ideal I, int i) 1507 1507 "USAGE: engine(I,i); I an ideal, i an int 1508 1508 RETURN: ideal … … 1527 1527 return(J); 1528 1528 } 1529 example 1529 example 1530 1530 { 1531 1531 "EXAMPLE:"; echo = 2; … … 1562 1562 else 1563 1563 { 1564 if (inp1 == "ideal") 1564 if (inp1 == "ideal") 1565 1565 { 1566 1566 ERROR("second argument has to be a poly if first argument is an ideal"); 1567 1567 } 1568 1568 else { vector f = #[2]; } … … 1579 1579 if (k<=0) 1580 1580 { 1581 1581 ERROR("third argument has to be positive"); 1582 1582 } 1583 1583 } -
Singular/LIB/elim.lib
r95edd5 r7f3ad4 1 // $Id: elim.lib,v 1.2 5 2008-11-13 10:50:17Singular Exp $2 /////////////////////////////////////////////////////////////////////////////// 3 version="$Id: elim.lib,v 1.2 5 2008-11-13 10:50:17Singular Exp $";1 // $Id: elim.lib,v 1.26 2009-01-14 16:07:04 Singular Exp $ 2 /////////////////////////////////////////////////////////////////////////////// 3 version="$Id: elim.lib,v 1.26 2009-01-14 16:07:04 Singular Exp $"; 4 4 category="Commutative Algebra"; 5 5 info=" … … 186 186 /////////////////////////////////////////////////////////////////////////////// 187 187 proc elimRing ( poly vars, list #) 188 "USAGE: elimRing(vars [,w]); vars = product of variables to be eliminated 188 "USAGE: elimRing(vars [,w]); vars = product of variables to be eliminated 189 189 (type poly), w = intvec (specifying weights for all variables) 190 RETURN: a ring, say R, s.t. the monomial ordering of R has 2 blocks. 190 RETURN: a ring, say R, s.t. the monomial ordering of R has 2 blocks. 191 191 The first block corresponds to the (given) variables to be eliminated 192 and has ordering dp if these variables have weight all 1; if w is 193 given or if not all variables in vars have weight 1 the ordering is 194 wp(w1) where w1 is the intvec of weights of the variables to be 195 eliminated. 196 The second block corresponds to variables not to be eliminated. 197 @* If the first variable not to be eliminated is global (i.e. > 1), 198 resp. local (i.e. < 1), the second block has ordering dp, resp. ds, 199 (or wp(w2), resp. ws(w2), where w2 is the intvec of weights of the 192 and has ordering dp if these variables have weight all 1; if w is 193 given or if not all variables in vars have weight 1 the ordering is 194 wp(w1) where w1 is the intvec of weights of the variables to be 195 eliminated. 196 The second block corresponds to variables not to be eliminated. 197 @* If the first variable not to be eliminated is global (i.e. > 1), 198 resp. local (i.e. < 1), the second block has ordering dp, resp. ds, 199 (or wp(w2), resp. ws(w2), where w2 is the intvec of weights of the 200 200 variables not to be eliminated). 201 @* If the basering is a quotient ring P/Q, then R a quotient ring 201 @* If the basering is a quotient ring P/Q, then R a quotient ring 202 202 with Q replaced by a standard basis of Q w.r.t. the new ordering 203 (parameters are not touched). 203 (parameters are not touched). 204 204 NOTE: The ordering in R is an elimination ordering for the variables 205 205 appearing in vars. 206 PURPOSE: Prepare a ring for eliminating vars from an ideal/moduel by 207 computing a standard basis in R with a fast monomial ordering. 206 PURPOSE: Prepare a ring for eliminating vars from an ideal/moduel by 207 computing a standard basis in R with a fast monomial ordering. 208 208 This procedure is used by the procedure elim. 209 209 EXAMPLE: example elimRing; shows an example … … 219 219 { 220 220 if ( typeof(#[1]) == "intvec" ) 221 { 221 { 222 222 @w = #[1]; //take the given weights 223 223 } … … 236 236 { 237 237 if( vars/var(ii)==0 ) //treat variables not to be eliminated 238 { 238 { 239 239 w2 = w2,@w[ii]; 240 240 v2 = v2+list(string(var(ii))); … … 244 244 } 245 245 } 246 else 246 else 247 247 { 248 248 w1 = w1,@w[ii]; … … 263 263 264 264 w1 = w1[2..size(w1)]; 265 w2 = w2[2..size(w2)]; 265 w2 = w2[2..size(w2)]; 266 266 267 267 //--- put variables to be eliminated in front: 268 BRlist[2] = v1 + v2; 269 268 BRlist[2] = v1 + v2; 269 270 270 //--- create a block ordering with two blocks and weights: 271 271 int nblock = size(BRlist[3]); //number of blocks … … 318 318 } 319 319 320 def eRing = ring(quotientList(BRlist)); 320 def eRing = ring(quotientList(BRlist)); 321 321 return (eRing); 322 322 } … … 327 327 intvec w = 1,1,3,4,5; 328 328 elimRing(yu,w); 329 329 330 330 ring S = (0,a),(x,y,z,u,v),ws(1,2,3,4,5); 331 331 minpoly = a2+1; 332 332 qring T = std(ideal(x+y2+v3,(x+v)^2)); 333 def Q = elimRing(yv); 333 def Q = elimRing(yv); 334 334 setring Q; Q; 335 335 } … … 337 337 338 338 proc elim (id, list #) 339 "USAGE: elim(id,arg[,\"withWeights\"]); id ideal/module, arg can be either 340 an intvec vor a product p of variables (type poly) 341 RETURN: ideal/module obtained from id by eliminating either the variables 342 with indices appearing in v or the variables appearing in p. 339 "USAGE: elim(id,arg[,\"withWeights\"]); id ideal/module, arg can be either 340 an intvec vor a product p of variables (type poly) 341 RETURN: ideal/module obtained from id by eliminating either the variables 342 with indices appearing in v or the variables appearing in p. 343 343 Works also in a qring. 344 344 METHOD: elim uses elimRing to create a ring with block ordering with two 345 blocks where the first block contains the variables to be eliminated 345 blocks where the first block contains the variables to be eliminated 346 346 and then uses groebner. If the variables in the basering have weights 347 347 these weights are used in elimRing. 348 @* If a string \"withWeigts\" as second, optional argument is given, 349 Singular computes weights for the variables to make the input as 348 @* If a string \"withWeigts\" as second, optional argument is given, 349 Singular computes weights for the variables to make the input as 350 350 homogeneous as possible. 351 351 @* The method is different from that used by eliminate and elim1; 352 352 in some examples elim can be significantly faster. 353 NOTE: No special monomial ordering is required, i.e. the ordering can be 354 local or mixed. The result is a SB with respect to the ordering of 355 the second block used by elimRing. E.g. if the first var not to be 356 eliminated is global, resp. local, this ordering is dp, resp. ds 357 (or wp, resp. ws, with the given weights for these variables). 358 If printlevel > 0 the ring for which the output is a SB is shown. 353 NOTE: No special monomial ordering is required, i.e. the ordering can be 354 local or mixed. The result is a SB with respect to the ordering of 355 the second block used by elimRing. E.g. if the first var not to be 356 eliminated is global, resp. local, this ordering is dp, resp. ds 357 (or wp, resp. ws, with the given weights for these variables). 358 If printlevel > 0 the ring for which the output is a SB is shown. 359 359 SEE ALSO: eliminate, elim1 360 360 EXAMPLE: example elim; shows an example 361 361 " 362 { 362 { 363 363 if (size(#) == 0) 364 364 { … … 369 369 //-------------------------------- check input ------------------------------- 370 370 poly vars; 371 int ii; 371 int ii; 372 372 if (size(#) > 0) 373 373 { 374 374 if ( typeof(#[1]) == "poly" ) 375 { 375 { 376 376 vars = #[1]; 377 377 } 378 378 if ( typeof(#[1]) == "intvec") 379 { 379 { 380 380 vars=1; 381 for( ii=1; ii<=size(#[1]); ii++ ) 382 { 383 vars=vars*var(#[1][ii]); 381 for( ii=1; ii<=size(#[1]); ii++ ) 382 { 383 vars=vars*var(#[1][ii]); 384 384 } 385 385 } … … 388 388 { 389 389 if ( typeof(#[2]) == "string" ) 390 { 390 { 391 391 if ( #[2] == "withWeights" ) 392 { 392 { 393 393 intvec @w = weight(id); 394 394 } … … 411 411 id = groebner(id); 412 412 id = nselect(id,1..size(ringlist(ER)[3][1][2])); 413 if ( pr > 0 ) 414 { 413 if ( pr > 0 ) 414 { 415 415 "// result is a SB in the following ring:"; 416 416 ER; … … 424 424 ideal i=x-u,y-u2,w-u3,v-x+y3; 425 425 elim(i,3..4); 426 elim(i,uv); 426 elim(i,uv); 427 427 int p = printlevel; 428 428 printlevel = 2; -
Singular/LIB/findifs.lib
r95edd5 r7f3ad4 1 1 /////////////////////////////////////////////////////////////////////////////// 2 version="$Id: findifs.lib,v 1. 3 2009-01-07 16:11:35Singular Exp $";2 version="$Id: findifs.lib,v 1.4 2009-01-14 16:07:04 Singular Exp $"; 3 3 category="Applications"; 4 4 info=" … … 6 6 AUTHORS: Viktor Levandovskyy, levandov@risc.uni-linz.ac.at 7 7 8 THEORY: We provide the presentation of difference operators in a polynomial, 9 semi-factorized and a nodal form. Running @code{findifs_example();} 10 will show how we generate finite difference schemes of linear PDE's 8 THEORY: We provide the presentation of difference operators in a polynomial, 9 semi-factorized and a nodal form. Running @code{findifs_example();} 10 will show how we generate finite difference schemes of linear PDE's 11 11 from given approximations. 12 12 … … 67 67 RETURN: string 68 68 PURPOSE: converts special characters to TeX in s 69 NOTE: the convention is the following: 70 'Tx' goes to 'T_x', 69 NOTE: the convention is the following: 70 'Tx' goes to 'T_x', 71 71 'dx' to '\\tri x' (the same for dt, dy, dz), 72 72 'theta', 'ro', 'A', 'V' are converted to greek letters. … … 114 114 RETURN: string 115 115 PURPOSE: replaces in 's' all the substrings 'what' with substring 'with' 116 NOTE: 116 NOTE: 117 117 EXAMPLE: example replace; shows examples 118 118 "{ … … 425 425 if ( (sout[i]=="+") || (sout[i]=="-") ) 426 426 { 427 427 NisPoly = 1; 428 428 } 429 429 } … … 722 722 " ideal I = decoef(p,dt);"; 723 723 " difpoly2tex(I,L);"; 724 difpoly2tex(I,L); // the nodal form of the scheme in TeX 724 difpoly2tex(I,L); // the nodal form of the scheme in TeX 725 725 "* Preparations for the semi-factorized form: "; 726 726 poly pi1 = subst(I[2],B,0); -
Singular/LIB/freegb.lib
r95edd5 r7f3ad4 1 1 ////////////////////////////////////////////////////////////////////////////// 2 version="$Id: freegb.lib,v 1.1 4 2009-01-14 15:48:37Singular Exp $";2 version="$Id: freegb.lib,v 1.15 2009-01-14 16:07:04 Singular Exp $"; 3 3 category="Noncommutative"; 4 4 info=" … … 10 10 freegbasis(L, int n); compute two-sided Groebner basis of ideal, encoded via L, up to degree n 11 11 12 AUXILIARY PROCEDURES: 12 AUXILIARY PROCEDURES: 13 13 14 14 lp2lstr(K, s); convert letter-place ideal to a list of modules … … 310 310 "USAGE: isVar(p); poly p 311 311 RETURN: int 312 PURPOSE: checks whether p is a power of a single variable from the basering. 312 PURPOSE: checks whether p is a power of a single variable from the basering. 313 313 @* Returns the exponent or 0 is p is not a power of a single variable. 314 314 EXAMPLE: example isVar; shows examples … … 913 913 } 914 914 915 /* EXAMPLES: 915 /* EXAMPLES: 916 916 917 917 //static proc ex_shift() … … 1065 1065 } 1066 1066 1067 // END COMMENTED EXAMPLES 1067 // END COMMENTED EXAMPLES 1068 1068 1069 1069 */ … … 1531 1531 // Adem rels modulo 2 are interesting 1532 1532 1533 //static 1533 //static 1534 1534 proc stringpoly2lplace(string s) 1535 1535 { … … 1706 1706 } 1707 1707 1708 //static 1708 //static 1709 1709 proc sent2lplace(string s) 1710 1710 { … … 2102 2102 { 2103 2103 "EXAMPLE:"; echo = 2; 2104 intmat A[3][3] = 2104 intmat A[3][3] = 2105 2105 2, -1, 0, 2106 2106 -1, 2, -3, … … 2345 2345 } 2346 2346 2347 /* EXAMPLES AGAIN: 2347 /* EXAMPLES AGAIN: 2348 2348 //static proc get_ls3nilp() 2349 2349 { -
Singular/LIB/general.lib
r95edd5 r7f3ad4 3 3 //eric, added absValue 11.04.2002 4 4 /////////////////////////////////////////////////////////////////////////////// 5 version="$Id: general.lib,v 1.5 8 2008-12-12 11:26:34 Singular Exp $";5 version="$Id: general.lib,v 1.59 2009-01-14 16:07:04 Singular Exp $"; 6 6 category="General purpose"; 7 7 info=" … … 197 197 binomial(200,100);""; //type bigint 198 198 int n,k = 200,100; 199 bigint b1 = binomial(n,k); 199 bigint b1 = binomial(n,k); 200 200 ring r = 0,x,dp; 201 201 poly b2 = coeffs((x+1)^n,x)[k+1,1]; //coefficient of x^k in (x+1)^n … … 1088 1088 def watchdog_rneu=basering; 1089 1089 setring rsave; 1090 1091 1092 1093 1090 if (!defined(result)) 1091 { 1092 def result=fetch(watchdog_rneu,result); 1093 } 1094 1094 } 1095 1095 if(defined(watchdog_interrupt)) -
Singular/LIB/jacobson.lib
r95edd5 r7f3ad4 1 1 ////////////////////////////////////////////////////////////////////////////// 2 version="$Id: jacobson.lib,v 1. 7 2009-01-07 16:11:37Singular Exp $";2 version="$Id: jacobson.lib,v 1.8 2009-01-14 16:07:04 Singular Exp $"; 3 3 category="System and Control Theory"; 4 4 info=" … … 6 6 AUTHOR: Kristina Schindelar, Kristina.Schindelar@math.rwth-aachen.de 7 7 8 THEORY: We work over a ring R, that is a principal ideal domain. 8 THEORY: We work over a ring R, that is a principal ideal domain. 9 9 @* If R is commutative, we suppose R to be a polynomial ring in one variable. 10 @* If R is non-commutative, we suppose R to be in two variables, say x and d. 10 @* If R is non-commutative, we suppose R to be in two variables, say x and d. 11 11 @* We treat then the basering as principal ideal ring with d a polynomial 12 @* variable and x an invertible one. That is, we work in the Ore localization of R 13 @* with respect to the mult. closed set S = K[x] without 0. 12 @* variable and x an invertible one. That is, we work in the Ore localization of R 13 @* with respect to the mult. closed set S = K[x] without 0. 14 14 @* Note, that in computations no division by x will actually happen. 15 @* Given a rectangular matrix M over R, one can compute unimodular (that is invertible) 16 @* square matrices U and V, such that U*M*V=D is a diagonal matrix. 15 @* Given a rectangular matrix M over R, one can compute unimodular (that is invertible) 16 @* square matrices U and V, such that U*M*V=D is a diagonal matrix. 17 17 @* Depending on the ring, the diagonal entries of D have certain properties. 18 18 19 REFERENCES: 19 REFERENCES: 20 20 @* N. Jacobson, 'The theory of rings', AMS, 1943. 21 21 @* Manuel Avelino Insua Hermo, 'Varias perspectives sobre las bases de Groebner: Forma normal de Smith, Algorithme de Berlekamp y algebras de Leibniz'. PhD thesis, Universidad de Santiago de Compostela, 2005. … … 35 35 "USAGE: smith(M[, eng1, eng2]); M matrix, eng1 and eng2 are optional integers 36 36 RETURN: matrix or list 37 ASSUME: The current ring is assumed to be the commutative polynomial ring in 37 ASSUME: The current ring is assumed to be the commutative polynomial ring in 38 38 one variable 39 39 PURPOSE: compute the Smith Normal Form of M with transformation matrices (optionally) 40 NOTE: If the optional integer eng1 is non-zero, returns the list {U,D,V}, 40 NOTE: If the optional integer eng1 is non-zero, returns the list {U,D,V}, 41 41 where U*M*V = D and the diagonal field entries of D are not normalized. 42 42 @* Otherwise only the matrix D, that is the Smith Normal Form of M, is returned. … … 48 48 EXAMPLE: example smith; shows examples 49 49 " 50 { 50 { 51 51 def R = basering; 52 52 // check assume: R must be a polynomial ring in 1 variable … … 70 70 { 71 71 BASIS=#[2]; 72 } 72 } 73 73 else{BASIS=0;} 74 74 75 75 76 76 int ROW=ncols(MA); … … 100 100 if(eng==1) 101 101 { 102 list rueckLI=diagonal_with_trafo(R,MA,BASIS); 102 list rueckLI=diagonal_with_trafo(R,MA,BASIS); 103 103 list rueckLII=divisibility(rueckLI[2]); 104 104 matrix CON=divideByContent(rueckLII[2]); … … 108 108 else 109 109 { 110 matrix rueckm=diagonal_without_trafo(R,MA,BASIS); 110 matrix rueckm=diagonal_without_trafo(R,MA,BASIS); 111 111 list rueckL=divisibility(rueckm); 112 112 matrix CON=divideByContent(rueckm); … … 152 152 if(k==0){adrow++;} 153 153 } 154 154 155 155 m=transpose(m); 156 156 for(i=1;i<=adrow;i++){m=m,0;} … … 181 181 182 182 int s,st,p,ff; 183 183 184 184 module LT,TSTD; 185 185 module STD=transpose(m); … … 189 189 matrix END; 190 190 matrix ENDSTD; 191 matrix STDFIN; 192 STDFIN=STD; 191 matrix STDFIN; 192 STDFIN=STD; 193 193 list COMPARE=STDFIN; 194 194 … … 200 200 { 201 201 STD_EX=EXL,transpose(STD); 202 } 203 else 202 } 203 else 204 204 { 205 205 STD_EX=EXR,transpose(STD); 206 206 } 207 208 207 dbprint(ppl,"Computing Groebner basis: start"); 208 dbprint(ppl-1,STD); 209 209 STD=engine(STD,BASIS); 210 211 210 dbprint(ppl,"Computing Groebner basis: finished"); 211 dbprint(ppl-1,STD); 212 212 213 213 if(flag mod 2==1){s=ROW; st=COL;}else{s=COL; st=ROW;} 214 215 214 dbprint(ppl,"Computing Groebner basis for transformation matrix: start"); 215 dbprint(ppl-1,STD_EX); 216 216 STD_EX=transpose(STD_EX); 217 217 STD_EX=engine(STD_EX,BASIS); 218 219 218 dbprint(ppl,"Computing Groebner basis for transformation matrix: finished"); 219 dbprint(ppl-1,STD_EX); 220 220 221 221 //////// split STD_EX in STD and the transformation matrix … … 241 241 242 242 ////////////////////// compute the transformation matrices 243 243 244 244 if (flag mod 2 ==1) 245 { 245 { 246 246 TrafoL=transpose(LT)*TrafoL; 247 247 } 248 else 249 { 248 else 249 { 250 250 TrafoR=TrafoR*LT; 251 251 } 252 252 253 253 254 STDFIN=STD; 254 STDFIN=STD; 255 255 /////////////////////////////////// check if the D-th row is finished /////////////////////////////////// 256 256 COMPARE=insert(COMPARE,STDFIN); 257 258 { 257 if(size(COMPARE)>=3) 258 { 259 259 if(STD==COMPARE[3]){finish=1;} 260 260 } … … 268 268 269 269 if (flag mod 2!=0) { STD=transpose(STD); } 270 271 270 271 272 272 //zero colums to the end 273 273 matrix STDMM=STD; … … 278 278 for(i=1; i<=ncols(STDMM); i++) 279 279 { 280 ff=0; 280 ff=0; 281 281 for(j=1; j<=nrows(STDMM); j++) 282 282 { … … 291 291 int fehlposc=fehlpos; 292 292 module SORT; 293 for(i=1; i<=fehlpos; i++) 293 for(i=1; i<=fehlpos; i++) 294 294 { 295 295 SORT=gen(2); 296 296 for (j=3;j<=ROW;j++) 297 { 297 { 298 298 SORT=SORT,gen(j); 299 299 } … … 308 308 fehlpos=0; 309 309 while( size(transpose(STD))+fehlpos-ncols(STDMM) < 0) 310 { 310 { 311 311 for(i=1; i<=ncols(STDMM); i++) 312 312 { … … 319 319 int fehlposr=fehlpos; 320 320 321 for(i=1; i<=fehlpos; i++) 321 for(i=1; i<=fehlpos; i++) 322 322 { 323 323 SORT=gen(2); … … 328 328 TrafoL=SORT*TrafoL; 329 329 } 330 330 331 331 setring R; 332 332 map MAPinv=r,var(1); … … 338 338 matrix STDM=STD; 339 339 340 //Test 340 //Test 341 341 if(TrafoLM*m*TrafoRM!=STDM){ return(0); } 342 342 343 343 list RUECK=TrafoRM; 344 344 RUECK=insert(RUECK,STDM); … … 393 393 for(j=i+1; j<=Sort; j++) 394 394 { 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 395 GCDL=UNITL; 396 GCDR=UNITR; 397 G=gcd(STDM[i,i],STDM[j,j]); 398 ideal Z=STDM[i,i],STDM[j,j]; 399 matrix T=lift(Z,G); 400 GCDL[i,i]=T[1,1]; 401 GCDL[i,j]=T[2,1]; 402 GCDL[j,i]=-STDM[j,j]/G; 403 GCDL[j,j]=STDM[i,i]/G; 404 GCDR[i,j]=T[2,1]*STDM[j,j]/G; 405 GCDR[j,j]=T[2,1]*STDM[j,j]/G-1; 406 GCDR[j,i]=1; 407 STDM=GCDL*STDM*GCDR; 408 TrafoLM=GCDL*TrafoLM; 409 TrafoRM=TrafoRM*GCDR; 410 410 } 411 411 } … … 418 418 static proc diagonal_without_trafo( R, matrix MA, int B) 419 419 { 420 int ppl = printlevel-voice+2; 420 int ppl = printlevel-voice+2; 421 421 422 422 int BASIS=B; … … 452 452 int finish=0; 453 453 matrix STDFIN; 454 STDFIN=STD; 454 STDFIN=STD; 455 455 list COMPARE=STDFIN; 456 456 … … 463 463 dbprint(ppl,"Computing Groebner basis: finished"); 464 464 dbprint(ppl-1,STD); 465 STDFIN=STD; 465 STDFIN=STD; 466 466 /////////////////////////////////// check if the D-th row is finished /////////////////////////////////// 467 467 COMPARE=insert(COMPARE,STDFIN); 468 469 { 468 if(size(COMPARE)>=3) 469 { 470 470 if(STD==COMPARE[3]){finish=1;} 471 } 472 473 474 475 476 471 } 472 ////////////////////////////////// change to the opposite module 473 474 TSTD=transpose(STD); 475 STD=TSTD; 476 flag++; 477 477 dbprint(ppl,"Finished one while cycle"); 478 478 } … … 485 485 for(i=1; i<=ncols(STDMM); i++) 486 486 { 487 ff=0; 487 ff=0; 488 488 for(j=1; j<=nrows(STDMM); j++) 489 489 { … … 498 498 int fehlposc=fehlpos; 499 499 module SORT; 500 for(i=1; i<=fehlpos; i++) 500 for(i=1; i<=fehlpos; i++) 501 501 { 502 502 SORT=gen(2); 503 503 for (j=3;j<=ROW;j++) 504 { 504 { 505 505 SORT=SORT,gen(j); 506 506 } … … 514 514 fehlpos=0; 515 515 while( size(transpose(STD))+fehlpos-ncols(STDMM) < 0) 516 { 516 { 517 517 for(i=1; i<=ncols(STDMM); i++) 518 518 { … … 525 525 int fehlposr=fehlpos; 526 526 527 for(i=1; i<=fehlpos; i++) 527 for(i=1; i<=fehlpos; i++) 528 528 { 529 529 SORT=gen(2); … … 533 533 STD=SORT*STD; 534 534 } 535 535 536 536 //add zero rows or columns 537 537 … … 573 573 proc jacobson(matrix MA, list #) 574 574 "USAGE: jacobson(M, eng); M matrix, eng an optional int 575 RETURN: list 575 RETURN: list 576 576 ASSUME: Basering is a noncommutative ring in two variables. 577 577 PURPOSE: compute a weak Jacobson Normal Form of M over a noncommutative ring … … 585 585 EXAMPLE: example jacobson; shows examples 586 586 " 587 { 587 { 588 588 def R = basering; 589 589 // check assume: R must be a polynomial ring in 2 variables … … 626 626 def r=ring(RINGLIST); 627 627 setring r; 628 628 629 629 //fix the required ordering 630 630 map MAP=R,var(1),var(2); … … 638 638 module m=TRIANGLE[2]; 639 639 640 //back to the ring 640 //back to the ring 641 641 setring R; 642 642 map MAPR=r,var(1),var(2); … … 646 646 module TR=MAPR(TrafoR); 647 647 matrix CON=divideByContent(MAA); 648 648 649 649 list RUECK=CON*TL, CON*MAA, TR; 650 650 return(RUECK); 651 651 } 652 652 example 653 { 653 { 654 654 "EXAMPLE:"; echo = 2; 655 655 ring r = 0,(x,d),Dp; … … 663 663 def R2 = nc_algebra(1,s); setring R2; // the 1st shift algebra 664 664 matrix m[2][2] = s,x,0,s; print(m); // matrix of the same for as above 665 list J = jacobson(m); 665 list J = jacobson(m); 666 666 print(J[2]); // a Jacobson Form D, quite different from above 667 667 print(J[1]*m*J[3] - J[2]); // check that U*M*V = D … … 670 670 static proc triangle( matrix MA, int B) 671 671 { 672 int ppl = printlevel-voice+2; 672 int ppl = printlevel-voice+2; 673 673 674 674 map inv=ncdetection(); … … 713 713 module STD_EX,LT,TSTD, L, Trafo; 714 714 715 716 715 716 717 717 module STD=transpose(m); 718 718 int finish=0; … … 734 734 dbprint(ppl-1,STD); 735 735 if(flag mod 2==1){s=ROW; st=COL;}else{s=COL; st=ROW;} 736 736 737 737 STD_EX=transpose(STD_EX); 738 738 dbprint(ppl,"Computing Groebner basis for transformation matrix: start"); … … 745 745 COM_EX=1; 746 746 for(i=2; i<=size(STD); i++) 747 { COM=COM[1..size(COM)],i; COM_EX=COM_EX[1..size(COM_EX)],i; } 748 nz=size(STD_EX)-size(STD); 749 750 //zero rows in the begining 747 { COM=COM[1..size(COM)],i; COM_EX=COM_EX[1..size(COM_EX)],i; } 748 nz=size(STD_EX)-size(STD); 749 750 //zero rows in the begining 751 751 752 752 if(size(STD)!=size(STD_EX) ) … … 756 756 COM_EX=0,COM_EX[1..size(COM_EX)]; 757 757 } 758 } 759 760 761 762 758 } 759 760 761 762 763 763 for(i=nz+1; i<=size(STD_EX); i++ ) 764 {if( leadcoef(STD[i-nz])!=leadcoef(STD_EX[i]) ) 765 } 766 767 764 {if( leadcoef(STD[i-nz])!=leadcoef(STD_EX[i]) ) {STD[i-nz]=leadcoef(STD_EX[i])*STD[i-nz];} 765 } 766 767 //assign the zero rows in STD_EX 768 768 769 769 for (j=2; j<=nz; j++) 770 770 { 771 771 p=0; 772 772 i=1; 773 773 while(STD_EX[j-1][i]==0){i++;}; … … 780 780 if (k==p){ COM_EX[j]=-1; } 781 781 } 782 782 783 783 //assign the zero rows in STD 784 784 for (j=2; j<=size(STD); j++) 785 785 { 786 786 i=size(transpose(STD)); 787 787 while(STD[j-1][i]==0){i--;} 788 788 p=i; … … 796 796 if(COM[j]<0){COM=delete(COM,j);} 797 797 } 798 798 799 799 for(i=1; i<=size(COM_EX); i++) 800 800 {ff=0; … … 819 819 LT=L[1]; 820 820 821 821 822 822 for(i=2; i<=s+st; i++) 823 823 { … … 838 838 839 839 ////////////////////// compute the transformation matrices 840 840 841 841 if (flag mod 2 ==1) 842 { 842 { 843 843 TrafoL=transpose(LT)*TrafoL; 844 844 } 845 else 846 { 845 else 846 { 847 847 TrafoR=TrafoR*involution(LT,inv); 848 848 } … … 851 851 ///////////////////////// check whether the alg termined ///////////////// 852 852 if(size(COMPARE)>=3) 853 { 853 { 854 854 if(STD==COMPARE[3]){finish=1;} 855 } 855 } 856 856 ////////////////////////////////// change to the opposite module 857 857 TSTD=transpose(STD); … … 861 861 } 862 862 863 if (flag mod 2 ==0){ STD = involution(STD,inv);} else { STD = transpose(STD); } 864 863 if (flag mod 2 ==0){ STD = involution(STD,inv);} else { STD = transpose(STD); } 864 865 865 list REVERSE=TrafoL,STD,TrafoR; 866 866 return(REVERSE); … … 877 877 if(leadcoef(M[i])!=0){CON=CON+leadcoef(M[i])*gen(k); k++;} 878 878 } 879 poly con=content(CON); 879 poly con=content(CON); 880 880 matrix TL=1/con*freemodule(nrows(M)); 881 881 return(TL); … … 888 888 889 889 //static proc Ex_One_wheeled_bicycle() 890 { 890 { 891 891 ring RA=(0,m), D, lp; 892 892 matrix bicycle[2][3]=(1+m)*D^2, D^2, 1, D^2, D^2-1, 0; … … 897 897 898 898 899 //static proc Ex_RLC-circuit() 899 //static proc Ex_RLC-circuit() 900 900 { 901 901 ring RA=(0,m,R1,R2,L,C), D, lp; … … 946 946 /* 947 947 948 //static proc Ex_compare_output_with_maple_package_JanetOre() 949 { 948 //static proc Ex_compare_output_with_maple_package_JanetOre() 949 { 950 950 ring w = 0,(x,d),Dp; 951 951 def W=nc_algebra(1,1); 952 952 setring W; 953 matrix m[3][3]=[d2,d+1,0],[d+1,0,d3-x2*d],[2d+1, d3+d2, d2]; 953 matrix m[3][3]=[d2,d+1,0],[d+1,0,d3-x2*d],[2d+1, d3+d2, d2]; 954 954 list J=jacobson(m,0); 955 print(J[1]*m*J[3]); 955 print(J[1]*m*J[3]); 956 956 print(J[2]); 957 957 print(J[1]); … … 965 965 def W=nc_algebra(1,s); 966 966 setring W; 967 matrix m[3][3]=[s^2,s+1,0],[s+1,0,s^3-x^2*s],[2*s+1, s^3+s^2, s^2]; 967 matrix m[3][3]=[s^2,s+1,0],[s+1,0,s^3-x^2*s],[2*s+1, s^3+s^2, s^2]; 968 968 list J=jacobson(m,0); 969 print(J[1]*m*J[3]); 969 print(J[1]*m*J[3]); 970 970 print(J[2]); 971 971 print(J[1]); … … 975 975 976 976 //static proc Ex_cyclic() 977 { 977 { 978 978 ring w = 0,(x,d),Dp; 979 979 def W=nc_algebra(1,1); … … 981 981 matrix m[3][3]=d,0,0,x*d+1,d,0,0,x*d,d; 982 982 list J=jacobson(m,0); 983 print(J[1]*m*J[3]); 983 print(J[1]*m*J[3]); 984 984 print(J[2]); 985 985 print(J[1]); … … 995 995 matrix m[3][3]=s,0,0,x*s+1,s,0,0,x*s,s; 996 996 list J=jacobson(m,0); 997 print(J[1]*m*J[3]); 997 print(J[1]*m*J[3]); 998 998 print(J[2]); 999 999 print(J[1]); … … 1010 1010 matrix m[3][3]=s,0,0,x*s+s,s,0,0,x*s,s; 1011 1011 list J=jacobson(m,0); 1012 print(J[1]*m*J[3]); 1012 print(J[1]*m*J[3]); 1013 1013 print(J[2]); 1014 1014 print(J[1]); -
Singular/LIB/latex.lib
r95edd5 r7f3ad4 1 1 /////////////////////////////////////////////////////////////////////////////// 2 version="$Id: latex.lib,v 1. 29 2007-06-20 22:30:41 levandovExp $";2 version="$Id: latex.lib,v 1.30 2009-01-14 16:07:05 Singular Exp $"; 3 3 category="Visualization"; 4 4 info=" … … 677 677 if (size(#)==1) 678 678 { if (typeof(#[1])=="int" or typeof(#[1])=="intvec" or typeof(#[1])=="vector" 679 or typeof(#[1])=="number" or typeof(#[1])=="bigint" or defined(TeXaligned)) 680 { DA = D; DE = D; } 679 or typeof(#[1])=="number" or typeof(#[1])=="bigint" or defined(TeXaligned)) 680 { DA = D; DE = D; } 681 681 } 682 682 … … 696 696 else {s = s + obj + newline;} 697 697 } 698 if (typeof(obj) == "int" or typeof(#[1])=="bigint") 698 if (typeof(obj) == "int" or typeof(#[1])=="bigint") 699 699 { s = s + " " + string(obj) + " ";} 700 700 … … 1594 1594 //if(defined(TeXreplace)){ short =0;} // hier ueberfluessig 31.5.07 1595 1595 if (short) 1596 { j = 0; // 31.5.07 1596 { j = 0; // 31.5.07 1597 1597 while(s[i]<>"!") 1598 1598 { b=i; if (s[i]=="+" or s[i]=="-") {j++;} // 31.5.07 -
Singular/LIB/matrix.lib
r95edd5 r7f3ad4 1 1 /////////////////////////////////////////////////////////////////////////////// 2 version="$Id: matrix.lib,v 1.4 5 2008-12-08 14:31:46 motsakExp $";2 version="$Id: matrix.lib,v 1.46 2009-01-14 16:07:05 Singular Exp $"; 3 3 category="Linear Algebra"; 4 4 info=" … … 30 30 rowred(A[,any]); reduction of matrix A with elementary row-operations 31 31 colred(A[,any]); reduction of matrix A with elementary col-operations 32 linear_relations(E); find linear relations between homogeneous vectors 32 linear_relations(E); find linear relations between homogeneous vectors 33 33 rm_unitrow(A); remove unit rows and associated columns of A 34 34 rm_unitcol(A); remove unit columns and associated rows of A … … 37 37 exteriorBasis(n,k[,s]); basis of k-th exterior power of n-dim v.space 38 38 symmetricPower(A,k); k-th symmetric power of a module/matrix A 39 exteriorPower(A,k); k-th exterior power of a module/matrix A 39 exteriorPower(A,k); k-th exterior power of a module/matrix A 40 40 (parameters in square brackets [] are optional) 41 41 "; … … 910 910 "USAGE: linear_relations(M); 911 911 M: a module 912 ASSUME: All non-zero entries of M are homogeneous polynomials of the same 913 positife degree. The base field must be an exact field (not real 912 ASSUME: All non-zero entries of M are homogeneous polynomials of the same 913 positife degree. The base field must be an exact field (not real 914 914 or complex). 915 915 It is not checked whether these assumptions hold. … … 957 957 pmat(REL); 958 958 pmat(M*REL); 959 } 959 } 960 960 961 961 ////////////////////////////////////////////////////////////////////////////// … … 1078 1078 proc symmetricBasis(int n, int k, list #) 1079 1079 "USAGE: symmetricBasis(n, k[,s]); n int, k int, s string 1080 RETURN: ring, poynomial ring containing the ideal \"symBasis\", 1080 RETURN: ring, poynomial ring containing the ideal \"symBasis\", 1081 1081 being a basis of the k-th symmetric power of an n-dim vector space. 1082 NOTE: The output polynomial ring has characteristics 0 and n variables 1082 NOTE: The output polynomial ring has characteristics 0 and n variables 1083 1083 named \"S(i)\", where the base variable name S is either given by the 1084 1084 optional string argument(which must not contain brackets) or equal to … … 1099 1099 if( (find(S, "(") + find(S, ")")) > 0 ) 1100 1100 { 1101 ERROR("Wrong optional argument: must be a string without brackets"); 1101 ERROR("Wrong optional argument: must be a string without brackets"); 1102 1102 } 1103 1103 } … … 1117 1117 1118 1118 // basis of the 3-rd symmetricPower of a 4-dim vector space: 1119 def R = symmetricBasis(4, 3, "@e"); setring R; 1119 def R = symmetricBasis(4, 3, "@e"); setring R; 1120 1120 R; // container ring: 1121 1121 symBasis; // symmetric basis: … … 1126 1126 proc exteriorBasis(int n, int k, list #) 1127 1127 "USAGE: exteriorBasis(n, k[,s]); n int, k int, s string 1128 RETURN: qring, an exterior algebra containing the ideal \"extBasis\", 1128 RETURN: qring, an exterior algebra containing the ideal \"extBasis\", 1129 1129 being a basis of the k-th exterior power of an n-dim vector space. 1130 NOTE: The output polynomial ring has characteristics 0 and n variables 1130 NOTE: The output polynomial ring has characteristics 0 and n variables 1131 1131 named \"S(i)\", where the base variable name S is either given by the 1132 1132 optional string argument(which must not contain brackets) or equal to … … 1147 1147 if( (find(S, "(") + find(S, ")")) > 0 ) 1148 1148 { 1149 ERROR("Wrong optional argument: must be a string without brackets"); 1149 ERROR("Wrong optional argument: must be a string without brackets"); 1150 1150 } 1151 1151 } … … 1165 1165 { "EXAMPLE:"; echo = 2; 1166 1166 // basis of the 3-rd symmetricPower of a 4-dim vector space: 1167 def r = exteriorBasis(4, 3, "@e"); setring r; 1167 def r = exteriorBasis(4, 3, "@e"); setring r; 1168 1168 r; // container ring: 1169 1169 extBasis; // exterior basis: … … 1194 1194 rings Tn is source- and Tm is image-ring with bases 1195 1195 resp. Ink and Imk. 1196 M = max dim of Image, N - dim. of source 1196 M = max dim of Image, N - dim. of source 1197 1197 SEE ALSO: symmetricPower, exteriorPower" 1198 1198 { … … 1206 1206 1207 1207 //------------------------- compute matrix of single images ------------------ 1208 def Rm = save + Tm; setring Rm; 1208 def Rm = save + Tm; setring Rm; 1209 1209 dbprint(p-2, "Temporary Working Ring", Rm); 1210 1210 … … 1228 1228 //------------------------- compute image --------------------- 1229 1229 // apply S^k(A): Tn -> Rm to Source basis vectors Ink: 1230 map TMap = Tn, B; 1231 1232 ideal C = NF(TMap(Ink), std(0)); 1230 map TMap = Tn, B; 1231 1232 ideal C = NF(TMap(Ink), std(0)); 1233 1233 dbprint(p-1, "Image Matrix: ", C); 1234 1234 … … 1273 1273 "USAGE: symmetricPower(A, k); A module, k int 1274 1274 RETURN: module: the k-th symmetric power of A 1275 NOTE: the chosen bases and most of intermediate data will be shown if 1275 NOTE: the chosen bases and most of intermediate data will be shown if 1276 1276 printlevel is big enough 1277 1277 SEE ALSO: exteriorPower … … 1303 1303 1304 1304 //------------------------- compute and return S^k(A) in chosen bases -- 1305 setring save; 1305 setring save; 1306 1306 1307 1307 return(mapPower(p, A, k, Tn, Tm)); … … 1332 1332 "USAGE: exteriorPower(A, k); A module, k int 1333 1333 RETURN: module: the k-th exterior power of A 1334 NOTE: the chosen bases and most of intermediate data will be shown if 1334 NOTE: the chosen bases and most of intermediate data will be shown if 1335 1335 printlevel is big enough. Last rows will be invisible if zero. 1336 1336 SEE ALSO: symmetricPower … … 1366 1366 example 1367 1367 { "EXAMPLE:"; echo = 2; 1368 ring r = (0),(a, b, c, d, e, f), dp; 1368 ring r = (0),(a, b, c, d, e, f), dp; 1369 1369 r; "base ring:"; 1370 1370 1371 module B = a*gen(1) + c*gen(2) + e*gen(3), 1372 b*gen(1) + d*gen(2) + f*gen(3), 1371 module B = a*gen(1) + c*gen(2) + e*gen(3), 1372 b*gen(1) + d*gen(2) + f*gen(3), 1373 1373 e*gen(1) + f*gen(3); 1374 1374 1375 1375 print(B); 1376 print(exteriorPower(B, 2)); 1377 print(exteriorPower(B, 3)); 1376 print(exteriorPower(B, 2)); 1377 print(exteriorPower(B, 3)); 1378 1378 1379 1379 def g = SuperCommutative(); setring g; g; … … 1384 1384 print(exteriorPower(A, 2)); 1385 1385 1386 module B = a*gen(1) + c*gen(2) + e*gen(3), 1387 b*gen(1) + d*gen(2) + f*gen(3), 1386 module B = a*gen(1) + c*gen(2) + e*gen(3), 1387 b*gen(1) + d*gen(2) + f*gen(3), 1388 1388 e*gen(1) + f*gen(3); 1389 1389 print(B); -
Singular/LIB/nchomolog.lib
r95edd5 r7f3ad4 1 version="$Id: nchomolog.lib,v 1. 8 2008-08-07 21:15:02 levandovExp $";1 version="$Id: nchomolog.lib,v 1.9 2009-01-14 16:07:05 Singular Exp $"; 2 2 category="Noncommutative"; 3 3 info=" … … 168 168 ring A=0,(x,t,dx,dt),dp; 169 169 def W = Weyl(); setring W; 170 matrix M[2][2] = 170 matrix M[2][2] = 171 171 dt, dx, 172 172 t*dx,x*dt; … … 226 226 "{ 227 227 if (i==0) 228 { 228 { 229 229 return(ncHom_R(Ps)); // the rest is not needed 230 230 } … … 512 512 // assumed to be basering 513 513 // returns the difference between M and Ext^n_D(Ext^n_D(M,D),D) 514 def save = basering; 514 def save = basering; 515 515 setring save; 516 516 module Md = ncExt_R(n,M); // right module … … 537 537 ring R = 0,(x,y),dp; 538 538 poly F = x3-y2; 539 def A = annfs(F); 539 def A = annfs(F); 540 540 setring A; 541 541 dmodualtest(LD,2); … … 544 544 545 545 proc dmodoublext(module M, list #) 546 "USAGE: dmodoublext(M [,i]); M module, i optional int 546 "USAGE: dmodoublext(M [,i]); M module, i optional int 547 547 COMPUTE: a presentation of Ext^i(Ext^i(M,D),D); for basering D 548 548 RETURN: left module … … 553 553 { 554 554 // assume: basering is a Weyl algebra? 555 def save = basering; 555 def save = basering; 556 556 setring save; 557 557 // if a list is nonempty and contains an integer N, n = N; otherwise n = nvars/2 … … 572 572 n = nvars(save); n = n div 2; 573 573 } 574 // returns Ext^i_D(Ext^i_D(M,D),D), that is 574 // returns Ext^i_D(Ext^i_D(M,D),D), that is 575 575 // computes the "dual" of the "dual" of a d-mod M (for n = nvars/2) 576 576 module Md = ncExt_R(n,M); // right module … … 602 602 ring R = 0,(x,y),dp; 603 603 poly F = x3-y2; 604 def A = annfs(F); 604 def A = annfs(F); 605 605 setring A; 606 606 dmodoublext(LD); -
Singular/LIB/nctools.lib
r95edd5 r7f3ad4 1 1 /////////////////////////////////////////////////////////////////////////////// 2 version="$Id: nctools.lib,v 1. 39 2008-04-23 14:06:10 motsakExp $";2 version="$Id: nctools.lib,v 1.40 2009-01-14 16:07:05 Singular Exp $"; 3 3 category="Noncommutative"; 4 4 info=" … … 156 156 execute (newringstring); 157 157 def lnewring=imap(r,lr); 158 return( nc_algebra(lnewring[1],lnewring[2]) ); 158 return( nc_algebra(lnewring[1],lnewring[2]) ); 159 159 } 160 160 else … … 491 491 D[1,3]=2*x; 492 492 D[2,3]=-2*y; 493 def S = nc_algebra(1,D); setring S; 493 def S = nc_algebra(1,D); setring S; 494 494 S; // this is U(sl_2) 495 495 poly c = 4*x*y+z^2-2*z; … … 595 595 matrix D[3][3]; 596 596 D[1,2]=x; D[1,3]=z; 597 def S = nc_algebra(C,D); setring S; 597 def S = nc_algebra(C,D); setring S; 598 598 S; 599 599 ideal j=ndcond(); // the silent version … … 664 664 "EXAMPLE:";echo=2; 665 665 ring A1=0,(x(1..2),d(1..2)),dp; 666 def S=Weyl(); 666 def S=Weyl(); 667 667 setring S; S; 668 668 kill A1,S; … … 722 722 RETURN: qring 723 723 PURPOSE: create the super-commutative algebra (as a GR-algebra) 'over' a basering, 724 NOTE: activate this qring with the \"setring\" command. 724 NOTE: activate this qring with the \"setring\" command. 725 725 NOTE: if b==e then the resulting ring is commutative unles 'flag' is given and non-zero. 726 726 THEORY: given a basering, this procedure introduces the anticommutative relations x(j)x(i)=-x(i)x(j) for all e>=j>i>=b, … … 732 732 // NOTE: as a side effect the basering will be changed (if not in a commutative case) to bo the ground G-algebra (without factor). 733 733 int fprot = (find(option(),"prot") != 0); 734 734 735 735 string rname=nameof(basering); 736 736 737 737 if ( rname == "basering") // i.e. no ring has been set yet 738 738 { … … 742 742 743 743 def saveRing = basering; 744 744 745 745 int N = nvars(saveRing); 746 746 int b = 1; 747 747 int e = N; 748 748 int flag = 0; 749 749 750 750 ideal Q = 0; 751 751 … … 756 756 ERROR("The argument 'b' must be an integer!"); 757 757 return(); 758 } 758 } 759 759 b = #[1]; 760 760 … … 763 763 ERROR("The argument 'b' must within [1..nvars(basering)]!"); 764 764 return(); 765 } 766 765 } 766 767 767 } 768 768 … … 781 781 return(); 782 782 } 783 783 784 784 if(e < b) 785 785 { … … 798 798 Q = #[3]; 799 799 } 800 800 801 801 if(size(#)>3) 802 802 { … … 809 809 } 810 810 811 int iSavedDegBoung = degBound; 811 int iSavedDegBoung = degBound; 812 812 813 813 if( (b == e) && (flag == 0) ) // commutative ring!!! … … 817 817 print("Warning: (b==e) means that the resulting ring will be commutative!"); 818 818 } 819 819 820 820 degBound=0; 821 821 Q = std(Q + (var(b)^2)); 822 822 degBound = iSavedDegBoung; 823 823 824 824 qring @EA = Q; // and it will be internally commutative as well!!! 825 826 return(@EA); 825 826 return(@EA); 827 827 } 828 828 829 829 /* 830 // Singular'(H.S.) politics: no ring copies! 830 // Singular'(H.S.) politics: no ring copies! 831 831 // in future nc_algebra() should return a new ring!!! 832 832 list CurrRing = ringlist(basering); … … 841 841 print("Warning: (char == 2) means that the resulting ring will be commutative!"); 842 842 } 843 843 844 844 int j = ncols(Q) + 1; 845 845 846 846 for ( int i=e; i>=b; i--, j++ ) 847 847 { 848 848 Q[j] = var(i)^2; 849 849 } 850 851 degBound=0; 850 851 degBound=0; 852 852 Q = std(Q); 853 853 degBound = iSavedDegBoung; 854 854 855 855 qring @EA = Q; // and it will be internally commutative as well!!! 856 return(@EA); 857 } 858 856 return(@EA); 857 } 858 859 859 860 860 int i, j; 861 861 862 862 if( (b == 1) && (e == N) ) // just an exterior algebra? 863 { 863 { 864 864 def S = nc_algebra(-1, 0); // define ground G-algebra! 865 setring S; 865 setring S; 866 866 } else 867 867 { 868 868 matrix @E = UpOneMatrix(N); 869 869 870 870 for ( i = b; i < e; i++ ) 871 871 { … … 880 880 881 881 ideal @Q = fetch(saveRing, Q); 882 882 883 883 j = ncols(@Q) + 1; 884 884 … … 894 894 } 895 895 896 degBound=0; 896 degBound=0; 897 897 @Q = twostd(@Q); // must be computed within the ground G-algebra => problems with local orderings! 898 898 degBound = iSavedDegBoung; 899 899 900 900 qring @EA = @Q; 901 901 … … 945 945 return("SCA rings are factors by (at least) squares!"); // no squares in the factor ideal! 946 946 } 947 947 948 948 list L = ringlist(saveRing); 949 949 … … 960 960 { 961 961 if( (fprot == 1) and (i > 1) ) 962 { 962 { 963 963 print("Warning: the SCA representation of the current commutative factor ring may be ambiguous!"); 964 964 } 965 965 966 966 return( list(i, i) ); // this is not unique in this case! there may be other squares in the factor ideal! 967 967 } 968 } 968 } 969 969 970 970 return("The current commutative ring is not SCA! (Wrong quotient ideal)"); // no squares in the factor ideal! … … 991 991 if(i < b) 992 992 { 993 b = i; 993 b = i; 994 994 } 995 995 996 996 if(j > e) 997 997 { 998 e = j; 998 e = j; 999 999 } 1000 1000 } else … … 1020 1020 { 1021 1021 if( (fprot == 1) and (i > 1) ) 1022 { 1022 { 1023 1023 print("Warning: the SCA representation of the current factor ring may be ambiguous!"); 1024 1024 } 1025 1025 1026 1026 return( list(i, i) ); // this is not unique in this case! there may be other squares in the factor ideal! 1027 1027 } … … 1183 1183 1184 1184 def S = nc_algebra(E,0); setring S; S; 1185 1185 1186 1186 if(IsSCA()) 1187 1187 { "Alternating variables: [", AltVarStart(), ",", AltVarEnd(), "]."; } -
Singular/LIB/polymake.lib
r95edd5 r7f3ad4 1 version="$Id: polymake.lib,v 1. 9 2008-08-29 15:16:49 keilenExp $";1 version="$Id: polymake.lib,v 1.10 2009-01-14 16:07:05 Singular Exp $"; 2 2 category="Tropical Geometry"; 3 3 info=" … … 7 7 WARNING: 8 8 Most procedures will not work unless polymake or topcom is installed and 9 if so, they will only work with the operating system LINUX! 9 if so, they will only work with the operating system LINUX! 10 10 For more detailed information see IMPORTANT NOTE respectively consult the 11 11 help string of the procedures. 12 12 13 13 IMPORTANT NOTE: 14 Even though this is a Singular library for computing polytopes and fans such 15 as the Newton polytope or the Groebner fan of a polynomial, most of the hard 16 computations are NOT done by Singular but by the program 14 Even though this is a Singular library for computing polytopes and fans such 15 as the Newton polytope or the Groebner fan of a polynomial, most of the hard 16 computations are NOT done by Singular but by the program 17 17 @* - polymake by Ewgenij Gawrilow, TU Berlin and Michael Joswig, TU Darmstadt 18 @* (see http://www.math.tu-berlin.de/polymake/), 18 @* (see http://www.math.tu-berlin.de/polymake/), 19 19 @* respectively (only in the procedure triangularions) by the program 20 20 @* - topcom by Joerg Rambau, Universitaet Bayreuth 21 21 @* (see http://www.uni-bayreuth.de/departments/wirtschaftsmathematik/rambau/TOPCOM); 22 @* this library should rather be seen as an interface which allows to use a (very limited) 23 number of options which polymake respectively topcom offers to compute with polytopes 24 and fans and to make the results available in Singular for further computations; 22 @* this library should rather be seen as an interface which allows to use a (very limited) 23 number of options which polymake respectively topcom offers to compute with polytopes 24 and fans and to make the results available in Singular for further computations; 25 25 moreover, the user familiar with Singular does not have to learn the syntax of polymake 26 26 or topcom, if the options offered here are sufficient for his purposes. … … 35 35 groebnerFan(poly) computes the Groebner fan of a polynomial 36 36 intmatToPolymake(intmat,string) transforms an integer matrix into polymake format 37 polymakeToIntmat(string,string) transforms polymake output into an integer matrix 37 polymakeToIntmat(string,string) transforms polymake output into an integer matrix 38 38 39 39 PROCEDURES USING TOPCOM: … … 59 59 60 60 KEYWORDS: polytope; fan; secondary fan; secondary polytope; polymake; 61 Newton polytope; Groebner fan 61 Newton polytope; Groebner fan 62 62 63 63 "; … … 99 99 RETURN: list, L with four entries 100 100 @* L[1] : an integer matrix whose rows are the coordinates of vertices 101 of the polytope 101 of the polytope 102 102 @* L[2] : the dimension of the polytope 103 103 @* L[3] : a list whose ith entry explains to which vertices the ith vertex … … 109 109 i.e. the smallest affine space containing the polytope 110 110 NOTE: - for its computations the procedure calls the program polymake by Ewgenij Gawrilow, 111 TU Berlin and Michael Joswig, TU Darmstadt; it therefore is necessary that 111 TU Berlin and Michael Joswig, TU Darmstadt; it therefore is necessary that 112 112 this program is installed in order to use this procedure; 113 113 see http://www.math.tu-berlin.de/polymake/ … … 117 117 in polymake format; if you wish to use this for further computations with polymake, 118 118 you have to use the procedure polymakeKeepTmpFiles in before 119 @* - moreover, the procedure creates the file /tmp/polytope.output which it deletes 119 @* - moreover, the procedure creates the file /tmp/polytope.output which it deletes 120 120 again before ending 121 121 @* - it is possible to give as an optional second argument as string which then will be … … 191 191 } 192 192 } 193 } 193 } 194 194 newveg=newveg[1,size(newveg)-1]; 195 195 execute("list nveg="+newveg+";"); … … 226 226 "EXAMPLE:"; 227 227 echo=2; 228 // the lattice points of the unit square in the plane 228 // the lattice points of the unit square in the plane 229 229 list points=intvec(0,0),intvec(0,1),intvec(1,0),intvec(1,1); 230 230 // the secondary polytope of this lattice point configuration is computed … … 266 266 @* - the procedure creates the file /tmp/newtonPolytope.polymake which contains the polytope 267 267 in polymake format and which can be used for further computations with polymake 268 @* - moreover, the procedure creates the file /tmp/newtonPolytope.output which it deletes 268 @* - moreover, the procedure creates the file /tmp/newtonPolytope.output which it deletes 269 269 again before ending 270 270 @* - it is possible to give as an optional second argument as string which then will be … … 303 303 np[2]; 304 304 // np[3] contains information how the vertices are connected to each other, 305 // e.g. the first vertex (number 0) is connected to the second, third and 305 // e.g. the first vertex (number 0) is connected to the second, third and 306 306 // fourth vertex 307 307 np[3][1]; … … 313 313 np[1]; 314 314 // its dimension is 315 np[2]; 316 // the Newton polytope is contained in the affine space given 315 np[2]; 316 // the Newton polytope is contained in the affine space given 317 317 // by the equations 318 318 np[4]*M; … … 348 348 "USAGE: normalFan (vert,aff,graph,rays,[,#]); vert,aff intmat, graph list, rays int, # string 349 349 ASSUME: - vert is an integer matrix whose rows are the coordinate of the vertices of 350 a convex lattice polygon; 350 a convex lattice polygon; 351 351 @* - aff describes the affine hull of this polytope, i.e. 352 the smallest affine space containing it, in the following sense: 353 denote by n the number of columns of vert, then multiply aff by (1,x(1),...,x(n)) 352 the smallest affine space containing it, in the following sense: 353 denote by n the number of columns of vert, then multiply aff by (1,x(1),...,x(n)) 354 354 and set the resulting terms to zero in order to get the equations for the affine hull; 355 355 @* - the ith entry of graph is an integer vector describing to which vertices … … 357 357 connected to vert[k]; 358 358 @* - the integer rays is either one (if the extreme rays should be computed) or zero (otherwise) 359 RETURN: list, the ith entry of L[1] contains information about the cone in the normal fan 360 dual to the ith vertex of the polytope 359 RETURN: list, the ith entry of L[1] contains information about the cone in the normal fan 360 dual to the ith vertex of the polytope 361 361 @* L[1][i][1] = integer matrix representing the inequalities which describe the 362 362 cone dual to the ith vertex … … 370 370 TU Berlin and Michael Joswig, so it only works if polymake is installed; 371 371 see http://www.math.tu-berlin.de/polymake/ 372 @* - in the optional argument # it is possible to hand over other names for the 372 @* - in the optional argument # it is possible to hand over other names for the 373 373 variables to be used -- be carful, the format must be correct and that is 374 374 not tested, e.g. if you want the variable names to be u00,u10,u01,u11 … … 378 378 list ineq; // stores the inequalities of the cones 379 379 int i,j,k; 380 // we work over the following ring 380 // we work over the following ring 381 381 execute("ring ineqring=0,x(1.."+string(ncols(vertices))+"),lp;"); 382 382 string greatersign=">"; … … 403 403 for (i=1;i<=nrows(vertices);i++) 404 404 { 405 // first we produce for each vertex in the polytope 405 // first we produce for each vertex in the polytope 406 406 // the inequalities describing the dual cone in the normal fan 407 407 list pp; // contain strings representing the inequalities describing the normal cone … … 489 489 } 490 490 // get the linearity space 491 return(list(ineq,linearity)); 491 return(list(ineq,linearity)); 492 492 } 493 493 example … … 516 516 proc groebnerFan (poly f,list #) 517 517 "USAGE: groebnerFan(f[,#]); f poly, # string 518 RETURN: list, the ith entry of L[1] contains information about the ith cone in the Groebner fan 518 RETURN: list, the ith entry of L[1] contains information about the ith cone in the Groebner fan 519 519 dual to the ith vertex in the Newton polytope of the f 520 @* L[1][i][1] = integer matrix representing the inequalities which describe the cone 520 @* L[1][i][1] = integer matrix representing the inequalities which describe the cone 521 521 @* L[1][i][2] = a list which contains the inequalities represented by L[1][i][1] 522 522 as a list of strings 523 523 @* L[1][i][3] = an interger matrix whose rows are the extreme rays of the cone 524 524 @* L[2] = is an integer matrix whose rows span the linearity space of the fan, 525 i.e. the linear space which is contained in each cone 525 i.e. the linear space which is contained in each cone 526 526 @* L[3] = the Newton polytope of f in the format of the procedure newtonPolytope 527 527 @* L[4] = integer matrix where each row represents the exponet vector of one monomial … … 533 533 TU Berlin and Michael Joswig, so it only works if polymake is installed; 534 534 see http://www.math.tu-berlin.de/polymake/ 535 @* - the procedure creates the file /tmp/newtonPolytope.polymake which contains the 536 Newton polytope of f in polymake format and which can be used for further 535 @* - the procedure creates the file /tmp/newtonPolytope.polymake which contains the 536 Newton polytope of f in polymake format and which can be used for further 537 537 computations with polymake 538 538 @* - it is possible to give as an optional second argument as string which then will be … … 605 605 ASSUME: - M is an integer matrix which should be transformed into polymake format; 606 606 @* - art is one of the following strings: 607 @* + 'rays' : indicating that a first column of 0's should be added 608 @* + 'points' : indicating that a first column of 1's should be added 607 @* + 'rays' : indicating that a first column of 0's should be added 608 @* + 'points' : indicating that a first column of 1's should be added 609 609 RETURN: string, the matrix is transformed in a string and a first column has been added 610 610 EXAMPLE: example intmatToPolymake; shows an example" … … 614 614 string anf="0 "; 615 615 } 616 else 616 else 617 617 { 618 618 string anf="1 "; … … 654 654 where each row has been multiplied with the lowest common multiple of the 655 655 denominators of its entries so as to be an integer matrix; moreover, 656 if art=='affine', then the first column is omitted since we only want affine 656 if art=='affine', then the first column is omitted since we only want affine 657 657 coordinates 658 658 EXAMPLE: example polymakeToIntmat; shows an example" … … 666 666 pm=stringdelete(pm,1); 667 667 } 668 pm=stringdelete(pm,1); 668 pm=stringdelete(pm,1); 669 669 // find out how many entries each vector has, namely one more than 'spaces' in a row 670 670 int i=1; … … 681 681 // if we want to have affine coordinates 682 682 if (art=="affine") 683 { 683 { 684 684 s--; // then there is one column less 685 685 // and the entry of the first column (in the first row) has to be removed … … 720 720 if (pm[i]==" ") 721 721 { 722 pm[i]=","; 722 pm[i]=","; 723 723 } 724 724 } … … 730 730 } 731 731 // since the matrix could be over the rationals, we need a ring with rational coefficients 732 ring zwischering=0,x,lp; 732 ring zwischering=0,x,lp; 733 733 // create the matrix with the elements of pm as entries 734 734 execute("matrix mm["+string(z)+"]["+string(s)+"]="+pm+";"); … … 780 780 "USAGE: triangulations(polygon); list polygon 781 781 ASSUME: polygon is a list of integer vectors of the same size representing the affine 782 coordinates of the lattice points 782 coordinates of the lattice points 783 783 PURPOSE: the procedure considers the marked polytope given as the convex hull of 784 784 the lattice points and with these lattice points as markings; it then 785 computes all possible triangulations of this marked polytope 785 computes all possible triangulations of this marked polytope 786 786 RETURN: list, each entry corresponds to one triangulation and the ith entry is 787 787 itself a list of integer vectors of size three, where each integer … … 790 790 NOTE: - the procedure calls for its computations the program points2triangs 791 791 from the program topcom by Joerg Rambau, Universitaet Bayreuth; it 792 therefore is necessary that this program is installed in order to use this 792 therefore is necessary that this program is installed in order to use this 793 793 procedure; see 794 794 @* http://www.uni-bayreuth.de/departments/wirtschaftsmathematik/rambau/TOPCOM … … 799 799 you have to use the procedure polymakeKeepTmpFiles in before 800 800 @* - note that an integer i in an integer vector representing a triangle refers to 801 the ith lattice point, i.e. polygon[i]; this convention is different from 801 the ith lattice point, i.e. polygon[i]; this convention is different from 802 802 TOPCOM's convention, where i would refer to the i-1st lattice point 803 803 EXAMPLE: example triangulations; shows an example" 804 804 { 805 805 int i,j; 806 // prepare the input for points2triangs by writing the input polygon in the 806 // prepare the input for points2triangs by writing the input polygon in the 807 807 // necessary format 808 808 string spi="["; … … 847 847 } 848 848 else 849 { 849 { 850 850 np2t=np2t+p2t[i]; 851 851 } … … 859 859 { 860 860 if (np2t[size(np2t)]!=";") 861 { 861 { 862 862 np2t=np2t+p2t[size(p2t)-1]+p2t[size(p2t)]; 863 863 } … … 881 881 np2t=np2t+"))"; 882 882 i++; 883 } 883 } 884 884 else 885 885 { … … 919 919 "EXAMPLE:"; 920 920 echo=2; 921 // the lattice points of the unit square in the plane 921 // the lattice points of the unit square in the plane 922 922 list polygon=intvec(0,0),intvec(0,1),intvec(1,0),intvec(1,1); 923 923 // the triangulations of this lattice point configuration are computed … … 935 935 PURPOSE: the procedure considers the marked polytope given as the convex hull of 936 936 the lattice points and with these lattice points as markings; it then 937 computes the lattice points of the secondary polytope given by this 937 computes the lattice points of the secondary polytope given by this 938 938 marked polytope which correspond to the triangulations computed by 939 939 the procedure triangulations 940 940 RETURN: list, say L, such that: 941 @* L[1] = intmat, each row gives the affine coordinates of a lattice point 941 @* L[1] = intmat, each row gives the affine coordinates of a lattice point 942 942 in the secondary polytope given by the marked 943 943 polytope corresponding to polygon 944 944 @* L[2] = the list of corresponding triangulations 945 NOTE: if the triangluations are not handed over as optional argument the procedure calls 945 NOTE: if the triangluations are not handed over as optional argument the procedure calls 946 946 for its computation of these triangulations the program points2triangs 947 947 from the program topcom by Joerg Rambau, Universitaet Bayreuth; it 948 therefore is necessary that this program is installed in order to use this 948 therefore is necessary that this program is installed in order to use this 949 949 procedure; see 950 950 @* http://www.uni-bayreuth.de/departments/wirtschaftsmathematik/rambau/TOPCOM … … 995 995 secpoly[i,1..size(polygon)]=vertex; 996 996 } 997 return(list(secpoly,triangs)); 997 return(list(secpoly,triangs)); 998 998 } 999 999 example … … 1024 1024 PURPOSE: the procedure considers the marked polytope given as the convex hull of 1025 1025 the lattice points and with these lattice points as markings; it then 1026 computes the lattice points of the secondary polytope given by this 1026 computes the lattice points of the secondary polytope given by this 1027 1027 marked polytope which correspond to the triangulations computed by 1028 1028 the procedure triangulations 1029 RETURN: list, the ith entry of L[1] contains information about the ith cone in the 1029 RETURN: list, the ith entry of L[1] contains information about the ith cone in the 1030 1030 secondary fan of the polygon, i.e. the cone dual to the ith vertex of the 1031 1031 secondary polytope … … 1039 1039 i.e. the linear space which is contained in each cone 1040 1040 @* L[3] = the secondary polytope in the format of the procedure polymakePolytope 1041 @* L[4] = the list of triangulations corresponding to the vertices 1041 @* L[4] = the list of triangulations corresponding to the vertices 1042 1042 of the secondary polytope 1043 1043 NOTE: - the procedure calls for its computation polymake by Ewgenij Gawrilow, 1044 1044 TU Berlin and Michael Joswig, so it only works if polymake is installed; 1045 1045 see http://www.math.tu-berlin.de/polymake/ 1046 @* - in the optional argument # it is possible to hand over other names for the 1046 @* - in the optional argument # it is possible to hand over other names for the 1047 1047 variables to be used -- be carful, the format must be correct and that is 1048 1048 not tested, e.g. if you want the variable names to be u00,u10,u01,u11 1049 1049 then you must hand over the string u11,u10,u01,u11 1050 @* - if the triangluations are not handed over as optional argument the procedure calls 1050 @* - if the triangluations are not handed over as optional argument the procedure calls 1051 1051 for its computation of these triangulations the program points2triangs 1052 1052 from the program topcom by Joerg Rambau, Universitaet Bayreuth; it 1053 therefore is necessary that this program is installed in order to use this 1053 therefore is necessary that this program is installed in order to use this 1054 1054 procedure; see 1055 1055 @* http://www.uni-bayreuth.de/departments/wirtschaftsmathematik/rambau/TOPCOM … … 1143 1143 // interior is a lattice point in the interior of this lattice polygon 1144 1144 intvec interior=1,1; 1145 // compute the general cycle length of a cycle of the corresponding cycle 1145 // compute the general cycle length of a cycle of the corresponding cycle 1146 1146 // in the dual tropical curve, note that (0,1) and (2,1) do not contribute 1147 1147 cycleLength(boundary,interior); … … 1162 1162 @* L[2][i][j][1] = intvec, the coordinates of the jth lattice point on that facet 1163 1163 @* L[2][i][j][2] = int, the position of L[2][i][j][1] in markings 1164 @* L[3] : represents the interior lattice points of the polygon 1164 @* L[3] : represents the interior lattice points of the polygon 1165 1165 @* L[3][i][1] = intvec, the coordinates of the ith interior point 1166 1166 @* L[3][i][2] = int, the position of L[3][i][1] in markings … … 1247 1247 } 1248 1248 vert[3][i]=list(vert[3][i],j); 1249 } 1249 } 1250 1250 return(vert); 1251 1251 } … … 1254 1254 "EXAMPLE:"; 1255 1255 echo=2; 1256 // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 1256 // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 1257 1257 // with all integer points as markings 1258 1258 list polygon=intvec(1,1),intvec(3,0),intvec(2,0),intvec(1,0), … … 1272 1272 proc eta (list triang,list polygon) 1273 1273 "USAGE: eta(triang,polygon); triang, polygon list 1274 ASSUME: polygon has the format of the output of splitPolygon, i.e. it is a list with three 1274 ASSUME: polygon has the format of the output of splitPolygon, i.e. it is a list with three 1275 1275 entries describing a convex lattice polygon in the following way: 1276 1276 @* polygon[1] : is a list of lists; for each i the entry polygon[1][i][1] is a lattice point which is … … 1289 1289 polygon described by polygon; if an entry of triang is the vector (i,j,k) then the triangle 1290 1290 is build by the vertices with indices i, j and k 1291 RETURN: intvec, the integer vector eta describing that vertex of the Newton polytope discriminant 1292 of the polygone whose dual cone in the Groebner fan contains the cone of the 1291 RETURN: intvec, the integer vector eta describing that vertex of the Newton polytope discriminant 1292 of the polygone whose dual cone in the Groebner fan contains the cone of the 1293 1293 secondary fan of the polygon corresponding to the given triangulation 1294 NOTE: for a better description of eta see either Gelfand, Kapranov, Zelevinski: Discriminants, 1294 NOTE: for a better description of eta see either Gelfand, Kapranov, Zelevinski: Discriminants, 1295 1295 Resultants and multidimensional Determinants. Chapter 10. 1296 1296 EXAMPLE: example eta; shows an example" … … 1359 1359 if ((polygon[1][j][2]==triang[k][1]) or (polygon[1][j][2]==triang[k][2]) or (polygon[1][j][2]==triang[k][3])) 1360 1360 { 1361 // ... if so, add the area of the triangle to etaij 1361 // ... if so, add the area of the triangle to etaij 1362 1362 etaij=etaij+triangarea[k]; 1363 // then check if that triangle has a facet which is contained in one of the 1363 // then check if that triangle has a facet which is contained in one of the 1364 1364 // two facets of the polygon which are adjecent to the given vertex ... 1365 1365 // these two facets are seiten[j] and seiten[j+1] … … 1393 1393 { 1394 1394 for (j=1;j<=size(polygon[2][i]);j++) 1395 { 1395 { 1396 1396 // initialise etaij 1397 1397 etaij=0; … … 1404 1404 if ((polygon[2][i][j][2]==triang[k][1]) or (polygon[2][i][j][2]==triang[k][2]) or (polygon[2][i][j][2]==triang[k][3])) 1405 1405 { 1406 // ... if so, add the area of the triangle to etaij 1406 // ... if so, add the area of the triangle to etaij 1407 1407 etaij=etaij+triangarea[k]; 1408 // then check if that triangle has a facet which is contained in the 1408 // then check if that triangle has a facet which is contained in the 1409 1409 // facet of the polygon which contains the lattice point in question, 1410 1410 // this is the facet seiten[i+1]; … … 1414 1414 // ... and for each lattice point in the triangle ... 1415 1415 for (m=1;m<=size(triang[k]);m++) 1416 { 1416 { 1417 1417 // ... if they coincide and are not the vertex itself ... 1418 1418 if ((seiten[i+1][l][2]==triang[k][m]) and (seiten[i+1][l][2]!=polygon[2][i][j][2])) … … 1451 1451 if ((polygon[3][j][2]==triang[k][1]) or (polygon[3][j][2]==triang[k][2]) or (polygon[3][j][2]==triang[k][3])) 1452 1452 { 1453 // ... if so, add the area of the triangle to etaij 1453 // ... if so, add the area of the triangle to etaij 1454 1454 etaij=etaij+triangarea[k]; 1455 1455 } … … 1464 1464 "EXAMPLE:"; 1465 1465 echo=2; 1466 // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 1466 // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 1467 1467 // with all integer points as markings 1468 1468 list polygon=intvec(1,1),intvec(3,0),intvec(2,0),intvec(1,0), … … 1471 1471 // split the polygon in its vertices, its facets and its interior points 1472 1472 list sp=splitPolygon(polygon); 1473 // define a triangulation by connecting the only interior point 1473 // define a triangulation by connecting the only interior point 1474 1474 // with the vertices 1475 1475 list triang=intvec(1,2,5),intvec(1,5,10),intvec(1,5,10); … … 1477 1477 eta(triang,sp); 1478 1478 } 1479 1479 1480 1480 proc findOrientedBoundary (list polygon) 1481 1481 "USAGE: findOrientedBoundary(polygon); polygon list … … 1517 1517 // compute their pairwise angles and their lengths 1518 1518 for (i=1;i<=size(polygon)-1;i++) 1519 { 1519 { 1520 1520 for (j=i+1;j<=size(polygon);j++) 1521 1521 { … … 1541 1541 polygon=sortlistbyintvec(polygon,abstand); 1542 1542 return(list(polygon,endpoints)); 1543 } 1543 } 1544 1544 /////////////////////////////////////////////////////////////// 1545 1545 list orderedvertices; // stores the vertices in an ordered way … … 1551 1551 intvec startvertex=polygon[1]; // keep the starting vertex to test, when the end is reached 1552 1552 int endtest; // is set to one, when the end is reached 1553 int startvertexfound;// is 1, once for some testvertex a candidate for the next vertex has been found 1553 int startvertexfound;// is 1, once for some testvertex a candidate for the next vertex has been found 1554 1554 polygon=delete(polygon,1); // delete the testvertex 1555 1555 intvec v,w; … … 1577 1577 // therefore find a vertex in the interior as candidate; but always testing against 1578 1578 // the starting vertex, this can not happen 1579 comparevertices[size(comparevertices)+1]=startvertex; 1579 comparevertices[size(comparevertices)+1]=startvertex; 1580 1580 for (j=1;(j<=size(comparevertices)) and (d<=0);j++) 1581 1581 { … … 1591 1591 } 1592 1592 if (size(naechste)>0) // then a candidate for the next vertex has been found 1593 { 1593 { 1594 1594 startvertexfound=1; // at least once a candidate has been found 1595 1595 naechste=sortlist(naechste,3); //we order the candidates according to their distance from testvertex; … … 1607 1607 } 1608 1608 } 1609 else // that means either that the vertex was inside the polygon, 1609 else // that means either that the vertex was inside the polygon, 1610 1610 { // or that we have reached the last vertex on the boundary of the polytope 1611 1611 if (startvertexfound==0) // the vertex was in the interior; we delete it and start all over again 1612 { 1613 orderedvertices[1]=polygon[1]; 1614 minimisedorderedvertices[1]=polygon[1]; 1612 { 1613 orderedvertices[1]=polygon[1]; 1614 minimisedorderedvertices[1]=polygon[1]; 1615 1615 testvertex=polygon[1]; 1616 1616 startvertex=polygon[1]; … … 1673 1673 computes all marked points in points which ly on the boundary of that polygon, ordered 1674 1674 clockwise 1675 RETURN: list, of integer vectors which are the coordinates of the lattice points on 1675 RETURN: list, of integer vectors which are the coordinates of the lattice points on 1676 1676 the boundary of the above mentioned polygon P, if this polygon is not the 1677 empty set (that would be the case if points[pt] is not a vertex of any 1677 empty set (that would be the case if points[pt] is not a vertex of any 1678 1678 triangle in the triangulation); otherwise return the empty list 1679 1679 EXAMPLE: example cyclePoints; shows an example" … … 1723 1723 "EXAMPLE:"; 1724 1724 echo=2; 1725 // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 1725 // the lattice polygon spanned by the points (0,0), (3,0) and (0,3) 1726 1726 // with all integer points as markings 1727 1727 list points=intvec(1,1),intvec(3,0),intvec(2,0),intvec(1,0), 1728 1728 intvec(0,0),intvec(2,1),intvec(0,1),intvec(1,2), 1729 1729 intvec(0,2),intvec(0,3); 1730 // define a triangulation 1730 // define a triangulation 1731 1731 list triang=intvec(1,2,5),intvec(1,5,7),intvec(1,7,9),intvec(8,9,10), 1732 1732 intvec(1,8,9),intvec(1,2,8); … … 1765 1765 proc picksFormula (list polygon) 1766 1766 "USAGE: picksFormula(polygon); polygon list 1767 ASSUME: polygon is a list of integer vectors in the plane and consider their convex hull C 1768 RETURN: list, L of three integersthe 1767 ASSUME: polygon is a list of integer vectors in the plane and consider their convex hull C 1768 RETURN: list, L of three integersthe 1769 1769 @* L[1] : the lattice area of C, i.e. twice the Euclidean area 1770 1770 @* L[2] : the number of lattice points on the boundary of C … … 1815 1815 proc ellipticNF (list polygon) 1816 1816 "USAGE: ellipticNF(polygon); polygon list 1817 ASSUME: polygon is a list of integer vectors in the plane such that their convex hull C 1817 ASSUME: polygon is a list of integer vectors in the plane such that their convex hull C 1818 1818 has precisely one interior lattice point; i.e. C is the Newton polygon of an 1819 1819 elliptic curve 1820 1820 PURPOSE: compute the normal form of the polygon with respect to the unimodular affine 1821 transformations T=A*x+v; there are sixteen different normal forms 1821 transformations T=A*x+v; there are sixteen different normal forms 1822 1822 (see e.g. Bjorn Poonen, Fernando Rodriguez-Villegas: Lattice Polygons and 1823 1823 the number 12. Amer. Math. Monthly 107 (2000), no. 3, 238--250.) … … 1952 1952 M=pg[max],1,pg[max+1],1,pg[max+2],1; 1953 1953 // the orientation of the polygon matters 1954 A=pg[max-1]-pg[max],pg[max+1]-pg[max]; 1954 A=pg[max-1]-pg[max],pg[max+1]-pg[max]; 1955 1955 if (det(A)==4) 1956 1956 { … … 2001 2001 { 2002 2002 max++; 2003 } 2003 } 2004 2004 M=pg[max],1,pg[max+1],1,pg[max+2],1; 2005 2005 N=0,1,1,1,2,1,2,1,1; … … 2064 2064 // the vertices of the normal form are 2065 2065 nf[1]; 2066 // it has been transformed by the unimodular affine transformation A*x+v 2066 // it has been transformed by the unimodular affine transformation A*x+v 2067 2067 // with matrix A 2068 2068 nf[2]; … … 2079 2079 "USAGE: ellipticNFDB(n[,#]); n int, # list 2080 2080 ASSUME: n is an intger between 1 and 16 2081 PURPOSE: this is a database storing the 16 normal forms of planar polygons with 2081 PURPOSE: this is a database storing the 16 normal forms of planar polygons with 2082 2082 precisely one interior point up to unimodular affine transformations 2083 2083 @* (see e.g. Bjorn Poonen, Fernando Rodriguez-Villegas: Lattice Polygons and 2084 2084 the number 12. Amer. Math. Monthly 107 (2000), no. 3, 238--250.) 2085 2085 RETURN: list, L such that 2086 @* L[1] : list whose entries are the vertices of the nth normal form 2087 @* L[2] : list whose entries are all the lattice points of the nth normal form 2086 @* L[1] : list whose entries are the vertices of the nth normal form 2087 @* L[2] : list whose entries are all the lattice points of the nth normal form 2088 2088 @* L[3] : only present if the optional parameter # is present, and then 2089 it is a polynomial in the variables (x,y) whose Newton polygon 2089 it is a polynomial in the variables (x,y) whose Newton polygon 2090 2090 is the nth normal form 2091 2091 NOTE: the optional parameter is only allowed if the basering has the variables x and y … … 2139 2139 proc polymakeKeepTmpFiles (int i) 2140 2140 "USAGE: polymakeKeepTmpFiles(int i); i int 2141 PURPOSE: some procedures create files in the directory /tmp which are used for 2141 PURPOSE: some procedures create files in the directory /tmp which are used for 2142 2142 computations with polymake respectively topcom; these will be removed 2143 2143 when the corresponding procedure is left; however, it might be desireable … … 2184 2184 static proc scalarproduct (intvec w,intvec v) 2185 2185 "USAGE: scalarproduct(w,v); w,v intvec 2186 ASSUME: w and v are integer vectors of the same length 2186 ASSUME: w and v are integer vectors of the same length 2187 2187 RETURN: int, the scalarproduct of v and w 2188 2188 NOTE: the procedure is called by findOrientedBoundary" … … 2231 2231 { 2232 2232 int m=nrows(M); 2233 2233 2234 2234 } 2235 2235 else … … 2289 2289 { 2290 2290 return(""); 2291 2291 2292 2292 } 2293 2293 if (i==1) … … 2399 2399 k++; 2400 2400 } 2401 else 2401 else 2402 2402 { 2403 2403 stop=1; … … 2442 2442 k++; 2443 2443 } 2444 else 2444 else 2445 2445 { 2446 2446 stop=1; … … 2491 2491 static proc polygonToCoordinates (list points) 2492 2492 "USAGE: polygonToCoordinates(points); points list 2493 ASSUME: points is a list of integer vectors each of size two describing the 2493 ASSUME: points is a list of integer vectors each of size two describing the 2494 2494 marked points of a convex lattice polygon like the output of polygonDB 2495 RETURN: list, the first entry is a string representing the coordinates corresponding 2495 RETURN: list, the first entry is a string representing the coordinates corresponding 2496 2496 to the latticpoints seperated by commata 2497 2497 the second entry is a list where the ith entry is a string representing … … 2528 2528 } 2529 2529 size(etavectors); 2530 2530 2531 2531 for (i=size(etavectors);i>=2;i--) 2532 2532 { … … 2563 2563 } 2564 2564 return(list(etavectors,string(ad))); 2565 2566 2567 } 2568 2565 2566 2567 } 2568 2569 2569 return(etavectors); 2570 2570 } … … 2599 2599 } 2600 2600 2601 */ 2601 */ -
Singular/LIB/powers.lib
r95edd5 r7f3ad4 1 1 // version string automatically expanded by CVS 2 version="$Id: powers.lib,v 1. 3 2008-06-26 13:17:43 motsakExp $";2 version="$Id: powers.lib,v 1.4 2009-01-14 16:07:05 Singular Exp $"; 3 3 category="Linear algebra"; 4 4 … … 15 15 exteriorBasis(int, int) return a basis of a k-th exterior power 16 16 exteriorPower(module,int) return k-th exterior power of a matrix 17 17 18 18 "; 19 19 20 20 21 21 LIB "general.lib"; // for sort … … 81 81 p = char(basering); 82 82 } 83 83 84 84 ring S = (p), (e(1..n)), dp; 85 85 def T = SuperCommutative(); setring T; -
Singular/LIB/ratgb.lib
r95edd5 r7f3ad4 1 1 ////////////////////////////////////////////////////////////////////////////// 2 version="$Id: ratgb.lib,v 1.1 2 2008-02-26 23:36:12 levandovExp $";2 version="$Id: ratgb.lib,v 1.13 2009-01-14 16:07:05 Singular Exp $"; 3 3 category="Noncommutative"; 4 4 info=" … … 14 14 LIB "poly.lib"; 15 15 16 //static 16 //static