GCC Code Coverage Report


Directory: ./
File: tasks/bortsova_a_integrals_rectangle/seq/src/ops_seq.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 37 37 100.0%
Functions: 5 5 100.0%
Branches: 23 34 67.6%

Line Branch Exec Source
1 #include "bortsova_a_integrals_rectangle/seq/include/ops_seq.hpp"
2
3 #include <cstdint>
4 #include <vector>
5
6 #include "bortsova_a_integrals_rectangle/common/include/common.hpp"
7
8 namespace bortsova_a_integrals_rectangle {
9
10
1/2
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
80 BortsovaAIntegralsRectangleSEQ::BortsovaAIntegralsRectangleSEQ(const InType &in) {
11 SetTypeOfTask(GetStaticTypeOfTask());
12
1/2
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
80 GetInput() = in;
13 80 GetOutput() = 0.0;
14 80 }
15
16
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 bool BortsovaAIntegralsRectangleSEQ::ValidationImpl() {
17 const auto &input = GetInput();
18
3/6
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 80 times.
80 return input.func && !input.lower_bounds.empty() && input.lower_bounds.size() == input.upper_bounds.size() &&
19
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 input.num_steps > 0;
20 }
21
22 80 bool BortsovaAIntegralsRectangleSEQ::PreProcessingImpl() {
23 const auto &input = GetInput();
24 80 func_ = input.func;
25 80 num_steps_ = input.num_steps;
26 80 dims_ = static_cast<int>(input.lower_bounds.size());
27
28 80 midpoints_.resize(dims_);
29 80 volume_ = 1.0;
30 80 total_points_ = 1;
31
32
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 80 times.
216 for (int di = 0; di < dims_; di++) {
33 136 double step = (input.upper_bounds[di] - input.lower_bounds[di]) / static_cast<double>(num_steps_);
34 136 volume_ *= step;
35 136 total_points_ *= num_steps_;
36
37 136 midpoints_[di].resize(num_steps_);
38
2/2
✓ Branch 0 taken 23368 times.
✓ Branch 1 taken 136 times.
23504 for (int si = 0; si < num_steps_; si++) {
39 23368 midpoints_[di][si] = input.lower_bounds[di] + ((si + 0.5) * step);
40 }
41 }
42
43 80 return true;
44 }
45
46 80 bool BortsovaAIntegralsRectangleSEQ::RunImpl() {
47 double sum = 0.0;
48 80 std::vector<int> indices(dims_, 0);
49
1/4
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
80 std::vector<double> point(dims_);
50
51
2/2
✓ Branch 0 taken 385608 times.
✓ Branch 1 taken 80 times.
385688 for (int64_t pt = 0; pt < total_points_; pt++) {
52
2/2
✓ Branch 0 taken 881608 times.
✓ Branch 1 taken 385608 times.
1267216 for (int di = 0; di < dims_; di++) {
53 881608 point[di] = midpoints_[di][indices[di]];
54 }
55 385608 sum += func_(point);
56
57
2/2
✓ Branch 0 taken 394728 times.
✓ Branch 1 taken 80 times.
394808 for (int di = dims_ - 1; di >= 0; di--) {
58
2/2
✓ Branch 0 taken 9200 times.
✓ Branch 1 taken 385528 times.
394728 indices[di]++;
59
2/2
✓ Branch 0 taken 9200 times.
✓ Branch 1 taken 385528 times.
394728 if (indices[di] < num_steps_) {
60 break;
61 }
62 9200 indices[di] = 0;
63 }
64 }
65
66
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 GetOutput() = sum * volume_;
67 80 return true;
68 }
69
70 80 bool BortsovaAIntegralsRectangleSEQ::PostProcessingImpl() {
71 80 return true;
72 }
73
74 } // namespace bortsova_a_integrals_rectangle
75