#18231: constructing matrices is very slow
-------------------------------------+-------------------------------------
Reporter: vdelecroix | Owner:
Type: defect | Status: needs_work
Priority: major | Milestone: sage-6.7
Component: linear algebra | Resolution:
Keywords: | Merged in:
Authors: Vincent Delecroix | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/vdelecroix/18231 | da310db9b3b4238121b1a1ad2c3d5e36a5e846b5
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Changes (by ncohen):
* status: needs_review => needs_work
Comment:
Hello Vincent,
In this branch you create functions, remove others, and change a lot of
code. There is still a lot of guessing to do on the reviewer's part.
It would be really cool if you could be more verbose about what you do.
Really.
I began to read the first commit, and I have several more specific
questions:
- You modify a function which takes a `MonoidElement` as input, which you
immeditely cast with `cdef Matrix right = _right`. Either it is a matrix
and it should not read `MonoidElement` in the first place, or it is not a
`Matrix` and you cannot cast it?..
- This is cool and everything to gain miliseconds, but that's not a good
way to write public code
{{{
- matrix.Matrix.__init__(self, parent)
+ # the four lines below avoid the following call
+ # matrix.Matrix.__init__(self, parent)
+ self._parent = parent
+ res._ncols = parent.ncols()
+ res._nrows = parent.nrows()
+ R = res._base_ring = parent.base_ring()
}}}
If the main constructor does not do what you want ty to change it. What
if somebody adds a new parameter to matrix? The code has to be copy/pasted
in every single function that did not want to call `__init__`?
- Why?
{{{
cdef set_unsafe(self, Py_ssize_t i, Py_ssize_t j, value):
- Py_DECREF(<object>PyList_GET_ITEM(self._entries, i*self._ncols +
j))
- Py_INCREF(value)
- PyList_SET_ITEM(self._entries, i*self._ncols + j, value)
+ self._entries[i*self._ncols + j] = value
cdef get_unsafe(self, Py_ssize_t i, Py_ssize_t j):
- return <object>PyList_GET_ITEM(self._entries, i*self._ncols + j)
+ return self._entries[i*self._ncols + j]
}}}
Nathann
--
Ticket URL: <http://trac.sagemath.org/ticket/18231#comment:3>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.