| 
									
										
										
										
											2010-10-14 12:54:38 +08:00
										 |  |  | /* ----------------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * 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 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * -------------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-14 11:23:14 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * @file iterative.cpp | 
					
						
							| 
									
										
										
										
											2009-12-28 17:56:58 +08:00
										 |  |  |  * @brief Iterative methods, implementation | 
					
						
							|  |  |  |  * @author Frank Dellaert | 
					
						
							| 
									
										
										
										
											2011-10-14 11:23:14 +08:00
										 |  |  |  * @date Dec 28, 2009 | 
					
						
							| 
									
										
										
										
											2009-12-28 17:56:58 +08:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-04 04:45:00 +08:00
										 |  |  | #include <gtsam_unstable/linear/iterative-inl.h>
 | 
					
						
							| 
									
										
										
										
											2010-08-20 01:23:19 +08:00
										 |  |  | #include <gtsam/base/Vector.h>
 | 
					
						
							|  |  |  | #include <gtsam/base/Matrix.h>
 | 
					
						
							| 
									
										
										
										
											2012-06-07 10:11:16 +08:00
										 |  |  | #include <gtsam/linear/JacobianFactorGraph.h>
 | 
					
						
							| 
									
										
										
										
											2012-06-09 00:45:16 +08:00
										 |  |  | #include <gtsam/linear/IterativeSolver.h>
 | 
					
						
							| 
									
										
										
										
											2012-06-04 04:45:00 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <iostream>
 | 
					
						
							| 
									
										
										
										
											2009-12-28 17:56:58 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | using namespace std; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace gtsam { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-11 16:32:59 +08:00
										 |  |  | 	/* ************************************************************************* */ | 
					
						
							|  |  |  | 	void System::print (const string& s) const { | 
					
						
							|  |  |  | 		cout << s << endl; | 
					
						
							|  |  |  | 		gtsam::print(A_, "A"); | 
					
						
							|  |  |  | 		gtsam::print(b_, "b"); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-28 17:56:58 +08:00
										 |  |  | 	/* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2010-10-25 13:29:52 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-09 00:45:16 +08:00
										 |  |  | 	Vector steepestDescent(const System& Ab, const Vector& x, const ConjugateGradientParameters & parameters) { | 
					
						
							| 
									
										
										
										
											2010-10-25 13:29:52 +08:00
										 |  |  | 		return conjugateGradients<System, Vector, Vector> (Ab, x, parameters, true); | 
					
						
							| 
									
										
										
										
											2009-12-28 20:37:34 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-09 00:45:16 +08:00
										 |  |  | 	Vector conjugateGradientDescent(const System& Ab, const Vector& x, const ConjugateGradientParameters & parameters) { | 
					
						
							| 
									
										
										
										
											2010-10-25 13:29:52 +08:00
										 |  |  | 		return conjugateGradients<System, Vector, Vector> (Ab, x, parameters); | 
					
						
							| 
									
										
										
										
											2009-12-28 17:56:58 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2012-06-09 00:45:16 +08:00
										 |  |  | 	Vector steepestDescent(const Matrix& A, const Vector& b, const Vector& x, const ConjugateGradientParameters & parameters) { | 
					
						
							| 
									
										
										
										
											2009-12-29 01:28:48 +08:00
										 |  |  | 		System Ab(A, b); | 
					
						
							| 
									
										
										
										
											2010-10-25 13:29:52 +08:00
										 |  |  | 		return conjugateGradients<System, Vector, Vector> (Ab, x, parameters, true); | 
					
						
							| 
									
										
										
										
											2009-12-28 20:37:34 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-09 00:45:16 +08:00
										 |  |  | 	Vector conjugateGradientDescent(const Matrix& A, const Vector& b, const Vector& x, const ConjugateGradientParameters & parameters) { | 
					
						
							| 
									
										
										
										
											2009-12-29 01:28:48 +08:00
										 |  |  | 		System Ab(A, b); | 
					
						
							| 
									
										
										
										
											2010-10-25 13:29:52 +08:00
										 |  |  | 		return conjugateGradients<System, Vector, Vector> (Ab, x, parameters); | 
					
						
							| 
									
										
										
										
											2009-12-28 17:56:58 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2012-06-09 00:45:16 +08:00
										 |  |  | 	VectorValues steepestDescent(const FactorGraph<JacobianFactor>& fg, const VectorValues& x, const ConjugateGradientParameters & parameters) { | 
					
						
							| 
									
										
										
										
											2011-02-19 06:10:21 +08:00
										 |  |  | 		return conjugateGradients<FactorGraph<JacobianFactor>, VectorValues, Errors> (fg, x, parameters, true); | 
					
						
							| 
									
										
										
										
											2009-12-28 20:37:34 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-09 00:45:16 +08:00
										 |  |  | 	VectorValues conjugateGradientDescent(const FactorGraph<JacobianFactor>& fg, const VectorValues& x, const ConjugateGradientParameters & parameters) { | 
					
						
							| 
									
										
										
										
											2011-02-19 06:10:21 +08:00
										 |  |  | 		return conjugateGradients<FactorGraph<JacobianFactor>, VectorValues, Errors> (fg, x, parameters); | 
					
						
							| 
									
										
										
										
											2009-12-28 17:56:58 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-31 20:55:16 +08:00
										 |  |  | 	/* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-12-28 17:56:58 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | } // namespace gtsam
 |