def _make_ToricVariety(self, name, coordinate_names): """ Construct a toric variety and cache the result. INPUT: - ``name`` -- string. One of the pre-defined names in the ``toric_varieties_rays_cones`` data structure. - ``coordinate_names`` -- A string describing the names of the homogeneous coordinates of the toric variety. OUTPUT: A :class:`toric variety <sage.schemes.generic.toric_variety.ToricVariety_field>`. EXAMPLES:: sage: toric_varieties.A1() # indirect doctest 1-d affine toric variety """ rays, cones = toric_varieties_rays_cones[name] if coordinate_names is None: dict_key = "_cached_" + name else: import toric_variety coordinate_names = toric_variety.normalize_names(coordinate_names, len(rays), toric_variety.DEFAULT_PREFIX) dict_key = "_cached_" + name + "_" + "_".join(coordinate_names) if dict_key not in self.__dict__: fan = Fan(cones, rays, check=self._check) self.__dict__[dict_key] = ToricVariety(fan, coordinate_names=coordinate_names) return self.__dict__[dict_key]
def _make_CPRFanoToricVariety(self, name, coordinate_names): """ Construct a (crepant partially resolved) Fano toric variety and cache the result. INPUT: - ``name`` -- string. One of the pre-defined names in the ``toric_varieties_rays_cones`` data structure. - ``coordinate_names`` -- A string describing the names of the homogeneous coordinates of the toric variety. OUTPUT: A :class:`CPR-Fano toric variety <sage.schemes.generic.fano_toric_variety.CPRFanoToricVariety_field>`. EXAMPLES:: sage: toric_varieties.P2() # indirect doctest 2-d CPR-Fano toric variety covered by 3 affine patches """ rays, cones = toric_varieties_rays_cones[name] if coordinate_names is None: dict_key = "_cached_" + name else: import toric_variety coordinate_names = toric_variety.normalize_names(coordinate_names, len(rays), toric_variety.DEFAULT_PREFIX) dict_key = "_cached_" + name + "_" + "_".join(coordinate_names) if dict_key not in self.__dict__: polytope = LatticePolytope(matrix(rays).transpose()) points = map(tuple, polytope.points().columns()) ray2point = [points.index(r) for r in rays] charts = [[ray2point[i] for i in c] for c in cones] self.__dict__[dict_key] = CPRFanoToricVariety( Delta_polar=polytope, coordinate_points=ray2point, charts=charts, coordinate_names=coordinate_names, check=self._check, ) return self.__dict__[dict_key]