Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
refcount libsingular rings used in plural
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-king-jena committed Jul 17, 2015
1 parent 90ed181 commit 64b572c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/sage/libs/singular/ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,14 @@ cdef ring *singular_ring_reference(ring *existing_ring) except NULL:
INPUT:
- ``existing_ring`` -- an existing Singular ring.
- ``existing_ring`` -- a Singular ring.
OUTPUT:
The same ring with its refcount increased. After calling this
function `n` times, you need to call :func:`singular_ring_delete`
The same ring with its refcount increased. If ``existing_ring``
has not been refcounted yet, it will be after calling this function.
If initially ``existing_ring`` was refcounted once, then after
calling this function `n` times, you need to call :func:`singular_ring_delete`
`n+1` times to actually deallocate the ring.
EXAMPLE::
Expand Down Expand Up @@ -487,8 +489,7 @@ cdef ring *singular_ring_reference(ring *existing_ring) except NULL:
if existing_ring==NULL:
raise ValueError('singular_ring_reference(ring*) called with NULL pointer.')
cdef object r = wrap_ring(existing_ring)
refcount = ring_refcount_dict.pop(r)
ring_refcount_dict[r] = refcount+1
ring_refcount_dict[r] = ring_refcount_dict.get(r,0)+1
return existing_ring


Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/polynomial/plural.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ from sage.libs.singular.function cimport RingWrap
from sage.libs.singular.polynomial cimport (singular_polynomial_call, singular_polynomial_cmp, singular_polynomial_add, singular_polynomial_sub, singular_polynomial_neg, singular_polynomial_pow, singular_polynomial_mul, singular_polynomial_rmul, singular_polynomial_deg, singular_polynomial_str_with_changed_varnames, singular_polynomial_latex, singular_polynomial_str, singular_polynomial_div_coeff)

import sage.libs.singular.ring
from sage.libs.singular.ring cimport singular_ring_new, singular_ring_delete, wrap_ring
from sage.libs.singular.ring cimport singular_ring_new, singular_ring_delete, wrap_ring, singular_ring_reference

from sage.libs.singular.singular cimport si2sa, sa2si, overflow_check

Expand Down Expand Up @@ -327,7 +327,7 @@ cdef class NCPolynomialRing_plural(Ring):
cdef RingWrap rw = ncalgebra(self._c, self._d, ring = P)

# rw._output()
self._ring = rw._ring
self._ring = singular_ring_reference(rw._ring)
self._ring.ShortOut = 0

self.__ngens = n
Expand Down

0 comments on commit 64b572c

Please sign in to comment.