Commit a849243a authored by David Frank's avatar David Frank
Browse files

Simplify calculation of Lipschitz constant

parent b8549267
......@@ -160,16 +160,14 @@ namespace elsa
}
// compute the Lipschitz Constant as the largest eigenvalue of the Hessian
const auto hessian = getHessian();
Eigen::Matrix<data_t, Eigen::Dynamic, 1> bVec(
hessian.getDomainDescriptor().getNumberOfCoefficients());
bVec.setOnes();
DataContainer<data_t> dcB(hessian.getDomainDescriptor(), bVec);
DataContainer<data_t> dcB(hessian.getDomainDescriptor());
dcB = 1;
for (index_t i = 0; i < nIterations; i++) {
dcB = hessian.apply(dcB);
dcB = dcB / sqrt(dcB.dot(dcB));
dcB = dcB / dcB.l2Norm();
}
return dcB.dot(hessian.apply(dcB)) / (dcB.dot(dcB));
return dcB.dot(hessian.apply(dcB)) / dcB.l2Norm();
}
template <typename data_t>
......
......@@ -131,7 +131,7 @@ TEST_CASE_TEMPLATE("Scenario: Testing LASSOProblem", data_t, float, double)
THEN("the Lipschitz Constant of a LASSOProblem with an Identity Operator as the "
"Linear Operator A is 1")
{
REQUIRE_EQ(lipschitzConstant, as<data_t>(1.0));
REQUIRE_EQ(lipschitzConstant, Approx(as<data_t>(1.0)));
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment