Eigen permutate columns/rows

#include <iostream>
#include "Eigen/Dense"
#include "eigen_consts.H"
#include "eigen_test.H"


using namespace std;
using namespace Eigen;

int main()
{
	MatrixXf A(3,4);
	A << 1,2,3,4,5,6,7,8,9,10,11,12;
	cout << A << endl;

	PermutationMatrix<4, 4> permX(4);
	permX.setIdentity();
	// Your permutation
	cout << permX.indices()<< endl;
	permX.indices() << 1,0,2,3;
	// Permutate rows
	// A = permX * A;
	A = (A * permX).rightCols(2);
	cout << A << endl;

	return 0;
}
上一篇:图形学实验用的VS2017本地环境配置,VS 2017配置opencv、Eigen


下一篇:auto与Eigen混用Debug和Release模式下值会变化