The time efficiency test of QR decomposition of matrix inversion and ordinary inversion

#define MATRIX_SIZE 50

clock_t time_stt = clock();
	Eigen::Matrix<double, MATRIX_SIZE, 1>x = matrix_NN.inverse()*v_Nd;
	cout << "time use in normal inverse is " << 1000 * (clock() - time_stt) / (double)CLOCKS_PER_SEC << "ms" << endl;

//奇了怪了,我是QR比较慢!!!!!!!
	time_stt = clock();
	x = matrix_NN.colPivHouseholderQr().solve(v_Nd);
	cout << "time use in QRsolve is " << 1000 * (clock() - time_stt) / (double)CLOCKS_PER_SEC << "ms" << endl;

	system("pause");

Guess you like

Origin blog.csdn.net/guanxunmeng8928/article/details/111759612
Recommended