| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2009-11-01 03:53:20 +08:00
										 |  |  |  * @file    GaussianBayesNet.h | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  |  * @brief   Chordal Bayes Net, the result of eliminating a factor graph | 
					
						
							| 
									
										
										
										
											2009-11-01 03:53:20 +08:00
										 |  |  |  * @brief   GaussianBayesNet | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  |  * @author  Frank Dellaert | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // \callgraph
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <list>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-13 00:41:18 +08:00
										 |  |  | #include "GaussianConditional.h"
 | 
					
						
							| 
									
										
										
										
											2009-11-01 03:53:20 +08:00
										 |  |  | #include "BayesNet.h"
 | 
					
						
							| 
									
										
										
										
											2010-01-18 03:34:57 +08:00
										 |  |  | #include "Key.h"
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace gtsam { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-09 15:04:26 +08:00
										 |  |  | 	/** A Bayes net made from linear-Gaussian densities */ | 
					
						
							| 
									
										
										
										
											2009-11-13 00:41:18 +08:00
										 |  |  | 	typedef BayesNet<GaussianConditional> GaussianBayesNet; | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-09 06:50:26 +08:00
										 |  |  | 	/** Create a scalar Gaussian */ | 
					
						
							| 
									
										
										
										
											2010-01-18 03:34:57 +08:00
										 |  |  | 	GaussianBayesNet scalarGaussian(const Symbol& key, double mu=0.0, double sigma=1.0); | 
					
						
							| 
									
										
										
										
											2009-11-09 06:50:26 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/** Create a simple Gaussian on a single multivariate variable */ | 
					
						
							| 
									
										
										
										
											2010-01-18 03:34:57 +08:00
										 |  |  | 	GaussianBayesNet simpleGaussian(const Symbol& key, const Vector& mu, double sigma=1.0); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-12 14:09:03 +08:00
										 |  |  | 	/**
 | 
					
						
							|  |  |  | 	 * Add a conditional node with one parent | 
					
						
							|  |  |  | 	 * |Rx+Sy-d| | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2010-01-18 03:34:57 +08:00
										 |  |  | 	void push_front(GaussianBayesNet& bn, const Symbol& key, Vector d, Matrix R, | 
					
						
							|  |  |  | 			const Symbol& name1, Matrix S, Vector sigmas); | 
					
						
							| 
									
										
										
										
											2009-11-12 14:09:03 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/**
 | 
					
						
							|  |  |  | 	 * Add a conditional node with two parents | 
					
						
							|  |  |  | 	 * |Rx+Sy+Tz-d| | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2010-01-18 03:34:57 +08:00
										 |  |  | 	void push_front(GaussianBayesNet& bn, const Symbol& key, Vector d, Matrix R, | 
					
						
							|  |  |  | 			const Symbol& name1, Matrix S, const Symbol& name2, Matrix T, Vector sigmas); | 
					
						
							| 
									
										
										
										
											2009-11-12 14:09:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-27 22:14:36 +08:00
										 |  |  | 	/**
 | 
					
						
							|  |  |  | 	 * optimize, i.e. return x = inv(R)*d | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2009-11-09 15:04:26 +08:00
										 |  |  | 	VectorConfig optimize(const GaussianBayesNet&); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-19 18:46:12 +08:00
										 |  |  | 	/**
 | 
					
						
							|  |  |  | 	 * shared pointer version | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	boost::shared_ptr<VectorConfig> optimize_(const GaussianBayesNet& bn); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-31 01:13:24 +08:00
										 |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * Backsubstitute | 
					
						
							|  |  |  | 	 * (R*x)./sigmas = y by solving x=inv(R)*(y.*sigmas) | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	VectorConfig backSubstitute(const GaussianBayesNet& bn, const VectorConfig& y); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-31 12:39:41 +08:00
										 |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * Backsubstitute in place, y is replaced with solution | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	void backSubstituteInPlace(const GaussianBayesNet& bn, VectorConfig& y); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-31 01:13:24 +08:00
										 |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * Transpose Backsubstitute | 
					
						
							|  |  |  | 	 * gy=inv(L)*gx by solving L*gy=gx. | 
					
						
							|  |  |  | 	 * gy=inv(R'*inv(Sigma))*gx | 
					
						
							|  |  |  | 	 * gz'*R'=gx', gy = gz.*sigmas | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	VectorConfig backSubstituteTranspose(const GaussianBayesNet& bn, const VectorConfig& gx); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 	/**
 | 
					
						
							|  |  |  | 	 * Return (dense) upper-triangular matrix representation | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2009-11-09 15:04:26 +08:00
										 |  |  | 	std::pair<Matrix, Vector> matrix(const GaussianBayesNet&); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | } /// namespace gtsam
 |