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
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)
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
def __init__(self, parent=UnsignedInfinityRing): """ Initialize ``self``. EXAMPLES:: sage: sage.rings.infinity.LessThanInfinity() is UnsignedInfinityRing(5) True """ RingElement.__init__(self, parent)
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
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
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)
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)
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_()
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
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