# HG changeset patch
# User Volker Braun <vbraun@stp.dias.ie>
# Date 1371694409 25200
# Wed Jun 19 19:13:29 2013 -0700
# Node ID fc05ca1d7d6c9b1073a79fa0a263adccb87fe7e5
# Parent adaade0c9cc104e93bcfd035736cda27bed224aa
Use the morphism framework for composition of toric morphisms
diff --git a/sage/schemes/toric/morphism.py b/sage/schemes/toric/morphism.py
a
|
b
|
|
161 | 161 | # http://www.gnu.org/licenses/ |
162 | 162 | #***************************************************************************** |
163 | 163 | |
| 164 | # For now, the scheme morphism base class cannot derive from Morphism |
| 165 | # since this would clash with elliptic curves. So we derive only on |
| 166 | # the toric varieties level from Morphism. See |
| 167 | # https://groups.google.com/d/msg/sage-devel/qF4yU6Vdmao/wQlNrneSmWAJ |
| 168 | from sage.categories.morphism import Morphism |
| 169 | |
164 | 170 | from sage.structure.sequence import Sequence |
165 | 171 | from sage.rings.all import ZZ |
166 | 172 | |
… |
… |
|
174 | 180 | |
175 | 181 | ############################################################################ |
176 | 182 | # A points on a toric variety determined by homogeneous coordinates. |
177 | | class SchemeMorphism_point_toric_field(SchemeMorphism_point): |
| 183 | class SchemeMorphism_point_toric_field(SchemeMorphism_point, Morphism): |
178 | 184 | """ |
179 | 185 | A point of a toric variety determined by homogeneous coordinates |
180 | 186 | in a field. |
… |
… |
|
245 | 251 | |
246 | 252 | ############################################################################ |
247 | 253 | # A morphism of toric varieties determined by homogeneous polynomials. |
248 | | class SchemeMorphism_polynomial_toric_variety(SchemeMorphism_polynomial): |
| 254 | class SchemeMorphism_polynomial_toric_variety(SchemeMorphism_polynomial, Morphism): |
249 | 255 | """ |
250 | 256 | A morphism determined by homogeneous polynomials. |
251 | 257 | |
… |
… |
|
341 | 347 | |
342 | 348 | ############################################################################ |
343 | 349 | # A morphism of toric varieties determined by a fan morphism |
344 | | class SchemeMorphism_fan_toric_variety(SchemeMorphism): |
| 350 | class SchemeMorphism_fan_toric_variety(SchemeMorphism, Morphism): |
345 | 351 | """ |
346 | 352 | Construct a morphism determined by a fan morphism |
347 | 353 | |
… |
… |
|
462 | 468 | else: |
463 | 469 | return cmp(type(self), type(right)) |
464 | 470 | |
465 | | def __imul__(self, right): |
| 471 | def _composition_(self, right, homset): |
466 | 472 | """ |
467 | 473 | Return the composition of ``self`` and ``right``. |
468 | 474 | |
… |
… |
|
480 | 486 | sage: P3 = toric_varieties.P(3) |
481 | 487 | sage: m = matrix([(2,0,0), (1,1,0)]) |
482 | 488 | sage: phi = A2.hom(m, P3) |
483 | | sage: phi |
| 489 | sage: phi1, phi2, phi3 = phi.factor() |
| 490 | sage: phi1 * phi2 |
484 | 491 | Scheme morphism: |
485 | 492 | From: 2-d affine toric variety |
486 | 493 | 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. |
| 494 | Defn: Defined by sending Rational polyhedral fan in Sublattice |
| 495 | <N(1, 0, 0), N(0, 1, 0)> to Rational polyhedral fan in 3-d lattice N. |
| 496 | sage: phi1 * phi2 * phi3 == phi |
| 497 | True |
495 | 498 | """ |
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 | 499 | f = self.fan_morphism() * right.fan_morphism() |
500 | | return right.domain().hom(f, self.codomain()) |
501 | | |
| 500 | return homset(f, self.codomain()) |
| 501 | |
502 | 502 | def _repr_defn(self): |
503 | 503 | """ |
504 | 504 | Return a string representation of the definition of ``self``. |