Skip to content

Commit

Permalink
templating power by the matrix storage order
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinll authored and fabinsch committed Nov 13, 2023
1 parent 002266b commit 4a9dd8f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/cpp/estimate_nonconvex_eigenvalue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ main()
dense::QP<T> qp(dim, n_eq, n_in); // create the QP object
// choose the option for estimating this eigenvalue
T estimate_minimal_eigen_value =
dense::estimate_minimal_eigen_value_of_symmetric_matrix<T>(
dense::estimate_minimal_eigen_value_of_symmetric_matrix<T, Eigen::RowMajor>(
qp_random.H, EigenValueEstimateMethodOption::ExactMethod, 1.E-6, 10000);
bool compute_preconditioner = false;
// input the estimate for making rho appropriate
Expand Down
12 changes: 6 additions & 6 deletions include/proxsuite/proxqp/dense/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ namespace proxsuite {
namespace proxqp {
namespace dense {

template<typename T>
template<typename T, int l>
T
power_iteration(MatRef<T> H,
power_iteration(MatRef<T, l> H,
VecRefMut<T> dw,
VecRefMut<T> rhs,
VecRefMut<T> err_v,
Expand Down Expand Up @@ -55,9 +55,9 @@ power_iteration(MatRef<T> H,
}
return eig;
}
template<typename T>
template<typename T, int l>
T
min_eigen_value_via_modified_power_iteration(MatRef<T> H,
min_eigen_value_via_modified_power_iteration(MatRef<T, l> H,
VecRefMut<T> dw,
VecRefMut<T> rhs,
VecRefMut<T> err_v,
Expand Down Expand Up @@ -104,10 +104,10 @@ min_eigen_value_via_modified_power_iteration(MatRef<T> H,
* @param nb_power_iteration maximal number of power iteration executed
*
*/
template<typename T>
template<typename T, int l>
T
estimate_minimal_eigen_value_of_symmetric_matrix(
MatRef<T> H,
MatRef<T, l> H,
EigenValueEstimateMethodOption estimate_method_option,
T power_iteration_accuracy,
isize nb_power_iteration)
Expand Down
5 changes: 3 additions & 2 deletions test/src/dense_qp_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using T = double;
using namespace proxsuite;
using namespace proxsuite::proxqp;


/*
DOCTEST_TEST_CASE(
"ProxQP::dense: sparse random strongly convex qp with inequality constraints"
"and empty equality constraints")
Expand Down Expand Up @@ -7591,6 +7591,7 @@ DOCTEST_TEST_CASE("check that model.is_valid function for symmetric matrices "
qp.init(symmetric_mat, nullopt, nullopt, nullopt, nullopt, nullopt, nullopt);
}
*/

TEST_CASE(
"ProxQP::dense: test memory allocation when estimating biggest eigenvalue with power iteration")
Expand All @@ -7614,7 +7615,7 @@ TEST_CASE(
qp_random.H.diagonal().tail(1).setConstant(-0.5);
H = qp_random.H;
PROXSUITE_EIGEN_MALLOC_NOT_ALLOWED();
dense::power_iteration<T>(
dense::power_iteration<T, Eigen::ColMajor>(
H, dw, rhs, err_v, 1.E-6, 10000);
PROXSUITE_EIGEN_MALLOC_ALLOWED();
}

0 comments on commit 4a9dd8f

Please sign in to comment.