| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "levonychev_i_mult_matrix_vec/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <cstddef> | ||
| 4 | #include <vector> | ||
| 5 | |||
| 6 | #include "levonychev_i_mult_matrix_vec/common/include/common.hpp" | ||
| 7 | |||
| 8 | namespace levonychev_i_mult_matrix_vec { | ||
| 9 | |||
| 10 |
1/2✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
|
64 | LevonychevIMultMatrixVecSEQ::LevonychevIMultMatrixVecSEQ(const InType &in) { |
| 11 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 12 | GetInput() = in; | ||
| 13 | GetOutput() = {}; | ||
| 14 | 64 | } | |
| 15 | |||
| 16 |
1/2✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
|
64 | bool LevonychevIMultMatrixVecSEQ::ValidationImpl() { |
| 17 | const size_t matrix_size = std::get<0>(GetInput()).size(); | ||
| 18 | 64 | const int rows = std::get<1>(GetInput()); | |
| 19 | 64 | const int cols = std::get<2>(GetInput()); | |
| 20 | 64 | bool is_correct_matrix_size = (matrix_size == static_cast<size_t>(rows) * static_cast<size_t>(cols)); | |
| 21 | bool is_correct_vector_size = (static_cast<size_t>(cols) == std::get<3>(GetInput()).size()); | ||
| 22 |
3/6✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 64 times.
|
64 | return matrix_size != 0 && rows != 0 && cols != 0 && is_correct_matrix_size && is_correct_vector_size; |
| 23 | } | ||
| 24 | |||
| 25 | 64 | bool LevonychevIMultMatrixVecSEQ::PreProcessingImpl() { | |
| 26 | 64 | GetOutput().resize(static_cast<size_t>(std::get<1>(GetInput()))); | |
| 27 | 64 | return true; | |
| 28 | } | ||
| 29 | |||
| 30 | 64 | bool LevonychevIMultMatrixVecSEQ::RunImpl() { | |
| 31 | const std::vector<double> &matrix = std::get<0>(GetInput()); | ||
| 32 | 64 | const int rows = std::get<1>(GetInput()); | |
| 33 | 64 | const int cols = std::get<2>(GetInput()); | |
| 34 | const std::vector<double> &vec_x = std::get<3>(GetInput()); | ||
| 35 | |||
| 36 | OutType &result = GetOutput(); | ||
| 37 | |||
| 38 |
2/2✓ Branch 0 taken 168 times.
✓ Branch 1 taken 64 times.
|
232 | for (int i = 0; i < rows; ++i) { |
| 39 | double scalar_product = 0; | ||
| 40 |
2/2✓ Branch 0 taken 656 times.
✓ Branch 1 taken 168 times.
|
824 | for (int j = 0; j < cols; ++j) { |
| 41 | 656 | scalar_product += matrix[(i * cols) + j] * vec_x[j]; | |
| 42 | } | ||
| 43 | 168 | result[i] = scalar_product; | |
| 44 | } | ||
| 45 | 64 | return true; | |
| 46 | } | ||
| 47 | |||
| 48 | 64 | bool LevonychevIMultMatrixVecSEQ::PostProcessingImpl() { | |
| 49 | 64 | return true; | |
| 50 | } | ||
| 51 | |||
| 52 | } // namespace levonychev_i_mult_matrix_vec | ||
| 53 |