gtsam  3.2.1
gtsam
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GaussianBayesTree-inl.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
20 #pragma once
21 
22 #include <boost/foreach.hpp>
23 
24 #include <gtsam/linear/GaussianBayesTree.h> // Only to help Eclipse
25 
26 #include <stdarg.h>
27 
28 namespace gtsam {
29 
30 /* ************************************************************************* */
31 namespace internal {
32 template<class BAYESTREE>
33 void optimizeInPlace(const typename BAYESTREE::sharedClique& clique, VectorValues& result) {
34  // parents are assumed to already be solved and available in result
35  clique->conditional()->solveInPlace(result);
36 
37  // starting from the root, call optimize on each conditional
38  BOOST_FOREACH(const typename BAYESTREE::sharedClique& child, clique->children_)
39  optimizeInPlace<BAYESTREE>(child, result);
40 }
41 
42 /* ************************************************************************* */
43 template<class BAYESTREE>
44 double logDeterminant(const typename BAYESTREE::sharedClique& clique) {
45  double result = 0.0;
46 
47  // this clique
48  result += clique->conditional()->get_R().diagonal().unaryExpr(std::ptr_fun<double,double>(log)).sum();
49 
50  // sum of children
51  BOOST_FOREACH(const typename BAYESTREE::sharedClique& child, clique->children_)
52  result += logDeterminant<BAYESTREE>(child);
53 
54  return result;
55 }
56 
57 /* ************************************************************************* */
58 } // \namespace internal
59 } // \namespace gtsam
Gaussian Bayes Tree, the result of eliminating a GaussianJunctionTree.