GCC Code Coverage Report


Directory: ./
File: tasks/akhmetov_daniil_integration_monte_carlo/seq/src/ops_seq.cpp
Date: 2026-01-27 01:59:34
Exec Total Coverage
Lines: 24 24 100.0%
Functions: 5 5 100.0%
Branches: 7 10 70.0%

Line Branch Exec Source
1 #include "akhmetov_daniil_integration_monte_carlo/seq/include/ops_seq.hpp"
2
3 #include <cmath>
4
5 #include "akhmetov_daniil_integration_monte_carlo/common/include/common.hpp"
6
7 namespace akhmetov_daniil_integration_monte_carlo {
8
9 80 AkhmetovDaniilIntegrationMonteCarloSEQ::AkhmetovDaniilIntegrationMonteCarloSEQ(const InType &in) {
10 SetTypeOfTask(GetStaticTypeOfTask());
11 GetInput() = in;
12 GetOutput() = 0;
13 80 }
14
15 80 bool AkhmetovDaniilIntegrationMonteCarloSEQ::ValidationImpl() {
16 const auto &[a, b, n, func_id] = GetInput();
17
18
3/6
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 80 times.
80 return (a < b) && (n > 0) && (func_id >= FuncType::kLinearFunc) && (func_id <= FuncType::kConstFunc);
19 }
20
21 80 bool AkhmetovDaniilIntegrationMonteCarloSEQ::PreProcessingImpl() {
22 const auto &[a, b, n, func_id] = GetInput();
23 80 a_ = a;
24 80 b_ = b;
25 80 point_count_ = n;
26 80 func_id_ = func_id;
27
28 80 return true;
29 }
30
31 80 bool AkhmetovDaniilIntegrationMonteCarloSEQ::RunImpl() {
32 const double magic_constant = 0.75487766624669276;
33 double current = 0.5;
34
35 double sum = 0.0;
36
2/2
✓ Branch 0 taken 11600000 times.
✓ Branch 1 taken 80 times.
11600080 for (int i = 0; i < point_count_; ++i) {
37 11600000 current += magic_constant;
38
2/2
✓ Branch 0 taken 8756600 times.
✓ Branch 1 taken 2843400 times.
11600000 if (current >= 1.0) {
39 8756600 current -= 1.0;
40 }
41
42 11600000 double x = a_ + ((b_ - a_) * current);
43
44 11600000 double fx = FunctionPair::Function(func_id_, x);
45 11600000 sum += fx;
46 }
47
48 80 double average = sum / static_cast<double>(point_count_);
49 80 double integral = (b_ - a_) * average;
50 80 GetOutput() = integral;
51
52 80 return true;
53 }
54
55 80 bool AkhmetovDaniilIntegrationMonteCarloSEQ::PostProcessingImpl() {
56 80 return true;
57 }
58
59 } // namespace akhmetov_daniil_integration_monte_carlo
60