Skip to content

Commit 19ebc94

Browse files
committed
serialization/eigen: account specifically for storage order
- options is ENUM which could contain further information about alignment https://eigen.tuxfamily.org/dox-3.3/group__enums.html#gaacded1a18ae58b0f554751f6cdf9eb13
1 parent 68cc316 commit 19ebc94

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

include/proxsuite/serialization/eigen.hpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,15 @@ save(
3030
{
3131
Eigen::Index rows = m.rows();
3232
Eigen::Index cols = m.cols();
33-
ar(rows);
34-
ar(cols);
35-
ar(_Options);
33+
ar(CEREAL_NVP(rows));
34+
ar(CEREAL_NVP(cols));
35+
int storage_order;
36+
if (m.IsRowMajor) {
37+
storage_order = 1;
38+
} else {
39+
storage_order = 0;
40+
}
41+
ar(CEREAL_NVP(storage_order));
3642

3743
for (Eigen::Index i = 0; i < m.size(); i++)
3844
ar(m.data()[i]);
@@ -51,18 +57,18 @@ load(Archive& ar,
5157
{
5258
Eigen::Index rows;
5359
Eigen::Index cols;
54-
int _OptionsLoaded;
55-
ar(rows);
56-
ar(cols);
57-
ar(_OptionsLoaded);
60+
int storage_order;
61+
ar(CEREAL_NVP(rows));
62+
ar(CEREAL_NVP(cols));
63+
ar(CEREAL_NVP(storage_order));
5864

5965
m.resize(rows, cols);
6066

6167
for (Eigen::Index i = 0; i < m.size(); i++)
6268
ar(m.data()[i]);
6369

6470
// Account for different storage orders
65-
if (!(_OptionsLoaded == _Options)) {
71+
if (!(storage_order == m.IsRowMajor)) {
6672
#if EIGEN_VERSION_AT_LEAST(3, 4, 0)
6773
m.transposeInPlace();
6874
#else

test/src/serialization.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ DOCTEST_TEST_CASE("test serialization of qp model, results and settings")
113113
{
114114
std::cout << "--- serialization ---" << std::endl;
115115
double sparsity_factor = 0.15;
116-
T eps_abs = T(1e-9);
117116
utils::rand::set_seed(1);
118117
dense::isize dim = 10;
119118

0 commit comments

Comments
 (0)