[380a17b] | 1 | /////////////////////////////////////////////////////////////////////////////// |
---|
[3686937] | 2 | version="version divisors.lib 4.0.0.0 Jun_2013 "; // $Id$ |
---|
[1e1ec4] | 3 | category = "Commutative Algebra"; |
---|
| 4 | info=" |
---|
| 5 | LIBRARY: divisors.lib Divisors and P-Divisors |
---|
| 6 | |
---|
| 7 | AUTHORS: Janko Boehm boehm@mathematik.uni-kl.de |
---|
| 8 | @* Lars Kastner kastner@math.fu-berlin.de |
---|
| 9 | @* Benjamin Lorenz blorenz@math.uni-frankfurt.de |
---|
| 10 | @* Hans Schoenemann hannes@mathematik.uni-kl.de |
---|
| 11 | @* Yue Ren ren@mathematik.uni-kl.de |
---|
| 12 | |
---|
| 13 | OVERVIEW: |
---|
| 14 | |
---|
| 15 | We implement a class divisor on an algebraic variety and methods |
---|
| 16 | for computing with them. Divisors are represented by tuples of ideals |
---|
| 17 | defining the positive and the negative part. In particular, we implement the group |
---|
| 18 | structure on divisors, computing global sections and testing linear |
---|
| 19 | equivalence. |
---|
| 20 | |
---|
| 21 | In addition to this we provide a class formaldivisor which implements |
---|
| 22 | integer formal sums of divisors (not necessarily prime). A formal divisor |
---|
| 23 | can be evaluated to a divisor, and a divisor can be decomposed into |
---|
| 24 | a formal sum. |
---|
| 25 | |
---|
| 26 | Finally we provide a class pdivisor which implements polyhedral formal sums of |
---|
| 27 | divisors (P-divisors) where the coefficients are assumed to be polyhedra with fixed tail cone. |
---|
| 28 | There is a function to evaluate a P-divisor on a vector in the dual of the tail cone. The |
---|
| 29 | result will be a formal divisor. |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | REFERENCES: |
---|
| 33 | |
---|
| 34 | For the class divisor we closely follow Macaulay2's tutorial on divisors. |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | PROCEDURES: |
---|
| 38 | |
---|
| 39 | makeDivisor(ideal,ideal) create a divisor |
---|
| 40 | divisorplus(divisor,divisor) add two divisors |
---|
| 41 | multdivisor(int,divisor) multiply a divisor by an interger |
---|
| 42 | negativedivisor(divisor) compute the negative of the divisor |
---|
| 43 | normalForm(divisor) normal form of a divisor |
---|
| 44 | isEqualDivisor(divisor,divisor) test whether two divisors are equal |
---|
| 45 | globalSections(divisor) compute the global sections of a divisor |
---|
| 46 | degreeDivisor(divisor) degree of a divisor |
---|
| 47 | linearlyEquivalent(divisor,divisor) test whether two divisors a linearly equivalent |
---|
| 48 | effective(divisor) compute an effective divisor |
---|
| 49 | linearly equivalent to a divisor |
---|
| 50 | |
---|
| 51 | makeFormalDivisor(list) make a formal integer sum of divisors |
---|
| 52 | evaluateFormalDivisor(formaldivisor) evalutate a formal sum of divisors to a divisor |
---|
| 53 | formaldivisorplus(formaldivisor,formaldivisor) add two formal divisors |
---|
| 54 | negativeformaldivisor(formaldivisor) compute the negative of the formal divisor |
---|
| 55 | multformaldivisor(int,formaldivisor) multiply a formal divisor by an interger |
---|
| 56 | degreeFormalDivisor(formaldivisor) degree of a formal divisor |
---|
| 57 | |
---|
| 58 | makePDivisor(List) make a formal polyhedral sum of divisors |
---|
| 59 | evaluatePDivisor(pdivisor,intvec) evaluate a polyhedral divisor |
---|
| 60 | to an integer formal divisor |
---|
| 61 | pdivisorplus(pdivisor,pdivisor) add two polyhedral divisors |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | "; |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | //////////////////////////////////////////////////////////////////////////////// |
---|
| 68 | |
---|
| 69 | LIB "primdec.lib"; |
---|
| 70 | |
---|
| 71 | proc mod_init() |
---|
| 72 | { |
---|
[80f146c] | 73 | LIB"gfanlib.so"; |
---|
[1e1ec4] | 74 | newstruct("divisor","ideal den,ideal num"); |
---|
| 75 | newstruct("formaldivisor","list summands"); |
---|
| 76 | newstruct("pdivisor","list summands, cone tail"); |
---|
| 77 | |
---|
| 78 | system("install","divisor","print",divisor_print,1); |
---|
| 79 | system("install","divisor","+",divisorplus,2); |
---|
| 80 | system("install","divisor","*",proxymultdivisor,2); |
---|
| 81 | system("install","formaldivisor","print",formaldivisor_print,1); |
---|
| 82 | system("install","formaldivisor","+",formaldivisorplus,2); |
---|
| 83 | system("install","formaldivisor","*",proxymultformaldivisor,2); |
---|
| 84 | system("install","pdivisor","+",pdivisorplus,2); |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | proc divisor_print(divisor D) |
---|
| 90 | "USAGE: divisor_print(D); D; D = divisor. @* |
---|
| 91 | ASSUME: D is a divisor. |
---|
| 92 | RETURN: Will print D. |
---|
| 93 | KEYWORDS: divisors |
---|
| 94 | EXAMPLE: example divisor_print; shows an example |
---|
| 95 | " |
---|
| 96 | { |
---|
| 97 | "("+string(D.num)+") - ("+string(D.den)+")"; |
---|
| 98 | } |
---|
| 99 | example |
---|
| 100 | { "EXAMPLE:"; |
---|
| 101 | ring r=31991,(x,y,z),dp; |
---|
| 102 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 103 | qring Q = std(I); |
---|
| 104 | divisor P = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 105 | P; |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | |
---|
| 109 | proc formaldivisor_print(formaldivisor fD) |
---|
| 110 | "USAGE: formaldivisor_print(D); D; D = formaldivisor. @* |
---|
| 111 | ASSUME: fD is a formaldivisor. |
---|
| 112 | RETURN: Will print fD. |
---|
| 113 | KEYWORDS: divisors |
---|
| 114 | EXAMPLE: example formaldivisor_print; shows an example |
---|
| 115 | " |
---|
| 116 | { |
---|
| 117 | int i; string s; list L=fD.summands; |
---|
| 118 | list cd; int c; divisor d; |
---|
| 119 | string linebreak = |
---|
| 120 | " |
---|
| 121 | "; |
---|
| 122 | for (i=1; i<=size(L); i++) |
---|
| 123 | { |
---|
| 124 | cd=L[i]; c=cd[1]; d=cd[2]; |
---|
| 125 | if (i>1 && c>=0) { s = s + "+"; } |
---|
| 126 | s = s + string(c)+"*( ("+string(d.num)+") - ("+string(d.den)+") )"; |
---|
| 127 | if (i!=size(L)) { s = s + linebreak; } |
---|
| 128 | } |
---|
| 129 | s; |
---|
| 130 | } |
---|
| 131 | example |
---|
| 132 | { "EXAMPLE:"; |
---|
| 133 | ring r=31991,(x,y,z),dp; |
---|
| 134 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 135 | qring Q = std(I); |
---|
| 136 | divisor P = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 137 | P; |
---|
| 138 | } |
---|
| 139 | |
---|
| 140 | |
---|
| 141 | //////////////////////////////////////////////////////////////////////////////// |
---|
| 142 | // divisors as numerator and denomiator ideals |
---|
| 143 | |
---|
| 144 | proc makeDivisor(ideal I, ideal J) |
---|
| 145 | "USAGE: makeDivisor(I ,J); I = ideal, J = ideal. @* |
---|
| 146 | ASSUME: I and J are ideals in a qring Q of a smooth irreducible variety X |
---|
| 147 | such that any ideal in Q satisfies the S2 condition. |
---|
| 148 | RETURN: a divisor on X |
---|
| 149 | THEORY: The procedure will eliminate all components which are not of codimension 1. |
---|
| 150 | The S2 condition requires that every proper nonzero principal ideal |
---|
| 151 | has pure codimension 1. |
---|
| 152 | KEYWORDS: divisors |
---|
| 153 | EXAMPLE: example makeDivisor; shows an example |
---|
| 154 | " |
---|
| 155 | { |
---|
| 156 | divisor C; |
---|
| 157 | C.num = purify1(I); |
---|
| 158 | C.den = purify1(J); |
---|
| 159 | return(C); |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | example |
---|
| 163 | { "EXAMPLE:"; |
---|
| 164 | ring r=31991,(x,y,z),dp; |
---|
| 165 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 166 | qring Q = std(I); |
---|
| 167 | divisor P = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | |
---|
| 171 | proc divisorplus(divisor A, divisor B) |
---|
| 172 | "USAGE: divisorplus(A ,B); A + B; A = divisor, B = divisor. @* |
---|
| 173 | ASSUME: A and B are divisors on X. |
---|
| 174 | RETURN: a divisor on X |
---|
| 175 | THEORY: The procedure will compute the product of the numerator |
---|
| 176 | and denominator ideals, respectively. |
---|
| 177 | KEYWORDS: divisors |
---|
| 178 | EXAMPLE: example divisorplus; shows an example |
---|
| 179 | " |
---|
| 180 | { |
---|
| 181 | return(makeDivisor(interred(A.num*B.num),interred(A.den*B.den))); |
---|
| 182 | } |
---|
| 183 | example |
---|
| 184 | { "EXAMPLE:"; |
---|
| 185 | ring r=31991,(x,y,z),dp; |
---|
| 186 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 187 | qring Q = std(I); |
---|
| 188 | divisor A = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 189 | divisor B = makeDivisor(ideal(x,y),ideal(1)); |
---|
| 190 | A+B; |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | |
---|
| 194 | proc multdivisor(int n, divisor A) |
---|
| 195 | "USAGE: multdivisor(n ,A); A*n; n = integer, A = divisor.@* |
---|
| 196 | ASSUME: n is an integer and A is a divisor on X. |
---|
| 197 | RETURN: a divisor on X |
---|
| 198 | THEORY: The procedure will compute the n-th power of the numerator |
---|
| 199 | and denominator ideals, respectively. |
---|
| 200 | KEYWORDS: divisors |
---|
| 201 | EXAMPLE: example multdivisor; shows an example |
---|
| 202 | " |
---|
| 203 | { |
---|
| 204 | if (n<0) {return(multdivisor(-n,negativedivisor(A)));} |
---|
| 205 | return(makeDivisor(interred((A.num)^n),interred((A.den)^n))); |
---|
| 206 | } |
---|
| 207 | example |
---|
| 208 | { "EXAMPLE:"; |
---|
| 209 | ring r=31991,(x,y,z),dp; |
---|
| 210 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 211 | qring Q = std(I); |
---|
| 212 | divisor A = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 213 | A; |
---|
| 214 | divisor D = multdivisor(4,A); |
---|
| 215 | D; |
---|
| 216 | A*4; |
---|
| 217 | } |
---|
| 218 | |
---|
| 219 | |
---|
| 220 | /*** |
---|
| 221 | * For operator overloading, which needs a procedure which takes a divisor first |
---|
| 222 | * and integer second. |
---|
| 223 | **/ |
---|
| 224 | proc proxymultdivisor(divisor A, int n) |
---|
| 225 | { |
---|
| 226 | if (n<0) {return(multdivisor(-n,negativedivisor(A)));} |
---|
| 227 | return(makeDivisor(interred((A.num)^n),interred((A.den)^n))); |
---|
| 228 | } |
---|
| 229 | |
---|
| 230 | |
---|
| 231 | proc negativedivisor(divisor A) |
---|
| 232 | "USAGE: negativedivisor(A); A*(-1); A = divisor.@* |
---|
| 233 | ASSUME: A is a divisor on X. |
---|
| 234 | RETURN: a divisor on X |
---|
| 235 | THEORY: The procedure will interchange the numerator and denominator ideals. |
---|
| 236 | KEYWORDS: divisors |
---|
| 237 | EXAMPLE: example negativedivisor; shows an example |
---|
| 238 | " |
---|
| 239 | { |
---|
| 240 | divisor B; |
---|
| 241 | B.num=A.den; |
---|
| 242 | B.den=A.num; |
---|
| 243 | return(B); |
---|
| 244 | } |
---|
| 245 | example |
---|
| 246 | { "EXAMPLE:"; |
---|
| 247 | ring r=31991,(x,y,z),dp; |
---|
| 248 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 249 | qring Q = std(I); |
---|
| 250 | divisor A = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 251 | A; |
---|
| 252 | divisor D = negativedivisor(A); |
---|
| 253 | D; |
---|
| 254 | } |
---|
| 255 | |
---|
| 256 | |
---|
| 257 | proc normalForm(divisor A) |
---|
| 258 | "USAGE: normalForm(A); A = divisor.@* |
---|
| 259 | ASSUME: A is a divisor on X. |
---|
| 260 | RETURN: different representative of the same divisor on X |
---|
| 261 | THEORY: The procedure will cancel common components of numerator and denominator. |
---|
| 262 | KEYWORDS: divisors |
---|
| 263 | EXAMPLE: example normalForm; shows an example |
---|
| 264 | " |
---|
| 265 | { |
---|
| 266 | divisor B; |
---|
| 267 | B.num=quotient(A.num,A.den); |
---|
| 268 | B.den=quotient(A.den,A.num); |
---|
| 269 | return(B); |
---|
| 270 | } |
---|
| 271 | example |
---|
| 272 | { "EXAMPLE:"; |
---|
| 273 | ring r=31991,(x,y,z),dp; |
---|
| 274 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 275 | qring Q = std(I); |
---|
| 276 | divisor A = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 277 | divisor B = makeDivisor(ideal(x,y),ideal(1)); |
---|
| 278 | divisor D = (A+B)+multdivisor(-1,B); |
---|
| 279 | D; |
---|
| 280 | normalForm(D); |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | |
---|
| 284 | |
---|
| 285 | |
---|
| 286 | static proc isEqualIdeal(ideal A,ideal B){ |
---|
| 287 | return((size(NF(A,std(B)))==0) && (size(NF(B,std(A)))==0)); |
---|
| 288 | } |
---|
| 289 | |
---|
| 290 | |
---|
| 291 | proc isEqualDivisor(divisor A,divisor B) |
---|
| 292 | "USAGE: isEqualDivisor(A,B); A = divisor, B = divisor.@* |
---|
| 293 | ASSUME: A and B are divisors on X. |
---|
| 294 | RETURN: int 0 or 1, checks equality of A and B. |
---|
| 295 | THEORY: The procedure will compute the normal forms of A and B and compare. |
---|
| 296 | KEYWORDS: divisors |
---|
| 297 | EXAMPLE: example isEqualDivisor; shows an example |
---|
| 298 | " |
---|
| 299 | { |
---|
| 300 | A=normalForm(A); |
---|
| 301 | B=normalForm(B); |
---|
| 302 | return((isEqualIdeal(A.num,B.num)) && (isEqualIdeal(A.den,B.den))); |
---|
| 303 | } |
---|
| 304 | example |
---|
| 305 | { "EXAMPLE:"; |
---|
| 306 | ring r=31991,(x,y,z),dp; |
---|
| 307 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 308 | qring Q = std(I); |
---|
| 309 | divisor A = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 310 | divisor B = makeDivisor(ideal(x,y),ideal(1)); |
---|
| 311 | divisor D = (A+B)+multdivisor(-1,B); |
---|
| 312 | isEqualDivisor(A,D); |
---|
| 313 | } |
---|
| 314 | |
---|
| 315 | |
---|
| 316 | static proc purify1(ideal I) |
---|
| 317 | { |
---|
| 318 | I = simplify(I,2); |
---|
| 319 | if (I[1]==0){ERROR("expected a non-zero ideal");} |
---|
| 320 | ideal f = I[1]; |
---|
| 321 | return(minbase(quotient(f,quotient(f,I)))); |
---|
| 322 | } |
---|
| 323 | |
---|
| 324 | |
---|
| 325 | static proc basis(ideal I,int d) |
---|
| 326 | { |
---|
| 327 | I=simplify(jet(intersect(I,maxideal(d)),d),2); |
---|
| 328 | return(I)} |
---|
| 329 | |
---|
| 330 | //basis(ideal(x,y^3),2); |
---|
| 331 | |
---|
| 332 | |
---|
| 333 | proc globalSections(divisor D) |
---|
| 334 | "USAGE: globalSections(A); A = divisor.@* |
---|
| 335 | ASSUME: A is a divisor on X. |
---|
| 336 | RETURN: a list with a basis of the space of global sections of D. |
---|
[389c6d] | 337 | THEORY: We assume that the qring of X satisfies the S2-condition and that X is smooth. We compute sat((f*J) : I) /f |
---|
[1e1ec4] | 338 | where D = (I)-(J). |
---|
| 339 | KEYWORDS: divisors |
---|
| 340 | EXAMPLE: example globalSections; shows an example |
---|
| 341 | " |
---|
| 342 | { |
---|
| 343 | poly f =(simplify(D.num,2))[1]; |
---|
| 344 | ideal LD = basis(purify1(quotient(f*D.den,D.num)),deg(f)); |
---|
| 345 | list L = simplify(LD,2),f; |
---|
| 346 | return(L); |
---|
| 347 | } |
---|
| 348 | example |
---|
| 349 | { "EXAMPLE:"; |
---|
| 350 | ring r=31991,(x,y,z),dp; |
---|
| 351 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 352 | qring Q = std(I); |
---|
| 353 | divisor P = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 354 | divisor D = multdivisor(4,P); |
---|
| 355 | globalSections(D); |
---|
| 356 | } |
---|
| 357 | |
---|
| 358 | |
---|
| 359 | static proc sectionIdeal(poly f, poly g, divisor D){ |
---|
| 360 | return(purify1(quotient(quotient(f*D.num,g), D.den))); |
---|
| 361 | } |
---|
| 362 | |
---|
| 363 | proc degreeDivisor(divisor A) |
---|
| 364 | "USAGE: degreeDivisor(A); A = divisor.@* |
---|
| 365 | ASSUME: A is a divisor on X. |
---|
| 366 | RETURN: The degree of A. |
---|
| 367 | THEORY: We compute difference of the degrees of the numerator and denominator ideals. |
---|
| 368 | KEYWORDS: divisors |
---|
| 369 | EXAMPLE: example degreeDivisor; shows an example |
---|
| 370 | " |
---|
| 371 | { |
---|
[389c6d] | 372 | return( mult(std(A.num))-mult(std(A.den))); |
---|
[1e1ec4] | 373 | } |
---|
| 374 | example |
---|
| 375 | { "EXAMPLE:"; |
---|
| 376 | ring r=31991,(x,y,z),dp; |
---|
| 377 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 378 | qring Q = std(I); |
---|
| 379 | divisor P = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 380 | degreeDivisor(P); |
---|
| 381 | } |
---|
| 382 | |
---|
| 383 | proc linearlyEquivalent(divisor A, divisor B) |
---|
| 384 | "USAGE: linearlyEquivalent(A,B); A = divisor, B = divisor.@* |
---|
| 385 | ASSUME: A and B are divisors on X. |
---|
| 386 | RETURN: list if A and B a linearly equivalent and int 0 otherwise. |
---|
| 387 | THEORY: Checks whether A-B is principle. If yes, returns a list L=(f,g) where |
---|
| 388 | A - B = (f/g). |
---|
| 389 | KEYWORDS: divisors |
---|
| 390 | EXAMPLE: example linearlyEquivalent; shows an example |
---|
| 391 | " |
---|
| 392 | { |
---|
| 393 | divisor F = normalForm(divisorplus(A,negativedivisor(B))); |
---|
| 394 | list LB = globalSections(F); |
---|
| 395 | if (size(LB[1])!=1) {return(0);} |
---|
| 396 | ideal V = sectionIdeal(LB[1][1,1],LB[2],F); |
---|
| 397 | if (isEqualIdeal(V,ideal(1))==1) {return(list(LB[1][1,1],LB[2]));} |
---|
| 398 | return(0); |
---|
| 399 | } |
---|
| 400 | example |
---|
| 401 | { "EXAMPLE:"; |
---|
| 402 | ring r=31991,(x,y,z),dp; |
---|
| 403 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 404 | qring Q = std(I); |
---|
| 405 | divisor A = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 406 | divisor B = makeDivisor(ideal(x,y),ideal(1)); |
---|
| 407 | linearlyEquivalent(A,B); |
---|
| 408 | linearlyEquivalent(multdivisor(2,A),multdivisor(2,B)); |
---|
| 409 | } |
---|
| 410 | |
---|
| 411 | |
---|
| 412 | proc effective(divisor A) |
---|
| 413 | "USAGE: effective(A); A = divisor.@* |
---|
| 414 | ASSUME: A is a divisor on X which is linearly equivalent to an effective divisor. |
---|
| 415 | RETURN: divisor on X. |
---|
| 416 | THEORY: We compute an effective divisor linearly equivalent to A. |
---|
| 417 | KEYWORDS: divisors |
---|
| 418 | EXAMPLE: example effective; shows an example |
---|
| 419 | " |
---|
| 420 | { |
---|
| 421 | list LB = globalSections(A); |
---|
| 422 | if (size(LB[1])==0) {ERROR("the divisor is not linearly equivalent to an effective divisor");} |
---|
| 423 | ideal V = sectionIdeal(LB[1][1,1],LB[2],A); |
---|
| 424 | return(makeDivisor(V,ideal(1))); |
---|
| 425 | } |
---|
| 426 | example |
---|
| 427 | { "EXAMPLE:"; |
---|
| 428 | ring r=31991,(x,y,z),dp; |
---|
| 429 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 430 | qring Q = std(I); |
---|
| 431 | divisor A = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 432 | divisor B = makeDivisor(ideal(x,y),ideal(1)); |
---|
| 433 | divisor D = divisorplus(multdivisor(2,B),negativedivisor(A)); |
---|
| 434 | effective(D); |
---|
| 435 | } |
---|
| 436 | |
---|
| 437 | |
---|
| 438 | |
---|
| 439 | //////////////////////////////////////////////////////////////////////////////// |
---|
| 440 | // formal sums of divisors |
---|
| 441 | |
---|
| 442 | proc makeFormalDivisor(list L) |
---|
| 443 | "USAGE: makeFormalDivisor(L); L = list.@* |
---|
| 444 | ASSUME: L is a list of tuples of an integer and a divisor. |
---|
| 445 | RETURN: a formal divisor on X |
---|
| 446 | THEORY: Represents an integer formal sum of divisors. |
---|
| 447 | KEYWORDS: divisors |
---|
| 448 | EXAMPLE: example makeFormalDivisor; shows an example |
---|
| 449 | " |
---|
| 450 | { |
---|
| 451 | formaldivisor C; |
---|
| 452 | C.summands = L; |
---|
| 453 | return(C); |
---|
| 454 | } |
---|
| 455 | example |
---|
| 456 | { "EXAMPLE:"; |
---|
| 457 | ring r=31991,(x,y,z),dp; |
---|
| 458 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 459 | qring Q = std(I); |
---|
| 460 | divisor A = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 461 | divisor B = makeDivisor(ideal(x,y),ideal(1)); |
---|
| 462 | makeFormalDivisor(list(list(-5,A),list(2,B))); |
---|
| 463 | } |
---|
| 464 | |
---|
| 465 | |
---|
| 466 | proc evaluateFormalDivisor(formaldivisor D) |
---|
| 467 | "USAGE: evaluateFormalDivisor(D); D = formal divisor.@* |
---|
| 468 | ASSUME: D is a formal divisor on X. |
---|
| 469 | RETURN: a divisor on X |
---|
| 470 | THEORY: Will evaluate the formal sum. |
---|
| 471 | KEYWORDS: divisors |
---|
| 472 | EXAMPLE: example evaluateFormalDivisor; shows an example |
---|
| 473 | " |
---|
| 474 | { |
---|
| 475 | list L = D.summands; |
---|
| 476 | if (size(L)==0) {return(makeDivisor(ideal(1),ideal(1)));} |
---|
| 477 | int i; |
---|
| 478 | divisor E = multdivisor(L[1][1],L[1][2]); |
---|
| 479 | for ( i=2; i <= size(L); i++ ) |
---|
| 480 | { |
---|
| 481 | E = divisorplus(E, multdivisor(L[i][1],L[i][2])); |
---|
| 482 | } |
---|
| 483 | return(E); |
---|
| 484 | } |
---|
| 485 | example |
---|
| 486 | { "EXAMPLE:"; |
---|
| 487 | ring r=31991,(x,y,z),dp; |
---|
| 488 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 489 | qring Q = std(I); |
---|
| 490 | divisor A = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 491 | divisor B = makeDivisor(ideal(x,y),ideal(1)); |
---|
| 492 | formaldivisor fE= makeFormalDivisor(list(list(-5,A),list(2,B))); |
---|
| 493 | evaluateFormalDivisor(fE); |
---|
| 494 | } |
---|
| 495 | |
---|
| 496 | |
---|
| 497 | |
---|
| 498 | static proc position(divisor I,list L){ |
---|
| 499 | int i; |
---|
| 500 | for (i=1; i <=size(L); i++){ |
---|
| 501 | if (isEqualDivisor(I,L[i][2])==1) {return(i);} |
---|
| 502 | } |
---|
| 503 | return(0);} |
---|
| 504 | |
---|
| 505 | |
---|
| 506 | proc formaldivisorplus(formaldivisor A, formaldivisor B) |
---|
| 507 | "USAGE: formaldivisorplus(A ,B); A + B; A = formaldivisor, B = formaldivisor. @* |
---|
| 508 | ASSUME: A and B are formal divisors on X. |
---|
| 509 | RETURN: a formal divisor on X |
---|
| 510 | THEORY: The procedure will add the formal sums. |
---|
| 511 | KEYWORDS: divisors |
---|
| 512 | EXAMPLE: example formaldivisorplus; shows an example |
---|
| 513 | " |
---|
| 514 | { |
---|
| 515 | formaldivisor C; |
---|
| 516 | int i,p; |
---|
| 517 | int j=1; |
---|
| 518 | list L; |
---|
| 519 | list LA=A.summands; |
---|
| 520 | list LB=B.summands; |
---|
| 521 | for (i=1; i<=size(LA);i++){ |
---|
| 522 | p=position(LA[i][2],L); |
---|
| 523 | if (p==0) { |
---|
| 524 | L[j]=list(); |
---|
| 525 | L[j][2]=LA[i][2]; |
---|
| 526 | L[j][1]=LA[i][1]; |
---|
| 527 | j=j+1; |
---|
| 528 | } else { |
---|
| 529 | L[p][1]=L[p][1]+LA[i][1]; |
---|
| 530 | }; |
---|
| 531 | } |
---|
| 532 | for (i=1; i<=size(LB);i++){ |
---|
| 533 | p=position(LB[i][2],L); |
---|
| 534 | if (p==0) { |
---|
| 535 | L[j]=list(); |
---|
| 536 | L[j][2]=LB[i][2]; |
---|
| 537 | L[j][1]=LB[i][1]; |
---|
| 538 | j=j+1; |
---|
| 539 | } else { |
---|
| 540 | L[p][1]=L[p][1]+LB[i][1]; |
---|
| 541 | }; |
---|
| 542 | } |
---|
| 543 | //C.summands = (A.summands)+(B.summands); |
---|
| 544 | return(L); |
---|
| 545 | } |
---|
| 546 | example |
---|
| 547 | { "EXAMPLE:"; |
---|
| 548 | ring r=31991,(x,y,z),dp; |
---|
| 549 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 550 | qring Q = std(I); |
---|
| 551 | divisor A = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 552 | divisor B = makeDivisor(ideal(x,y),ideal(1)); |
---|
| 553 | divisor C = makeDivisor(ideal(x-z,y),ideal(1)); |
---|
| 554 | formaldivisor fE= makeFormalDivisor(list(list(-5,A),list(2,B))); |
---|
| 555 | formaldivisor fE2= makeFormalDivisor(list(list(-5,A),list(2,C))); |
---|
| 556 | formaldivisorplus(fE,fE2); |
---|
| 557 | } |
---|
| 558 | |
---|
| 559 | |
---|
| 560 | proc degreeFormalDivisor(formaldivisor A) |
---|
| 561 | "USAGE: degreeFormalDivisor(A); A = formaldivisor.@* |
---|
| 562 | ASSUME: A is a formaldivisor on X. |
---|
| 563 | RETURN: The degree of A. |
---|
| 564 | THEORY: We compute degrees of the summands and return the weighted sum. |
---|
| 565 | KEYWORDS: divisors |
---|
| 566 | EXAMPLE: example degreeFormalDivisor; shows an example |
---|
| 567 | " |
---|
| 568 | { |
---|
| 569 | int i,s; |
---|
| 570 | list L = A.summands; |
---|
| 571 | for (i=1;i<=size(L);i++){ |
---|
| 572 | s=s+L[i][1]*degreeDivisor(L[i][2]); |
---|
| 573 | } |
---|
| 574 | return(s); |
---|
| 575 | } |
---|
| 576 | example |
---|
| 577 | { "EXAMPLE:"; |
---|
| 578 | ring r=31991,(x,y,z),dp; |
---|
| 579 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 580 | qring Q = std(I); |
---|
| 581 | divisor A = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 582 | divisor B = makeDivisor(ideal(x,y),ideal(1)); |
---|
| 583 | formaldivisor fE= makeFormalDivisor(list(list(-5,A),list(2,B))); |
---|
| 584 | degreeFormalDivisor(fE); |
---|
| 585 | } |
---|
| 586 | |
---|
| 587 | |
---|
| 588 | proc multformaldivisor(int n,formaldivisor A) |
---|
| 589 | "USAGE: multformaldivisor(n ,A); A*n; n = integer, A = formaldivisor.@* |
---|
| 590 | ASSUME: n is an integer and A is a formal divisor on X. |
---|
| 591 | RETURN: a formal divisor on X |
---|
| 592 | THEORY: The procedure will multiply the formal sum with n. |
---|
| 593 | KEYWORDS: divisors |
---|
| 594 | EXAMPLE: example multformaldivisor; shows an example |
---|
| 595 | " |
---|
| 596 | { |
---|
| 597 | formaldivisor B; |
---|
| 598 | list L=A.summands; |
---|
| 599 | int i; |
---|
| 600 | for (i=1;i<=size(L);i++){ |
---|
| 601 | L[i][1]=n*L[i][1]; |
---|
| 602 | } |
---|
| 603 | B.summands=L; |
---|
| 604 | return(B); |
---|
| 605 | } |
---|
| 606 | example |
---|
| 607 | { "EXAMPLE:"; |
---|
| 608 | ring r=31991,(x,y,z),dp; |
---|
| 609 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 610 | qring Q = std(I); |
---|
| 611 | divisor A = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 612 | divisor B = makeDivisor(ideal(x,y),ideal(1)); |
---|
| 613 | formaldivisor fE= makeFormalDivisor(list(list(-5,A),list(2,B))); |
---|
| 614 | fE*2; |
---|
| 615 | } |
---|
| 616 | |
---|
| 617 | |
---|
| 618 | /*** |
---|
| 619 | * For operator overloading, which needs a procedure which takes a divisor first |
---|
| 620 | * and integer second. |
---|
| 621 | **/ |
---|
| 622 | proc proxymultformaldivisor(formaldivisor A, int n) |
---|
| 623 | { |
---|
| 624 | formaldivisor B; |
---|
| 625 | list L=A.summands; |
---|
| 626 | int i; |
---|
| 627 | for (i=1;i<=size(L);i++){ |
---|
| 628 | L[i][1]=n*L[i][1]; |
---|
| 629 | } |
---|
| 630 | B.summands=L; |
---|
| 631 | return(B); |
---|
| 632 | } |
---|
| 633 | |
---|
| 634 | |
---|
| 635 | |
---|
| 636 | proc negativeformaldivisor(formaldivisor A) |
---|
| 637 | "USAGE: negativeformaldivisor(A); A = formaldivisor.@* |
---|
| 638 | ASSUME: A is a formaldivisor on X. |
---|
| 639 | RETURN: a formal divisor on X |
---|
| 640 | THEORY: The procedure will change the signs of the coefficients. |
---|
| 641 | KEYWORDS: divisors |
---|
| 642 | EXAMPLE: example negativeformaldivisor; shows an example |
---|
| 643 | " |
---|
| 644 | { |
---|
| 645 | formaldivisor B; |
---|
| 646 | list L=A.summands; |
---|
| 647 | int i; |
---|
| 648 | for (i=1;i<=size(L);i++){ |
---|
| 649 | L[i][1]=-L[i][1]; |
---|
| 650 | } |
---|
| 651 | B.summands=L; |
---|
| 652 | return(B); |
---|
| 653 | } |
---|
| 654 | example |
---|
| 655 | { "EXAMPLE:"; |
---|
| 656 | ring r=31991,(x,y,z),dp; |
---|
| 657 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 658 | qring Q = std(I); |
---|
| 659 | divisor A = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 660 | divisor B = makeDivisor(ideal(x,y),ideal(1)); |
---|
| 661 | formaldivisor fE= makeFormalDivisor(list(list(-5,A),list(2,B))); |
---|
| 662 | negativeformaldivisor(fE); |
---|
| 663 | } |
---|
| 664 | |
---|
| 665 | |
---|
| 666 | static proc primDecDivisor(divisor D) |
---|
| 667 | "decompose a divisor into a formal divisor of primary divisors" |
---|
| 668 | { |
---|
| 669 | formaldivisor E; |
---|
| 670 | ideal I = D.num; |
---|
| 671 | ideal J = D.den; |
---|
| 672 | list L; |
---|
| 673 | int i; |
---|
| 674 | int j = 1; |
---|
| 675 | list LI = primdecGTZ(I); |
---|
| 676 | for (i=1;i<=size(LI);i++){ |
---|
| 677 | LI[i][2]; |
---|
| 678 | L[j]=list(1,makeDivisor(LI[i][1],ideal(1))); |
---|
| 679 | j=j+1; |
---|
| 680 | }; |
---|
| 681 | list LJ = primdecGTZ(J); |
---|
| 682 | for (i=1;i<=size(LJ);i++){ |
---|
| 683 | LJ[i][2]; |
---|
| 684 | L[j]=list(-1,makeDivisor(LJ[i][1],ideal(1))); |
---|
| 685 | j=j+1; |
---|
| 686 | }; |
---|
| 687 | E.summands=L; |
---|
| 688 | return(E);} |
---|
| 689 | |
---|
| 690 | |
---|
| 691 | |
---|
| 692 | |
---|
| 693 | //////////////////////////////////////////////////////////////////////////////// |
---|
| 694 | // P-divisors |
---|
| 695 | |
---|
| 696 | proc makePDivisor(list L) |
---|
| 697 | "USAGE: makePDivisor(L); L = list.@* |
---|
| 698 | ASSUME: L is a list of tuples of a integral polyhedron and a divisor such that |
---|
| 699 | all polyhedra have the same tail cone. |
---|
| 700 | RETURN: a pdivisor on X |
---|
| 701 | THEORY: Represents an polyhedral formal sum of divisors. |
---|
| 702 | KEYWORDS: divisors, polyhedra |
---|
| 703 | EXAMPLE: example makePDivisor; shows an example |
---|
| 704 | " |
---|
| 705 | { |
---|
| 706 | pdivisor P; |
---|
| 707 | list CP = decomposePolyhedron(L[1][1]); |
---|
| 708 | P.tail = CP[1]; |
---|
| 709 | list LP; |
---|
| 710 | LP[1]=list(CP[2],L[1][2]); |
---|
| 711 | int i; |
---|
| 712 | for (i=2; i<=size(L);i++){ |
---|
| 713 | CP = decomposePolyhedron(L[i][1]); |
---|
| 714 | if (!(CP[1]==P.tail)) {ERROR("All P-coefficients should have the same tail cone");} |
---|
| 715 | LP[i]=list(CP[2],L[i][2]); |
---|
| 716 | } |
---|
| 717 | P.summands = LP; |
---|
| 718 | return(P); |
---|
| 719 | } |
---|
| 720 | example |
---|
| 721 | { "EXAMPLE:"; |
---|
| 722 | ring r=31991,(x,y,z),dp; |
---|
| 723 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 724 | qring Q = std(I); |
---|
| 725 | divisor A = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 726 | divisor B = makeDivisor(ideal(x,y),ideal(1)); |
---|
| 727 | intmat M[4][4]= 1,4,0,0, |
---|
| 728 | 1,0,3,0, |
---|
| 729 | 0,0,0,2, |
---|
| 730 | 1,1,1,1; |
---|
| 731 | polytope PP = polytopeViaPoints(M); |
---|
| 732 | makePDivisor(list(list(PP,A),list(PP,B))); |
---|
| 733 | } |
---|
| 734 | |
---|
| 735 | static proc decomposePolyhedron(polytope P){ |
---|
| 736 | intmat rays = vertices(P); |
---|
| 737 | intmat rays2 = rays; |
---|
| 738 | int i,j; |
---|
| 739 | for (i=1; i<=nrows(rays);i++){ |
---|
| 740 | if (rays[i,1]==1) { |
---|
| 741 | for (j=1; j<=ncols(rays);j++){ |
---|
| 742 | rays[i,j]=0; |
---|
| 743 | } |
---|
| 744 | } else { |
---|
| 745 | for (j=1; j<=ncols(rays);j++){ |
---|
| 746 | rays2[i,j]=0; |
---|
| 747 | } |
---|
| 748 | } |
---|
| 749 | } |
---|
| 750 | cone C = coneViaPoints(rays); |
---|
| 751 | polytope C2 = polytopeViaPoints(rays2); |
---|
| 752 | return(list(C,C2)); |
---|
| 753 | } |
---|
| 754 | |
---|
| 755 | |
---|
| 756 | proc evaluatePDivisor(pdivisor D,intvec v) |
---|
| 757 | "USAGE: evaluatePDivisor(D,v); D = pdivisor, v = intvec.@* |
---|
| 758 | ASSUME: D is a polyhedral divisor on X and v is a point in the dual of the |
---|
| 759 | tailcone of the coefficients. |
---|
| 760 | RETURN: a formal divisor on X |
---|
| 761 | THEORY: Will evaluate the polyhedral sum to an integer formal sum. |
---|
| 762 | KEYWORDS: divisors, polyhedra |
---|
| 763 | EXAMPLE: example evaluatePDivisor; shows an example |
---|
| 764 | " |
---|
| 765 | { |
---|
| 766 | formaldivisor vD; |
---|
| 767 | list L = D.summands; |
---|
| 768 | cone C = D.tail; |
---|
| 769 | cone dC = dualCone(C); |
---|
| 770 | list vL; |
---|
| 771 | int i; |
---|
| 772 | intvec vv = 0,v; |
---|
| 773 | if (!(containsInSupport(dC,vv))) |
---|
| 774 | {ERROR("the linear form given should be in the dual tail cone");} |
---|
| 775 | for (i=1; i<=size(L);i++){ |
---|
| 776 | vL[i]=list(); |
---|
| 777 | vL[i][2]=L[i][2]; |
---|
| 778 | vL[i][1]=Polymake::minimalValue(L[i][1],vv); |
---|
| 779 | } |
---|
| 780 | vD.summands = vL; |
---|
| 781 | return(vD);} |
---|
| 782 | example |
---|
| 783 | { "EXAMPLE:"; |
---|
| 784 | LIB("polymake.so"); |
---|
| 785 | ring r=31991,(x,y,z),dp; |
---|
| 786 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 787 | qring Q = std(I); |
---|
| 788 | divisor A = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 789 | divisor B = makeDivisor(ideal(x,y),ideal(1)); |
---|
| 790 | intmat M[4][4]= 1,4,0,0, |
---|
| 791 | 1,0,3,0, |
---|
| 792 | 0,0,0,2, |
---|
| 793 | 1,1,1,1; |
---|
| 794 | polytope PP = polytopeViaPoints(M); |
---|
| 795 | pdivisor pD = makePDivisor(list(list(PP,A),list(PP,B))); |
---|
| 796 | intvec v=1,1,1; |
---|
| 797 | evaluatePDivisor(pD,v); |
---|
| 798 | } |
---|
| 799 | |
---|
| 800 | |
---|
| 801 | |
---|
| 802 | |
---|
| 803 | |
---|
| 804 | proc pdivisorplus(pdivisor A, pdivisor B) |
---|
| 805 | "USAGE: pdivisorplus(A ,B); A + B; A = pdivisor, B = pdivisor. @* |
---|
| 806 | ASSUME: A and B are polyhedral divisors on X. |
---|
| 807 | RETURN: a pdivisor on X |
---|
| 808 | THEORY: The procedure will add the polyhedral formal sums by doing Minkowski sums. |
---|
| 809 | KEYWORDS: divisors, polyhedra |
---|
| 810 | EXAMPLE: example pdivisorplus; shows an example |
---|
| 811 | " |
---|
| 812 | { |
---|
| 813 | pdivisor C; |
---|
| 814 | int i,p; |
---|
| 815 | int j=1; |
---|
| 816 | if (!(A.tail==B.tail)) {ERROR("tail cones should be equal");} |
---|
| 817 | list L; |
---|
| 818 | list LA=A.summands; |
---|
| 819 | list LB=B.summands; |
---|
| 820 | for (i=1; i<=size(LA);i++){ |
---|
| 821 | p=position(LA[i][2],L); |
---|
| 822 | if (p==0) { |
---|
| 823 | L[j]=list(); |
---|
| 824 | L[j][2]=LA[i][2]; |
---|
| 825 | L[j][1]=LA[i][1]; |
---|
| 826 | j=j+1; |
---|
| 827 | } else { |
---|
| 828 | L[p][1]=Polymake::minkowskiSum(L[p][1],LA[i][1]); |
---|
| 829 | }; |
---|
| 830 | } |
---|
| 831 | for (i=1; i<=size(LB);i++){ |
---|
| 832 | p=position(LB[i][2],L); |
---|
| 833 | if (p==0) { |
---|
| 834 | L[j]=list(); |
---|
| 835 | L[j][2]=LB[i][2]; |
---|
| 836 | L[j][1]=LB[i][1]; |
---|
| 837 | j=j+1; |
---|
| 838 | } else { |
---|
| 839 | L[p][1]=Polymake::minkowskiSum(L[p][1],LB[i][1]); |
---|
| 840 | }; |
---|
| 841 | } |
---|
| 842 | C.summands = L; |
---|
| 843 | C.tail = A.tail; |
---|
| 844 | return(C); |
---|
| 845 | } |
---|
| 846 | example |
---|
| 847 | { "EXAMPLE:"; |
---|
| 848 | LIB("polymake.so"); |
---|
| 849 | ring r=31991,(x,y,z),dp; |
---|
| 850 | ideal I = y^2*z - x*(x-z)*(x+3*z); |
---|
| 851 | qring Q = std(I); |
---|
| 852 | divisor A = makeDivisor(ideal(x,z),ideal(1)); |
---|
| 853 | divisor B = makeDivisor(ideal(x,y),ideal(1)); |
---|
| 854 | intmat M[4][4]= 1,4,0,0, |
---|
| 855 | 1,0,3,0, |
---|
| 856 | 0,0,0,2, |
---|
| 857 | 1,1,1,1; |
---|
| 858 | polytope PP = polytopeViaPoints(M); |
---|
| 859 | pdivisor pD = makePDivisor(list(list(PP,A),list(PP,B))); |
---|
| 860 | pdivisorplus(pD,pD); |
---|
| 861 | } |
---|
| 862 | |
---|
| 863 | |
---|