So-Bogus
A c++ sparse block matrix library aimed at Second Order cone problems
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Serialization.hpp
1 /*
2  * This file is part of bogus, a C++ sparse block matrix library.
3  *
4  * Copyright 2013 Gilles Daviet <gdaviet@gmail.com>
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
10 
11 #ifndef BOGUS_BLOCK_SERIALIZATION_HPP
12 #define BOGUS_BLOCK_SERIALIZATION_HPP
13 
14 #include "SparseBlockMatrix.hpp"
15 
16 namespace boost {
17 namespace serialization {
18 
19 template< typename Index, typename BlockPtr >
20 struct version < bogus::SparseBlockIndex<true, Index, BlockPtr > >
21 {
22  enum { value = 1 };
23 } ;
24 
25 template < typename BlockT, int Flags >
26 struct version < bogus::SparseBlockMatrix< BlockT, Flags > >
27 {
28  enum { value = 1 };
29 } ;
30 
31 template<typename Archive, typename Index, typename BlockPtr >
32 inline void serialize(
33  Archive & ar,
35  const unsigned int file_version
36  )
37 {
38  (void) file_version ;
39  ar & index.valid ;
40  ar & index.innerOffsets ;
41  ar & index.outer ;
42 }
43 
44 template<typename Archive, typename Index, typename BlockPtr >
45 inline void serialize(
46  Archive & ar,
48  const unsigned int file_version
49  )
50 {
51  BlockPtr dummy_base ;
52 
53  ar & index.valid ;
54  ar & index.innerOffsets ;
55  if ( file_version == 0 )
56  ar & dummy_base ;
57  ar & index.inner ;
58  ar & index.outer ;
59 }
60 
61 } //serialization
62 } //boost
63 
64 namespace bogus {
65 
66 template < typename Derived >
67 template < typename Archive >
68 void SparseBlockMatrixBase< Derived >::serialize(
69  Archive & ar,
70  const unsigned int file_version
71  )
72 {
73  std::size_t dummyNBlocks( 0 ) ;
74 
75  ar & m_rows ;
76  ar & m_cols ;
77  ar & m_blocks ;
78  if( file_version == 0 )
79  ar & dummyNBlocks ;
80  ar & m_majorIndex ;
81  ar & m_minorIndex ;
82  ar & m_transposeIndex ;
83 
84  if( file_version == 0 ) {
85  m_transposeBlocks.clear() ;
86  m_transposeIndex.clear() ;
87  m_transposeIndex.valid = 0 ;
88  m_blocks.resize( dummyNBlocks ) ;
89  } else
90  ar & m_transposeBlocks ;
91 }
92 
93 } //bogus
94 
95 #endif
Uncompressed sparse block index.
Definition: SparseBlockIndex.hpp:86
bool valid
Whether this index is currently valid.
Definition: SparseBlockIndex.hpp:40