| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * @file    Ordering.h | 
					
						
							|  |  |  |  * @brief   Ordering of indices for eliminating a factor graph | 
					
						
							|  |  |  |  * @author  Frank Dellaert | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-31 23:24:22 +08:00
										 |  |  | #include <list>
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | #include <string>
 | 
					
						
							| 
									
										
										
										
											2009-10-31 23:24:22 +08:00
										 |  |  | #include "Testable.h"
 | 
					
						
							| 
									
										
										
										
											2010-01-18 03:34:57 +08:00
										 |  |  | #include "Key.h"
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace gtsam { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/**
 | 
					
						
							| 
									
										
										
										
											2009-10-07 02:01:40 +08:00
										 |  |  | 	 * @class Ordering | 
					
						
							|  |  |  | 	 * @brief ordering of indices for eliminating a factor graph | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2010-01-18 03:34:57 +08:00
										 |  |  | 	class Ordering: public std::list<Symbol>, public Testable<Ordering> { | 
					
						
							| 
									
										
										
										
											2009-10-07 02:01:40 +08:00
										 |  |  | 	public: | 
					
						
							| 
									
										
										
										
											2010-01-19 03:11:22 +08:00
										 |  |  | 		/** Default constructor creates empty ordering */ | 
					
						
							|  |  |  | 		Ordering() { } | 
					
						
							| 
									
										
										
										
											2009-10-07 02:01:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-19 03:11:22 +08:00
										 |  |  | 		/** Create from a single symbol */ | 
					
						
							|  |  |  | 		Ordering(Symbol key) { push_back(key); } | 
					
						
							| 
									
										
										
										
											2009-11-09 06:51:29 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-19 03:11:22 +08:00
										 |  |  | 		/** Copy constructor */ | 
					
						
							|  |  |  | 		Ordering(const std::list<Symbol>& keys_in) : std::list<Symbol>(keys_in) {} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-04-09 06:16:08 +08:00
										 |  |  | 		/** whether a key exists */ | 
					
						
							|  |  |  | 		bool exists(const Symbol& key) { return std::find(begin(), end(), key) != end(); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-19 03:11:22 +08:00
										 |  |  | 		// Testable
 | 
					
						
							|  |  |  | 		void print(const std::string& s = "Ordering") const; | 
					
						
							|  |  |  | 		bool equals(const Ordering &ord, double tol=0) const; | 
					
						
							| 
									
										
										
										
											2009-10-07 02:01:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-29 02:35:36 +08:00
										 |  |  | 		/**
 | 
					
						
							|  |  |  | 		 * Remove a set of keys from an ordering | 
					
						
							|  |  |  | 		 * @param keys to remove | 
					
						
							|  |  |  | 		 * @return a new ordering without the selected keys | 
					
						
							|  |  |  | 		 */ | 
					
						
							|  |  |  | 		Ordering subtract(const Ordering& keys) const; | 
					
						
							| 
									
										
										
										
											2009-10-07 02:01:40 +08:00
										 |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | } |