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.

2
  • You'll have to find a c++ library that implements sparse matrices. By themselves these 4 arrays aren't going to be useful. Commented Apr 5, 2016 at 18:32
  • A recent C++ sparse matrix question on SO: stackoverflow.com/questions/29598299/… Commented Apr 5, 2016 at 20:24

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.