fix formatting for examples

This is mostly just applying the existing clang format config, except:
- Use NOLINT on overlong comment lines.
- Wrap some sections in 'clang-format off' / 'clang format on'.
- Manually split or join some multi-line strings.

Change-Id: Ia1a40eeb92112e12c3a169309afe087af55b2f4f
This commit is contained in:
Nikolaus Demmel
2020-09-08 17:51:32 +02:00
parent 82275d8a4e
commit 7b6b2491cc
35 changed files with 743 additions and 717 deletions
+7 -9
View File
@@ -43,6 +43,7 @@
// data = [x', y_observed'];
const int kNumObservations = 67;
// clang-format off
const double data[] = {
0.000000e+00, 1.133898e+00,
7.500000e-02, 1.334902e+00,
@@ -112,21 +113,20 @@ const double data[] = {
4.875000e+00, 4.727863e+00,
4.950000e+00, 4.669206e+00
};
// clang-format on
using ceres::AutoDiffCostFunction;
using ceres::CostFunction;
using ceres::CauchyLoss;
using ceres::CostFunction;
using ceres::Problem;
using ceres::Solve;
using ceres::Solver;
struct ExponentialResidual {
ExponentialResidual(double x, double y)
: x_(x), y_(y) {}
ExponentialResidual(double x, double y) : x_(x), y_(y) {}
template <typename T> bool operator()(const T* const m,
const T* const c,
T* residual) const {
template <typename T>
bool operator()(const T* const m, const T* const c, T* residual) const {
residual[0] = y_ - exp(m[0] * x_ + c[0]);
return true;
}
@@ -147,9 +147,7 @@ int main(int argc, char** argv) {
CostFunction* cost_function =
new AutoDiffCostFunction<ExponentialResidual, 1, 1, 1>(
new ExponentialResidual(data[2 * i], data[2 * i + 1]));
problem.AddResidualBlock(cost_function,
new CauchyLoss(0.5),
&m, &c);
problem.AddResidualBlock(cost_function, new CauchyLoss(0.5), &m, &c);
}
Solver::Options options;