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

Clean up qualifiers

parent 8068ec21
Branches
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ template <int dim> class SampleFunctional { ...@@ -26,7 +26,7 @@ template <int dim> class SampleFunctional {
MyNonlinearity<dim> const &phi) MyNonlinearity<dim> const &phi)
: A(A), b(b), phi(phi) {} : A(A), b(b), phi(phi) {}
double operator()(const SmallVector v) const { double operator()(SmallVector const v) const {
SmallVector y; SmallVector y;
A.mv(v, y); // y = Av A.mv(v, y); // y = Av
y /= 2; // y = 1/2 Av y /= 2; // y = 1/2 Av
...@@ -34,7 +34,7 @@ template <int dim> class SampleFunctional { ...@@ -34,7 +34,7 @@ template <int dim> class SampleFunctional {
return y * v + phi(v); // <1/2 Av - b,v> + H(|v|) return y * v + phi(v); // <1/2 Av - b,v> + H(|v|)
} }
void descentDirection(const SmallVector x, SmallVector &ret) const { void descentDirection(SmallVector const x, SmallVector &ret) const {
// Check the squared norm rather than each component because // Check the squared norm rather than each component because
// negative_projection() divides by it // negative_projection() divides by it
if (x.two_norm2() == 0.0) { if (x.two_norm2() == 0.0) {
...@@ -87,21 +87,21 @@ template <int dim> class SampleFunctional { ...@@ -87,21 +87,21 @@ template <int dim> class SampleFunctional {
private: private:
// Gradient of the smooth part // Gradient of the smooth part
SmallVector smoothGradient(const SmallVector x) const { SmallVector smoothGradient(SmallVector const 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 upperGradient(const SmallVector x) const { SmallVector upperGradient(SmallVector const x) const {
SmallVector y; SmallVector y;
phi.upperGradient(x, y); phi.upperGradient(x, y);
y += smoothGradient(x); y += smoothGradient(x);
return y; return y;
} }
SmallVector lowerGradient(const SmallVector x) const { SmallVector lowerGradient(SmallVector const x) const {
SmallVector y; SmallVector y;
phi.lowerGradient(x, y); phi.lowerGradient(x, y);
y += smoothGradient(x); y += smoothGradient(x);
...@@ -109,8 +109,8 @@ template <int dim> class SampleFunctional { ...@@ -109,8 +109,8 @@ template <int dim> class SampleFunctional {
} }
// No normalising is done! // No normalising is done!
SmallVector negative_projection(const SmallVector z, SmallVector negative_projection(SmallVector const z,
const SmallVector x) const { SmallVector const x) const {
SmallVector y = z; SmallVector y = z;
y.axpy(-(z * x) / x.two_norm2(), x); y.axpy(-(z * x) / x.two_norm2(), x);
return y; return y;
...@@ -118,7 +118,7 @@ template <int dim> class SampleFunctional { ...@@ -118,7 +118,7 @@ template <int dim> class SampleFunctional {
}; };
template <class Functional> template <class Functional>
void minimise(const Functional J, typename Functional::SmallVector &x, void minimise(Functional const J, typename Functional::SmallVector &x,
size_t steps = 1, size_t steps = 1,
Bisection const &bisection = Bisection const &bisection =
Bisection(0.0, // acceptError: Stop if the search interval has Bisection(0.0, // acceptError: Stop if the search interval has
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment