GCC Code Coverage Report


Directory: ./
File: tasks/mityaeva_d_striped_horizontal_matrix_vector/seq/src/ops_seq.cpp
Date: 2026-01-10 02:40:41
Exec Total Coverage
Lines: 31 33 93.9%
Functions: 5 5 100.0%
Branches: 22 40 55.0%

Line Branch Exec Source
1 #include "mityaeva_d_striped_horizontal_matrix_vector/seq/include/ops_seq.hpp"
2
3 #include <cstddef>
4 #include <vector>
5
6 #include "mityaeva_d_striped_horizontal_matrix_vector/common/include/common.hpp"
7
8 namespace mityaeva_d_striped_horizontal_matrix_vector {
9
10
1/2
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
64 StripedHorizontalMatrixVectorSEQ::StripedHorizontalMatrixVectorSEQ(const InType &in) {
11 SetTypeOfTask(GetStaticTypeOfTask());
12
1/2
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
64 GetInput() = in;
13
1/2
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
64 GetOutput() = std::vector<double>{0.0};
14 64 }
15
16
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 bool StripedHorizontalMatrixVectorSEQ::ValidationImpl() {
17 const auto &input = GetInput();
18
19
2/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 if (input.empty() || input.size() < 3) {
20 return false;
21 }
22
23 64 rows_ = static_cast<int>(input[0]);
24 64 cols_ = static_cast<int>(input[1]);
25
26
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 if (rows_ <= 0 || cols_ <= 0) {
27 return false;
28 }
29
30
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if (static_cast<int>(input[2]) != cols_) {
31 return false;
32 }
33
34 64 size_t expected_size = 3 + (static_cast<size_t>(rows_) * static_cast<size_t>(cols_)) + static_cast<size_t>(cols_);
35
36 64 return input.size() == expected_size;
37 }
38
39 64 bool StripedHorizontalMatrixVectorSEQ::PreProcessingImpl() {
40 64 return true;
41 }
42
43 64 bool StripedHorizontalMatrixVectorSEQ::RunImpl() {
44 const auto &input = GetInput();
45
46 try {
47 size_t matrix_start_idx = 3;
48 64 size_t vector_start_idx = matrix_start_idx + (static_cast<size_t>(rows_) * static_cast<size_t>(cols_));
49
50
1/2
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
64 std::vector<double> result(rows_, 0.0);
51
52
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 64 times.
216 for (int i = 0; i < rows_; ++i) {
53 double sum = 0.0;
54 152 size_t row_start = matrix_start_idx + (static_cast<size_t>(i) * static_cast<size_t>(cols_));
55
56
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 152 times.
560 for (int j = 0; j < cols_; ++j) {
57 408 double matrix_element = input[row_start + j];
58 408 double vector_element = input[vector_start_idx + j];
59 408 sum += matrix_element * vector_element;
60 }
61
62 152 result[i] = sum;
63 }
64
65 auto &output = GetOutput();
66 output.clear();
67
1/2
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
64 output.reserve(rows_ + 1);
68
69
1/4
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
64 output.push_back(static_cast<double>(result.size()));
70
71
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 64 times.
216 for (const auto &val : result) {
72 output.push_back(val);
73 }
74
75 return true;
76
77 } catch (...) {
78 return false;
79 }
80 }
81
82
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 bool StripedHorizontalMatrixVectorSEQ::PostProcessingImpl() {
83 const auto &output = GetOutput();
84
85
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if (output.empty()) {
86 return false;
87 }
88
89 64 int result_size = static_cast<int>(output[0]);
90
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 return result_size == rows_ && output.size() == static_cast<size_t>(result_size) + 1;
91 }
92
93 } // namespace mityaeva_d_striped_horizontal_matrix_vector
94