Skip to content
Snippets Groups Projects
Commit d7234806 authored by Elias Pipping's avatar Elias Pipping Committed by Elias Pipping
Browse files

v need not be normalised

parent e74dab2b
No related branches found
No related tags found
No related merge requests found
...@@ -24,15 +24,22 @@ class MyNonlinearity { ...@@ -24,15 +24,22 @@ class MyNonlinearity {
typedef SmallVector VectorType; typedef SmallVector VectorType;
typedef SmallMatrix MatrixType; typedef SmallMatrix MatrixType;
// directional subdifferential: at u on the line u + t*v
void directionalSubDiff(VectorType u, VectorType v, Interval<double>& D) { void directionalSubDiff(VectorType u, VectorType v, Interval<double>& D) {
if (u == SmallVector(0.0)) { if (u == SmallVector(0.0)) {
D[0] = D[1] = func_.rightDifferential(0); D[0] = D[1] = func_.rightDifferential(0);
} else if (u * v > 0) { return;
D[1] = (v * u) * func_.rightDifferential(u.two_norm()) / u.two_norm(); }
D[0] = (v * u) * func_.leftDifferential(u.two_norm()) / u.two_norm(); double const un = u.two_norm();
double const ndotp = (u * v) / (un * v.two_norm());
if (ndotp > 0) {
// If we had |v| = 1, this would be
// <f'_pm(|u|)*u/|u|,v>
D[1] = ndotp * func_.rightDifferential(un);
D[0] = ndotp * func_.leftDifferential(un);
} else { } else {
D[1] = (v * u) * func_.leftDifferential(u.two_norm()) / u.two_norm(); D[1] = ndotp * func_.leftDifferential(un);
D[0] = (v * u) * func_.rightDifferential(u.two_norm()) / u.two_norm(); D[0] = ndotp * func_.rightDifferential(un);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment