#include "ExaTrkXUtils.hpp"
#include <numeric>
#include <algorithm>
Go to the source code of this file.
|
void | buildEdges (std::vector< float > &embedFeatures, std::vector< int64_t > &edgeList, int64_t numSpacepoints, int embeddingDim, float rVal, int kVal) |
|
◆ buildEdges()
void buildEdges |
( |
std::vector< float > & |
embedFeatures, |
|
|
std::vector< int64_t > & |
edgeList, |
|
|
int64_t |
numSpacepoints, |
|
|
int |
embeddingDim, |
|
|
float |
rVal, |
|
|
int |
kVal |
|
) |
| |
Definition at line 10 of file ExaTrkXUtils.cxx.
26 std::vector<float> dists;
27 dists.reserve(numSpacepoints);
28 std::vector<int>
idx(numSpacepoints);
29 std::vector<int64_t> senders;
30 std::vector<int64_t> receivers;
31 for (int64_t
i = 0;
i < numSpacepoints;
i++) {
33 for (int64_t j = 0; j < numSpacepoints; j++) {
39 for (
int k = 0;
k < embeddingDim;
k++) {
40 float dist_k = embedFeatures[
i * embeddingDim +
k] - embedFeatures[j * embeddingDim +
k];
41 dist += dist_k * dist_k;
43 dists.push_back(sqrt(dist));
45 std::iota(
idx.begin(),
idx.end(), 0);
46 std::sort(
idx.begin(),
idx.end(), [&dists](
int i1,
int i2) {return dists[i1] < dists[i2];});
48 for (
int j = 0; j < numSpacepoints; j++) {
50 if (dists[
idx[j]] >
rVal)
break;
53 receivers.push_back(
idx[j]);
54 if (numFilled >= kVal)
break;
57 edgeList.resize(2 * senders.size());
58 std::copy(senders.begin(), senders.end(), edgeList.begin());
59 std::copy(receivers.begin(), receivers.end(), edgeList.begin() + senders.size());
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.