GCC Code Coverage Report


Directory: ./
File: tasks/sabutay_sparse_complex_ccs_mult/seq/src/ops_seq.cpp
Date: 2026-04-02 17:12:27
Exec Total Coverage
Lines: 36 36 100.0%
Functions: 6 6 100.0%
Branches: 22 34 64.7%

Line Branch Exec Source
1 #include "../include/ops_seq.hpp"
2
3 #include <cmath>
4 #include <complex>
5 #include <vector>
6
7 #include "../../common/include/common.hpp"
8
9 namespace sabutay_sparse_complex_ccs_mult {
10
11
1/2
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 SabutaySparseComplexCcsMultSEQ::SabutaySparseComplexCcsMultSEQ(const InType &in) {
12 SetTypeOfTask(GetStaticTypeOfTask());
13 GetInput() = in;
14
1/2
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
24 GetOutput() = CCS();
15 24 }
16
17 24 void SabutaySparseComplexCcsMultSEQ::SpMM(const CCS &a, const CCS &b, CCS &c) {
18 24 c.m = a.m;
19 24 c.n = b.n;
20
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 c.col_ptr.assign(b.n + 1, 0);
21 c.row_ind.clear();
22 c.values.clear();
23 std::complex<double> zero(0.0, 0.0);
24 24 std::vector<int> rows;
25
1/4
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
24 std::vector<int> marker(a.m, -1);
26
1/4
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
24 std::vector<std::complex<double>> acc(a.m);
27 const double eps = 1e-14;
28
29
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 24 times.
64 for (int j = 0; j < b.n; ++j) {
30 rows.clear();
31
32
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 40 times.
88 for (int k = b.col_ptr[j]; k < b.col_ptr[j + 1]; ++k) {
33 48 std::complex<double> tmpval = b.values[k];
34 48 int btmpind = b.row_ind[k];
35
36
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 for (int zp = a.col_ptr[btmpind]; zp < a.col_ptr[btmpind + 1]; ++zp) {
37
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 8 times.
48 int atmpind = a.row_ind[zp];
38
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 8 times.
48 acc[atmpind] += tmpval * a.values[zp];
39
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 8 times.
48 if (marker[atmpind] != j) {
40 rows.push_back(atmpind);
41 40 marker[atmpind] = j;
42 }
43 }
44 }
45
46
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 40 times.
80 for (int tmpind : rows) {
47
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if (std::abs(acc[tmpind]) > eps) {
48
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 c.values.push_back(acc[tmpind]);
49
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 c.row_ind.push_back(tmpind);
50 40 ++c.col_ptr[j + 1];
51 }
52 40 acc[tmpind] = zero;
53 }
54
55 40 c.col_ptr[j + 1] += c.col_ptr[j];
56 }
57 24 }
58
59 24 bool SabutaySparseComplexCcsMultSEQ::ValidationImpl() {
60 const CCS &a = std::get<0>(GetInput());
61 const CCS &b = std::get<1>(GetInput());
62 24 return a.n == b.m;
63 }
64
65 24 bool SabutaySparseComplexCcsMultSEQ::PreProcessingImpl() {
66 24 return true;
67 }
68
69 24 bool SabutaySparseComplexCcsMultSEQ::RunImpl() {
70 const CCS &a = std::get<0>(GetInput());
71 const CCS &b = std::get<1>(GetInput());
72 CCS &c = GetOutput();
73
74 24 SpMM(a, b, c);
75
76 24 return true;
77 }
78
79 24 bool SabutaySparseComplexCcsMultSEQ::PostProcessingImpl() {
80 24 return true;
81 }
82
83 } // namespace sabutay_sparse_complex_ccs_mult
84