Skip to content

Commit c6b138b

Browse files
committed
dense/model: use PROXSUITE_THROW_PRETTY in isValid()
1 parent 266cd67 commit c6b138b

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

include/proxsuite/proxqp/dense/model.hpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -108,29 +108,23 @@ struct Model
108108

109109
// check that all matrices and vectors of qpmodel have the correct size
110110
// and that H and C have expected properties
111-
PROXSUITE_CHECK_SIZE(g.size(), dim);
112-
PROXSUITE_CHECK_SIZE(b.size(), n_eq);
113-
PROXSUITE_CHECK_SIZE(u.size(), n_in);
114-
PROXSUITE_CHECK_SIZE(l.size(), n_in);
115-
if (box_constraints) {
116-
PROXSUITE_CHECK_SIZE(u_box.size(), dim);
117-
PROXSUITE_CHECK_SIZE(l_box.size(), dim);
118-
}
111+
PROXSUITE_CHECK_ARGUMENT_SIZE(g.size(), dim, "g has not the expected size.")
112+
PROXSUITE_CHECK_ARGUMENT_SIZE(b.size(), n_eq, "b has not the expected size.")
113+
PROXSUITE_CHECK_ARGUMENT_SIZE(l.size(), n_in, "l has not the expected size.")
114+
PROXSUITE_CHECK_ARGUMENT_SIZE(u.size(), n_in, "u has not the expected size.")
119115
if (H.size()) {
120-
PROXSUITE_CHECK_SIZE(H.rows(), dim);
121-
PROXSUITE_CHECK_SIZE(H.cols(), dim);
122-
if (!H.isApprox(H.transpose(), 0.0))
123-
return false;
116+
PROXSUITE_CHECK_ARGUMENT_SIZE(H.rows(), dim, "H has not the expected number of rows.");
117+
PROXSUITE_CHECK_ARGUMENT_SIZE(H.cols(), dim, "H has not the expected number of cols.");
118+
PROXSUITE_THROW_PRETTY((!H.isApprox(H.transpose(), 0.0)), std::invalid_argument, "H is not symmetric.");
124119
}
125120
if (A.size()) {
126-
PROXSUITE_CHECK_SIZE(A.rows(), n_eq);
127-
PROXSUITE_CHECK_SIZE(A.cols(), dim);
121+
PROXSUITE_CHECK_ARGUMENT_SIZE(A.rows(), n_eq, "A has not the expected number of rows.");
122+
PROXSUITE_CHECK_ARGUMENT_SIZE(A.cols(), dim, "A has not the expected number of cols.");
128123
}
129124
if (C.size()) {
130-
PROXSUITE_CHECK_SIZE(C.rows(), n_in);
131-
PROXSUITE_CHECK_SIZE(C.cols(), dim);
132-
if (C.isZero())
133-
return false;
125+
PROXSUITE_CHECK_ARGUMENT_SIZE(C.rows(), n_in, "C has not the expected number of rows.");
126+
PROXSUITE_CHECK_ARGUMENT_SIZE(C.cols(), dim, "C has not the expected number of cols.");
127+
PROXSUITE_THROW_PRETTY(C.isZero(), std::invalid_argument, "C is zero, while n_in != 0.");
134128
}
135129
return true;
136130
#undef PROXSUITE_CHECK_SIZE

0 commit comments

Comments
 (0)