GCC Code Coverage Report


Directory: ./
File: tasks/Nazarova_K_rad_sort_batcher_metod/seq/src/ops_seq.cpp
Date: 2026-06-04 20:25:32
Exec Total Coverage
Lines: 37 37 100.0%
Functions: 6 6 100.0%
Branches: 27 42 64.3%

Line Branch Exec Source
1 #include "Nazarova_K_rad_sort_batcher_metod/seq/include/ops_seq.hpp"
2
3 #include <cmath>
4 #include <cstddef>
5 #include <vector>
6
7 #include "Nazarova_K_rad_sort_batcher_metod/common/include/common.hpp"
8
9 namespace nazarova_k_calc_integ_rectangles {
10
11
1/2
✓ Branch 1 taken 56 times.
✗ Branch 2 not taken.
56 NazarovaKCalcIntegRectanglesSEQ::NazarovaKCalcIntegRectanglesSEQ(const InType &in) {
12 SetTypeOfTask(GetStaticTypeOfTask());
13
1/2
✓ Branch 1 taken 56 times.
✗ Branch 2 not taken.
56 GetInput() = in;
14 56 GetOutput() = {};
15 56 }
16
17
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 bool NazarovaKCalcIntegRectanglesSEQ::HasValidInput() {
18 const auto &input = GetInput();
19 const std::size_t dimension = input.lower_bounds.size();
20
4/8
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 56 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 56 times.
56 if (!input.function || dimension == 0U || input.upper_bounds.size() != dimension || input.steps.size() != dimension) {
21 return false;
22 }
23
24
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 56 times.
168 for (std::size_t i = 0; i < dimension; ++i) {
25
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 112 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 112 times.
112 if (input.steps[i] == 0U || !std::isfinite(input.lower_bounds[i]) || !std::isfinite(input.upper_bounds[i]) ||
26 input.lower_bounds[i] > input.upper_bounds[i]) {
27 return false;
28 }
29 }
30
31 return true;
32 }
33
34 56 bool NazarovaKCalcIntegRectanglesSEQ::ValidationImpl() {
35 56 return HasValidInput();
36 }
37
38 56 bool NazarovaKCalcIntegRectanglesSEQ::PreProcessingImpl() {
39 const auto &input = GetInput();
40 56 dimension_ = input.lower_bounds.size();
41 56 step_sizes_.assign(dimension_, 0.0);
42 56 cell_volume_ = 1.0;
43 56 result_ = 0.0;
44
45
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 56 times.
168 for (std::size_t i = 0; i < dimension_; ++i) {
46 112 step_sizes_[i] = (input.upper_bounds[i] - input.lower_bounds[i]) / static_cast<double>(input.steps[i]);
47 112 cell_volume_ *= step_sizes_[i];
48 }
49
50 56 GetOutput() = 0.0;
51 56 return true;
52 }
53
54 56 bool NazarovaKCalcIntegRectanglesSEQ::RunImpl() {
55 const auto &input = GetInput();
56 56 std::vector<double> point(dimension_, 0.0);
57
1/4
✓ Branch 1 taken 56 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
56 std::vector<std::size_t> indices(dimension_, 0U);
58 double sum = 0.0;
59
60 while (true) {
61
2/2
✓ Branch 0 taken 2002912 times.
✓ Branch 1 taken 995296 times.
2998208 for (std::size_t i = 0; i < dimension_; ++i) {
62 2002912 point[i] = input.lower_bounds[i] + ((static_cast<double>(indices[i]) + 0.5) * step_sizes_[i]);
63 }
64 995296 sum += input.function(point);
65
66 std::size_t axis = 0U;
67
2/2
✓ Branch 0 taken 1000168 times.
✓ Branch 1 taken 56 times.
1000224 while (axis < dimension_) {
68
2/2
✓ Branch 0 taken 4928 times.
✓ Branch 1 taken 995240 times.
1000168 ++indices[axis];
69
2/2
✓ Branch 0 taken 4928 times.
✓ Branch 1 taken 995240 times.
1000168 if (indices[axis] < input.steps[axis]) {
70 break;
71 }
72 4928 indices[axis] = 0U;
73 4928 ++axis;
74 }
75
2/2
✓ Branch 0 taken 995240 times.
✓ Branch 1 taken 56 times.
995296 if (axis == dimension_) {
76 break;
77 }
78 }
79
80 56 result_ = sum * cell_volume_;
81
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 GetOutput() = result_;
82 56 return true;
83 }
84
85 56 bool NazarovaKCalcIntegRectanglesSEQ::PostProcessingImpl() {
86 56 return true;
87 }
88
89 } // namespace nazarova_k_calc_integ_rectangles
90