[sage-support] Re: fast slicing of matrix

2009-06-02 Thread davidp
Success! sage: G = graphs.GridGraph([100,100]) sage: L = G.laplacian_matrix() sage: L 1 x 1 sparse matrix over Integer Ring sage: sage: time M = L[1:] CPU times: user 21.98 s, sys: 0.01 s, total: 21.99 s Wall time: 22.93 s sage: sage: time N = L._delete_row_(0) CPU times: user 0.01 s,

[sage-support] Re: fast slicing of matrix

2009-06-02 Thread William Stein
On Tue, Jun 2, 2009 at 10:10 PM, davidp wrote: > > I might be going down the wrong path, but is seems like I would want > to add a > >         copy_mpz_vector_init > > function to  vector_integer_sparse_c.pxi that would make a copy of an > mpz_vector.  Is that overkill? That sounds like a good i

[sage-support] Re: fast slicing of matrix

2009-06-02 Thread davidp
I might be going down the wrong path, but is seems like I would want to add a copy_mpz_vector_init function to vector_integer_sparse_c.pxi that would make a copy of an mpz_vector. Is that overkill? My first idea was to use add_mpz_vector_init(sum, v, w, mul), which sets sum equal to

[sage-support] Re: fast slicing of matrix

2009-06-02 Thread William Stein
On Tue, Jun 2, 2009 at 8:45 PM, davidp wrote: > > I can't figure out how to create a new sparse matrix (see below). > > Sorry, > Dave You can make a new matrix with the analogous parent but a different shape using the new_matrix method. sage: a = random_matrix(ZZ,3,4,sparse=True) sage: a.new_ma

[sage-support] Re: fast slicing of matrix

2009-06-02 Thread davidp
I can't figure out how to create a new sparse matrix (see below). Sorry, Dave M = Matrix_integer_sparse.__new__(Matrix_integer_sparse, sage.matrix.matrix_space.MatrixSpace(ZZ, self._nrows-1, self._ncols, sparse=True), None, None, None) --- ... def _delete_row_(self, Py_ssiz

[sage-support] Re: fast slicing of matrix

2009-06-02 Thread Jason Grout
William Stein wrote: > On Tue, Jun 2, 2009 at 7:22 PM, davidp wrote: >> I tried adding a delete_row method to matrix_integer_sparse.pyx but >> stopped after getting the error message: > > Just def your method -- do not cpdef it. You can still use Cython > code in a cpdef's method and it will be

[sage-support] Re: fast slicing of matrix

2009-06-02 Thread William Stein
On Tue, Jun 2, 2009 at 7:22 PM, davidp wrote: > > I tried adding a delete_row method to matrix_integer_sparse.pyx but > stopped after getting the error message: Just def your method -- do not cpdef it. You can still use Cython code in a cpdef's method and it will be just as fast. Make sure tha

[sage-support] Re: fast slicing of matrix

2009-06-02 Thread davidp
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_vec

[sage-support] Re: fast slicing of matrix

2009-06-02 Thread Jason Grout
William Stein wrote: > On Mon, Jun 1, 2009 at 5:16 PM, davidp 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]) >> sa

[sage-support] Re: fast slicing of matrix

2009-06-01 Thread William Stein
On Mon, Jun 1, 2009 at 5:16 PM, davidp 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() >