#15104: Special case modn_dense matrix operations to improve performance
-------------------------------------+-------------------------------------
       Reporter:  nbruin             |        Owner:
           Type:  enhancement        |       Status:  needs_work
       Priority:  major              |    Milestone:  sage-6.2
      Component:  linear algebra     |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Nils Bruin, Simon  |    Reviewers:
  King                               |  Work issues:  regression in
Report Upstream:  N/A                |  right_kernel_matrix
         Branch:                     |       Commit:
  u/SimonKing/ticket/15104           |  0f008f9266e3ed6fbd67e7f3d357474825bdb160
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------
Changes (by SimonKing):

 * cc: nthiery (added)


Comment:

 It seems to me that the following happens when creating a square matrix
 and then computing right kernel:
 - The parent of the matrix is ''incompletely'' (by #11900) initialised in
 the category of algebras. This will ''not'' trigger the creation of super
 categories, as the incomplete category initialisation skips the category's
 parent class.
 - When computing the kernel, some temporary results are created that are
 non-square matrices. Their parents are initialised in the category of
 vector spaces.
 - The temporary results, their parents and thus also the category of
 vector spaces will be garbage collected as soon as the kernel computation
 is done. Hence, when we compute another kernel, then the category of
 vector spaces is created again. And that's the regression.

 I just tested: If one adds the following initialisation method to the
 category of algebras, then the regression vanishes:
 {{{
     def __init__(self, B):
         Category_over_base_ring.__init__(self, B)
         self._super_categories
 }}}

 It stores the category of B-modules as an attribute of the category of
 B-algebras. Hence, if we create a square matrix M over GF(5), then there
 will be a chain of strong references
 {{{
 M->M.parent()->Algebras(GF(5))->VectorSpaces(GF(5))
 }}}
 And thus the undue garbage collection of `VectorSpaces(GF(5))`, that seems
 to be the cause of the regression, will not take place.

 However, I can imagine that some code (number fields and elliptic curves
 are the usual suspects) will regress when the creation of the category of
 algebras always creates the super categories. After all, an observed
 regression was the reason for introducing the incomplete initialisation of
 matrix spaces in #11900.

 What do you think we should do?

--
Ticket URL: <http://trac.sagemath.org/ticket/15104#comment:30>
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/groups/opt_out.

Reply via email to