Last active
August 29, 2015 14:23
-
-
Save firegurafiku/221c3a2e94e706260308 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Coompilation: | |
// g++ -I/usr/include/eigen3 -O3 -march=native -fopenmp -o test-eigen-lu test-eigen-lu.cpp | |
// | |
// Run: | |
// export OMP_NUM_THREADS=N ; time ./test-eigen-lu | |
//#include <iostream> | |
#include <Eigen/Dense> | |
#include <Eigen/Core> | |
using namespace std; | |
using namespace Eigen; | |
int main() { | |
Eigen::initParallel(); | |
MatrixXd A = MatrixXd::Random(8000, 8000); | |
VectorXd B = VectorXd::Random(8000); | |
//cout << "Here is the invertible matrix A:" << endl << A << endl; | |
//cout << "Here is the matrix B:" << endl << B << endl; | |
VectorXd X = A.lu().solve(B); | |
//cout << "Here is the (unique) solution X to the equation AX=B:" << endl << X << endl; | |
//cout << "Relative error: " << (A*X-B).norm() / B.norm() << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run in a cycle with 8000×8000 matrices: