https://github.com/HTDerekLiu/surface_multigrid_code
Revision d79181f2d8eb642d3bbf7b6faf95a93bf3511de0 authored by eriszhang on 08 August 2021, 01:50:25 UTC, committed by eriszhang on 08 August 2021, 01:50:25 UTC
1 parent 535fef7
Tip revision: d79181f2d8eb642d3bbf7b6faf95a93bf3511de0 authored by eriszhang on 08 August 2021, 01:50:25 UTC
update code and rename folder
update code and rename folder
Tip revision: d79181f
sort_vec.cpp
#include "sort_vec.h"
void sort_vec(
const Eigen::VectorXd & vec,
Eigen::VectorXd & sorted_vec,
Eigen::VectorXi & ind)
{
// https://www.programmersought.com/article/343692646/
using namespace Eigen;
using namespace std;
ind=VectorXi::LinSpaced(vec.size(),0,vec.size()-1);//[0 1 2 3 ... N-1]
auto rule=[vec](int i, int j)->bool{
return vec(i)<vec(j);
}; // regular expression, as a predicate of sort
std::sort(ind.data(),ind.data()+ind.size(),rule);
//The data member function returns a pointer to the first element of VectorXd, similar to begin()
sorted_vec.resize(vec.size());
for(int i=0;i<vec.size();i++){
sorted_vec(i)=vec(ind(i));
}
}
void sort_vec(
const Eigen::VectorXi & vec,
Eigen::VectorXi & sorted_vec,
Eigen::VectorXi & ind)
{
// https://www.programmersought.com/article/343692646/
using namespace Eigen;
using namespace std;
ind=VectorXi::LinSpaced(vec.size(),0,vec.size()-1);//[0 1 2 3 ... N-1]
auto rule=[vec](int i, int j)->bool{
return vec(i)<vec(j);
}; // regular expression, as a predicate of sort
std::sort(ind.data(),ind.data()+ind.size(),rule);
//The data member function returns a pointer to the first element of VectorXd, similar to begin()
sorted_vec.resize(vec.size());
for(int i=0;i<vec.size();i++){
sorted_vec(i)=vec(ind(i));
}
}
Computing file changes ...