def __init__(self, parent, degree, fun = None):
        r"""
        Construct a differential form.

        INPUT:

        - ``parent`` -- Parent algebra of differential forms.

        - ``degree`` -- Degree of the differential form.

        - ``fun`` (default: None) -- Initialize this differential form with the given function.  If the degree is not zero, this argument is silently ignored.

        EXAMPLES::

            sage: x, y, z = var('x, y, z')
            sage: F = DifferentialForms(); F
            Algebra of differential forms in the variables x, y, z
            sage: f = DifferentialForm(F, 0, sin(z)); f
            sin(z)

        """

        from sage.tensor.differential_forms import DifferentialForms
        if not isinstance(parent, DifferentialForms):
            raise TypeError("Parent not an algebra of differential forms.")

        RingElement.__init__(self, parent)

        self._degree = degree
        self._components = {}

        if degree == 0 and fun is not None:
            self.__setitem__([], fun)
Example #2
0
    def __init__(self, parent, value, is_name=False, name=None):
        RingElement.__init__(self, parent)
        self._create = value
        if parent is None: return     # means "invalid element"
        # idea: Joe Wetherell -- try to find out if the output
        # is too long and if so get it using file, otherwise
        # don't.
        if isinstance(value, basestring) and parent._eval_using_file_cutoff and \
           parent._eval_using_file_cutoff < len(value):
            self._get_using_file = True

        if is_name:
            self._name = value
        else:
            try:
                self._name = parent._create(value, name=name)
            # Convert ValueError and RuntimeError to TypeError for
            # coercion to work properly.
            except (RuntimeError, ValueError) as x:
                self._session_number = -1
                raise TypeError, x, sys.exc_info()[2]
            except BaseException:
                self._session_number = -1
                raise
        self._session_number = parent._session_number
Example #3
0
    def __init__(self, parent, value, is_name=False, name=None):
        RingElement.__init__(self, parent)
        self._create = value
        if parent is None: return     # means "invalid element"
        # idea: Joe Wetherell -- try to find out if the output
        # is too long and if so get it using file, otherwise
        # don't.
        if isinstance(value, basestring) and parent._eval_using_file_cutoff and \
           parent._eval_using_file_cutoff < len(value):
            self._get_using_file = True

        if is_name:
            self._name = value
        else:
            try:
                self._name = parent._create(value, name=name)
            # Convert ValueError and RuntimeError to TypeError for
            # coercion to work properly.
            except (RuntimeError, ValueError) as x:
                self._session_number = -1
                raise TypeError, x, sys.exc_info()[2]
            except BaseException:
                self._session_number = -1
                raise
        self._session_number = parent._session_number
Example #4
0
    def __init__(self, parent, degree, fun = None):
        r"""
        Construct a differential form.

        INPUT:

        - ``parent`` -- Parent algebra of differential forms.

        - ``degree`` -- Degree of the differential form.

        - ``fun`` (default: None) -- Initialize this differential form with the given function.  If the degree is not zero, this argument is silently ignored.

        EXAMPLES::

            sage: x, y, z = var('x, y, z')
            sage: F = DifferentialForms(); F
            Algebra of differential forms in the variables x, y, z
            sage: f = DifferentialForm(F, 0, sin(z)); f
            sin(z)

        """

        from sage.tensor.differential_forms import DifferentialForms
        if not isinstance(parent, DifferentialForms):
            raise TypeError("Parent not an algebra of differential forms.")

        RingElement.__init__(self, parent)

        self._degree = degree
        self._components = {}

        if degree == 0 and fun is not None:
            self[[]] = fun
Example #5
0
    def __init__(self, parent=UnsignedInfinityRing):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: sage.rings.infinity.LessThanInfinity() is UnsignedInfinityRing(5)
            True
        """
        RingElement.__init__(self, parent)
Example #6
0
    def __init__(self, parent=UnsignedInfinityRing):
        """
        Initialize ``self``.

        EXAMPLES::

            sage: sage.rings.infinity.LessThanInfinity() is UnsignedInfinityRing(5)
            True
        """
        RingElement.__init__(self, parent)
Example #7
0
 def __init__(self, parent, value, is_name=False, name=None):
     RingElement.__init__(self, parent)
     self._create = value
     if parent is None: return     # means "invalid element"
     # idea: Joe Wetherell -- try to find out if the output
     # is too long and if so get it using file, otherwise
     # don't.
         
     if is_name:
         self._name = value
     else:
         try:
             self._name = parent._create(value, name=name)
         except (TypeError, KeyboardInterrupt, RuntimeError, ValueError), x:
             raise TypeError, x
Example #8
0
    def __init__(self, parent, x):
        """
        Initialize ``self``.

        TESTS::

            sage: sage.rings.infinity.FiniteNumber(InfinityRing, 1)
            A positive finite number
            sage: sage.rings.infinity.FiniteNumber(InfinityRing, -1)
            A negative finite number
            sage: sage.rings.infinity.FiniteNumber(InfinityRing, 0)
            Zero
        """
        RingElement.__init__(self, parent)
        self.value = x
Example #9
0
    def __init__(self, parent, value, is_name=False, name=None):
        RingElement.__init__(self, parent)
        self._create = value
        if parent is None: return  # means "invalid element"
        # idea: Joe Wetherell -- try to find out if the output
        # is too long and if so get it using file, otherwise
        # don't.

        if is_name:
            self._name = value
        else:
            try:
                self._name = parent._create(value, name=name)
            except (TypeError, RuntimeError, ValueError) as x:
                raise TypeError(x)
Example #10
0
    def __init__(self, parent, x):
        """
        Initialize ``self``.

        TESTS::

            sage: sage.rings.infinity.FiniteNumber(InfinityRing, 1)
            A positive finite number
            sage: sage.rings.infinity.FiniteNumber(InfinityRing, -1)
            A negative finite number
            sage: sage.rings.infinity.FiniteNumber(InfinityRing, 0)
            Zero
        """
        RingElement.__init__(self, parent)
        self.value = x
Example #11
0
 def __init__(self, x, parent=None):
     """
     EXAMPLES:
         sage: R = PariRing()
         sage: f = R('x^3 + 1/2')
         sage: f
         x^3 + 1/2
         sage: type(f)
         <class 'sage.rings.pari_ring.PariRing_with_category.element_class'>
         sage: loads(f.dumps()) == f
         True
     """
     if parent is None:
         parent = _inst
     RingElement.__init__(self, parent)
     self.__x = pari.pari(x)
Example #12
0
    def __init__(self, parent, rep, reduce=True):
        """
        An element of a quotient ring `R/I`.  See
        ``QuotientRingElement`` for full documentation.

        EXAMPLES::

            sage: R.<x> = PolynomialRing(ZZ)
            sage: S.<xbar> = R.quo((4 + 3*x + x^2, 1 + x^2)); S
            Quotient of Univariate Polynomial Ring in x over Integer Ring by the ideal (x^2 + 3*x + 4, x^2 + 1)
            sage: v = S.gens(); v
            (xbar,)
        """
        RingElement.__init__(self, parent)
        self.__rep = rep
        if reduce:
            self._reduce_()
Example #13
0
 def __pow__(self, n):
     """
     EXAMPLES:
         sage: a = lisp(3)
         sage: a^3
         27
     """
     return RingElement.__pow__(self, n)
Example #14
0
 def __pow__(self, n):
     """
     EXAMPLES:
         sage: a = lisp(3)
         sage: a^3
         27
     """
     return RingElement.__pow__(self, n)
Example #15
0
    def __init__(self, parent, value, is_name=False, name=None):
        RingElement.__init__(self, parent)
        self._create = value
        if parent is None: return  # means "invalid element"
        # idea: Joe Wetherell -- try to find out if the output
        # is too long and if so get it using file, otherwise
        # don't.
        if isinstance(value, basestring) and parent._eval_using_file_cutoff and \
           parent._eval_using_file_cutoff < len(value):
            self._get_using_file = True

        if is_name:
            self._name = value
        else:
            try:
                self._name = parent._create(value, name=name)
            except (TypeError, KeyboardInterrupt, RuntimeError, ValueError), x:
                self._session_number = -1
                raise TypeError, x
Example #16
0
 def __init__(self, parent, value, is_name=False, name=None):
     RingElement.__init__(self, parent)
     self._create = value
     if parent is None: return     # means "invalid element"
     # idea: Joe Wetherell -- try to find out if the output
     # is too long and if so get it using file, otherwise
     # don't.
     if isinstance(value, basestring) and parent._eval_using_file_cutoff and \
        parent._eval_using_file_cutoff < len(value):
         self._get_using_file = True
         
     if is_name:
         self._name = value
     else:
         try:
             self._name = parent._create(value, name=name)
         except (TypeError, KeyboardInterrupt, RuntimeError, ValueError), x:
             self._session_number = -1
             raise TypeError, x
Example #17
0
 def __init__(self,parent,x,val=0,normalized=False):
     RingElement.__init__(self,parent)
     Approximation.__init__(self,parent)
     self._x = QQ(x)
     self._val = val
     self._normalized = normalized