Re: [sage-devel] mutable rows of immutable matrix?

2015-10-23 Thread Nathann Cohen
The code is there: http://trac.sagemath.org/ticket/19462 Nathann On 23 October 2015 at 20:21, Nathann Cohen wrote: >> What problem are you solving by using immutable matrices/vectors? > > I have many vectors v1,...,vk and a ring R, and I want to see if two > of them are R-collinear (hoping that

Re: [sage-devel] mutable rows of immutable matrix?

2015-10-23 Thread Nathann Cohen
> What problem are you solving by using immutable matrices/vectors? I have many vectors v1,...,vk and a ring R, and I want to see if two of them are R-collinear (hoping that it's how you guys say it). > Why is anything immutable for what you are doing? I multiply vi by R, and take this as a set.

Re: [sage-devel] mutable rows of immutable matrix?

2015-10-23 Thread Nathann Cohen
On 23 October 2015 at 20:01, William Stein wrote: > Hi Nathann, > > What problem are you solving by using immutable matrices/vectors? Why > is anything immutable for what you are doing? > > For reference, I explained above the actual problem which motivated my > writing immutable matrices/vectors

Re: [sage-devel] mutable rows of immutable matrix?

2015-10-23 Thread William Stein
Hi Nathann, What problem are you solving by using immutable matrices/vectors? Why is anything immutable for what you are doing? For reference, I explained above the actual problem which motivated my writing immutable matrices/vectors for Sage in the first place. -- William On Fri, Oct 23, 201

Re: [sage-devel] mutable rows of immutable matrix?

2015-10-23 Thread Nathann Cohen
>> I do not see why matrix.row(0) should return a *copy* of the row when >> the matrix is immutable. > > > It depends on the implementation. I agree, and that was my point. As you say, under different circumstances (different implementation of matrices) we may have chosen to return 'views' on the

Re: [sage-devel] mutable rows of immutable matrix?

2015-10-23 Thread Nils Bruin
On Friday, October 23, 2015 at 6:20:19 AM UTC-7, Nathann Cohen wrote: > > I do not see why matrix.row(0) should return a *copy* of the row when > the matrix is immutable. > It depends on the implementation. I think most matrices allocate their element store as a contiguous block. Hence the vect

Re: [sage-devel] mutable rows of immutable matrix?

2015-10-23 Thread Nathann Cohen
> So we agree that there is no performance problem, great. Then don't try to > illustrate your problem with computational complexity, because as you said > that is not a problem. O_o Nathann -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To uns

Re: [sage-devel] mutable rows of immutable matrix?

2015-10-23 Thread Volker Braun
On Friday, October 23, 2015 at 3:52:18 PM UTC+2, Nathann Cohen wrote: > > Volker, please do not change the subject. I did not. > I did not say that complexity was a problem. So we agree that there is no performance problem, great. Then don't try to illustrate your problem with computation

Re: [sage-devel] mutable rows of immutable matrix?

2015-10-23 Thread Nathann Cohen
> None of the examples you quoted would have a lower complexity with O(1) row > references. If temporaries are a real problem (Benchmarks first, please) Volker, please do not change the subject. I did not say that complexity was a problem. My problem is with the behaviour of .row which returns mut

Re: [sage-devel] mutable rows of immutable matrix?

2015-10-23 Thread Volker Braun
On Friday, October 23, 2015 at 3:20:19 PM UTC+2, Nathann Cohen wrote: > > Depending on how matrices are implemented matrix.row(0) could very > well be a O(1) operation None of the examples you quoted would have a lower complexity with O(1) row references. If temporaries are a real problem (Benc

Re: [sage-devel] mutable rows of immutable matrix?

2015-10-23 Thread Nathann Cohen
> Perhaps should we have a "mutable" argument (True by default to be consistent > with the current behaviour) in the matrix/vector constructors, so that we can > do: > > {vector(m.row(0), mutable=False) for m in blah} That would be a "working fix", but really the problem is that operations

Re: [sage-devel] mutable rows of immutable matrix?

2015-10-23 Thread Nathann Cohen
Yo, > m.row() returns a new (copy) of the row of the matrix, so making that > immutable would be inconsistent with how copy works for matrices. > > sage: m = matrix.ones(10) > sage: m.set_immutable() > sage: copy(m).is_immutable() > False I do not see why matrix.row(0) should return a *copy* of t

Re: [sage-devel] mutable rows of immutable matrix?

2015-10-23 Thread sage-googlesucks
On Fri, Oct 25, 2015 at 06:04:45AM -0700, William Stein wrote: [...] > > At least you can do "v = m.row(0); v.set_immutable()". There is some issue with this when trying to use set comprehension, see http://ask.sagemath.org/question/30102/how-do-i-define-and-work-with-a-set-of-matrices/ Perhaps

Re: [sage-devel] mutable rows of immutable matrix?

2015-10-23 Thread William Stein
On Fri, Oct 23, 2015 at 6:04 AM, William Stein wrote: > On Fri, Oct 23, 2015 at 5:04 AM, Nathann Cohen > wrote: >> Hello everybody, >> >> When calling .row() on an immutable matrix, one gets mutable vectors. >> I can easily avoid it for the code I am writing, but do you think we >> should do som

Re: [sage-devel] mutable rows of immutable matrix?

2015-10-23 Thread William Stein
On Fri, Oct 23, 2015 at 5:04 AM, Nathann Cohen wrote: > Hello everybody, > > When calling .row() on an immutable matrix, one gets mutable vectors. > I can easily avoid it for the code I am writing, but do you think we > should do something about it? m.row() returns a new (copy) of the row of the

[sage-devel] mutable rows of immutable matrix?

2015-10-23 Thread Nathann Cohen
Hello everybody, When calling .row() on an immutable matrix, one gets mutable vectors. I can easily avoid it for the code I am writing, but do you think we should do something about it? sage: m = matrix.ones(10) sage: m.set_immutable() sage: hash(m.row(0)) ... TypeError: mutab