def TrivialBundle(X, rank=1): r""" Return the trivial bundle of rank ``r``. INPUT: - ``X`` -- a toric variety. The base space of the bundle. - ``rank`` -- the rank of the bundle. OUTPUT: The trivial bundle as a Klyachko bundle. EXAMPLES:: sage: P2 = toric_varieties.P2() sage: from sage.schemes.toric.sheaf.constructor import TrivialBundle sage: I3 = TrivialBundle(P2, 3); I3 Rank 3 bundle on 2-d CPR-Fano toric variety covered by 3 affine patches. sage: I3.cohomology(weight=(0,0), dim=True) (3, 0, 0) """ if not is_ToricVariety(X): raise ValueError('not a toric variety') from sage.modules.free_module import VectorSpace base_ring = X.base_ring() filtrations = dict( [ray, FilteredVectorSpace(rank, 0, base_ring=base_ring)] for ray in X.fan().rays()) import klyachko return klyachko.Bundle(X, filtrations, check=True)
def TangentBundle(X): r""" Construct the tangent bundle of a toric variety. INPUT: - ``X`` -- a toric variety. The base space of the bundle. OUTPUT: The tangent bundle as a Klyachko bundle. EXAMPLES:: sage: dP7 = toric_varieties.dP7() sage: from sage.schemes.toric.sheaf.constructor import TangentBundle sage: TangentBundle(dP7) Rank 2 bundle on 2-d CPR-Fano toric variety covered by 5 affine patches. """ if not is_ToricVariety(X): raise ValueError('not a toric variety') base_ring = X.base_ring() fan = X.fan() filtrations = dict() from sage.modules.filtered_vector_space import FilteredVectorSpace for i, ray in enumerate(fan.rays()): F = FilteredVectorSpace(fan.rays(), {0: range(fan.nrays()), 1: [i]}) filtrations[ray] = F import klyachko return klyachko.Bundle(X, filtrations, check=True)
def LineBundle(X, D): """ Construct the rank-1 bundle `O(D)`. INPUT: - ``X`` -- a toric variety. The base space of the bundle. - ``D`` -- a toric divisor. OUTPUT: The line bundle `O(D)` as a Klyachko bundle of rank 1. EXAMPLES:: sage: X = toric_varieties.dP8() sage: D = X.divisor(0) sage: from sage.schemes.toric.sheaf.constructor import LineBundle sage: O_D = LineBundle(X, D) sage: O_D.cohomology(dim=True, weight=(0,0)) (1, 0, 0) """ if not is_ToricVariety(X): raise ValueError('not a toric variety') from sage.modules.free_module import VectorSpace base_ring = X.base_ring() filtrations = dict([ X.fan().ray(i), FilteredVectorSpace(1, D.function_value(i), base_ring=base_ring) ] for i in range(X.fan().nrays())) import klyachko return klyachko.Bundle(X, filtrations, check=True)
def _repr_(self): r""" Return as string representation of ``self``. OUTPUT: A string. EXAMPLES:: sage: rays = [(1,0), (1,1), (1,2), (-1,-1)] sage: F1 = FilteredVectorSpace(rays, {0:[1, 2], 2:[3]}) sage: F2 = FilteredVectorSpace(rays, {0:[1, 2], oo:[3]}) sage: F3 = FilteredVectorSpace(rays, {oo:[3]}) sage: F4 = FilteredVectorSpace(rays, {0:[3]}) sage: MultiFilteredVectorSpace({'a':F1, 'b':F2, 'c': F3, 'd': F4}) Filtrations a: QQ^2 >= QQ^1 >= QQ^1 >= 0 b: QQ^2 >= QQ^1 >= QQ^1 >= QQ^1 c: QQ^1 >= QQ^1 >= QQ^1 >= QQ^1 d: QQ^1 >= 0 >= 0 >= 0 sage: MultiFilteredVectorSpace(123, base_ring=RR) Unfiltered RR^123 """ if not self._filt: F = FilteredVectorSpace(self.dimension(), base_ring=self.base_ring()) return 'Unfiltered ' + repr(F) rows = [] support = self.support() min_deg, max_deg = self.min_degree(), self.max_degree() for key in sorted(self.index_set()): F = self.get_filtration(key) r = [str(key)] + F._repr_degrees(min_deg, max_deg - 1) rows.append(r) from sage.misc.table import table t = table(rows) w = t._widths() lines = ['Filtrations'] for r in rows: s = ' ' s += r[0].rjust(w[0]) + ': ' s += ' >= '.join(r[i].center(w[i]) for i in range(1, len(w))) lines.append(s) return '\n'.join(lines)
def _repr_(self): r""" Return as string representation of ``self``. OUTPUT: A string. EXAMPLES:: sage: rays = [(1,0), (1,1), (1,2), (-1,-1)] sage: F1 = FilteredVectorSpace(rays, {0:[1, 2], 2:[3]}) sage: F2 = FilteredVectorSpace(rays, {0:[1, 2], oo:[3]}) sage: F3 = FilteredVectorSpace(rays, {oo:[3]}) sage: F4 = FilteredVectorSpace(rays, {0:[3]}) sage: MultiFilteredVectorSpace({'a':F1, 'b':F2, 'c': F3, 'd': F4}) Filtrations a: QQ^2 >= QQ^1 >= QQ^1 >= 0 b: QQ^2 >= QQ^1 >= QQ^1 >= QQ^1 c: QQ^1 >= QQ^1 >= QQ^1 >= QQ^1 d: QQ^1 >= 0 >= 0 >= 0 sage: MultiFilteredVectorSpace(123, base_ring=RR) Unfiltered RR^123 """ if not self._filt: F = FilteredVectorSpace(self.dimension(), base_ring=self.base_ring()) return 'Unfiltered ' + repr(F) rows = [] support = self.support() min_deg, max_deg = self.min_degree(), self.max_degree() for key in sorted(self.index_set()): F = self.get_filtration(key) r = [str(key)] + F._repr_degrees(min_deg, max_deg-1) rows.append(r) from sage.misc.table import table t = table(rows) w = t._widths() lines = ['Filtrations'] for r in rows: s = ' ' s += r[0].rjust(w[0]) + ': ' s += ' >= '.join(r[i].center(w[i]) for i in range(1, len(w))) lines.append(s) return '\n'.join(lines)