| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <array> | ||
| 4 | #include <vector> | ||
| 5 | |||
| 6 | #include "lazareva_a_matrix_mult_strassen/common/include/common.hpp" | ||
| 7 | #include "task/include/task.hpp" | ||
| 8 | |||
| 9 | namespace lazareva_a_matrix_mult_strassen { | ||
| 10 | |||
| 11 | 160 | struct StrassenNode { | |
| 12 | std::vector<double> a; | ||
| 13 | std::vector<double> b; | ||
| 14 | int n{}; | ||
| 15 | int result_slot{}; | ||
| 16 | std::array<int, 7> child_slots{}; | ||
| 17 | bool expanded{}; | ||
| 18 | }; | ||
| 19 | |||
| 20 | class LazarevaATestTaskSEQ : public BaseTask { | ||
| 21 | public: | ||
| 22 | static constexpr ppc::task::TypeOfTask GetStaticTypeOfTask() { | ||
| 23 | return ppc::task::TypeOfTask::kSEQ; | ||
| 24 | } | ||
| 25 | explicit LazarevaATestTaskSEQ(const InType &in); | ||
| 26 | |||
| 27 | private: | ||
| 28 | bool ValidationImpl() override; | ||
| 29 | bool PreProcessingImpl() override; | ||
| 30 | bool RunImpl() override; | ||
| 31 | bool PostProcessingImpl() override; | ||
| 32 | |||
| 33 | int n_{}; | ||
| 34 | int padded_n_{}; | ||
| 35 | std::vector<double> a_; | ||
| 36 | std::vector<double> b_; | ||
| 37 | std::vector<double> result_; | ||
| 38 | |||
| 39 | static int NextPowerOfTwo(int n); | ||
| 40 | static std::vector<double> PadMatrix(const std::vector<double> &m, int old_n, int new_n); | ||
| 41 | static std::vector<double> UnpadMatrix(const std::vector<double> &m, int old_n, int new_n); | ||
| 42 | static std::vector<double> Add(const std::vector<double> &a, const std::vector<double> &b, int n); | ||
| 43 | static std::vector<double> Sub(const std::vector<double> &a, const std::vector<double> &b, int n); | ||
| 44 | static void Split(const std::vector<double> &parent, int n, std::vector<double> &a11, std::vector<double> &a12, | ||
| 45 | std::vector<double> &a21, std::vector<double> &a22); | ||
| 46 | static std::vector<double> Merge(const std::vector<double> &c11, const std::vector<double> &c12, | ||
| 47 | const std::vector<double> &c21, const std::vector<double> &c22, int n); | ||
| 48 | static std::vector<double> NaiveMult(const std::vector<double> &a, const std::vector<double> &b, int n); | ||
| 49 | static std::vector<double> Strassen(const std::vector<double> &a, const std::vector<double> &b, int n); | ||
| 50 | }; | ||
| 51 | |||
| 52 | } // namespace lazareva_a_matrix_mult_strassen | ||
| 53 |