From 83abb4c6ed1b68f290b4f1c770939af0f90150fa Mon Sep 17 00:00:00 2001 From: dellaert Date: Sun, 23 Nov 2014 18:04:54 +0100 Subject: [PATCH] unit test with manual Fourier --- .cproject | 106 ++++++++++-------- .../tests/testBasisDecompositions.cpp | 64 +++++++++++ 2 files changed, 126 insertions(+), 44 deletions(-) create mode 100644 gtsam_unstable/nonlinear/tests/testBasisDecompositions.cpp diff --git a/.cproject b/.cproject index b3709d422..1dcc51dfe 100644 --- a/.cproject +++ b/.cproject @@ -592,6 +592,7 @@ make + tests/testBayesTree.run true false @@ -599,6 +600,7 @@ make + testBinaryBayesNet.run true false @@ -646,6 +648,7 @@ make + testSymbolicBayesNet.run true false @@ -653,6 +656,7 @@ make + tests/testSymbolicFactor.run true false @@ -660,6 +664,7 @@ make + testSymbolicFactorGraph.run true false @@ -675,6 +680,7 @@ make + tests/testBayesTree true false @@ -1122,6 +1128,7 @@ make + testErrors.run true false @@ -1351,6 +1358,46 @@ true true + + make + -j5 + testBTree.run + true + true + true + + + make + -j5 + testDSF.run + true + true + true + + + make + -j5 + testDSFMap.run + true + true + true + + + make + -j5 + testDSFVector.run + true + true + true + + + make + -j5 + testFixedVector.run + true + true + true + make -j2 @@ -1433,7 +1480,6 @@ make - testSimulated2DOriented.run true false @@ -1473,7 +1519,6 @@ make - testSimulated2D.run true false @@ -1481,7 +1526,6 @@ make - testSimulated3D.run true false @@ -1495,46 +1539,6 @@ true true - - make - -j5 - testBTree.run - true - true - true - - - make - -j5 - testDSF.run - true - true - true - - - make - -j5 - testDSFMap.run - true - true - true - - - make - -j5 - testDSFVector.run - true - true - true - - - make - -j5 - testFixedVector.run - true - true - true - make -j5 @@ -1792,6 +1796,7 @@ cpack + -G DEB true false @@ -1799,6 +1804,7 @@ cpack + -G RPM true false @@ -1806,6 +1812,7 @@ cpack + -G TGZ true false @@ -1813,6 +1820,7 @@ cpack + --config CPackSourceConfig.cmake true false @@ -2627,6 +2635,7 @@ make + testGraph.run true false @@ -2634,6 +2643,7 @@ make + testJunctionTree.run true false @@ -2641,6 +2651,7 @@ make + testSymbolicBayesNetB.run true false @@ -2758,6 +2769,14 @@ true true + + make + -j4 + testBasisDecompositions.run + true + true + true + make -j2 @@ -3168,7 +3187,6 @@ make - tests/testGaussianISAM2 true false diff --git a/gtsam_unstable/nonlinear/tests/testBasisDecompositions.cpp b/gtsam_unstable/nonlinear/tests/testBasisDecompositions.cpp new file mode 100644 index 000000000..db6023629 --- /dev/null +++ b/gtsam_unstable/nonlinear/tests/testBasisDecompositions.cpp @@ -0,0 +1,64 @@ +/* ---------------------------------------------------------------------------- + + * GTSAM Copyright 2010, Georgia Tech Research Corporation, + * Atlanta, Georgia 30332-0415 + * All Rights Reserved + * Authors: Frank Dellaert, et al. (see THANKS for the full author list) + + * See LICENSE for the license information + + * -------------------------------------------------------------------------- */ + +/** + * @file testBasisDecompositions.cpp + * @date November 23, 2014 + * @author Frank Dellaert + * @brief unit tests for Basis Decompositions w Expressions + */ + +#include +#include +#include +#include +#include + +#include + +#include +using boost::assign::list_of; + +using namespace std; +using namespace gtsam; + +noiseModel::Diagonal::shared_ptr model = noiseModel::Unit::Create(1); + +//****************************************************************************** +TEST(BasisDecompositions, Fourier) { + + // Create linear factor graph + GaussianFactorGraph g; + Key key(1); + for (size_t i = 0; i < 16; i++) { + double x = i * M_PI / 8, y = exp(sin(x) + cos(x)); + Matrix A(1, 3); + A << 1, cos(x), sin(x); + Vector b(1); + b << y; + g.add(key, A, b, model); + } + + // Solve + VectorValues actual = g.optimize(); + + // Check + Vector3 expected(1.5661, 1.2717, 1.2717); + CHECK(assert_equal((Vector) expected, actual.at(key),1e-4)); +} + +//****************************************************************************** +int main() { + TestResult tr; + return TestRegistry::runAllTests(tr); +} +//****************************************************************************** +