PhysicsBasedAnimationToolkit
0.0.10
Cross-platform C++20 library of algorithms and data structures commonly used in computer graphics research on physically-based simulation.
Loading...
Searching...
No Matches
ArgSort.h
Go to the documentation of this file.
1
9
10
#ifndef PBAT_COMMON_ARG_SORT_H
11
#define PBAT_COMMON_ARG_SORT_H
12
13
#include "
pbat/Aliases.h
"
14
15
#include <algorithm>
16
#include <concepts>
17
#include <numeric>
18
19
namespace
pbat
{
20
namespace
common
{
21
31
template
<std::
int
egral TIndex,
class
FLess>
32
auto
ArgSort
(TIndex n, FLess less) -> Eigen::Vector<TIndex, Eigen::Dynamic>
33
{
34
using
IndexVectorType = Eigen::Vector<TIndex, Eigen::Dynamic>;
35
IndexVectorType inds(n);
36
std::iota(inds.begin(), inds.end(), TIndex(0));
37
std::stable_sort(inds.begin(), inds.end(), less);
38
return
inds;
39
}
40
41
}
// namespace common
42
}
// namespace pbat
43
44
#endif
// PBAT_COMMON_ARG_SORT_H
Aliases.h
pbat::common
Common functionality.
Definition
ArgSort.h:20
pbat::common::ArgSort
auto ArgSort(TIndex n, FLess less) -> Eigen::Vector< TIndex, Eigen::Dynamic >
Computes the indices that would sort an array.
Definition
ArgSort.h:32
pbat
The main namespace of the library.
Definition
Aliases.h:15
source
pbat
common
ArgSort.h
Generated by
1.13.2