| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "titaev_m_metod_pryamougolnikov/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <cstddef> | ||
| 4 | #include <vector> | ||
| 5 | |||
| 6 | #include "titaev_m_metod_pryamougolnikov/common/include/common.hpp" | ||
| 7 | |||
| 8 | namespace titaev_m_metod_pryamougolnikov { | ||
| 9 | |||
| 10 | namespace { | ||
| 11 | |||
| 12 | double Function(const std::vector<double> &coords) { | ||
| 13 | double sum = 0.0; | ||
| 14 |
2/4✓ Branch 0 taken 4800 times.
✓ Branch 1 taken 2400 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
7200 | for (double x : coords) { |
| 15 | 4800 | sum += x; | |
| 16 | } | ||
| 17 | return sum; | ||
| 18 | } | ||
| 19 | |||
| 20 | } // namespace | ||
| 21 | |||
| 22 |
1/2✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
|
24 | TitaevMMetodPryamougolnikovSEQ::TitaevMMetodPryamougolnikovSEQ(const InType &input) { |
| 23 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 24 | GetInput() = input; | ||
| 25 | 24 | GetOutput() = 0.0; | |
| 26 | 24 | } | |
| 27 | |||
| 28 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
|
24 | bool TitaevMMetodPryamougolnikovSEQ::ValidationImpl() { |
| 29 | const auto &input = GetInput(); | ||
| 30 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
|
24 | if (input.left_bounds.size() != input.right_bounds.size()) { |
| 31 | return false; | ||
| 32 | } | ||
| 33 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
|
24 | if (input.partitions <= 0) { |
| 34 | return false; | ||
| 35 | } | ||
| 36 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 24 times.
|
72 | for (std::size_t i = 0; i < input.left_bounds.size(); ++i) { // Исправлено на std::size_t |
| 37 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
|
48 | if (input.right_bounds[i] <= input.left_bounds[i]) { |
| 38 | return false; | ||
| 39 | } | ||
| 40 | } | ||
| 41 | return true; | ||
| 42 | } | ||
| 43 | |||
| 44 | 24 | bool TitaevMMetodPryamougolnikovSEQ::PreProcessingImpl() { | |
| 45 | 24 | GetOutput() = 0.0; | |
| 46 | 24 | return true; | |
| 47 | } | ||
| 48 | |||
| 49 | ✗ | double TitaevMMetodPryamougolnikovSEQ::IntegrandFunction(const std::vector<double> &coords) { | |
| 50 | ✗ | return Function(coords); | |
| 51 | } | ||
| 52 | |||
| 53 | 24 | bool TitaevMMetodPryamougolnikovSEQ::RunImpl() { | |
| 54 | const auto &input = GetInput(); | ||
| 55 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
|
24 | const int partitions = input.partitions; |
| 56 | 24 | const int dimensions = static_cast<int>(input.left_bounds.size()); | |
| 57 | |||
| 58 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
|
24 | if (dimensions == 0) { |
| 59 | ✗ | GetOutput() = 0.0; | |
| 60 | ✗ | return true; | |
| 61 | } | ||
| 62 | |||
| 63 | 24 | std::vector<double> step_sizes(dimensions); | |
| 64 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 24 times.
|
72 | for (int dimension = 0; dimension < dimensions; ++dimension) { |
| 65 | 48 | step_sizes[dimension] = (input.right_bounds[dimension] - input.left_bounds[dimension]) / partitions; | |
| 66 | } | ||
| 67 | |||
| 68 |
1/4✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
24 | std::vector<int> indices(dimensions, 0); |
| 69 | int total_points = 1; | ||
| 70 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 24 times.
|
72 | for (int dimension = 0; dimension < dimensions; ++dimension) { |
| 71 | 48 | total_points *= partitions; | |
| 72 | } | ||
| 73 | |||
| 74 | double total_sum = 0.0; | ||
| 75 |
2/2✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 24 times.
|
2424 | for (int point_idx = 0; point_idx < total_points; ++point_idx) { |
| 76 | int temp = point_idx; | ||
| 77 |
2/2✓ Branch 0 taken 4800 times.
✓ Branch 1 taken 2400 times.
|
7200 | for (int dimension = 0; dimension < dimensions; ++dimension) { |
| 78 | 4800 | indices[dimension] = temp % partitions; | |
| 79 | 4800 | temp /= partitions; | |
| 80 | } | ||
| 81 | |||
| 82 |
1/4✓ Branch 1 taken 2400 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
2400 | std::vector<double> point(dimensions); |
| 83 |
2/2✓ Branch 0 taken 4800 times.
✓ Branch 1 taken 2400 times.
|
7200 | for (int dimension = 0; dimension < dimensions; ++dimension) { |
| 84 | 4800 | point[dimension] = input.left_bounds[dimension] + ((indices[dimension] + 0.5) * step_sizes[dimension]); | |
| 85 | } | ||
| 86 | |||
| 87 |
1/2✓ Branch 0 taken 2400 times.
✗ Branch 1 not taken.
|
2400 | total_sum += Function(point); |
| 88 | } | ||
| 89 | |||
| 90 | double volume_element = 1.0; | ||
| 91 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 24 times.
|
72 | for (double h : step_sizes) { |
| 92 | 48 | volume_element *= h; | |
| 93 | } | ||
| 94 | |||
| 95 |
1/2✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 | GetOutput() = total_sum * volume_element; |
| 96 | return true; | ||
| 97 | } | ||
| 98 | |||
| 99 | 24 | bool TitaevMMetodPryamougolnikovSEQ::PostProcessingImpl() { | |
| 100 | 24 | return true; | |
| 101 | } | ||
| 102 | |||
| 103 | } // namespace titaev_m_metod_pryamougolnikov | ||
| 104 |