GCC Code Coverage Report


Directory: ./
File: tasks/goriacheva_k_mult_sparse_complex_matrix_ccs/seq/src/ops_seq.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 35 36 97.2%
Functions: 5 5 100.0%
Branches: 24 36 66.7%

Line Branch Exec Source
1 #include "goriacheva_k_mult_sparse_complex_matrix_ccs/seq/include/ops_seq.hpp"
2
3 #include <algorithm>
4 #include <ranges>
5 #include <utility>
6 #include <vector>
7
8 #include "goriacheva_k_mult_sparse_complex_matrix_ccs/common/include/common.hpp"
9
10 namespace goriacheva_k_mult_sparse_complex_matrix_ccs {
11
12
1/2
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
112 GoriachevaKMultSparseComplexMatrixCcsSEQ::GoriachevaKMultSparseComplexMatrixCcsSEQ(const InType &in) {
13 SetTypeOfTask(GetStaticTypeOfTask());
14 GetInput() = in;
15 112 }
16
17 112 bool GoriachevaKMultSparseComplexMatrixCcsSEQ::ValidationImpl() {
18 auto &[a, b] = GetInput();
19
20
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if (a.cols != b.rows) {
21 return false;
22 }
23
24
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
112 if (a.col_ptr.empty() || b.col_ptr.empty()) {
25 return false;
26 }
27
28 return true;
29 }
30
31 112 bool GoriachevaKMultSparseComplexMatrixCcsSEQ::PreProcessingImpl() {
32 112 GetOutput() = {};
33 112 return true;
34 }
35
36 112 bool GoriachevaKMultSparseComplexMatrixCcsSEQ::RunImpl() {
37 auto &[a, b] = GetInput();
38 auto &c = GetOutput();
39
40 112 c.rows = a.rows;
41 112 c.cols = b.cols;
42 112 c.col_ptr.resize(c.cols + 1);
43
44 112 std::vector<Complex> values;
45 112 std::vector<int> rows;
46
47
1/4
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
112 std::vector<Complex> accumulator(a.rows);
48
1/4
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
112 std::vector<int> marker(a.rows, -1);
49 112 std::vector<int> used_rows;
50
51
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 112 times.
440 for (int j = 0; j < b.cols; j++) {
52
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 176 times.
328 c.col_ptr[j] = static_cast<int>(values.size());
53 used_rows.clear();
54
55
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 328 times.
552 for (int bi = b.col_ptr[j]; bi < b.col_ptr[j + 1]; bi++) {
56 224 int k = b.row_ind[bi];
57 224 Complex b_val = b.values[bi];
58
59
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 224 times.
440 for (int ai = a.col_ptr[k]; ai < a.col_ptr[k + 1]; ai++) {
60
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 int i = a.row_ind[ai];
61
62
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if (marker[i] != j) {
63
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 120 times.
216 marker[i] = j;
64
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 120 times.
216 accumulator[i] = Complex(0.0, 0.0);
65 used_rows.push_back(i);
66 }
67
68 accumulator[i] += a.values[ai] * b_val;
69 }
70 }
71
72 std::ranges::sort(used_rows);
73
74
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 328 times.
544 for (int r : used_rows) {
75
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 192 times.
216 if (accumulator[r] != Complex(0.0, 0.0)) {
76 rows.push_back(r);
77 values.push_back(accumulator[r]);
78 }
79 }
80 }
81
82 112 c.col_ptr[c.cols] = static_cast<int>(values.size());
83 112 c.values = std::move(values);
84 112 c.row_ind = std::move(rows);
85
86 112 return true;
87 }
88
89 112 bool GoriachevaKMultSparseComplexMatrixCcsSEQ::PostProcessingImpl() {
90 112 return true;
91 }
92
93 } // namespace goriacheva_k_mult_sparse_complex_matrix_ccs
94