.. _program_listing_file_src_neighbours.cpp: Program Listing for File neighbours.cpp ======================================= |exhale_lsh| :ref:`Return to documentation for file ` (``src/neighbours.cpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /* This file is part of brille. Copyright © 2019,2020 Greg Tucker brille is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. brille is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with brille. If not, see . */ #include "neighbours.hpp" #include #include using namespace brille; static std::vector all_from_extent(const int extent){ int min = -extent, max = extent+1; std::vector vec; for (int i=min; i brille::make_relative_neighbour_indices(const int extent){ auto vec = all_from_extent(extent); size_t num = vec.size(); size_t n{0}; std::vector> o(num*num*num-1); //-1 because we're skipping the origin) for (auto i: vec) for (auto j: vec) for (auto k: vec) if (i||j||k) o[n++] = {{i,j,k}}; return bArray::from_std(o); } bArray brille::make_relative_neighbour_indices_prime(const int extent){ auto vec = all_from_extent(extent); size_t num = vec.size(); size_t n{0}; std::vector> o(num*num*num-1); for (size_t i=0; i::from_std(o); } bArray brille::make_relative_neighbour_indices4(const int extent){ auto v = all_from_extent(extent); std::vector> o; for (auto i: v) for (auto j: v) for (auto k: v) for (auto l: v) if (i||j||k||l) o.push_back({{i,j,k,l}}); return bArray::from_std(o); }