| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | %----------------------------------------------------------------------- | 
					
						
							|  |  |  | % eliminate | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | % the combined linear factor | 
					
						
							|  |  |  | Ax2 = [ | 
					
						
							|  |  |  | -5., 0. | 
					
						
							|  |  |  | +0.,-5. | 
					
						
							|  |  |  | 10., 0. | 
					
						
							|  |  |  | +0.,10. | 
					
						
							|  |  |  | ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Al1 = [ | 
					
						
							|  |  |  | 5., 0. | 
					
						
							|  |  |  | 0., 5. | 
					
						
							|  |  |  | 0., 0. | 
					
						
							|  |  |  | 0., 0. | 
					
						
							|  |  |  | ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Ax1 = [ | 
					
						
							|  |  |  | 0.00,  0. % f4 | 
					
						
							|  |  |  | 0.00,  0. % f4 | 
					
						
							|  |  |  | -10.,  0. % f2 | 
					
						
							|  |  |  | 0.00,-10. % f2 | 
					
						
							|  |  |  | ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | % the RHS | 
					
						
							|  |  |  | b2=[-1;1.5;2;-1]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-13 00:16:32 +08:00
										 |  |  | combined = GaussianFactor('x2', Ax2,  'l1', Al1, 'x1', Ax1, b2, 1); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | % eliminate the combined factor | 
					
						
							|  |  |  | % NOT WORKING | 
					
						
							|  |  |  | % this is not working because there is no elimination function for a linear | 
					
						
							| 
									
										
										
										
											2009-11-13 00:16:32 +08:00
										 |  |  | % factor. Just for the MutableGaussianFactor | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | %[actualCG,actualLF] = combined.eliminate('x2'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | % create expected Conditional Gaussian | 
					
						
							|  |  |  | R11 = [ | 
					
						
							|  |  |  | 11.1803,  0.00 | 
					
						
							|  |  |  | 0.00, 11.1803 | 
					
						
							|  |  |  | ]; | 
					
						
							|  |  |  | S12 = [ | 
					
						
							|  |  |  | -2.23607, 0.00 | 
					
						
							|  |  |  | +0.00,-2.23607 | 
					
						
							|  |  |  | ]; | 
					
						
							|  |  |  | S13 = [ | 
					
						
							|  |  |  | -8.94427, 0.00 | 
					
						
							|  |  |  | +0.00,-8.94427 | 
					
						
							|  |  |  | ]; | 
					
						
							|  |  |  | d=[2.23607;-1.56525]; | 
					
						
							| 
									
										
										
										
											2009-11-11 15:14:13 +08:00
										 |  |  | expectedCG = ConditionalGaussian('x2',d,R11,'l1',S12,'x1',S13,[1 1]'); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | % the expected linear factor | 
					
						
							|  |  |  | Bl1 = [ | 
					
						
							|  |  |  | 4.47214, 0.00 | 
					
						
							|  |  |  | 0.00, 4.47214 | 
					
						
							|  |  |  | ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Bx1 = [ | 
					
						
							|  |  |  | % x1 | 
					
						
							|  |  |  | -4.47214,  0.00 | 
					
						
							|  |  |  | +0.00, -4.47214 | 
					
						
							|  |  |  | ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | % the RHS | 
					
						
							|  |  |  | b1= [0.0;0.894427]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-13 00:16:32 +08:00
										 |  |  | expectedLF = GaussianFactor('l1', Bl1, 'x1', Bx1, b1, 1); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | % check if the result matches | 
					
						
							|  |  |  | % NOT WORKING  | 
					
						
							| 
									
										
										
										
											2009-11-13 00:16:32 +08:00
										 |  |  | % because can not be computed with GaussianFactor.eliminate | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | %if(~actualCG.equals(expectedCG)), warning('GTSAM:unit','~actualCG.equals(expectedCG)'); end | 
					
						
							|  |  |  | %if(~actualLF.equals(expectedLF,1e-5)), warning('GTSAM:unit','~actualLF.equals(expectedLF,1e-5)');end |