# HG changeset patch
# User Burcin Erocal <burcin@erocal.org>
# Date 1237912294 -3600
# Node ID 99916902b1d1b0674315779687b6d23133bb899f
# Parent cdc1edc584f69da3df11190919feedd0bf1e2265
Change base class of sage.symbolic.ring.NSymbolicRing to CommutativeRing and
add is_exact and is_field methods. This allows constructing matrices and
vectors with pynac expressions.
diff --git a/sage/symbolic/ring.pxd b/sage/symbolic/ring.pxd
|
a
|
b
|
|
| 1 | 1 | include "../libs/ginac/decl.pxi" |
| 2 | 2 | |
| 3 | | from sage.rings.ring cimport Ring |
| | 3 | from sage.rings.ring cimport CommutativeRing |
| 4 | 4 | |
| 5 | | cdef class NSymbolicRing(Ring) |
| | 5 | cdef class NSymbolicRing(CommutativeRing) |
diff --git a/sage/symbolic/ring.pyx b/sage/symbolic/ring.pyx
|
a
|
b
|
|
| 7 | 7 | # http://www.gnu.org/licenses/ |
| 8 | 8 | ############################################################################### |
| 9 | 9 | |
| | 10 | """ |
| | 11 | |
| | 12 | TESTS: |
| | 13 | creating matrices and vectors with pynac expresssions:: |
| | 14 | sage: var('x,y,z',ns=1) |
| | 15 | (x, y, z) |
| | 16 | sage: M = matrix(2,2,[x,y,z,x]) |
| | 17 | sage: M.base_ring() |
| | 18 | New Symbolic Ring |
| | 19 | |
| | 20 | sage: v = vector([x,y]) |
| | 21 | sage: v.base_ring() |
| | 22 | New Symbolic Ring |
| | 23 | """ |
| | 24 | |
| 10 | 25 | include "../ext/stdsage.pxi" |
| 11 | 26 | include "../ext/cdefs.pxi" |
| 12 | 27 | |
| … |
… |
|
| 23 | 38 | |
| 24 | 39 | from sage.structure.element import RingElement |
| 25 | 40 | |
| 26 | | cdef class NSymbolicRing(Ring): |
| | 41 | cdef class NSymbolicRing(CommutativeRing): |
| 27 | 42 | """ |
| 28 | 43 | Symbolic Ring, parent object for all symbolic expressions. |
| 29 | 44 | """ |
| … |
… |
|
| 138 | 153 | arctan(x^2) |
| 139 | 154 | """ |
| 140 | 155 | return new_Expression_from_GEx(g_wild(n)) |
| 141 | | |
| | 156 | |
| | 157 | def is_field(self): |
| | 158 | """ |
| | 159 | Returns True, since symbolic expressions behave (mostly) like |
| | 160 | field elements. |
| | 161 | |
| | 162 | EXAMPLES: |
| | 163 | sage: from sage.symbolic.ring import NSR |
| | 164 | sage: NSR.is_field() |
| | 165 | True |
| | 166 | """ |
| | 167 | return True |
| | 168 | |
| | 169 | def is_exact(self): |
| | 170 | """ |
| | 171 | Returns False, since there are approximate symbolic expressions. |
| | 172 | |
| | 173 | EXAMPLES: |
| | 174 | sage: from sage.symbolic.ring import NSR |
| | 175 | sage: NSR.is_exact() |
| | 176 | False |
| | 177 | """ |
| | 178 | return False |
| | 179 | |
| 142 | 180 | |
| 143 | 181 | NSR = NSymbolicRing() |
| 144 | 182 | |