Last active
December 15, 2015 12:39
-
-
Save mattmcd/5261952 to your computer and use it in GitHub Desktop.
Installing and testing Eigen3 linear algebra C++ library.
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
#include <iostream> | |
#include <Eigen/Dense> | |
using Eigen::MatrixXd; // m by n double matrix | |
int main() | |
{ | |
// Example from Eigen3 doc | |
MatrixXd m(2,2); | |
// Comma initialization, row major order | |
m << 3, 2.5, -1, m(1,0) + m(0,1); | |
std::cout << m << std::endl; | |
/* Equivalent to: | |
m(0,0) = 3; | |
m(1,0) = 2.5; | |
m(0,1) = -1; | |
m(1,1) = m(1,0) + m(0,1); | |
*/ | |
// vertcat( m, m) | |
MatrixXd m2(4,2); | |
m2 << m, m; | |
std::cout << std::endl << m2 << std::endl; | |
// horzcat( m, m) | |
MatrixXd m3(2,4); | |
m3 << m, m; | |
std::cout << std::endl << m3 << std::endl; | |
return 0; | |
} |
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
all: HelloEigen | |
HelloEigen: HelloEigen.cpp | |
clang++ -std=c++0x -I /usr/include/eigen3 -o HelloEigen HelloEigen.cpp | |
# Install eigen3: | |
# sudo apt-get install libeigen3-dev libeigen3-doc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment