Skip to content

Commit

Permalink
Prefere const
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwoerer committed Nov 26, 2024
1 parent f6f78f6 commit 5a60a52
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/mesh/invert3x3.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ inline std::optional<BoutReal> invert3x3(Matrix<BoutReal>& a) {
TRACE("invert3x3");

// Calculate the first co-factors
BoutReal A = a(1, 1) * a(2, 2) - a(1, 2) * a(2, 1);
BoutReal B = a(1, 2) * a(2, 0) - a(1, 0) * a(2, 2);
BoutReal C = a(1, 0) * a(2, 1) - a(1, 1) * a(2, 0);
const BoutReal A = a(1, 1) * a(2, 2) - a(1, 2) * a(2, 1);
const BoutReal B = a(1, 2) * a(2, 0) - a(1, 0) * a(2, 2);
const BoutReal C = a(1, 0) * a(2, 1) - a(1, 1) * a(2, 0);

// Calculate the determinant
const BoutReal det = a(0, 0) * A + a(0, 1) * B + a(0, 2) * C;
Expand All @@ -52,15 +52,15 @@ inline std::optional<BoutReal> invert3x3(Matrix<BoutReal>& a) {
}

// Calculate the rest of the co-factors
BoutReal D = a(0, 2) * a(2, 1) - a(0, 1) * a(2, 2);
BoutReal E = a(0, 0) * a(2, 2) - a(0, 2) * a(2, 0);
BoutReal F = a(0, 1) * a(2, 0) - a(0, 0) * a(2, 1);
BoutReal G = a(0, 1) * a(1, 2) - a(0, 2) * a(1, 1);
BoutReal H = a(0, 2) * a(1, 0) - a(0, 0) * a(1, 2);
BoutReal I = a(0, 0) * a(1, 1) - a(0, 1) * a(1, 0);
const BoutReal D = a(0, 2) * a(2, 1) - a(0, 1) * a(2, 2);
const BoutReal E = a(0, 0) * a(2, 2) - a(0, 2) * a(2, 0);
const BoutReal F = a(0, 1) * a(2, 0) - a(0, 0) * a(2, 1);
const BoutReal G = a(0, 1) * a(1, 2) - a(0, 2) * a(1, 1);
const BoutReal H = a(0, 2) * a(1, 0) - a(0, 0) * a(1, 2);
const BoutReal I = a(0, 0) * a(1, 1) - a(0, 1) * a(1, 0);

// Now construct the output, overwrites input
BoutReal detinv = 1.0 / det;
const BoutReal detinv = 1.0 / det;

a(0, 0) = A * detinv;
a(0, 1) = D * detinv;
Expand Down

0 comments on commit 5a60a52

Please sign in to comment.