| 430 | def __cmp__(self, right): |
| 431 | r""" |
| 432 | Compare ``self`` and ``right``. |
| 433 | |
| 434 | INPUT: |
| 435 | |
| 436 | - ``right`` -- anything. |
| 437 | |
| 438 | OUTPUT: |
| 439 | |
| 440 | - 0 if ``right`` is also a toric morphism between the same domain and |
| 441 | codomain, given by an equal fan morphism. 1 or -1 otherwise. |
| 442 | |
| 443 | TESTS:: |
| 444 | |
| 445 | sage: A2 = toric_varieties.A2() |
| 446 | sage: P3 = toric_varieties.P(3) |
| 447 | sage: m = matrix([(2,0,0), (1,1,0)]) |
| 448 | sage: phi = A2.hom(m, P3) |
| 449 | sage: cmp(phi, phi) |
| 450 | 0 |
| 451 | sage: cmp(phi, prod(phi.factor())) |
| 452 | 0 |
| 453 | sage: cmp(phi, phi.factor()[0]) |
| 454 | -1 |
| 455 | sage: cmp(phi, 1) * cmp(1, phi) |
| 456 | -1 |
| 457 | """ |
| 458 | if isinstance(right, SchemeMorphism_fan_toric_variety): |
| 459 | return cmp( |
| 460 | [self.domain(), self.codomain(), self.fan_morphism()], |
| 461 | [right.domain(), right.codomain(), right.fan_morphism()]) |
| 462 | else: |
| 463 | return cmp(type(self), type(right)) |
| 464 | |
| 465 | def __imul__(self, right): |
| 466 | """ |
| 467 | Return the composition of ``self`` and ``right``. |
| 468 | |
| 469 | INPUT: |
| 470 | |
| 471 | - ``right`` -- a toric morphism defined by a fan morphism. |
| 472 | |
| 473 | OUTPUT: |
| 474 | |
| 475 | - a toric morphism. |
| 476 | |
| 477 | EXAMPLES:: |
| 478 | |
| 479 | sage: A2 = toric_varieties.A2() |
| 480 | sage: P3 = toric_varieties.P(3) |
| 481 | sage: m = matrix([(2,0,0), (1,1,0)]) |
| 482 | sage: phi = A2.hom(m, P3) |
| 483 | sage: phi |
| 484 | Scheme morphism: |
| 485 | From: 2-d affine toric variety |
| 486 | To: 3-d CPR-Fano toric variety covered by 4 affine patches |
| 487 | Defn: Defined by sending Rational polyhedral fan in 2-d lattice N to |
| 488 | Rational polyhedral fan in 3-d lattice N. |
| 489 | sage: prod(phi.factor()) # indirect test |
| 490 | Scheme morphism: |
| 491 | From: 2-d affine toric variety |
| 492 | To: 3-d CPR-Fano toric variety covered by 4 affine patches |
| 493 | Defn: Defined by sending Rational polyhedral fan in 2-d lattice N to |
| 494 | Rational polyhedral fan in 3-d lattice N. |
| 495 | """ |
| 496 | if not isinstance(right, SchemeMorphism_fan_toric_variety): |
| 497 | raise NotImplementedError("only composing toric morphisms based on " |
| 498 | "fan morphisms is implemented at the moment") |
| 499 | f = self.fan_morphism() * right.fan_morphism() |
| 500 | return right.domain().hom(f, self.codomain()) |
| 501 | |
| 525 | def factor(self): |
| 526 | r""" |
| 527 | Factor ``self`` into injective * birational * surjective morphisms. |
| 528 | |
| 529 | OUTPUT: |
| 530 | |
| 531 | - a triple of toric morphisms `(\phi_i, \phi_b, \phi_s)`, such that |
| 532 | `\phi_s` is surjective, `\phi_b` is birational, `\phi_i` is injective, |
| 533 | and ``self`` is equal to `\phi_i \circ \phi_b \circ \phi_s`. |
| 534 | |
| 535 | The intermediate varieties are universal in the following sense. Let |
| 536 | ``self`` map `X` to `X'` and let `X_s`, `X_i` seat in between, i.e. |
| 537 | |
| 538 | .. math:: |
| 539 | |
| 540 | X |
| 541 | \twoheadrightarrow |
| 542 | X_s |
| 543 | \to |
| 544 | X_i |
| 545 | \hookrightarrow |
| 546 | X'. |
| 547 | |
| 548 | Then any toric morphism from `X` coinciding with ``self`` on the maximal |
| 549 | torus factors through `X_s` and any toric morphism into `X'` coinciding |
| 550 | with ``self`` on the maximal torus factors through `X_i`. In particular, |
| 551 | `X_i` is the closure of the image of ``self`` in `X'`. |
| 552 | |
| 553 | See |
| 554 | :meth:`~sage.geometry.fan_morphism.FanMorphism.factor` |
| 555 | for a description of the toric algorithm. |
| 556 | |
| 557 | EXAMPLES: |
| 558 | |
| 559 | We map an affine plane into a projective 3-space in such a way, that it |
| 560 | becomes "a double cover of a chart of the blow up of one of the |
| 561 | coordinate planes":: |
| 562 | |
| 563 | sage: A2 = toric_varieties.A2() |
| 564 | sage: P3 = toric_varieties.P(3) |
| 565 | sage: m = matrix([(2,0,0), (1,1,0)]) |
| 566 | sage: phi = A2.hom(m, P3) |
| 567 | sage: phi.as_polynomial_map() |
| 568 | Scheme morphism: |
| 569 | From: 2-d affine toric variety |
| 570 | To: 3-d CPR-Fano toric variety covered by 4 affine patches |
| 571 | Defn: Defined on coordinates by sending [x : y] to |
| 572 | [x^2*y : y : 1 : 1] |
| 573 | |
| 574 | sage: phi.is_surjective(), phi.is_birational(), phi.is_injective() |
| 575 | (False, False, False) |
| 576 | sage: phi_i, phi_b, phi_s = phi.factor() |
| 577 | sage: phi_s.is_surjective(), phi_b.is_birational(), phi_i.is_injective() |
| 578 | (True, True, True) |
| 579 | sage: prod(phi.factor()) == phi |
| 580 | True |
| 581 | |
| 582 | Double cover (surjective):: |
| 583 | |
| 584 | sage: phi_s.as_polynomial_map() |
| 585 | Scheme morphism: |
| 586 | From: 2-d affine toric variety |
| 587 | To: 2-d affine toric variety |
| 588 | Defn: Defined on coordinates by sending [x : y] to |
| 589 | [x^2 : y] |
| 590 | |
| 591 | Blowup chart (birational):: |
| 592 | |
| 593 | sage: phi_b.as_polynomial_map() |
| 594 | Scheme morphism: |
| 595 | From: 2-d affine toric variety |
| 596 | To: 2-d toric variety covered by 3 affine patches |
| 597 | Defn: Defined on coordinates by sending [z0 : z1] to |
| 598 | [z0*z1 : z1 : 1] |
| 599 | |
| 600 | Coordinate plane inclusion (injective):: |
| 601 | |
| 602 | sage: phi_i.as_polynomial_map() |
| 603 | Scheme morphism: |
| 604 | From: 2-d toric variety covered by 3 affine patches |
| 605 | To: 3-d CPR-Fano toric variety covered by 4 affine patches |
| 606 | Defn: Defined on coordinates by sending [z0 : z1 : z2] to |
| 607 | [z0 : z1 : z2 : z2] |
| 608 | """ |
| 609 | phi_i, phi_b, phi_s = self.fan_morphism().factor() |
| 610 | from sage.schemes.toric.all import ToricVariety |
| 611 | X = self.domain() |
| 612 | X_s = ToricVariety(phi_s.codomain_fan()) |
| 613 | X_i = ToricVariety(phi_i.domain_fan()) |
| 614 | X_prime = self.codomain() |
| 615 | return X_i.hom(phi_i, X_prime), X_s.hom(phi_b, X_i), X.hom(phi_s, X_s) |
| 616 | |