In this example, we will compile a program that allocates a random square matrix and vector of dimension passed from the command line. We will then solve the linear system Ax=b using LU decomposition. We will use the following source code (linear-algebra.cpp):
#include <chrono>#include <cmath>#include <cstdlib>#include <iomanip>#include <iostream>#include <vector>#include <Eigen/Dense>int main(int argc, char **argv) { if (argc != 2) { std::cout << "Usage: ./linear-algebra dim" << std::endl; return EXIT_FAILURE; } std::chrono::time_point<std::chrono::system_clock> start, end; std::chrono::duration<double> elapsed_seconds; std::time_t end_time; std::cout << "Number of threads used by Eigen: " << Eigen::nbThreads() << std::endl; ...