Squashed 'third_party/eigen/' changes from 61d72f6..cf794d3
Change-Id: I9b814151b01f49af6337a8605d0c42a3a1ed4c72
git-subtree-dir: third_party/eigen
git-subtree-split: cf794d3b741a6278df169e58461f8529f43bce5d
diff --git a/doc/special_examples/CMakeLists.txt b/doc/special_examples/CMakeLists.txt
index 3ab75db..66ba4de 100644
--- a/doc/special_examples/CMakeLists.txt
+++ b/doc/special_examples/CMakeLists.txt
@@ -19,3 +19,16 @@
add_dependencies(all_examples Tutorial_sparse_example)
endif(QT4_FOUND)
+if(EIGEN_COMPILER_SUPPORT_CPP11)
+ add_executable(random_cpp11 random_cpp11.cpp)
+ target_link_libraries(random_cpp11 ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
+ add_dependencies(all_examples random_cpp11)
+ ei_add_target_property(random_cpp11 COMPILE_FLAGS "-std=c++11")
+
+ add_custom_command(
+ TARGET random_cpp11
+ POST_BUILD
+ COMMAND random_cpp11
+ ARGS >${CMAKE_CURRENT_BINARY_DIR}/random_cpp11.out
+ )
+endif()
diff --git a/doc/special_examples/Tutorial_sparse_example.cpp b/doc/special_examples/Tutorial_sparse_example.cpp
index 002f19f..c5767a8 100644
--- a/doc/special_examples/Tutorial_sparse_example.cpp
+++ b/doc/special_examples/Tutorial_sparse_example.cpp
@@ -1,5 +1,6 @@
#include <Eigen/Sparse>
#include <vector>
+#include <iostream>
typedef Eigen::SparseMatrix<double> SpMat; // declares a column-major sparse matrix type of double
typedef Eigen::Triplet<double> T;
@@ -9,6 +10,11 @@
int main(int argc, char** argv)
{
+ if(argc!=2) {
+ std::cerr << "Error: expected one and only one argument.\n";
+ return -1;
+ }
+
int n = 300; // size of the image
int m = n*n; // number of unknows (=number of pixels)
diff --git a/doc/special_examples/Tutorial_sparse_example_details.cpp b/doc/special_examples/Tutorial_sparse_example_details.cpp
index 7d820b4..bc18b01 100644
--- a/doc/special_examples/Tutorial_sparse_example_details.cpp
+++ b/doc/special_examples/Tutorial_sparse_example_details.cpp
@@ -8,7 +8,7 @@
void insertCoefficient(int id, int i, int j, double w, std::vector<T>& coeffs,
Eigen::VectorXd& b, const Eigen::VectorXd& boundary)
{
- int n = boundary.size();
+ int n = int(boundary.size());
int id1 = i+j*n;
if(i==-1 || i==n) b(id) -= w * boundary(j); // constrained coefficient
diff --git a/doc/special_examples/random_cpp11.cpp b/doc/special_examples/random_cpp11.cpp
new file mode 100644
index 0000000..33744c0
--- /dev/null
+++ b/doc/special_examples/random_cpp11.cpp
@@ -0,0 +1,14 @@
+#include <Eigen/Core>
+#include <iostream>
+#include <random>
+
+using namespace Eigen;
+
+int main() {
+ std::default_random_engine generator;
+ std::poisson_distribution<int> distribution(4.1);
+ auto poisson = [&] () {return distribution(generator);};
+
+ RowVectorXi v = RowVectorXi::NullaryExpr(10, poisson );
+ std::cout << v << "\n";
+}