GCC Code Coverage Report


Directory: ./
File: tasks/matrix_band_multiplication/seq/src/ops_seq.cpp
Date: 2026-01-10 02:40:41
Exec Total Coverage
Lines: 35 35 100.0%
Functions: 5 5 100.0%
Branches: 19 28 67.9%

Line Branch Exec Source
1 #include "matrix_band_multiplication/seq/include/ops_seq.hpp"
2
3 #include <cstddef>
4
5 #include "matrix_band_multiplication/common/include/common.hpp"
6
7 namespace matrix_band_multiplication {
8
9 namespace {
10 bool MatrixIsValid(const Matrix &m) {
11
5/10
✓ 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.
✓ Branch 6 taken 24 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
24 return m.rows > 0 && m.cols > 0 && m.values.size() == m.rows * m.cols;
12 }
13
14 } // namespace
15
16
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 MatrixBandMultiplicationSeq::MatrixBandMultiplicationSeq(const InType &in) {
17 SetTypeOfTask(GetStaticTypeOfTask());
18
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 GetInput() = in;
19 24 GetOutput() = Matrix{};
20 24 }
21
22
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 bool MatrixBandMultiplicationSeq::ValidationImpl() {
23 const auto &matrix_a = GetInput().a;
24 const auto &matrix_b = GetInput().b;
25 if (!MatrixIsValid(matrix_a) || !MatrixIsValid(matrix_b)) {
26 return false;
27 }
28 24 return matrix_a.cols == matrix_b.rows;
29 }
30
31 24 bool MatrixBandMultiplicationSeq::PreProcessingImpl() {
32 const auto &matrix_a = GetInput().a;
33 const auto &matrix_b = GetInput().b;
34 24 result_.assign(matrix_a.rows * matrix_b.cols, 0.0);
35 24 transposed_b_.assign(matrix_b.cols * matrix_b.rows, 0.0);
36 24 const std::size_t cols_b = matrix_b.cols;
37 24 const std::size_t rows_b = matrix_b.rows;
38
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 24 times.
80 for (std::size_t i = 0; i < rows_b; ++i) {
39 56 const std::size_t row_offset = i * cols_b;
40
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 56 times.
184 for (std::size_t j = 0; j < cols_b; ++j) {
41 128 transposed_b_[(j * rows_b) + i] = matrix_b.values[row_offset + j];
42 }
43 }
44 24 return true;
45 }
46
47 24 bool MatrixBandMultiplicationSeq::RunImpl() {
48 const auto &matrix_a = GetInput().a;
49 const auto &matrix_b = GetInput().b;
50 24 const std::size_t rows_a = matrix_a.rows;
51 24 const std::size_t cols_a = matrix_a.cols;
52 24 const std::size_t cols_b = matrix_b.cols;
53 const double *a_data = matrix_a.values.data();
54 const double *b_data = transposed_b_.data();
55
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 24 times.
80 for (std::size_t i = 0; i < rows_a; ++i) {
56 56 const double *a_row = a_data + (i * cols_a);
57
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 56 times.
192 for (std::size_t j = 0; j < cols_b; ++j) {
58 136 const double *b_col = b_data + (j * cols_a);
59 double sum = 0.0;
60
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 136 times.
440 for (std::size_t k = 0; k < cols_a; ++k) {
61 304 sum += a_row[k] * b_col[k];
62 }
63 136 result_[(i * cols_b) + j] = sum;
64 }
65 }
66 24 return true;
67 }
68
69 24 bool MatrixBandMultiplicationSeq::PostProcessingImpl() {
70 24 OutType output;
71 24 output.rows = GetInput().a.rows;
72 24 output.cols = GetInput().b.cols;
73
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 output.values = result_;
74 GetOutput() = output;
75 24 return true;
76 }
77
78 } // namespace matrix_band_multiplication
79