GCC Code Coverage Report


Directory: ./
File: tasks/posternak_a_crs_mul_complex_matrix/common/include/common.hpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 5 6 83.3%
Functions: 1 1 100.0%
Branches: 7 12 58.3%

Line Branch Exec Source
1 #pragma once
2
3 #include <complex>
4 #include <cstddef>
5 #include <string>
6 #include <tuple>
7 #include <utility>
8 #include <vector>
9
10 #include "task/include/task.hpp"
11
12 namespace posternak_a_crs_mul_complex_matrix {
13
14 struct CRSMatrix {
15 int rows = 0;
16 int cols = 0;
17 std::vector<std::complex<double>> values; // вектор ненулевых значений
18 std::vector<int> index_col; // индексация столбцов для каждого значения
19 std::vector<int> index_row; // количество ненулевых элементов в строках (размер N+1 для запирающего 0 в начале)
20
21 264 [[nodiscard]] bool IsValid() const {
22
2/4
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264 times.
✗ Branch 3 not taken.
264 if (rows < 0 || cols < 0) {
23 return false;
24 }
25
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if (index_row.size() != static_cast<size_t>(rows) + 1) {
26 return false;
27 }
28
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if (values.size() != index_col.size()) {
29 return false;
30 }
31
3/4
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 204 times.
264 if (!values.empty() && std::cmp_not_equal(index_row.back(), static_cast<int>(values.size()))) {
32 return false;
33 }
34 return true;
35 }
36 };
37
38 using InType = std::pair<CRSMatrix, CRSMatrix>;
39 using OutType = CRSMatrix;
40 using TestType = std::tuple<int, std::string>;
41 using BaseTask = ppc::task::Task<InType, OutType>;
42
43 CRSMatrix MakeCRS(int rows, int cols, const std::vector<std::vector<std::complex<double>>> &default_matrix);
44 bool MatricesEqual(const CRSMatrix &a, const CRSMatrix &b);
45
46 CRSMatrix MakeBandedCRS(int size, int bandwidth);
47 std::complex<double> ComputeExpectedValue(const CRSMatrix &a, const CRSMatrix &b, int row, int col);
48 bool CheckKeyElements(const CRSMatrix &result, const CRSMatrix &a, const CRSMatrix &b);
49 bool CheckSingleElement(const CRSMatrix &result, const CRSMatrix &a, const CRSMatrix &b, int row, int col);
50
51 } // namespace posternak_a_crs_mul_complex_matrix
52