From: Karl R. <ru...@iu...> - 2017-04-06 19:16:06
|
Hi! On 04/06/2017 06:44 PM, Chris Marsh wrote: > Hi, > > I know the number of non-zero entries for a sparse matrix so I am trying > to pre-allocate it with > > viennacl::compressed_matrix<vcl_scalar_type> vl_C(row, col, nnz); At this point your matrix is still empty (i.e. no nonzeros). It only preallocated an array to hold up to 'nnz' entries. > and access it with vl_C.operator(). Unless you are changing only a few entries, this is likely to be too slow. > I am using host only memory context, with ViennaCL 1.7.1 from homebrew. > > How should I proceed with this? To fill the CSR format efficiencly, have a look here: https://sourceforge.net/p/viennacl/discussion/1143678/thread/325a937c/?limit=25#d6f0 For host-based memory, an example of how to get pointers to the three CSR arrays is here: https://github.com/viennacl/viennacl-dev/blob/master/viennacl/linalg/host_based/sparse_matrix_operations.hpp#L115 Best regards, Karli |