8 Eigen::Ref<Eigen::VectorXd> matrix)
10 for(
auto& swap : swapInds)
11 std::swap(matrix(swap.first),matrix(swap.second));
15 std::vector<bool> & vec)
17 for(
auto& swap : swapInds)
18 std::vector<bool>::swap(vec[swap.first],vec[swap.second]);
22 Eigen::Ref<Eigen::MatrixXd> matrix)
24 for(
auto& swap : swapInds)
25 matrix.col(swap.first).swap(matrix.col(swap.second));
30 std::vector<bool> allActive(residNorms.size(),
true);
35 std::vector<bool>
const& isActive)
37 Eigen::VectorXd newResids = resids;
38 std::vector<bool> newIsActive = isActive;
40 const unsigned int size = resids.size();
42 std::vector<std::pair<int,int>> swaps;
46 int firstInactiveInd = 0;
47 while((firstInactiveInd<isActive.size())&&(newIsActive.at(firstInactiveInd)))
50 int lastActiveInd = isActive.size()-1;
51 while((lastActiveInd>=0)&&(!newIsActive.at(lastActiveInd)))
54 while(firstInactiveInd<lastActiveInd){
56 swaps.push_back(std::make_pair(firstInactiveInd,lastActiveInd));
57 std::vector<bool>::swap(newIsActive.at(firstInactiveInd), newIsActive.at(lastActiveInd));
58 std::swap(newResids(firstInactiveInd), newResids(lastActiveInd));
60 while((firstInactiveInd<isActive.size())&&(newIsActive.at(firstInactiveInd)))
63 while((lastActiveInd>=0)&&(!newIsActive.at(lastActiveInd)))
67 unsigned int numActive = lastActiveInd+1;
70 for(
unsigned int i=0; i<numActive; ++i)
73 maxInd = std::distance(newResids.data(), std::max_element(&newResids(i), newResids.data()+numActive));
77 swaps.push_back( std::make_pair(i, maxInd) );
78 std::swap(newResids(i), newResids(maxInd));
static std::vector< std::pair< int, int > > GetSortSwaps(Eigen::Ref< const Eigen::VectorXd > const &residNorms, std::vector< bool > const &isActive)
static void SortVec(std::vector< std::pair< int, int >> const &swapInds, Eigen::Ref< Eigen::VectorXd > matrix)
static void SortCols(std::vector< std::pair< int, int >> const &swapInds, Eigen::Ref< Eigen::MatrixXd > matrix)