Re: [Numpy-discussion] Adapting algorithm to accept Scipy sparse matrix

2007-03-26 Thread David Koch
Hi again, I want to select/access several columns from a sparse csc_matrix. The only way I could think of is the following enormously inefficient algorithm which basically initalizes a new lil_matrix (for assigments) and loops over all the specified columns and does sparse -> dense -> sparse. All

Re: [Numpy-discussion] Adapting algorithm to accept Scipy sparse matrix

2007-03-23 Thread David Koch
Hi, Ok, I got it to work now but - damn, it's ugly. I thought I'd have to watch the differences between ndarray and matrix type but it turns out sparseMatrix is yet again different from matrix in several respects when it comes to certain operations. Is this intended or something that will be mend

Re: [Numpy-discussion] Adapting algorithm to accept Scipy sparse matrix

2007-03-21 Thread David Koch
Alright, may all the trickery rest until that day. One thing I need to do however is patch a column of "ones" onto a sparse matrix of format n * d with n >> d. I tried "concatenate" and it didn't work so I did like this: def spInsCol(X): "insert doc string" n, d = shape(X) X = X.tocsc(

Re: [Numpy-discussion] Adapting algorithm to accept Scipy sparse matrix

2007-03-21 Thread Steve Lianoglou
Hi David, > The "worst" problem I encountered is that sparse matrices do not > seem to support the kind of indexing I need. At least I get > "NotImplementedError: sequence indexing not yet fully supported" > and " supports slices only of a single row" > errors all the time. I agree .. thi

Re: [Numpy-discussion] Adapting algorithm to accept Scipy sparse matrix

2007-03-21 Thread David Koch
Ok, I will bump this once ... The "worst" problem I encountered is that sparse matrices do not seem to support the kind of indexing I need. At least I get "NotImplementedError: sequence indexing not yet fully supported" and " supports slices only of a single row" errors all the time. Any advice

[Numpy-discussion] Adapting algorithm to accept Scipy sparse matrix

2007-03-20 Thread David Koch
Hi, I implemented an algorithm in NumPy which assumes that the input is of type ndarray, so elementwise multiplication is done as dot(x,y), equation solving using linalg.solve etc. I now want to modify the whole thing to accept scipy.sparse matrices (which for instance has linsolve.spsolve instea