[Numpy-discussion] sparse.hstack with empty sparse matrices

David Koch ogdude@googlemail....
Mon Apr 12 10:50:19 CDT 2010


For scipy.sparse.csc_matrices, is there an equivalent for the
following dense array operation?


tempA = scipy.empty((10,0))
tempB = scipy.random.random((10,1))
scipy.hstack((tempA, tempB))

i.e - you concatenate an empty n x 0 sparse matrix with a n x 1 sparse
matrix to yield a n x 1 output

I need to do this so I can iteratively build a matrix by adding new
columns. The problem is that sparse matrix constructors don't seem
expect "0" as input for a dimension.

Thank you,


More information about the NumPy-Discussion mailing list