diff --git a/.cproject b/.cproject
index 332430cf6..de1ddc75a 100644
--- a/.cproject
+++ b/.cproject
@@ -395,14 +395,6 @@
true
true
-
-make
-
-testLinearConstraint.run
-true
-true
-true
-
make
@@ -418,14 +410,6 @@
true
true
-
-make
-
-testConstrainedConditionalGaussian.run
-true
-true
-true
-
make
@@ -436,6 +420,7 @@
make
+
install
true
true
@@ -443,6 +428,7 @@
make
+
clean
true
true
diff --git a/cpp/smallExample.cpp b/cpp/smallExample.cpp
index 80ac96f42..0a35299ba 100644
--- a/cpp/smallExample.cpp
+++ b/cpp/smallExample.cpp
@@ -241,6 +241,7 @@ ExampleNonlinearFactorGraph createReallyNonlinearFactorGraph() {
/* ************************************************************************* */
ConstrainedLinearFactorGraph createSingleConstraintGraph() {
// create unary factor
+ // prior on "x", mean = [1,-1], sigma=0.1
double sigma = 0.1;
Matrix Ax = eye(2) / sigma;
Vector b1(2);
@@ -249,6 +250,9 @@ ConstrainedLinearFactorGraph createSingleConstraintGraph() {
LinearFactor::shared_ptr f1(new LinearFactor("x", Ax, b1 / sigma));
// create binary constraint factor
+ // between "x" and "y", that is going to be the only factor on "y"
+ // |1 2||x_1| + |10 0||y_1| = |1|
+ // |2 1||x_2| |0 10||y_2| |2|
Matrix Ax1(2, 2);
Ax1(0, 0) = 1.0; Ax1(0, 1) = 2.0;
Ax1(1, 0) = 2.0; Ax1(1, 1) = 1.0;
diff --git a/cpp/testConstrainedLinearFactorGraph.cpp b/cpp/testConstrainedLinearFactorGraph.cpp
index 4370c4412..14289faa1 100644
--- a/cpp/testConstrainedLinearFactorGraph.cpp
+++ b/cpp/testConstrainedLinearFactorGraph.cpp
@@ -16,6 +16,7 @@ using namespace std;
TEST( ConstrainedLinearFactorGraph, elimination1 )
{
// get the graph
+ // *-X-x-Y
ConstrainedLinearFactorGraph fg = createSingleConstraintGraph();
// verify construction of the graph
@@ -26,9 +27,14 @@ TEST( ConstrainedLinearFactorGraph, elimination1 )
ord.push_back("x");
ChordalBayesNet::shared_ptr cbn = fg.eliminate(ord);
- //verify changes and output
+ // verify result of elimination
+ // CBN of size 1, as we only eliminated X now
CHECK(fg.size() == 1);
CHECK(cbn->size() == 1);
+
+ // We will have a "delta function" on X as a function of Y
+ // |1 2||x_1| = |1| - |10 0||y_1|
+ // |2 1||x_2| |2| |0 10||y_2|
Matrix Ax1(2, 2);
Ax1(0, 0) = 1.0; Ax1(0, 1) = 2.0;
Ax1(1, 0) = 2.0; Ax1(1, 1) = 1.0;
@@ -36,6 +42,9 @@ TEST( ConstrainedLinearFactorGraph, elimination1 )
Vector b2 = Vector_(2, 1.0, 2.0);
ConstrainedConditionalGaussian expectedCCG1(b2, Ax1, "y", Ay1);
CHECK(expectedCCG1.equals(*(cbn->get("x"))));
+
+ // verify remaining factor on y
+ // Gaussian factor on X becomes different Gaussian factor on Y
Matrix Ap(2,2);
Ap(0, 0) = 1.0; Ap(0, 1) = -2.0;
Ap(1, 0) = -2.0; Ap(1, 1) = 1.0;
@@ -48,12 +57,14 @@ TEST( ConstrainedLinearFactorGraph, elimination1 )
Ordering ord2;
ord2.push_back("y");
cbn = fg.eliminate(ord2);
+
+ // Check result
CHECK(fg.size() == 0);
- Matrix Ar(2,2);
- Ar(0, 0) = 74.5356; Ar(0, 1) = -59.6285;
- Ar(1, 0) = 0.0; Ar(1, 1) = 44.7214;
+ Matrix R(2,2);
+ R(0, 0) = 74.5356; R(0, 1) = -59.6285;
+ R(1, 0) = 0.0; R(1, 1) = 44.7214;
Vector br = Vector_(2, 8.9443, 4.4721);
- ConditionalGaussian expected2(br, Ar);
+ ConditionalGaussian expected2(br, R);
CHECK(expected2.equals(*(cbn->get("y"))));
}