William Stein wrote:
> On Mon, Jun 1, 2009 at 5:16 PM, davidp <dav...@reed.edu> wrote:
>> Is there a fast way to create a submatrix?
>>
>> -------------------------------------------------
>>
>>
>> sage: version()
>> 'Sage Version 4.0.alpha0, Release Date: 2009-05-15'
>> sage: G = graphs.GridGraph([100,100])
>> sage: L = G.laplacian_matrix()
>> sage: L
>> 10000 x 10000 sparse matrix over Integer Ring
>> sage: time M = L[1:9999,1:9999]
>> CPU times: user 24.93 s, sys: 0.04 s, total: 24.97 s
>> Wall time: 25.27 s
>>
>>
>> ----------------------------------------------------
>>
>> I am just interested in deleting a single row and column of the matrix
>> (not necessarily the first).
>>
>> Thanks,
> 
> There is no fast way to do that right now.  One could easily add code
> to SAGE_ROOT/devel/sage/sage/matrix/matrix_integer_sparse.pyx that
> would provide blazingly fast deletion of a row, and reasonably fast
> deletion of a column.   Of course it would be better to implement
> arbitrary slicing in some optimized way in matrix_integer_sparse.pyx.
> I hope somebody does so.

Just looking at the generic code, it seems that it goes through each and 
every index position in the slice, setting the new matrix entry to the 
old one.  This is obviously the wrong thing to do for sparse matrices, 
and can likely trivially be made faster.  I think all you may have to do 
is override the matrix_from_rows_and_columns for sparse matrices.

Jason


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to