#10628: initialization of matrices from vectors or list of lists can be way
faster
------------------------------+---------------------------------------------
Reporter: mderickx | Owner: jason, was
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-4.7.2
Component: linear algebra | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author: Maarten Derickx, Simon King
Merged: | Dependencies:
------------------------------+---------------------------------------------
Changes (by SimonKing):
* status: needs_work => needs_review
Comment:
I updated my patch. Now, the doctests in sage/matrix,
sage/schemes/elliptic_curves and doc/ pass.
Let me summarise the problem:
- I think it should be possible to create a matrix from a list of vectors
''or'' matrices; actually it should be possible to combine both.
- The old "ducktyping" of vectors is not suitable for matrices, because
they don't have a method "is_vector()".
- Both vectors and matrices have a method "list()", and that is exactly
what is used in the pre-processing of data. Hence, why not just duck-type
via "list()"?
- Problem: Number field elements have that method as well. If v is a
number field element, then v.list() returns a pair of numbers - that is
not what we want.
My new patch works as follows:
1. Preprocessing is needed if the input is not a plain list of elements.
If the given list is too short or if the number of columns is one, then it
is possible that the given list contains something that is not just a ring
element (e.g., a vector, a matrix, or a list). That is line 1231 of my
patch.
2. Since pure duck typing turned out to be error prone, I test in line
1237 whether we have a list or tuple using "isinstance", in which case we
extend our list of entries.
3. Otherwise, duck typing is used to catch vectors and matrices. It turns
out that both vectors and matrices have an attribute "row()" and an
attribute "list()", whereas number field elements have no "row()". If we
have list/vector, then we extend our list of entries by "v.list()".
4. Otherwise, we suppose that we have an element of the base ring (or
something that will eventually be converted into the base ring - that case
is subject to a new doc test), and append it to our list of entries.
The doc test problems concerning number field elements vanished with the
new patch version. Moreover, the speed is still fine. I am running all
long doc tests now, and return to "needs review".
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10628#comment:17>
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 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-trac?hl=en.