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

Use references

parent dc6fd23f
No related branches found
No related tags found
No related merge requests found
...@@ -78,7 +78,7 @@ template <int dim> class SampleFunctional { ...@@ -78,7 +78,7 @@ template <int dim> class SampleFunctional {
// points in direction -x. The projection will then be zero. // points in direction -x. The projection will then be zero.
SmallVector d; SmallVector d;
smoothGradient(x, d); smoothGradient(x, d);
ret = negative_projection(d, x); negative_projection(d, x, ret);
dverb << "## Directional derivative (as per scalar product w/ " dverb << "## Directional derivative (as per scalar product w/ "
"semigradient): " << -(ret * ret) "semigradient): " << -(ret * ret)
<< " (coordinates of the restriction)" << std::endl; << " (coordinates of the restriction)" << std::endl;
...@@ -111,12 +111,13 @@ template <int dim> class SampleFunctional { ...@@ -111,12 +111,13 @@ template <int dim> class SampleFunctional {
y += z; y += z;
} }
// No normalising is done! // y = (id - P)(d) where P is the projection onto the line t*x
SmallVector negative_projection(SmallVector const z, void negative_projection(SmallVector const &d, SmallVector const &x,
SmallVector const x) const { SmallVector &y) const {
SmallVector y = z; double const dx = d * x;
y.axpy(-(z * x) / x.two_norm2(), x); double const xx = x.two_norm2();
return y; y = d;
y.axpy(-dx / xx, x);
} }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment