1############################################################################# 2## 3## ToricDivisors.gi ToricVarieties package 4## 5## Copyright 2011-2016, Sebastian Gutsche, TU Kaiserslautern 6## Martin Bies, ITP Heidelberg 7## 8## The category of toric divisors of a toric variety 9## 10############################################################################# 11 12################################# 13## 14## Representations 15## 16################################# 17 18DeclareRepresentation( "IsToricDivisorRep", 19 IsToricDivisor and IsAttributeStoringRep, 20 [ AmbientToricVariety, UnderlyingGroupElement ] 21 ); 22 23BindGlobal( "TheFamilyOfToricDivisors", 24 NewFamily( "TheFamilyOfToricDivisors" , IsToricDivisor ) ); 25 26BindGlobal( "TheTypeToricDivisor", 27 NewType( TheFamilyOfToricDivisors, 28 IsToricDivisorRep ) ); 29 30################################# 31## 32## Properties 33## 34################################# 35 36## 37InstallMethod( IsPrincipal, 38 "for toric divisors", 39 [ IsToricDivisor ], 40 41 function( divisor ) 42 43 return IsZero( ClassOfDivisor( divisor ) ); 44 45end ); 46 47## 48InstallMethod( IsPrimedivisor, 49 "for toric divisors", 50 [ IsToricDivisor ], 51 52 function( divisor ) 53 54 divisor := UnderlyingGroupElement( divisor ); 55 56 divisor := UnderlyingListOfRingElements( divisor ); 57 58 if ForAll( divisor, i -> i = 1 or i = 0 ) and Sum( divisor ) = 1 then 59 60 return true; 61 62 fi; 63 64 return false; 65 66end ); 67 68## 69InstallMethod( IsCartier, 70 "for toric divisors", 71 [ IsToricDivisor ], 72 73 function( divisor ) 74 local raysincones, rays, n, i, m, j, M, groupel, rayel, cartdata; 75 76 rays := RayGenerators( FanOfVariety( AmbientToricVariety( divisor ) ) ); 77 78 raysincones := RaysInMaximalCones( FanOfVariety( AmbientToricVariety( divisor ) ) ); 79 80 n := Length( raysincones ); 81 82 m := Length( rays ); 83 84 cartdata := [ 1 .. n ]; 85 86 groupel := UnderlyingListOfRingElements( UnderlyingGroupElement( divisor ) ); 87 88 for i in [ 1 .. n ] do 89 90 M := [ ]; 91 92 rayel := [ ]; 93 94 for j in [ 1 .. m ] do 95 96 if raysincones[ i ][ j ] = 1 then 97 98 Add( M, rays[ j ] ); 99 100 Add( rayel, - groupel[ j ] ); 101 102 fi; 103 104 od; 105 106 j := HomalgMatrix( rayel, Length( M ), 1, HOMALG_MATRICES.ZZ ); 107 108 M := HomalgMatrix( M, HOMALG_MATRICES.ZZ ); 109 110 j := LeftDivide( M, j ); 111 112 if j = fail then 113 114 return false; 115 116 fi; 117 118 cartdata[ i ] := EntriesOfHomalgMatrix( j ); 119 120 od; 121 122 SetCartierData( divisor, cartdata ); 123 124 return true; 125 126end ); 127 128## 129InstallMethod( IsAmple, 130 " for toric divisors", 131 [ IsToricDivisor ], 132 133 function( divisor ) 134 local rays, raysincones, cartdata, groupel, l, i, multlist, j; 135 136 rays := AmbientToricVariety( divisor ); 137 138 if not IsComplete( rays ) or not IsNormalVariety( rays ) then 139 140 Error( "computation may be wrong up to unfulfilled preconditions\n" ); 141 142 fi; 143 144 if not IsBasepointFree( divisor ) then 145 146 return false; 147 148 fi; 149 150 groupel := UnderlyingListOfRingElements( UnderlyingGroupElement( divisor ) ); 151 152 l := Length( groupel ); 153 154 Apply( groupel, i -> -i ); 155 156 rays := RayGenerators( FanOfVariety( AmbientToricVariety( divisor ) ) ); 157 158 cartdata := CartierData( divisor ); 159 160 raysincones := RaysInMaximalCones( FanOfVariety( AmbientToricVariety( divisor ) ) ); 161 162 for i in [ 1 .. Length( cartdata ) ] do 163 164 for j in [ 1 .. l ] do 165 166 if raysincones[ i ][ j ] = 0 then 167 168 multlist := Sum( List( [ 1 .. Length( cartdata[ i ] ) ], k -> rays[ j ][ k ] * cartdata[ i ][ k ] ) ); 169 170 if multlist <= groupel[ j ] then 171 172 return false; 173 174 fi; 175 176 fi; 177 178 od; 179 180 od; 181 182 return true; 183 184end ); 185 186## 187InstallMethod( IsBasepointFree, 188 "for toric divisors", 189 [ IsToricDivisor ], 190 191 function( divisor ) 192 local rays, cartdata, groupel, l, i, multlist, j; 193 194 if HasTorusfactor( AmbientToricVariety( divisor ) ) then 195 196 Error( "variety has torusfactors, computation may be wrong\n" ); 197 198 fi; 199 200# # if not IsComplete( AmbientToricVariety( divisor ) ) then 201# # 202# # Error( "variety is not complete, computation may be wrong." ); 203# # 204# # fi; 205 206 if not IsCartier( divisor ) then 207 208 return false; 209 210 fi; 211 212 groupel := UnderlyingListOfRingElements( UnderlyingGroupElement( divisor ) ); 213 214 l := Length( groupel ); 215 216 Apply( groupel, i -> -i ); 217 218 rays := RayGenerators( FanOfVariety( AmbientToricVariety( divisor ) ) ); 219 220 cartdata := CartierData( divisor ); 221 222 for i in cartdata do 223 224 multlist := List( rays, k -> Sum( [ 1 .. Length( k ) ], j -> k[j]*i[j] ) ); 225 226 if not ForAll( [ 1..l ], j -> multlist[ j ] >= groupel[ j ] ) then 227 228 return false; 229 230 fi; 231 232 od; 233 234 return true; 235 236end ); 237 238## 239InstallMethod( IsVeryAmple, 240 "for toric divisors", 241 [ IsToricDivisor and IsAmple ], 242 243 function( divisor ) 244 245 return IsVeryAmple( PolytopeOfDivisor( divisor ) ); 246 247end ); 248 249## 250## RedispatchOnCondition( IsVeryAmple, true, [ IsToricDivisor and IsAmple ], [ PolytopeOfDivisor ], 1 ); 251 252## 253RedispatchOnCondition( IsVeryAmple, true, [ IsToricDivisor ], [ IsAmple ], 0 ); 254 255 256################################# 257## 258## Attributes 259## 260################################# 261 262## 263InstallMethod( ClassOfDivisor, 264 "for toric divisors", 265 [ IsToricDivisor ], 266 267 function( divisor ) 268 269 return ApplyMorphismToElement( MapFromWeilDivisorsToClassGroup( AmbientToricVariety( divisor ) ), 270 UnderlyingGroupElement( divisor ) 271 ); 272 273end ); 274 275## 276InstallMethod( CartierData, 277 "for toric divisors", 278 [ IsToricDivisor and IsCartier ], 279 280 function( divisor ) 281 local raysincones, rays, n, i, m, j, M, groupel, rayel, cartdata; 282 283 rays := RayGenerators( FanOfVariety( AmbientToricVariety( divisor ) ) ); 284 285 raysincones := RaysInMaximalCones( FanOfVariety( AmbientToricVariety( divisor ) ) ); 286 287 n := Length( raysincones ); 288 289 m := Length( rays ); 290 291 cartdata := [ 1 .. n ]; 292 293 groupel := UnderlyingListOfRingElements( UnderlyingGroupElement( divisor ) ); 294 295 for i in [ 1 .. n ] do 296 297 M := [ ]; 298 299 rayel := [ ]; 300 301 for j in [ 1 .. m ] do 302 303 if raysincones[ i ][ j ] = 1 then 304 305 Add( M, rays[ j ] ); 306 307 Add( rayel, - groupel[ j ] ); 308 309 fi; 310 311 od; 312 313 j := HomalgMatrix( rayel, Length( M ), 1, HOMALG_MATRICES.ZZ ); 314 315 M := HomalgMatrix( M, HOMALG_MATRICES.ZZ ); 316 317 j := LeftDivide( M, j ); 318 319 if j = fail then 320 321 return false; 322 323 fi; 324 325 # this line causes problems 326 #cartdata[ i ] := HomalgModuleElement( j, CharacterLattice( AmbientToricVariety( divisor ) ) ); 327 # resolution is this here, which makes use of yet another bug, namely EntriesOfHomalgMatrix does in my opinion not operate correctly 328 cartdata[ i ] := EntriesOfHomalgMatrix( j ); 329 od; 330 331 return cartdata; 332 333end ); 334 335## 336InstallMethod( PolytopeOfDivisor, 337 "for toric divisors", 338 [ IsToricDivisor ], 339 340 function( divisor ) 341 local rays, divlist; 342 343 rays := RayGenerators( FanOfVariety( AmbientToricVariety( divisor ) ) ); 344 345 divlist := UnderlyingListOfRingElements( UnderlyingGroupElement( divisor ) ); 346 347 divlist := List( [ 1 .. Length( rays ) ], i -> Concatenation( [ divlist[ i ] ], rays[ i ] ) ); 348 349 return PolytopeByInequalities( divlist ); 350 351end ); 352 353## 354InstallMethod( BasisOfGlobalSections, 355 "for toric divisors", 356 [ IsToricDivisor ], 357 358 function( divisor ) 359 local points, divisor_polytope; 360 361 divisor_polytope := PolytopeOfDivisor( divisor ); 362 363 if not IsBounded( divisor_polytope ) then 364 365 Error( "list is infinite, cannot compute characters\n" ); 366 367 fi; 368 369 points := LatticePoints( divisor_polytope ); 370 371 return List( points, i -> CharacterToRationalFunction( i, AmbientToricVariety( divisor ) ) ); 372 373end ); 374 375## 376InstallMethod( IntegerForWhichIsSureVeryAmple, 377 "for toric divisors", 378 [ IsToricDivisor and IsAmple ], 379 380 function( divisor ) 381 local vari; 382 383 vari := AmbientToricVariety( divisor ); 384 385 if IsSmooth( vari ) and IsComplete( vari ) then 386 387 return 1; 388 389 fi; 390 391 if Dimension( vari ) >= 2 then 392 393 return Dimension( vari ) - 1; 394 395 fi; 396 397 TryNextMethod(); 398 399end ); 400 401## 402InstallMethod( UnderlyingToricVariety, 403 "for prime divisors", 404 [ IsToricDivisor and IsPrimedivisor ], 405 406 function( divisor ) 407 local pos, vari, cones, i, neuvar, ray; 408 409 pos := Position( UnderlyingListOfRingElements( UnderlyingGroupElement( divisor ) ), 1 ); 410 411 vari := AmbientToricVariety( divisor ); 412 413 vari := FanOfVariety( vari ); 414 415 cones := RaysInMaximalCones( vari ); 416 417 neuvar := [ ]; 418 419 for i in [ 1 .. Length( cones ) ] do 420 421 if cones[ i ][ pos ] = 1 then 422 423 neuvar := Concatenation( neuvar, [ i ] ); 424 425 fi; 426 427 od; 428 429 ray := Rays( vari )[ pos ]; 430 431 ray := ByASmallerPresentation( FactorGridMorphism( ray ) ); 432 433 cones := MaximalCones( vari ){ neuvar }; 434 435 cones := List( cones, HilbertBasis ); 436 437 cones := List( cones, i -> List( i, j -> HomalgMap( HomalgMatrix( [ j ], HOMALG_MATRICES.ZZ ), 1 * HOMALG_MATRICES.ZZ, ContainingGrid( vari ) ) ) ); 438 439 cones := List( cones, i -> List( i, j -> UnderlyingListOfRingElements( ApplyMorphismToElement( ray, HomalgElement( j ) ) ) ) ); 440 441 cones := Fan( cones ); 442 443 neuvar := ToricSubvariety( ToricVariety( cones ), AmbientToricVariety( divisor ) ); 444 445 SetIsClosedSubvariety( neuvar, true ); 446 447 SetIsOpen( neuvar, false ); 448 449 return neuvar; 450 451end ); 452 453## 454InstallMethod( DegreeOfDivisor, 455 "for toric divisors", 456 [ IsToricDivisor ], 457 458 function( divisor ) 459 460 return Sum( UnderlyingListOfRingElements( UnderlyingGroupElement( divisor ) ) ); 461 462end ); 463 464## 465InstallMethod( MonomsOfCoxRingOfDegree, 466 " for toric divisorsors", 467 [ IsToricDivisor ], 468 469 function( divisor ) 470 local cox_ring, ring, points, rays, n, i, j, mons, mon; 471 472 if not HasCoxRing( AmbientToricVariety( divisor ) ) then 473 474 Error( "specify cox ring first\n" ); 475 476 fi; 477 478 cox_ring := CoxRing( AmbientToricVariety( divisor ) ); 479 480 ring := ListOfVariablesOfCoxRing( AmbientToricVariety( divisor ) ); 481 482 if not IsBounded( PolytopeOfDivisor( divisor ) ) then 483 484 Error( "list is infinite, cannot compute basis because it is not finite\n" ); 485 486 fi; 487 488 points := LatticePoints( PolytopeOfDivisor( divisor ) ); 489 490 rays := RayGenerators( FanOfVariety( AmbientToricVariety( divisor ) ) ); 491 492 divisor := UnderlyingListOfRingElements( UnderlyingGroupElement( divisor ) ); 493 494 n := Length( rays ); 495 496 mons := [ ]; 497 498 for i in points do 499 500 mon := List( [ 1 .. n ], j -> JoinStringsWithSeparator( [ ring[ j ], String( ( Sum( List( [ 1 .. Length( i ) ], m -> rays[ j ][ m ] * i[ m ] ) ) ) + divisor[ j ] ) ], "^" ) ); 501 502 mon := JoinStringsWithSeparator( mon, "*" ); 503 504 Add( mons, HomalgRingElement( mon, cox_ring ) ); 505 506 od; 507 508 return mons; 509 510end ); 511 512## 513InstallMethod( CoxRingOfTargetOfDivisorMorphism, 514 "for basepoint free divisors", 515 [ IsToricDivisor ], 516 517 function( divisor ) 518 519 return CoxRingOfTargetOfDivisorMorphism( divisor, TORIC_VARIETIES.CoxRingIndet ); 520 521end ); 522 523## 524InstallMethod( RingMorphismOfDivisor, 525 "for basepoint free divisors", 526 [ IsToricDivisor ], 527 528 function( divisor ) 529 local coxring, images, var_coxring; 530 531 coxring := CoxRingOfTargetOfDivisorMorphism( divisor ); 532 533 var_coxring := CoxRing( AmbientToricVariety( divisor ) ); 534 535 images := MonomsOfCoxRingOfDegree( divisor ); 536 537 return RingMap( images, coxring, var_coxring ); 538 539end ); 540 541 542################################# 543## 544## Methods 545## 546################################# 547 548## 549InstallMethod( CharactersForClosedEmbedding, 550 "for toric varieties.", 551 [ IsToricDivisor and IsVeryAmple ], 552 553 function( divisor ) 554 555 return BasisOfGlobalSections( divisor ); 556 557end ); 558 559## 560RedispatchOnCondition( CharactersForClosedEmbedding, true, [ IsToricDivisor ], [ IsVeryAmple ], 0 ); 561 562## 563InstallMethod( VeryAmpleMultiple, 564 " for ample toric divisorsors.", 565 [ IsToricDivisor and IsAmple ], 566 567 function( divisor ) 568 569 return IntegerForWhichIsSureVeryAmple( divisor ) * divisor; 570 571end ); 572 573## 574RedispatchOnCondition( VeryAmpleMultiple, true, [ IsToricDivisor ], [ IsAmple ], 0 ); 575 576## 577InstallMethod( VarietyOfDivisorpolytope, 578 " for ample divisorsors", 579 [ IsToricDivisor and IsBasepointFree ], 580 581 function( divisor ) 582 583 return ToricVariety( PolytopeOfDivisor( divisor ) ); 584 585end ); 586 587## 588InstallMethod( MonomsOfCoxRingOfDegree, 589 " for homalg elements", 590 [ IsToricVariety, IsHomalgElement ], 591 592 function( vari, elem ) 593 local pos; 594 595 if not IsIdenticalObj( Range( UnderlyingMorphism( elem ) ), ClassGroup( vari ) ) then 596 597 Error( "wrong element\n" ); 598 599 fi; 600 601 pos := UnderlyingListOfRingElements( elem ); 602 603 pos := CreateDivisor( pos, vari ); 604 605 return MonomsOfCoxRingOfDegree( pos ); 606 607end ); 608 609## 610InstallMethod( MonomsOfCoxRingOfDegree, 611 " for lists", 612 [ IsToricVariety, IsList ], 613 614 function( vari, lis ) 615 local pos, elem, mor; 616 617 elem := HomalgMatrix( lis, 1, Length( lis ), HOMALG_MATRICES.ZZ ); 618 619 elem := HomalgMap( elem, 1 * HOMALG_MATRICES.ZZ, TorusInvariantDivisorGroup( vari ) ); 620 621 elem := HomalgElement( elem ); 622 623 mor := MapFromWeilDivisorsToClassGroup( vari ); 624 625 elem := ApplyMorphismToElement( mor, elem ); 626 627 return MonomsOfCoxRingOfDegree( vari, elem ); 628 629end ); 630 631## 632InstallMethod( CoxRingOfTargetOfDivisorMorphism, 633 "for toric divisors", 634 [ IsToricDivisor, IsString ], 635 636 function( divisor, variable ) 637 local nrpoints, classgroup, degrees, coxring; 638 639 if not IsBasepointFree( divisor ) then 640 641 Error( "no embedding in projective variety defined\n" ); 642 643 fi; 644 645 nrpoints := Length( LatticePoints( Polytope( divisor ) ) ); 646 647 classgroup := 1 * HOMALG_MATRICES.ZZ; 648 649 coxring := DefaultFieldForToricVarieties() * JoinStringsWithSeparator( [ variable, JoinStringsWithSeparator( [ "1", String( nrpoints ) ], ".." ) ], "_" ); 650 651 coxring := GradedRing( coxring ); 652 653 SetDegreeGroup( coxring, classgroup ); 654 655 degrees := List( [ 1 .. nrpoints ], i -> GeneratingElements( classgroup )[ 1 ] ); 656 657 SetWeightsOfIndeterminates( coxring, degrees ); 658 659 return coxring; 660 661end ); 662 663## 664InstallMethod( \+, 665 "for toric divisors", 666 [ IsToricDivisor, IsToricDivisor ], 667 668 function( divisor1, divisor2 ) 669 local sum_of_divisors; 670 671 if not IsIdenticalObj( AmbientToricVariety( divisor1 ), AmbientToricVariety( divisor2 ) ) then 672 673 Error( "cannot add these divisors\n" ); 674 675 return 0; 676 677 fi; 678 679 sum_of_divisors := CreateDivisor( UnderlyingGroupElement( divisor1 ) + UnderlyingGroupElement( divisor2 ), AmbientToricVariety( divisor1 ) ); 680 681 SetClassOfDivisor( sum_of_divisors, ClassOfDivisor( divisor1 ) + ClassOfDivisor( divisor2 ) ); 682 683 return sum_of_divisors; 684 685end ); 686 687## 688InstallMethod( \-, 689 "for toric divisor", 690 [ IsToricDivisor , IsToricDivisor ], 691 692 function( divisor1, divisor2 ) 693 694 return divisor1 + ( -1 ) * divisor2; 695 696end ); 697 698## 699InstallMethod( \*, 700 "for toric divisorsors", 701 [ IsInt, IsToricDivisor ], 702 703 function( a, divisor ) 704 local divisor1; 705 706 divisor1 := CreateDivisor( a * UnderlyingGroupElement( divisor ), AmbientToricVariety( divisor ) ); 707 708 SetClassOfDivisor( divisor1, a * ClassOfDivisor( divisor ) ); 709 710 return divisor1; 711 712end ); 713 714## 715InstallMethod( AddDivisorToItsAmbientVariety, 716 "for toric divisors", 717 [ IsToricDivisor ], 718 719 function( divisor ) 720 local ambient_variety; 721 722 ambient_variety := AmbientToricVariety( divisor ); 723 724 Add( ambient_variety!.WeilDivisors, divisor ); 725 726end ); 727 728## 729InstallMethod( Polytope, 730 "for toric divisors", 731 [ IsToricDivisor ], 732 733 function( divisor ) 734 735 return PolytopeOfDivisor( divisor ); 736 737end ); 738 739## 740InstallMethod( \=, 741 "for toric divisors", 742 [ IsToricDivisor, IsToricDivisor ], 743 744 function( divi1, divi2 ) 745 746 return UnderlyingGroupElement( divi1 ) = UnderlyingGroupElement( divi2 ); 747 748end ); 749 750################################## 751## 752## Constructors 753## 754################################## 755 756## 757InstallMethod( CreateDivisor, 758 " for toric varieties", 759 [ IsHomalgElement, IsToricVariety ], 760 761 function( group_element, variety ) 762 local divisor, entry; 763 764 divisor := rec( ); 765 766 ObjectifyWithAttributes( 767 divisor, TheTypeToricDivisor, 768 AmbientToricVariety, variety, 769 UnderlyingGroupElement, group_element 770 ); 771 772 entry := ToDoListEntry( [ [ divisor, "IsAmple", true ] ], variety, "IsProjective", true ); 773 774 SetDescriptionOfImplication( entry, "a variety with an ample divisor is projective." ); 775 776 AddToToDoList( entry ); 777 778 entry := ToDoListEntry( [ [ variety, "IsSmooth", true ] ], divisor, "IsCartier", true ); 779 780 SetDescriptionOfImplication( entry, "every divisor of a smooth variety is Cartier." ); 781 782 AddToToDoList( entry ); 783 784# entry := ToDoListEntry( [ [ variety, "IsSmooth", true ], [ divisor, "IsCartier", true ] ], divisor, "IsPrincipal", true ); 785# 786# SetDescriptionOfImplication( entry, "every Cartier divisor on a smooth variety is principal." ); 787# 788# AddToToDoList( entry ); 789 790 AddDivisorToItsAmbientVariety( divisor ); 791 792 return divisor; 793 794end ); 795 796## 797InstallMethod( CreateDivisor, 798 "for toric varieties", 799 [ IsList, IsToricVariety ], 800 801 function( group_element, variety ) 802 local elem; 803 804 elem := HomalgMatrix( [ group_element ], HOMALG_MATRICES.ZZ ); 805 806 elem := HomalgMap( elem, 1 * HOMALG_MATRICES.ZZ, TorusInvariantDivisorGroup( variety ) ); 807 808 elem := HomalgElement( elem ); 809 810 return CreateDivisor( elem, variety ); 811 812end ); 813 814## 815InstallMethod( DivisorOfCharacter, 816 " for toric varieties", 817 [ IsHomalgElement, IsToricVariety ], 818 819 function( character, variety ) 820 local group_element, divisor; 821 822 group_element := ApplyMorphismToElement( MapFromCharacterToPrincipalDivisor( variety ), character ); 823 824 divisor := CreateDivisor( group_element, variety ); 825 826 SetIsPrincipal( divisor, true ); 827 828 SetCharacterOfPrincipalDivisor( divisor, character ); 829 830 SetIsCartier( divisor, true ); 831 832 SetCartierData( divisor, List( MaximalCones( FanOfVariety( variety ) ), i -> ( -1 )* UnderlyingListOfRingElements( character ) ) ); 833 834 SetClassOfDivisor( divisor, TheZeroElement( ClassGroup( variety ) ) ); 835 836 AddDivisorToItsAmbientVariety( divisor ); 837 838 return divisor; 839 840end ); 841 842## 843InstallMethod( DivisorOfCharacter, 844 " for toric varieties.", 845 [ IsList, IsToricVariety ], 846 847 function( character, variety ) 848 849 character := HomalgMatrix( [ character ], HOMALG_MATRICES.ZZ ); 850 851 character := HomalgMap( character, 1 * HOMALG_MATRICES.ZZ, CharacterLattice( variety ) ); 852 853 character := HomalgElement( character ); 854 855 return DivisorOfCharacter( character, variety ); 856 857end ); 858 859## construct divisor associated to list encoding homalgElement in the classgroup of a toric variety 860InstallMethod( DivisorOfGivenClass, 861 " for toric varieties.", 862 [ IsToricVariety, IsList ], 863 864function( variety, list ) 865 866local epi, matrix, preimage; 867 868 if not Length( list ) = Rank( ClassGroup( variety ) ) then 869 870 Error( "Length of list does not match the rank of the class group" ); 871 872 fi; 873 874 epi := MapFromWeilDivisorsToClassGroup( variety ); 875 876 # and its mapping matrix 877 matrix := MatrixOfMap( epi ); 878 879 # now find solution to X * matrix = [list] by applying "RightDivide" 880 preimage := RightDivide( HomalgMatrix( [list], HOMALG_MATRICES.ZZ ) , matrix ); 881 882 # turn preimage into an HomalgElement 883 # the use of TorusInvariantDivisorGroup ensures that the method ClassOfDivisor is applicable to the created divisor 884 preimage := HomalgElement( HomalgMap( preimage, 1 * HOMALG_MATRICES.ZZ, TorusInvariantDivisorGroup( variety ) ) ); 885 886 # and now create a Weil divisor associated to this element 887 return CreateDivisor( preimage, variety ); 888 889end ); 890 891## Construct divisor associated to homalgElement in the classgroup of a toric variety 892InstallMethod( DivisorOfGivenClass, 893 " for toric varieties.", 894 [ IsToricVariety, IsHomalgElement ], 895 896function( variety, elem ) 897 898local list; 899 900 # express elem as a list 901 list := UnderlyingListOfRingElements( UnderlyingGroupElement( elem ) ); 902 903 # and then hand the data to the above method 904 return DivisorOfGivenClass( variety, list ); 905 906end ); 907 908################################# 909## 910## View 911## 912################################# 913 914## 915InstallMethod( ViewObj, 916 "for toric divisors", 917 [ IsToricDivisor ], 918 919 function( divisor ) 920 local prin; 921 922 prin := false; 923 924 Print( "<A" ); 925 926 if HasIsAmple( divisor ) then 927 928 if HasIsVeryAmple( divisor ) then 929 930 if IsVeryAmple( divisor ) then 931 932 Print( " very ample" ); 933 934 elif IsAmple( divisor ) then 935 936 Print( "n ample" ); 937 938 fi; 939 940 elif IsAmple( divisor ) then 941 942 Print( "n ample" ); 943 944 fi; 945 946 fi; 947 948 if HasIsBasepointFree( divisor ) then 949 950 if IsBasepointFree( divisor ) then 951 952 Print( " basepoint free" ); 953 954 fi; 955 956 fi; 957 958 if HasIsPrincipal( divisor ) then 959 960 if IsPrincipal( divisor ) then 961 962 Print( " principal" ); 963 964 prin := true; 965 966 fi; 967 968 fi; 969 970 if HasIsCartier( divisor ) then 971 972 if IsCartier( divisor ) and not prin then 973 974 Print( " Cartier" ); 975 976 fi; 977 978 fi; 979 980 if HasIsPrimedivisor( divisor ) then 981 982 if IsPrimedivisor( divisor ) then 983 984 Print( " prime" ); 985 986 fi; 987 988 fi; 989 990 Print( " divisor of a toric variety with coordinates " ); 991 992 ViewObj( UnderlyingGroupElement( divisor ) ); 993 994 Print( ">" ); 995 996end ); 997 998## 999InstallMethod( Display, 1000 "for toric divisors", 1001 [ IsToricDivisor ], 1002 1003 function( divisor ) 1004 local prin; 1005 1006 prin := false; 1007 1008 Print( "A" ); 1009 1010 if HasIsAmple( divisor ) then 1011 1012 if HasIsVeryAmple( divisor ) then 1013 1014 if IsVeryAmple( divisor ) then 1015 1016 Print( " very ample" ); 1017 1018 elif IsAmple( divisor ) then 1019 1020 Print( "n ample" ); 1021 1022 fi; 1023 1024 elif IsAmple( divisor ) then 1025 1026 Print( "n ample" ); 1027 1028 fi; 1029 1030 fi; 1031 1032 if HasIsBasepointFree( divisor ) then 1033 1034 if IsBasepointFree( divisor ) then 1035 1036 Print( " basepoint free" ); 1037 1038 fi; 1039 1040 fi; 1041 1042 if HasIsPrincipal( divisor ) then 1043 1044 if IsPrincipal( divisor ) then 1045 1046 Print( " principal" ); 1047 1048 prin := true; 1049 1050 fi; 1051 1052 fi; 1053 1054 if HasIsCartier( divisor ) then 1055 1056 if IsCartier( divisor ) and not prin then 1057 1058 Print( " Cartier" ); 1059 1060 fi; 1061 1062 fi; 1063 1064 Print( " divisor of a toric variety" ); 1065 1066 Print( ".\n" ); 1067 1068end ); 1069