| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <cstddef> | ||
| 4 | |||
| 5 | #include "common.hpp" | ||
| 6 | namespace guseva_crs { | ||
| 7 | |||
| 8 | class Multiplier { | ||
| 9 | public: | ||
| 10 | Multiplier() = default; | ||
| 11 | virtual ~Multiplier() = default; | ||
| 12 | |||
| 13 | 96 | [[nodiscard]] virtual CRS Transpose(const CRS &a) const { | |
| 14 | 96 | CRS transposed; | |
| 15 | 96 | transposed.nz = a.nz; | |
| 16 | 96 | transposed.ncols = a.nrows; | |
| 17 | 96 | transposed.nrows = a.ncols; | |
| 18 |
1/2✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
|
96 | transposed.row_ptrs.resize(transposed.nrows + 1, 0); |
| 19 |
1/2✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
|
96 | transposed.values.resize(a.nz, 0); |
| 20 |
1/2✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
|
96 | transposed.cols.resize(a.nz, 0); |
| 21 |
2/2✓ Branch 0 taken 3728 times.
✓ Branch 1 taken 96 times.
|
3824 | for (std::size_t i = 0; i < a.nz; i++) { |
| 22 | 3728 | transposed.row_ptrs[a.cols[i] + 1]++; | |
| 23 | } | ||
| 24 | std::size_t row = 0; | ||
| 25 |
2/2✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 96 times.
|
1648 | for (std::size_t i = 1; i <= transposed.nrows; i++) { |
| 26 | 1552 | auto tmp = transposed.row_ptrs[i]; | |
| 27 | 1552 | transposed.row_ptrs[i] = row; | |
| 28 | 1552 | row += tmp; | |
| 29 | } | ||
| 30 |
2/2✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 96 times.
|
1648 | for (std::size_t i = 0; i < a.nrows; i++) { |
| 31 | 1552 | auto j1 = a.row_ptrs[i]; | |
| 32 | 1552 | auto j2 = a.row_ptrs[i + 1]; | |
| 33 | auto col = i; | ||
| 34 |
2/2✓ Branch 0 taken 3728 times.
✓ Branch 1 taken 1552 times.
|
5280 | for (auto j = j1; j < j2; j++) { |
| 35 | 3728 | auto value = a.values[j]; | |
| 36 | 3728 | auto row_ind = a.cols[j]; | |
| 37 | 3728 | auto ind = transposed.row_ptrs[row_ind + 1]; | |
| 38 | 3728 | transposed.values[ind] = value; | |
| 39 | 3728 | transposed.cols[ind] = col; | |
| 40 | 3728 | transposed.row_ptrs[row_ind + 1]++; | |
| 41 | } | ||
| 42 | } | ||
| 43 | 96 | return transposed; | |
| 44 | ✗ | }; | |
| 45 | |||
| 46 | [[nodiscard]] virtual CRS Multiply(const CRS &a, const CRS &b) const = 0; | ||
| 47 | }; | ||
| 48 | |||
| 49 | } // namespace guseva_crs | ||
| 50 |