示例#1
0
    def __init__(self, domain):
        r"""
        Construct an algebra of scalar fields.

        TESTS::

            sage: M = Manifold(2, 'M', structure='topological')
            sage: X.<x,y> = M.chart()
            sage: CM = M.scalar_field_algebra(); CM
            Algebra of scalar fields on the 2-dimensional topological
             manifold M
            sage: type(CM)
            <class 'sage.manifolds.scalarfield_algebra.ScalarFieldAlgebra_with_category'>
            sage: type(CM).__base__
            <class 'sage.manifolds.scalarfield_algebra.ScalarFieldAlgebra'>
            sage: TestSuite(CM).run()

        """
        base_field = domain.base_field()
        if domain.base_field_type() in ['real', 'complex']:
            base_field = SR
        Parent.__init__(self,
                        base=base_field,
                        category=CommutativeAlgebras(base_field)
                        & TopologicalSpaces().Homsets())
        self._domain = domain
        self._populate_coercion_lists_()
    def __init__(self, base, ideal=None):
        """
        The Python constructor.

        EXAMPLES::

            sage: Berkovich_Cp_Projective(3)
            Projective Berkovich line over Cp(3) of precision 20
        """
        if base in ZZ:
            if base.is_prime():
                base = ProjectiveSpace(Qp(base), 1)
            else:
                raise ValueError("non-prime passed into Berkovich space")
        if base in NumberFields() or isinstance(base,
                                                sage.rings.abc.pAdicField):
            base = ProjectiveSpace(base, 1)
        if not is_ProjectiveSpace(base):
            try:
                base = ProjectiveSpace(base)
            except:
                raise ValueError(
                    "base of projective Berkovich space must be projective space"
                )
        if not isinstance(base.base_ring(), sage.rings.abc.pAdicField):
            if base.base_ring() not in NumberFields():
                raise ValueError("base of projective Berkovich space must be " + \
                    "projective space over Qp or a number field")
            else:
                if ideal is None:
                    raise ValueError('passed a number field but not an ideal')
                if base.base_ring() is not QQ:
                    if not isinstance(ideal, NumberFieldFractionalIdeal):
                        raise ValueError('ideal was not a number field ideal')
                    if ideal.number_field() != base.base_ring():
                        raise ValueError('passed number field ' + \
                            '%s but ideal was an ideal of %s' %(base.base_ring(), ideal.number_field()))
                    prime = ideal.smallest_integer()
                else:
                    if ideal not in QQ:
                        raise ValueError('ideal was not an element of QQ')
                    prime = ideal
                if not ideal.is_prime():
                    raise ValueError('passed non prime ideal')
                self._base_type = 'number field'
        else:
            prime = base.base_ring().prime()
            ideal = None
            self._base_type = 'padic field'
        if base.dimension_relative() != 1:
            raise ValueError("base of projective Berkovich space must be " + \
                "projective space of dimension 1 over Qp or a number field")
        self._p = prime
        self._ideal = ideal
        Parent.__init__(self, base=base, category=TopologicalSpaces())
    def __init__(self, base, ideal=None):
        """
        The Python constructor.

        EXAMPLES::

            sage: Berkovich_Cp_Affine(3)
            Affine Berkovich line over Cp(3) of precision 20
        """
        if base in ZZ:
            if base.is_prime():
                base = Qp(base)  # change to Qpbar
            else:
                raise ValueError("non-prime passed into Berkovich space")
        if is_AffineSpace(base):
            base = base.base_ring()
        if base in NumberFields():
            if ideal is None:
                raise ValueError('passed a number field but not an ideal')
            if base is not QQ:
                if not isinstance(ideal, NumberFieldFractionalIdeal):
                    raise ValueError(
                        'ideal was not an ideal of a number field')
                if ideal.number_field() != base:
                    raise ValueError('passed number field ' + \
                        '%s but ideal was an ideal of %s' %(base, ideal.number_field()))
                prime = ideal.smallest_integer()
            else:
                if ideal not in QQ:
                    raise ValueError('ideal was not an element of QQ')
                prime = ideal
            if not ideal.is_prime():
                raise ValueError('passed non prime ideal')
            self._base_type = 'number field'
        elif isinstance(base,
                        sage.rings.abc.pAdicField):  # change base to Qpbar
            prime = base.prime()
            ideal = None
            self._base_type = 'padic field'
        else:
            raise ValueError("base of Berkovich Space must be a padic field " + \
                "or a number field")
        self._ideal = ideal
        self._p = prime
        Parent.__init__(self, base=base, category=TopologicalSpaces())
示例#4
0
    def __init__(self,
                 n,
                 radius=1,
                 ambient_space=None,
                 center=None,
                 name=None,
                 latex_name=None,
                 coordinates='spherical',
                 names=None,
                 category=None,
                 init_coord_methods=None,
                 unique_tag=None):
        r"""
        Construct sphere smoothly embedded in Euclidean space.

        TESTS::

            sage: S2 = manifolds.Sphere(2); S2
            2-sphere S^2 of radius 1 smoothly embedded in the Euclidean space E^3
            sage: S2.metric()
            Riemannian metric g on the 2-sphere S^2 of radius 1 smoothly
             embedded in the Euclidean space E^3
            sage: TestSuite(S2).run()

        """
        # radius
        if radius <= 0:
            raise ValueError('radius must be greater than zero')
        # ambient space
        if ambient_space is None:
            ambient_space = EuclideanSpace(n + 1)
        elif not isinstance(ambient_space, EuclideanSpace):
            raise TypeError(
                "the argument 'ambient_space' must be a Euclidean space")
        elif ambient_space._dim != n + 1:
            raise ValueError(
                "Euclidean space must have dimension {}".format(n + 1))
        if center is None:
            cart = ambient_space.cartesian_coordinates()
            c_coords = [0] * (n + 1)
            center = ambient_space.point(c_coords, chart=cart)
        elif center not in ambient_space:
            raise ValueError('{} must be an element of {}'.format(
                center, ambient_space))
        if name is None:
            name = 'S^{}'.format(n)
            if radius != 1:
                name += r'_{}'.format(radius)
            if center._name:
                name += r'({})'.format(center._name)
            if latex_name is None:
                latex_name = r'\mathbb{S}^{' + str(n) + r'}'
                if radius != 1:
                    latex_name += r'_{{{}}}'.format(radius)
                if center._latex_name:
                    latex_name += r'({})'.format(center._latex_name)
        if category is None:
            category = Manifolds(RR).Smooth() & MetricSpaces().Complete() & \
                       TopologicalSpaces().Compact().Connected()
        # initialize
        PseudoRiemannianSubmanifold.__init__(self,
                                             n,
                                             name,
                                             ambient=ambient_space,
                                             signature=n,
                                             latex_name=latex_name,
                                             metric_name='g',
                                             start_index=1,
                                             category=category)
        # set attributes
        self._radius = radius
        self._center = center
        self._coordinates = {}  # established coordinates; values are lists
        self._init_coordinates = {
            'spherical': self._init_spherical,
            'stereographic': self._init_stereographic
        }
        # predefined coordinates
        if init_coord_methods:
            self._init_coordinates.update(init_coord_methods)
        if coordinates not in self._init_coordinates:
            raise ValueError(
                '{} coordinates not available'.format(coordinates))
        # up here, the actual initialization begins:
        self._init_chart_domains()
        self._init_embedding()
        self._init_coordinates[coordinates](names)