123456789101112131415161718192021222324252627282930313233 |
- #include "reorder.h"
- #include "SortableRow.h"
- #ifndef IGL_NO_EIGEN
- #include <Eigen/Core>
- #endif
- // This implementation is O(n), but also uses O(n) extra memory
- template< class T >
- IGL_INLINE void igl::reorder(
- const std::vector<T> & unordered,
- std::vector<size_t> const & index_map,
- std::vector<T> & ordered)
- {
- // copy for the reorder according to index_map, because unsorted may also be
- // sorted
- std::vector<T> copy = unordered;
- ordered.resize(index_map.size());
- for(int i = 0; i<(int)index_map.size();i++)
- {
- ordered[i] = copy[index_map[i]];
- }
- }
- #ifndef IGL_HEADER_ONLY
- // Explicit template specialization
- // generated by autoexplicit.sh
- template void igl::reorder<double>(std::vector<double, std::allocator<double> > const&, std::vector<size_t, std::allocator<size_t> > const&, std::vector<double, std::allocator<double> >&);
- template void igl::reorder<int>(std::vector<int, std::allocator<int> > const&, std::vector<size_t, std::allocator<size_t> > const&, std::vector<int, std::allocator<int> >&);
- # ifndef IGL_NO_EIGEN
- template void igl::reorder<SortableRow<Eigen::Matrix<int, -1, 1, 0, -1, 1> > >(std::vector<SortableRow<Eigen::Matrix<int, -1, 1, 0, -1, 1> >, std::allocator<SortableRow<Eigen::Matrix<int, -1, 1, 0, -1, 1> > > > const&, std::vector<unsigned long, std::allocator<unsigned long> > const&, std::vector<SortableRow<Eigen::Matrix<int, -1, 1, 0, -1, 1> >, std::allocator<SortableRow<Eigen::Matrix<int, -1, 1, 0, -1, 1> > > >&);
- template void igl::reorder<SortableRow<Eigen::Matrix<double, -1, 1, 0, -1, 1> > >(std::vector<SortableRow<Eigen::Matrix<double, -1, 1, 0, -1, 1> >, std::allocator<SortableRow<Eigen::Matrix<double, -1, 1, 0, -1, 1> > > > const&, std::vector<unsigned long, std::allocator<unsigned long> > const&, std::vector<SortableRow<Eigen::Matrix<double, -1, 1, 0, -1, 1> >, std::allocator<SortableRow<Eigen::Matrix<double, -1, 1, 0, -1, 1> > > >&);
- # endif
- #endif
|