Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Wrapper around Pynac's constants """
#***************************************************************************** # Copyright (C) 2008 William Stein <wstein@gmail.com> # Copyright (C) 2008 Burcin Erocal <burcin@erocal.org> # Copyright (C) 2009 Mike Hansen <mhansen@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # http://www.gnu.org/licenses/ #*****************************************************************************
from __future__ import absolute_import, division, print_function
from .pynac cimport * from sage.symbolic.expression cimport new_Expression_from_GEx from sage.symbolic.ring import SR from sage.cpython.string cimport str_to_bytes
cdef class PynacConstant: def __cinit__(self, name, texname, domain_string): """ Creates a constant in Pynac.
EXAMPLES:
sage: from sage.libs.pynac.constant import PynacConstant sage: f = PynacConstant('foo', 'foo', 'real') sage: f foo
Note that this just creates a 'constant' object and not an expression. If you want to work with this constant, you'll have to use the result of :meth:`expression`::
sage: foo = f.expression() sage: foo + 2 foo + 2 """ cdef unsigned domain else: raise ValueError
# For the constants explicitly defined in constant.cpp in the # Pynac library, we use those symbols. Otherwise, we create a # new constant stored in *self._object else:
def __dealloc__(self): del self._object
def serial(self): """ Returns the underlying Pynac serial for this constant.
EXAMPLES::
sage: from sage.libs.pynac.constant import PynacConstant sage: f = PynacConstant('foo', 'foo', 'real') sage: f.serial() #random 15 """
def name(self): """ Returns the name of this constant.
EXAMPLES::
sage: from sage.libs.pynac.constant import PynacConstant sage: f = PynacConstant('foo', 'foo', 'real') sage: f.name() 'foo' """
def __repr__(self): """ EXAMPLES::
sage: from sage.libs.pynac.constant import PynacConstant sage: f = PynacConstant('foo', 'foo', 'real'); f foo """
def expression(self): """ Returns this constant as an Expression.
EXAMPLES::
sage: from sage.libs.pynac.constant import PynacConstant sage: f = PynacConstant('foo', 'foo', 'real') sage: f + 2 Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for +: '<type 'sage.libs.pynac.constant.PynacConstant'>' and 'Integer Ring'
sage: foo = f.expression(); foo foo sage: foo + 2 foo + 2 """ |