I'm working on # 3212 and am running into trouble with self, I think.
I've kept everything identical except trying to catch exception of
uncoercible scalar row multiplication. If I put a line 'print
type(self)' after the self.change_ring, it *does* show the ring has
changed internally, but by the time the functions outputs, I either
get the original self back as the result or I get None. I am sure I
am misunderstanding how self and copying (since .change_ring yields a
copy) and assigning work, but after a lot of looking at both Python
(and Cython/Pyrex) and matrix documentation I am only quite a few
hours more tired. Thanks for any assistance.
- kcrisman
In matrix0.pyx:
def test(self, Py_ssize_t i, s, Py_ssize_t start_col=0):
try:
s = self._coerce_element(s)
except TypeError:
self = self.change_ring(Sequence([s,self.base_ring()
(0)]).universe())
self.rescale_row_c(i, s, start_col)
cdef rescale_row_c(self, Py_ssize_t i, s, Py_ssize_t start_col):
cdef Py_ssize_t j
for j from start_col <= j < self._ncols:
self.set_unsafe(i, j, self.get_unsafe(i, j)*s)
sage: a=matrix(3,range(9)); a
[0 1 2]
[3 4 5]
[6 7 8]
sage: b=a.test(1,-3); type(b)
<type 'NoneType'>
sage: a
[ 0 1 2]
[ -9 -12 -15]
[ 6 7 8]
sage: c=a.test(1,1/2); type(c)
<type 'NoneType'>
sage: a
[ 0 1 2]
[ -9 -12 -15]
[ 6 7 8]
sage: a.test(1,1/2); type(a)
<type 'sage.matrix.matrix_integer_dense.Matrix_integer_dense'>
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---