Skip to content

Commit 70c03da

Browse files
committed
macro: rename and move CHECK_DATA
1 parent f664a72 commit 70c03da

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

include/proxsuite/linalg/veg/internal/macros.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@
2424
throw exception(ss.str()); \
2525
}
2626

27-
#define CHECK_DATA(size, expected_size) \
28-
if (size != 0) { \
29-
if (!(size == expected_size)) \
30-
return false; \
31-
}
32-
3327
#define PROXSUITE_CHECK_ARGUMENT_SIZE(size, expected_size, message) \
3428
if (size != expected_size) { \
3529
std::ostringstream oss; \

include/proxsuite/proxqp/dense/model.hpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,29 +87,36 @@ struct Model
8787

8888
bool is_valid()
8989
{
90+
#define PROXSUITE_CHECK_SIZE(size, expected_size) \
91+
if (size != 0) { \
92+
if (!(size == expected_size)) \
93+
return false; \
94+
}
95+
9096
// check that all matrices and vectors of qpmodel have the correct size
9197
// and that H and C have expected properties
92-
CHECK_DATA(g.size(), dim);
93-
CHECK_DATA(b.size(), n_eq);
94-
CHECK_DATA(u.size(), n_in);
95-
CHECK_DATA(l.size(), n_in);
98+
PROXSUITE_CHECK_SIZE(g.size(), dim);
99+
PROXSUITE_CHECK_SIZE(b.size(), n_eq);
100+
PROXSUITE_CHECK_SIZE(u.size(), n_in);
101+
PROXSUITE_CHECK_SIZE(l.size(), n_in);
96102
if (H.size()) {
97-
CHECK_DATA(H.rows(), dim);
98-
CHECK_DATA(H.cols(), dim);
103+
PROXSUITE_CHECK_SIZE(H.rows(), dim);
104+
PROXSUITE_CHECK_SIZE(H.cols(), dim);
99105
if (!H.isApprox(H.transpose(), 0.0))
100106
return false;
101107
}
102108
if (A.size()) {
103-
CHECK_DATA(A.rows(), n_eq);
104-
CHECK_DATA(A.cols(), dim);
109+
PROXSUITE_CHECK_SIZE(A.rows(), n_eq);
110+
PROXSUITE_CHECK_SIZE(A.cols(), dim);
105111
}
106112
if (C.size()) {
107-
CHECK_DATA(C.rows(), n_in);
108-
CHECK_DATA(C.cols(), dim);
113+
PROXSUITE_CHECK_SIZE(C.rows(), n_in);
114+
PROXSUITE_CHECK_SIZE(C.cols(), dim);
109115
if (C.isZero())
110116
return false;
111117
}
112118
return true;
119+
#undef PROXSUITE_CHECK_SIZE
113120
}
114121
};
115122
} // namespace dense

0 commit comments

Comments
 (0)