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

Rename gradient methods:

SmoothGrad -> smoothGradient
PlusGrad   -> upperGradient
MinusGrad  -> lowerGradient
parent e00524bb
No related branches found
No related tags found
No related merge requests found
...@@ -31,7 +31,7 @@ class SampleFunctional { ...@@ -31,7 +31,7 @@ class SampleFunctional {
SmallVector descentDirection(const SmallVector x) const { SmallVector descentDirection(const SmallVector x) const {
if (x == SmallVector(0.0)) { if (x == SmallVector(0.0)) {
SmallVector d = SmoothGrad(x); SmallVector d = smoothGradient(x);
// Decline of the smooth part in the negative gradient direction // Decline of the smooth part in the negative gradient direction
double smoothDecline = -(d * d); double smoothDecline = -(d * d);
double nonlinearDecline = double nonlinearDecline =
...@@ -41,8 +41,8 @@ class SampleFunctional { ...@@ -41,8 +41,8 @@ class SampleFunctional {
return (combinedDecline < 0) ? d : SmallVector(0.0); return (combinedDecline < 0) ? d : SmallVector(0.0);
} }
SmallVector const pg = PlusGrad(x); SmallVector const pg = upperGradient(x);
SmallVector const mg = MinusGrad(x); SmallVector const mg = lowerGradient(x);
SmallVector ret; SmallVector ret;
// TODO: collinearity checks suck // TODO: collinearity checks suck
if (pg * x == pg.two_norm() * x.two_norm() && if (pg * x == pg.two_norm() * x.two_norm() &&
...@@ -53,7 +53,7 @@ class SampleFunctional { ...@@ -53,7 +53,7 @@ class SampleFunctional {
} else if (pg * x <= 0 && mg * x <= 0) { } else if (pg * x <= 0 && mg * x <= 0) {
ret = mg; ret = mg;
} else { } else {
ret = project(SmoothGrad(x), x); ret = project(smoothGradient(x), x);
} }
ret *= -1; ret *= -1;
return ret; return ret;
...@@ -66,21 +66,21 @@ class SampleFunctional { ...@@ -66,21 +66,21 @@ class SampleFunctional {
Function func_; Function func_;
// Gradient of the smooth part // Gradient of the smooth part
SmallVector SmoothGrad(const SmallVector x) const { SmallVector smoothGradient(const SmallVector x) const {
SmallVector y; SmallVector y;
A.mv(x, y); // y = Av A.mv(x, y); // y = Av
y -= b; // y = Av - b y -= b; // y = Av - b
return y; return y;
} }
SmallVector PlusGrad(const SmallVector x) const { SmallVector upperGradient(const SmallVector x) const {
SmallVector y = SmoothGrad(x); SmallVector y = smoothGradient(x);
y.axpy(func_.rightDifferential(x.two_norm()) / x.two_norm(), x); y.axpy(func_.rightDifferential(x.two_norm()) / x.two_norm(), x);
return y; return y;
} }
SmallVector MinusGrad(const SmallVector x) const { SmallVector lowerGradient(const SmallVector x) const {
SmallVector y = SmoothGrad(x); SmallVector y = smoothGradient(x);
y.axpy(func_.leftDifferential(x.two_norm()) / x.two_norm(), x); y.axpy(func_.leftDifferential(x.two_norm()) / x.two_norm(), x);
return y; return y;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment