Commit e6145647 authored by Carsten Gräser's avatar Carsten Gräser
Browse files

Adjust old subDifferential() and domain() to new interface

parent df68542d
......@@ -42,19 +42,20 @@ class DirectionalConvexFunction
return b;
}
void subDiff(double x, Dune::Solvers::Interval<double>& D) const
auto subDifferential(double x) const
{
Dune::Solvers::Interval<double> D;
temp_u_ = u_;
temp_u_.axpy(x, v_);
phi_.directionalSubDiff(temp_u_, v_, D);
D[0] += A*x - b;
D[1] += A*x - b;
return D;
}
void domain(Dune::Solvers::Interval<double>& domain) const
auto domain() const
{
domain[0] = this->dom_[0];
domain[1] = this->dom_[1];
return dom_;
}
double A;
......
......@@ -38,18 +38,20 @@ class OneDConvexFunction
* \param x argument
* \param[out] D The subdifferential, which may be an interval if the function is not differentiable at x
*/
void subDiff(double x, Dune::Solvers::Interval<double>& D) const
auto subDifferential(double x) const
{
Dune::Solvers::Interval<double> D;
phi_.subDiff(i, x, D, j);
D[0] += A*x - b;
D[1] += A*x - b;
return;
return D;
};
void domain(Dune::Solvers::Interval<double>& domain) const
auto domain() const
{
Dune::Solvers::Interval<double> domain;
phi_.domain(i, domain, j);
return;
return domain;
};
double A;
......
......@@ -24,8 +24,9 @@ class SimplexEdgeConvexFunction
return b;
}
void subDiff(double x, Dune::Solvers::Interval<double>& D) const
auto subDifferential(double x) const
{
Dune::Solvers::Interval<double> D;
// set local values both directions
phi.updateEntry(i, ui[j1] + x, j1);
phi.updateEntry(i, ui[j2] - x, j2);
......@@ -52,10 +53,12 @@ class SimplexEdgeConvexFunction
// restore local values both directions
phi.updateEntry(i, ui[j1], j1);
phi.updateEntry(i, ui[j2], j2);
return D;
};
void domain(Dune::Solvers::Interval<double>& domain, bool v=false) const
auto domain() const
{
Dune::Solvers::Interval<double> domain;
// initialize by first relative directional domain
phi.domain(i, domain, j1);
domain[0] -= ui[j1];
......@@ -77,6 +80,7 @@ class SimplexEdgeConvexFunction
domain[0] = domainj2[1];
if (domain[1] > domainj2[0])
domain[1] = domainj2[0];
return domain;
};
double A;
......
......@@ -24,8 +24,9 @@ class SimplexProjectionConvexFunction
return sum;
}
void subDiff(double lambda, Dune::Solvers::Interval<double>& D) const
auto subDifferential(double lambda) const
{
Dune::Solvers::Interval<double> D;
D[0] = sum;
for(int j=0; j<u.N(); ++j)
{
......@@ -35,13 +36,15 @@ class SimplexProjectionConvexFunction
D[0] -= Puj;
}
D[1] = D[0];
return D;
};
void domain(Dune::Solvers::Interval<double>& domain) const
auto domain() const
{
Dune::Solvers::Interval<double> domain;
domain[1] = std::numeric_limits<double>::max();
domain[0] = -std::numeric_limits<double>::max();
return;
return domain;
};
void getProjection(double lambda, VectorType& Pu)
......
Markdown is supported
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