27 static bool invert3by3(
double A[3][3]) {
28 const double kSmall = 1e-80;
30 double determinant = A[0][0] * (A[1][1] * A[2][2] - A[1][2] * A[2][1]) -
31 A[0][1] * (A[1][0] * A[2][2] - A[1][2] * A[2][0]) +
32 A[0][2] * (A[1][0] * A[2][1] - A[1][1] * A[2][0]);
34 double absDet = fabs(determinant);
36 if (absDet < kSmall) {
37 CORSIKA_LOG_WARN(
"invert3by3: Error-matrix singular (absDet={})", absDet);
43 B[0][0] = A[1][1] * A[2][2] - A[1][2] * A[2][1];
44 B[1][0] = A[1][2] * A[2][0] - A[2][2] * A[1][0];
45 B[2][0] = A[1][0] * A[2][1] - A[1][1] * A[2][0];
47 B[0][1] = A[0][2] * A[2][1] - A[2][2] * A[0][1];
48 B[1][1] = A[0][0] * A[2][2] - A[2][0] * A[0][2];
49 B[2][1] = A[0][1] * A[2][0] - A[0][0] * A[2][1];
51 B[0][2] = A[0][1] * A[1][2] - A[1][1] * A[0][2];
52 B[1][2] = A[0][2] * A[1][0] - A[1][2] * A[0][0];
53 B[2][2] = A[0][0] * A[1][1] - A[0][1] * A[1][0];
55 for (
int i = 0; i < 3; i++)
56 for (
int j = 0; j < 3; j++) A[i][j] = B[i][j] / determinant;
77 static bool solve3by3(
double y[3],
double A[3][3],
double x[3]) {
80 for (
int i = 0; i < 3; i++)
81 x[i] = A[i][0] * y[0] + A[i][1] * y[1] + A[i][2] * y[2];
90 static std::tuple<double, double> interpolateProfile(
double x1,
double x2,
double x3,
95 double x[3] = {x1, x2, x3};
96 double y[3] = {y1, y2, y3};
99 A[0][0] = x[0] * x[0];
102 A[1][0] = x[1] * x[1];
105 A[2][0] = x[2] * x[2];
114 double const Xmax = -a[1] / (2. * a[0]);
115 return std::make_tuple(Xmax, a[0] * Xmax * Xmax + a[1] * Xmax + a[2]);
117 return std::make_tuple(0, 0);
CORSIKA8 logging utilities.
`, since they are used everywhere as integral part of the framework.
Interpolates profiles around maximum.