@@ -16,10 +16,12 @@ struct MarosMeszarosQp
1616 Mat A;
1717 Vec l;
1818 Vec u;
19+
20+ bool skip = false ;
1921};
2022
2123auto
22- load_qp (char const * filename) -> MarosMeszarosQp
24+ load_qp (char const * filename, bool check_size = false ) -> MarosMeszarosQp
2325{
2426 using Mat = MarosMeszarosQp::Mat;
2527 using Vec = MarosMeszarosQp::Vec;
@@ -30,6 +32,8 @@ load_qp(char const* filename) -> MarosMeszarosQp
3032 proxsuite::linalg::veg::defer ([&] { Mat_Close (mat_fp); });
3133 proxsuite::linalg::veg::unused (_mat_fp_cleanup);
3234
35+ bool skip = false ;
36+
3337 auto load_mat = [&](char const * name) -> Mat {
3438 matvar_t * mat_var = Mat_VarRead (mat_fp, name);
3539 VEG_ASSERT (mat_var != nullptr );
@@ -44,27 +48,30 @@ load_qp(char const* filename) -> MarosMeszarosQp
4448
4549 isize nrows = isize (mat_var->dims [0 ]);
4650 isize ncols = isize (mat_var->dims [1 ]);
51+ Mat out;
4752
48- auto optr = reinterpret_cast <mat_int32_t const *>(ptr->jc ); // NOLINT
49- auto iptr = reinterpret_cast <mat_int32_t const *>(ptr->ir ); // NOLINT
50- auto vptr = static_cast <double const *>(ptr->data ); // NOLINT
53+ if (!check_size || (nrows <= 1000 && ncols <= 1000 )) {
54+ auto optr = reinterpret_cast <mat_int32_t const *>(ptr->jc ); // NOLINT
55+ auto iptr = reinterpret_cast <mat_int32_t const *>(ptr->ir ); // NOLINT
56+ auto vptr = static_cast <double const *>(ptr->data ); // NOLINT
5157
52- Mat out;
53- out.resize (nrows, ncols);
54- out.reserve (ptr->nzmax );
55- for (isize j = 0 ; j < ncols; ++j) {
56- isize col_start = optr[j];
57- isize col_end = optr[j + 1 ];
58+ out.resize (nrows, ncols);
59+ out.reserve (ptr->nzmax );
60+ for (isize j = 0 ; j < ncols; ++j) {
61+ isize col_start = optr[j];
62+ isize col_end = optr[j + 1 ];
5863
59- for (isize p = col_start; p < col_end; ++p) {
64+ for (isize p = col_start; p < col_end; ++p) {
6065
61- isize i = iptr[p];
62- double v = vptr[p];
66+ isize i = iptr[p];
67+ double v = vptr[p];
6368
64- out.insert (i, j) = v;
69+ out.insert (i, j) = v;
70+ }
6571 }
72+ } else {
73+ skip = true ;
6674 }
67-
6875 return out;
6976 };
7077
@@ -86,8 +93,8 @@ load_qp(char const* filename) -> MarosMeszarosQp
8693 };
8794
8895 return {
89- filename, load_mat (" P" ), load_vec (" q" ),
90- load_mat ( " A " ), load_vec (" l" ), load_vec (" u" ),
96+ filename, load_mat (" P" ), load_vec (" q" ), load_mat ( " A " ),
97+ load_vec (" l" ), load_vec (" u" ), skip ,
9198 };
9299}
93100
0 commit comments