[sage-devel] Re: MatrixSpace.zero_matrix

2011-07-10 Thread Simon King
Hi Martin, On 10 Jul., 20:38, Martin Albrecht wrote: > Which makes sense because we always return a zero matrix when we allocate in > M4RI, so copy() is alloc + memcpy while just creating it is just an alloc. How does that work? I learnt the hard way: Allocating memory does not necessarily mean

[sage-devel] Re: Deprecating functions that have been moved in another module

2011-07-10 Thread Rob Beezer
On Jul 10, 4:41 pm, Luca De Feo wrote: > This is an easy one line change in sage.misc.misc. What do you think? Sounds like a welcome improvement to me. Rob -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubs

[sage-devel] Deprecating functions that have been moved in another module

2011-07-10 Thread Luca De Feo
Hi deprecation experts, The current way to deprecate a function that has changed name is: old_func = deprecated_function_alias(new_func, "Sage version") which, upon calling old_func, takes care of printing a deprecation message "(Since Sage version) old_func is deprecated. Plea

[sage-devel] Re: Constructing free module morphisms

2011-07-10 Thread Rob Beezer
Hi Nils and Maarten, Thanks for your comments. > Excellent example. One can make even worse examples via submodules-of- > submodules (which sage forgets about. So for a 2-dim subspace of a 3- > dim subspace of a 4-dim subspace, you can't use length 2 sequences). I wonder if the way the category

[sage-devel] Re: Free module equality, Hermite form over PIDs

2011-07-10 Thread Rob Beezer
Thanks, Nils. I've added a link to this discussion on the Trac ticket. I agree that it might be nice if <= behaved like .is_submodule(). Rob -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegro

Re: [sage-devel] Re: MatrixSpace.zero_matrix

2011-07-10 Thread Robert Goss
Hi Simon, You have 100x100 matrices in both cases, the same as in my example. No unfortunately I ended up making a mistake when I was moving code between sage and my email client. But what you do here is to use a different number of loops in the "timeit" function -- you only make 100 runs,

[sage-devel] Re: MatrixSpace.zero_matrix

2011-07-10 Thread Simon King
Hi Robert, On 10 Jul., 21:20, "Robert Goss" wrote: > I had a go at this and found that for larger matrices it doesnt seem to   > hold (well for me at least) > > sage: from sage.matrix.matrix_modn_dense import Matrix_modn_dense > sage: MS = MatrixSpace(GF(3),100,100) > sage: M = Matrix_modn_dense(

[sage-devel] Re: MatrixSpace.zero_matrix

2011-07-10 Thread Simon King
PS: I just got an alternative idea, that might be a little faster and more flexible. Let MS be a matrix space. Note that it only (or at least mainly) depends on MS.__matrix_class whether it is faster to copy or faster to create from scratch. Hence, why not have a static method of MS.__matrix_cl

Re: [sage-devel] Re: MatrixSpace.zero_matrix

2011-07-10 Thread Robert Goss
Simon, But it DOES hold for dense matrices over GF(3): sage: from sage.matrix.matrix_modn_dense import Matrix_modn_dense sage: MS = MatrixSpace(GF(3),100,100) sage: M = Matrix_modn_dense(MS, None,True,True) sage: timeit("M = Matrix_modn_dense(MS, None,True,True)", number=1) 1 loops, be

[sage-devel] Re: MatrixSpace.zero_matrix

2011-07-10 Thread Simon King
Hi Martin, On 10 Jul., 20:38, Martin Albrecht wrote: > Btw. the speed argument does not seem to hold true for dense over GF(2): > > sage: MS = MatrixSpace(GF(2),1,1) > sage: %timeit A = Matrix_mod2_dense(MS,None,True,True) > 125 loops, best of 3: 2.25 ms per loop > sage: %timeit _ = copy(

Re: [sage-devel] Re: MatrixSpace.zero_matrix

2011-07-10 Thread Martin Albrecht
Hi Simon, > There are ways to create an empty matrix from scratch, whithout > calling zero_matrix first (namely by calling the matrix class). Well, it's not very straight-forward, but I agree there is a way (which I didn't think of before) sage: from sage.matrix.matrix_mod2_dense import Matrix

[sage-devel] Re: MatrixSpace.zero_matrix

2011-07-10 Thread Simon King
Hi Martin, On 10 Jul., 16:21, Martin Albrecht wrote: > which means that whenever on calls matrix(K,m,n) for the first time, it > creates two matrices which is a very very bad idea when working with big > matrices (== RAM full) I was searching the code of the "matrix" function, and the "zero_matr

[sage-devel] MatrixSpace.zero_matrix

2011-07-10 Thread Martin Albrecht
Hi there, currently, MatrixSpace's zero_matrix command is implemented as follows: @cached_method def zero_matrix(self): res = self.__matrix_class(self, 0, coerce=False, copy=False) res.set_immutable() return res which means that whenever on calls matrix(K,m,n) for

[sage-devel] Re: Constructing free module morphisms

2011-07-10 Thread Maarten Derickx
I agree with nils his remark: "I would say Hom(W,W)(L) should be equivalent to Hom(W,W)([W(l) for l in L])" Currently however the output of Hom(W,W)(list of vectors) does not depend on the ambiant space of the vectors in the list: sage: H = QQ^3 sage: W = (H).subspace_with_basis([[0,1,0],[0,0,1