[sympy] Re: Problems with Sparse Matrix

2013-06-03 Thread Saurabh Jha
I agree with you on the lambda part. I am still not sure with else part because users may not right about whether the matrix is enough sparse and the methods(which exploits sparsity) would be inefficient if someone enters the dense matrix actually. Maybe we should have a common matrix interface and

[sympy] Re: Problems with Sparse Matrix

2013-06-04 Thread Saurabh Jha
Can anyone please explain me why we have the different implementations for row and col in sparse class. Can't we just reuse these methods from the dense class? Is there the exploitation of sparsity in these methods? -Saurabh -- You received this message because you are subscribed to the Google G

[sympy] Re: Problems with Sparse Matrix

2013-06-04 Thread Saurabh Jha
> Isn't it more efficient if there are many zeros in a given row? As I said before, there was a bug in it. They just returned the row of zeroes or vector of zeroes every time I call them, even if there were non-zero element in the rows and columns in question. Furthermore, as chris pointed out in

[sympy] Re: Problems with Sparse Matrix

2013-06-04 Thread Saurabh Jha
> What if I have a billion by billion matrix with a single nonzero element? > > Aaron Meurer I think you are right. In that case, I will just make the implementation that was in an earlier commit in my current PR with lists converted to matrices. -Saurabh Jha -- You received this message because

[sympy] Re: Problems with Sparse Matrix

2013-06-04 Thread Saurabh Jha
I think you can't avoid checking all the columns of the concerned row if you want to return a particular row, because even if there is only one non-zero element in that row, we would still have to insert all zeroes in it. like in [0, 0, 0, 1, ,0,0, 0, 0] we would have to insert all these zeroes, a

[sympy] Re: Problems with Sparse Matrix

2013-06-04 Thread Saurabh Jha
I think I am getting it but just to be sure, is it intended to be a fix that will go along with current method(based on inheritance of methods) or a replacement. On Jun 4, 9:05 pm, Chris Smith wrote: > This is why it's better to work with smat -- you can load it up with the > non-zero elements a

Re: [sympy] Re: Problems with Sparse Matrix

2013-06-03 Thread Aaron Meurer
On Mon, Jun 3, 2013 at 7:45 PM, Saurabh Jha wrote: > I agree with you on the lambda part. I am still not sure with else > part because users may not right about whether the matrix is enough > sparse and the methods(which exploits sparsity) would be inefficient > if someone enters the dense matrix

Re: [sympy] Re: Problems with Sparse Matrix

2013-06-04 Thread Aaron Meurer
Isn't it more efficient if there are many zeros in a given row? Aaron Meurer On Tue, Jun 4, 2013 at 2:01 AM, Saurabh Jha wrote: > Can anyone please explain me why we have the different implementations > for row and col in sparse class. Can't we just reuse these methods > from the dense class? Is

Re: [sympy] Re: Problems with Sparse Matrix

2013-06-04 Thread Aaron Meurer
What if I have a billion by billion matrix with a single nonzero element? Aaron Meurer On Tue, Jun 4, 2013 at 10:16 AM, Saurabh Jha wrote: >> Isn't it more efficient if there are many zeros in a given row? > > As I said before, there was a bug in it. They just returned the row of > zeroes or vec

Re: [sympy] Re: Problems with Sparse Matrix

2013-06-04 Thread Chris Smith
Please don't go backwards. We know what to do and the fix is straightforward, I think: ``` def submatrix(self, keys): rlo, rhi, clo, chi = self.key2bounds(keys) r, c = rhi - rlo, chi - clo if r*c < len(self._smat): # the subregion is smaller than the number

Re: [sympy] Re: Problems with Sparse Matrix

2013-06-04 Thread Chris Smith
This is why it's better to work with smat -- you can load it up with the non-zero elements and pass that to `_new`. Something like I just posted would work, I think. -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and sto

Re: [sympy] Re: Problems with Sparse Matrix

2013-06-04 Thread Chris Smith
What I propose was to be used with your inheritance method. The else part should also be changed to ``` # the number of non-zero elements is smaller than the subregion smat = {} for rk, ck in self._smat: if rlo <= rk <= rhi and clo <= ck <= chi: