Complete LU documentation
diff --git a/doc/snippets/LU_computeKernel.cpp b/doc/snippets/LU_computeKernel.cpp
new file mode 100644
index 0000000..b08f7f1
--- /dev/null
+++ b/doc/snippets/LU_computeKernel.cpp
@@ -0,0 +1,10 @@
+MatrixXf m = MatrixXf::Random(3,5);
+cout << "Here is the matrix m:" << endl << m << endl;
+LU<MatrixXf> lu(m);
+// allocate the matrix ker with the correct size to avoid reallocation
+MatrixXf ker(m.rows(), lu.dimensionOfKernel());
+lu.computeKernel(&ker);
+cout << "Here is a matrix whose columns form a basis of the kernel of m:"
+ << endl << ker << endl;
+cout << "By definition of the kernel, m*ker is zero:"
+ << endl << m*ker << endl;
diff --git a/doc/snippets/LU_kernel.cpp b/doc/snippets/LU_kernel.cpp
new file mode 100644
index 0000000..e01186d
--- /dev/null
+++ b/doc/snippets/LU_kernel.cpp
@@ -0,0 +1,7 @@
+MatrixXf m = MatrixXf::Random(3,5);
+cout << "Here is the matrix m:" << endl << m << endl;
+MatrixXf ker = m.lu().kernel();
+cout << "Here is a matrix whose columns form a basis of the kernel of m:"
+ << endl << ker << endl;
+cout << "By definition of the kernel, m*ker is zero:"
+ << endl << m*ker << endl;
diff --git a/doc/snippets/LU_solve.cpp b/doc/snippets/LU_solve.cpp
new file mode 100644
index 0000000..7323338
--- /dev/null
+++ b/doc/snippets/LU_solve.cpp
@@ -0,0 +1,15 @@
+typedef Matrix<float,2,3> Matrix2x3;
+typedef Matrix<float,3,2> Matrix3x2;
+Matrix2x3 m = Matrix2x3::Random();
+Matrix2f y = Matrix2f::Random();
+cout << "Here is the matrix m:" << endl << m << endl;
+cout << "Here is the matrix y:" << endl << y << endl;
+Matrix3x2 x;
+if(m.lu().solve(y, &x))
+{
+ assert(y.isApprox(m*x));
+ cout << "Here is a solution x to the equation mx=y:" << endl << x << endl;
+}
+else
+ cout << "The equation mx=y does not have any solution." << endl;
+
diff --git a/doc/snippets/class_LU_1.cpp b/doc/snippets/class_LU_1.cpp
new file mode 100644
index 0000000..50cfc4b
--- /dev/null
+++ b/doc/snippets/class_LU_1.cpp
@@ -0,0 +1,12 @@
+Matrix3d m = Matrix3d::Random();
+cout << "Here is the matrix m:" << endl << m << endl;
+Eigen::LU<Matrix3d> lu(m);
+cout << "Here is, up to permutations, its LU decomposition matrix:"
+ << endl << lu.matrixLU() << endl;
+cout << "Let us now reconstruct the original matrix m from it:" << endl;
+Matrix3d x = lu.matrixL() * lu.matrixU();
+Matrix3d y;
+for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++)
+ y(i, lu.permutationQ()[j]) = x(lu.permutationP()[i], j);
+cout << y << endl;
+assert(y.isApprox(m));
diff --git a/doc/snippets/class_LU_2.cpp b/doc/snippets/class_LU_2.cpp
new file mode 100644
index 0000000..ccf89a9
--- /dev/null
+++ b/doc/snippets/class_LU_2.cpp
@@ -0,0 +1,18 @@
+typedef Matrix<double, 5, 3> Matrix5x3;
+typedef Matrix<double, 5, 5> Matrix5x5;
+Matrix5x3 m = Matrix5x3::Random();
+cout << "Here is the matrix m:" << endl << m << endl;
+Eigen::LU<Matrix5x3> lu(m);
+cout << "Here is, up to permutations, its LU decomposition matrix:"
+ << endl << lu.matrixLU() << endl;
+cout << "Here is the actual L matrix in this decomposition:" << endl;
+Matrix5x5 l = Matrix5x5::Identity();
+l.block<5,3>(0,0).part<StrictlyLower>() = lu.matrixLU();
+cout << l << endl;
+cout << "Let us now reconstruct the original matrix m:" << endl;
+Matrix5x3 x = l * lu.matrixU();
+Matrix5x3 y;
+for(int i = 0; i < 5; i++) for(int j = 0; j < 3; j++)
+ y(i, lu.permutationQ()[j]) = x(lu.permutationP()[i], j);
+cout << y << endl;
+assert(y.isApprox(m));