GCC Code Coverage Report


Directory: ./
File: tasks/romanov_m_matrix_ccs/seq/src/ops_seq.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 34 35 97.1%
Functions: 5 5 100.0%
Branches: 25 42 59.5%

Line Branch Exec Source
1 #include "romanov_m_matrix_ccs/seq/include/ops_seq.hpp"
2
3 #include <algorithm>
4 #include <cmath>
5 #include <cstddef>
6 #include <vector>
7
8 #include "romanov_m_matrix_ccs/common/include/common.hpp"
9
10 namespace romanov_m_matrix_ccs {
11
12
1/2
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 RomanovMMatrixCCSSeq::RomanovMMatrixCCSSeq(const InType &in) {
13 SetTypeOfTask(GetStaticTypeOfTask());
14 GetInput() = in;
15 24 }
16
17 24 bool RomanovMMatrixCCSSeq::ValidationImpl() {
18 const auto &left = GetInput().first;
19 const auto &right = GetInput().second;
20
21
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (left.cols_num != right.rows_num) {
22 return false;
23 }
24
3/6
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
24 if (left.rows_num == 0 || left.cols_num == 0 || right.cols_num == 0) {
25 return false;
26 }
27
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if (left.col_ptrs.size() != left.cols_num + 1 || right.col_ptrs.size() != right.cols_num + 1) {
28 return false;
29 }
30
31 return true;
32 }
33
34
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 bool RomanovMMatrixCCSSeq::PreProcessingImpl() {
35 GetOutput().vals.clear();
36 GetOutput().row_inds.clear();
37 24 return true;
38 }
39
40 24 bool RomanovMMatrixCCSSeq::RunImpl() {
41 const auto &a = GetInput().first;
42 const auto &b = GetInput().second;
43 auto &c = GetOutput();
44
45 24 c.rows_num = a.rows_num;
46 24 c.cols_num = b.cols_num;
47 24 c.col_ptrs.assign(c.cols_num + 1, 0);
48
49 24 std::vector<double> accumulator(a.rows_num, 0.0);
50 24 std::vector<size_t> active_rows;
51
1/4
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
24 std::vector<bool> row_mask(a.rows_num, false);
52
53
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 24 times.
64 for (size_t j = 0; j < b.cols_num; ++j) {
54 40 c.col_ptrs[j] = c.vals.size();
55
56
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 40 times.
80 for (size_t kb = b.col_ptrs[j]; kb < b.col_ptrs[j + 1]; ++kb) {
57 40 size_t k = b.row_inds[kb];
58 40 double v_b = b.vals[kb];
59
60
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 40 times.
80 for (size_t ka = a.col_ptrs[k]; ka < a.col_ptrs[k + 1]; ++ka) {
61
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 size_t i = a.row_inds[ka];
62
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 16 times.
40 if (!row_mask[i]) {
63 row_mask[i] = true;
64 active_rows.push_back(i);
65 }
66 40 accumulator[i] += a.vals[ka] * v_b;
67 }
68 }
69
70 std::ranges::sort(active_rows);
71
72
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 40 times.
64 for (size_t row_idx : active_rows) {
73
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (std::abs(accumulator[row_idx]) > 1e-12) {
74
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 c.vals.push_back(accumulator[row_idx]);
75
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 c.row_inds.push_back(row_idx);
76 }
77
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 accumulator[row_idx] = 0.0;
78 row_mask[row_idx] = false;
79 }
80 active_rows.clear();
81 }
82
83 24 c.nnz = c.vals.size();
84 24 c.col_ptrs[c.cols_num] = c.nnz;
85 24 return true;
86 }
87
88 24 bool RomanovMMatrixCCSSeq::PostProcessingImpl() {
89 24 return true;
90 }
91
92 } // namespace romanov_m_matrix_ccs
93