This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Serializing a Sparse Matrix

Tags: None
(comma "," separated)
dubmarauder
Registered Member
Posts
14
Karma
0
OS

Serializing a Sparse Matrix

Thu Mar 31, 2011 9:40 pm
I need to save a number of sizable sparse matrices to disk and read them in later. To do this, I am currently generating a CCS representation of the matrix and serializing these three arrays. To reload the matrix, I load these three arrays, dump them into a sparse matrix, and call finalize.

Not that this is hard, but is there an easier way to save out the internal state of the sparse matrix so I don't have to 're-finalize'?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Serializing a Sparse Matrix

Mon Apr 04, 2011 10:39 am
you could use the outerIndexPtr(), innerIndexPtr() and valuePtr() methods to directly save/store the values. For a store don't forget to allocate the buffer by calling resize(r,c) and resizeNonZeros(s)...
dubmarauder
Registered Member
Posts
14
Karma
0
OS

Re: Serializing a Sparse Matrix

Sun Apr 17, 2011 10:18 pm
Thanks for the response! Which version of the library are the *Ptr() methods available in? I am using the 3.0.0 release and the *Ptr() methods are not available from a sparse matrix. Do I have to do something extra to access the methods?

Tschüss!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Serializing a Sparse Matrix

Tue Apr 19, 2011 12:08 pm
they are available in the 3.0.0 release:

inline const Scalar* _valuePtr() const { return &m_data.value(0); }
inline Scalar* _valuePtr() { return &m_data.value(0); }

inline const Index* _innerIndexPtr() const { return &m_data.index(0); }
inline Index* _innerIndexPtr() { return &m_data.index(0); }

inline const Index* _outerIndexPtr() const { return m_outerIndex; }
inline Index* _outerIndexPtr() { return m_outerIndex; }

however they are prefixed by a "_" because they were initially supposed to be used internally.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], q.ignora