Skip to content

Commit 19c6aad

Browse files
quentinlljcarpent
authored andcommitted
dense_qp_wrapper.cpp: adding malloc test to power
1 parent b2cc776 commit 19c6aad

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/src/dense_qp_wrapper.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ using T = double;
1313
using namespace proxsuite;
1414
using namespace proxsuite::proxqp;
1515

16+
1617
DOCTEST_TEST_CASE(
1718
"ProxQP::dense: sparse random strongly convex qp with inequality constraints"
1819
"and empty equality constraints")
@@ -7588,4 +7589,32 @@ DOCTEST_TEST_CASE("check that model.is_valid function for symmetric matrices "
75887589
// model.is_valid() that performs the check above
75897590
proxqp::dense::QP<T> qp(3, 0, 0);
75907591
qp.init(symmetric_mat, nullopt, nullopt, nullopt, nullopt, nullopt, nullopt);
7592+
}
7593+
7594+
7595+
TEST_CASE(
7596+
"ProxQP::dense: test memory allocation when estimating biggest eigenvalue with power iteration")
7597+
{
7598+
double sparsity_factor = 1.;
7599+
T tol = T(1e-3);
7600+
utils::rand::set_seed(1);
7601+
dense::isize dim = 2;
7602+
dense::isize n_eq(dim);
7603+
dense::isize n_in(dim);
7604+
T strong_convexity_factor(1.e-2);
7605+
Eigen::Matrix<double, 2, 2, Eigen::ColMajor> H;
7606+
Eigen::VectorXd dw(2), rhs(2), err_v(2);
7607+
// trivial test
7608+
::proxsuite::proxqp::utils::rand::set_seed(1234);
7609+
proxqp::dense::Model<T> qp_random = proxqp::utils::dense_strongly_convex_qp(
7610+
dim, n_eq, n_in, sparsity_factor, strong_convexity_factor);
7611+
7612+
qp_random.H.setZero();
7613+
qp_random.H.diagonal().setOnes();
7614+
qp_random.H.diagonal().tail(1).setConstant(-0.5);
7615+
H = qp_random.H;
7616+
PROXSUITE_EIGEN_MALLOC_NOT_ALLOWED();
7617+
dense::power_iteration<T>(
7618+
H, dw, rhs, err_v, 1.E-6, 10000);
7619+
PROXSUITE_EIGEN_MALLOC_ALLOWED();
75917620
}

0 commit comments

Comments
 (0)