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

Only compute some scalar products once

parent dc4dc353
No related branches found
No related tags found
No related merge requests found
......@@ -46,17 +46,19 @@ class SampleFunctional {
SmallVector const pg = upperGradient(x);
SmallVector const mg = lowerGradient(x);
double const pgx = pg * x;
double const mgx = mg * x;
// TODO: collinearity checks suck
if (pg * x == pg.two_norm() * x.two_norm() &&
-(mg * x) == mg.two_norm() * x.two_norm()) {
if (pgx == pg.two_norm() * x.two_norm() &&
-mgx == mg.two_norm() * x.two_norm()) {
ret = SmallVector(0.0);
return;
} else if (pg * x >= 0 && mg * x >= 0) {
} else if (pgx >= 0 && mgx >= 0) {
ret = pg;
Dune::dverb << "## Directional derivative (as per scalar product w/ "
"semigradient): " << -(ret * mg)
<< " (coordinates of the restriction)" << std::endl;
} else if (pg * x <= 0 && mg * x <= 0) {
} else if (pgx <= 0 && mgx <= 0) {
ret = mg;
Dune::dverb << "## Directional derivative (as per scalar product w/ "
"semigradient): " << -(ret * pg)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment