Eigen - AshokBhat/notes GitHub Wiki

About

Getting started

  • Setup up $WORKDIR
  • Download and extract
mkdir -p $WORKDIR
cd $WORKDIR
wget http://bitbucket.org/eigen/eigen/get/3.3.7.tar.bz2
tar xf 3.3.7.tar.bz2
  • Setup $EIGENDIR (in this case eigen-eigen-323c052e1731)
  • Build and install
cd $WORKDIR/$EIGENDIR/
mkdir build install my_examples
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=$WORKDIR/$EIGENDIR/install/ ..
make -j
make install
  • Example code $WORKDIR/$EIGENDIR/my_examples/main.cpp from StackOverflow
#include <iostream>
#include <Dense>
#include <time.h>

using namespace Eigen;
using namespace std;

int main(int argc, const char * argv[]) {
    //RNG generator
    unsigned int seed = clock();
    srand(seed);

    int Msize=1000, Nloops=10;

    MatrixXd m1=MatrixXd::Random(Msize,Msize);
    MatrixXd m2=MatrixXd::Random(Msize,Msize);
    MatrixXd m3=MatrixXd::Random(Msize,Msize);

    cout << "Starting matrix multiplication test with " << Msize << 
    "matrices" << endl;
    clock_t start=clock();
    for (int i=0; i<Nloops; i++)
        m3=m1*m2;
    start = clock() - start;

    cout << "time elapsed for 1 multiplication: " << start / ((double) 
CLOCKS_PER_SEC * (double) Nloops) << " seconds" <<endl;
return 0;
}
  • Run the example code
cd $WORKDIR/$EIGENDIR/my_examples
g++ -I $WORKDIR/$EIGENDIR/install/include/eigen3/Eigen/ main.cpp -o my_exec -O3
./my_exec

See Also

External resources

⚠️ **GitHub.com Fallback** ⚠️