./
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
11 / 11
100.0%
Branches:
2 / 2
100.0%
Functions:
2 / 2
100.0%

src/analysis/variogram.cpp
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2
3 #include "terraingen/analysis/variogram.h"
4
5 #include <cmath>
6
7 namespace terraingen {
8
9 53 DeviogramFit FitDeviogram(const Raster<float>& heights) {
10 53 constexpr std::size_t kMaxLag = 8;
11 53 return FitLagLine(kMaxLag, [&](std::size_t lag) {
12 192 double sum = 0.0;
13 192 std::size_t count = 0;
14 192 ForEachLagPair(heights, lag, [&](double a, double b) {
15 5197454 sum += (b - a) * (b - a);
16 5197454 ++count;
17 5197454 });
18
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 3 times.
192 return count > 0 ? std::sqrt(sum / static_cast<double>(count)) : 0.0;
19 53 });
20 }
21
22 } // namespace terraingen
23