1

I saved a scipy sparse csr matrix in a .npz file thanks to the save_sparse_csr(filename,array) given in this link:

Save / load scipy sparse csr_matrix in portable data format

So, I obtained an .npz archive Matrix.npz which contains data.npy, indices.npy, indptr.npy, shape.npy files.

However I am trying to load with these files the initial sparse matrix in C++. Unfortunately I am a beginner in C++ and I don't know how to do it. I found a library which reads .npz and .npy files in C++ in that link : https://github.com/rogersce/cnpy

I loaded the four arrays mentioned above in this code:

cnpy::NpyArray d = cnpy::npz_load("Matrix.npz","data"); cnpy::NpyArray ind = cnpy::npz_load("Matrix.npz","indices"); cnpy::NpyArray indptr = cnpy::npz_load("Matrix.npz","indptr"); cnpy::NpyArray sh = cnpy::npz_load("Matrix.npz","shape");

Any help? Thanks.

Community
  • 1
  • 1
Samy Jelassi
  • 165
  • 7
  • You'll have to find a c++ library that implements sparse matrices. By themselves these 4 arrays aren't going to be useful. – hpaulj Apr 05 '16 at 18:32
  • A recent C++ sparse matrix question on SO: http://stackoverflow.com/questions/29598299/csr-matrix-matrix-multiplication – hpaulj Apr 05 '16 at 20:24

0 Answers0