| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "likhanov_m_hypercube/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <cstdint> | ||
| 4 | |||
| 5 | #include "likhanov_m_hypercube/common/include/common.hpp" | ||
| 6 | |||
| 7 | namespace likhanov_m_hypercube { | ||
| 8 | |||
| 9 | ✗ | LikhanovMHypercubeSEQ::LikhanovMHypercubeSEQ(const InType &in) { | |
| 10 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 11 | ✗ | GetInput() = in; | |
| 12 | GetOutput() = 0; | ||
| 13 | ✗ | } | |
| 14 | |||
| 15 | ✗ | bool LikhanovMHypercubeSEQ::ValidationImpl() { | |
| 16 | ✗ | return GetInput() > 0; | |
| 17 | } | ||
| 18 | |||
| 19 | ✗ | bool LikhanovMHypercubeSEQ::PreProcessingImpl() { | |
| 20 | ✗ | GetOutput() = 0; | |
| 21 | ✗ | return true; | |
| 22 | } | ||
| 23 | |||
| 24 | ✗ | bool LikhanovMHypercubeSEQ::RunImpl() { | |
| 25 | ✗ | const InType dimension = GetInput(); | |
| 26 | |||
| 27 | ✗ | const std::uint64_t vertices = static_cast<std::uint64_t>(1) << dimension; | |
| 28 | std::uint64_t total_edges = 0; | ||
| 29 | |||
| 30 | ✗ | for (std::uint64_t vertex = 0; vertex < vertices; ++vertex) { | |
| 31 | ✗ | for (InType bit = 0; bit < dimension; ++bit) { | |
| 32 | ✗ | const std::uint64_t neighbor = vertex ^ (1ULL << bit); | |
| 33 | ✗ | if (vertex < neighbor) { | |
| 34 | ✗ | ++total_edges; | |
| 35 | } | ||
| 36 | } | ||
| 37 | } | ||
| 38 | |||
| 39 | ✗ | GetOutput() = static_cast<OutType>(total_edges); | |
| 40 | ✗ | return true; | |
| 41 | } | ||
| 42 | |||
| 43 | ✗ | bool LikhanovMHypercubeSEQ::PostProcessingImpl() { | |
| 44 | ✗ | return true; | |
| 45 | } | ||
| 46 | |||
| 47 | } // namespace likhanov_m_hypercube | ||
| 48 |