I tried adding a delete_row method to matrix_integer_sparse.pyx but
stopped after getting the error message:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Error converting Pyrex file to C:
------------------------------------------------------------
...
            add_mpz_vector_init(&M._matrix[i], &self._matrix[i], &
(<Matrix_integer_sparse>right)._matrix[i], mul)
        mpz_clear(mul)
        return M

# added by David Perkinson
    cpdef ModuleElement _delete_row_(self, Py_ssize_t row_number):
         ^
------------------------------------------------------------

/usr/local/sage-devel/devel/sage-devel/sage/matrix/
matrix_integer_sparse.pyx:216:10: C method '_delete_row_' not
previously declared in definition part of extension type
Error running command, failed with status 256.
sage: There was an error installing modified sage library code.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

I might have to actually read the Cython documentation!

Dave



On Jun 2, 5:43 pm, Jason Grout <jason-s...@creativetrax.com> wrote:
> 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