GCC Code Coverage Report


Directory: ./
File: tasks/karpich_i_seidol_method/seq/src/ops_seq.cpp
Date: 2026-01-27 01:59:34
Exec Total Coverage
Lines: 27 28 96.4%
Functions: 5 6 83.3%
Branches: 11 18 61.1%

Line Branch Exec Source
1 #include "karpich_i_seidol_method/seq/include/ops_seq.hpp"
2
3 #include <algorithm>
4 #include <cmath>
5 #include <cstddef>
6 #include <tuple>
7 #include <vector>
8
9 #include "karpich_i_seidol_method/common/include/common.hpp"
10
11 namespace karpich_i_seidol_method {
12
13
1/2
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
16 KarpichISeidolMethodSEQ::KarpichISeidolMethodSEQ(const InType &in) {
14 SetTypeOfTask(GetStaticTypeOfTask());
15 GetInput() = in;
16 16 }
17
18 16 bool KarpichISeidolMethodSEQ::ValidationImpl() {
19 16 return true;
20 }
21
22 16 bool KarpichISeidolMethodSEQ::PreProcessingImpl() {
23 16 return true;
24 }
25
26 16 bool KarpichISeidolMethodSEQ::RunImpl() {
27 16 std::size_t n = std::get<0>(GetInput());
28 std::vector<double> &a = std::get<1>(GetInput());
29 std::vector<double> &b = std::get<2>(GetInput());
30 16 double eps = std::get<3>(GetInput());
31
32 16 std::vector<double> x(n, 0);
33
1/4
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
16 std::vector<double> epsilons(n, -1);
34 bool iter_continue = true;
35
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 16 times.
136 while (iter_continue) {
36
2/2
✓ Branch 0 taken 1120 times.
✓ Branch 1 taken 120 times.
1240 for (std::size_t i = 0; i < n; i++) {
37 1120 double ix = b[i];
38
2/2
✓ Branch 0 taken 6160 times.
✓ Branch 1 taken 1120 times.
7280 for (std::size_t j = 0; j < i; j++) {
39 6160 ix = ix - (a[(i * n) + j] * x[j]);
40 }
41
2/2
✓ Branch 0 taken 6160 times.
✓ Branch 1 taken 1120 times.
7280 for (std::size_t j = i + 1; j < n; j++) {
42 6160 ix = ix - (a[(i * n) + j] * x[j]);
43 }
44 1120 ix = ix / a[(i * n) + i];
45 1120 epsilons[i] = std::fabs(ix - x[i]);
46 1120 x[i] = ix;
47 }
48 iter_continue = IterContinue(epsilons, eps);
49 }
50
1/2
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
16 GetOutput() = x;
51 16 return true;
52 }
53
54 16 bool KarpichISeidolMethodSEQ::PostProcessingImpl() {
55 16 return true;
56 }
57
58 bool KarpichISeidolMethodSEQ::IterContinue(std::vector<double> &iter_eps, double correct_eps) {
59 120 double max_in_iter = *std::ranges::max_element(iter_eps);
60 120 return max_in_iter > correct_eps;
61 }
62
63 } // namespace karpich_i_seidol_method
64