GCC Code Coverage Report


Directory: ./
File: tasks/maslova_u_mult_matr_crs/seq/src/ops_seq.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 50 53 94.3%
Functions: 6 6 100.0%
Branches: 33 50 66.0%

Line Branch Exec Source
1 #include "maslova_u_mult_matr_crs/seq/include/ops_seq.hpp"
2
3 #include <algorithm>
4 #include <cmath>
5 #include <cstddef>
6 #include <vector>
7
8 #include "maslova_u_mult_matr_crs/common/include/common.hpp"
9
10 namespace maslova_u_mult_matr_crs {
11
12
1/2
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
40 MaslovaUMultMatrSEQ::MaslovaUMultMatrSEQ(const InType &in) {
13 SetTypeOfTask(GetStaticTypeOfTask());
14 GetInput() = in;
15 40 }
16
17 40 bool MaslovaUMultMatrSEQ::ValidationImpl() {
18 const auto &input = GetInput();
19 const auto &a = std::get<0>(input);
20 const auto &b = std::get<1>(input);
21
22
3/6
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 40 times.
✗ Branch 5 not taken.
40 if (a.cols != b.rows || a.rows <= 0 || b.cols <= 0) {
23 return false;
24 }
25
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if (a.row_ptr.size() != static_cast<size_t>(a.rows) + 1) {
26 return false;
27 }
28
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if (b.row_ptr.size() != static_cast<size_t>(b.rows) + 1) {
29 return false;
30 }
31 return true;
32 }
33
34 40 bool MaslovaUMultMatrSEQ::PreProcessingImpl() {
35 const auto &a = std::get<0>(GetInput());
36 const auto &b = std::get<1>(GetInput());
37 auto &c = GetOutput();
38
39 40 c.rows = a.rows;
40
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 c.cols = b.cols;
41
42
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if (temp_row_.size() != static_cast<size_t>(b.cols)) {
43 40 temp_row_.assign(static_cast<size_t>(b.cols), 0.0);
44 }
45
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if (marker_.size() != static_cast<size_t>(b.cols)) {
46 40 marker_.assign(static_cast<size_t>(b.cols), -1);
47 }
48 40 used_cols_.reserve(static_cast<size_t>(b.cols));
49
50 40 return true;
51 }
52
53
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 40 times.
64 void MaslovaUMultMatrSEQ::ProcessRow(int i, const CRSMatrix &a, const CRSMatrix &b, CRSMatrix &c) {
54 used_cols_.clear();
55
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 64 times.
160 for (int j = a.row_ptr[i]; j < a.row_ptr[i + 1]; ++j) {
56 96 const int col_a = a.col_ind[j];
57 96 const double val_a = a.values[j];
58
59
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 96 times.
240 for (int k = b.row_ptr[col_a]; k < b.row_ptr[col_a + 1]; ++k) {
60
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 56 times.
144 const int col_b = b.col_ind[k];
61 144 const double val_b = b.values[k];
62
63
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 56 times.
144 if (marker_[col_b] < i) {
64 88 marker_[col_b] = i;
65
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 used_cols_.push_back(col_b);
66 88 temp_row_[col_b] = val_a * val_b;
67 } else {
68 56 temp_row_[col_b] += val_a * val_b;
69 }
70 }
71 }
72
73
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 8 times.
64 if (!used_cols_.empty()) {
74 std::ranges::sort(used_cols_);
75
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 56 times.
144 for (int col_idx : used_cols_) {
76
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 const double val = temp_row_[col_idx];
77
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if (std::abs(val) > 1e-15) {
78
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 c.values.push_back(val);
79
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 c.col_ind.push_back(col_idx);
80 }
81 88 temp_row_[col_idx] = 0.0;
82 }
83 }
84 64 }
85
86
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 bool MaslovaUMultMatrSEQ::RunImpl() {
87 const auto &input = GetInput();
88 const auto &a = std::get<0>(input);
89 const auto &b = std::get<1>(input);
90 auto &c = GetOutput();
91
92 40 c.rows = a.rows;
93
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 c.cols = b.cols;
94 c.values.clear();
95 c.col_ind.clear();
96 40 c.row_ptr.assign(static_cast<size_t>(a.rows) + 1, 0);
97
98 40 c.values.reserve(a.values.size() + b.values.size());
99 40 c.col_ind.reserve(a.values.size() + b.values.size());
100
101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if (marker_.size() != static_cast<size_t>(b.cols)) {
102 marker_.assign(static_cast<size_t>(b.cols), -1);
103 temp_row_.assign(static_cast<size_t>(b.cols), 0.0);
104 } else {
105 std::ranges::fill(marker_, -1);
106 }
107 used_cols_.clear();
108
109
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 40 times.
104 for (int i = 0; i < a.rows; ++i) {
110 64 ProcessRow(i, a, b, c);
111 64 c.row_ptr[static_cast<size_t>(i) + 1] = static_cast<int>(c.values.size());
112 }
113
114 40 return true;
115 }
116
117 40 bool MaslovaUMultMatrSEQ::PostProcessingImpl() {
118 const auto &a = std::get<0>(GetInput());
119 const auto &b = std::get<1>(GetInput());
120 auto &c = GetOutput();
121 40 c.rows = a.rows;
122 40 c.cols = b.cols;
123 40 return true;
124 }
125
126 } // namespace maslova_u_mult_matr_crs
127