[cctbxbb] sparse matrix

Luc Bourhis luc_j_bourhis at mac.com
Fri Jun 6 06:18:00 PDT 2014


Hi David,

> Without having tried this, I sense it might be a burden. I have a lot
> of values to set and don't really want to convert from flex.double via
> a dictionary. Are there any philosophical/technical/other reasons for
> not writing a set_selected method for sparse.vector? If not, I might
> try to do this.

First I am the author of that sparse matrix code. 

Then could you tell me what application you have in mind? My sparse matrix code has very specific memory and time trade-offs, that may not be suitable for your problem.

But I can already answer your question: it would be slow as well as cumbersome to go through an intermediate dictionary. Initialising a sparse vector with a dictionary, I only implemented it to make testing easier. It is not designed to be used in heavy-duty production code. Moreover it would be perfectly legitimate for the sparse columns to support assignment through selections. I could easily make the following work:

x = sparse.vector(10) # vector with 10 elements
x.set_selected(index_selection, another_vector)
x.compact() # part of the trade-offs I was talking about

Best wishes,

Luc

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://phenix-online.org/pipermail/cctbxbb/attachments/20140606/c437897d/attachment.htm>


More information about the cctbxbb mailing list