Helper method can be static
							parent
							
								
									5b909e3c29
								
							
						
					
					
						commit
						12349b9201
					
				|  | @ -212,16 +212,15 @@ GaussianFactorGraphTree HybridGaussianFactor::asGaussianFactorGraphTree() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* *******************************************************************************/ | /* *******************************************************************************/ | ||||||
| double HybridGaussianFactor::potentiallyPrunedComponentError( | /// Helper method to compute the error of a component.
 | ||||||
|     const sharedFactor &gf, const VectorValues &values) const { | static double PotentiallyPrunedComponentError( | ||||||
|  |     const GaussianFactor::shared_ptr &gf, const VectorValues &values) { | ||||||
|   // Check if valid pointer
 |   // Check if valid pointer
 | ||||||
|   if (gf) { |   if (gf) { | ||||||
|     return gf->error(values); |     return gf->error(values); | ||||||
|   } else { |   } else { | ||||||
|     // If not valid, pointer, it means this component was pruned,
 |     // If nullptr this component was pruned, so we return maximum error. This
 | ||||||
|     // so we return maximum error.
 |     // way the negative exponential will give a probability value close to 0.0.
 | ||||||
|     // This way the negative exponential will give
 |  | ||||||
|     // a probability value close to 0.0.
 |  | ||||||
|     return std::numeric_limits<double>::max(); |     return std::numeric_limits<double>::max(); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | @ -230,8 +229,8 @@ double HybridGaussianFactor::potentiallyPrunedComponentError( | ||||||
| AlgebraicDecisionTree<Key> HybridGaussianFactor::errorTree( | AlgebraicDecisionTree<Key> HybridGaussianFactor::errorTree( | ||||||
|     const VectorValues &continuousValues) const { |     const VectorValues &continuousValues) const { | ||||||
|   // functor to convert from sharedFactor to double error value.
 |   // functor to convert from sharedFactor to double error value.
 | ||||||
|   auto errorFunc = [this, &continuousValues](const sharedFactor &gf) { |   auto errorFunc = [&continuousValues](const sharedFactor &gf) { | ||||||
|     return this->potentiallyPrunedComponentError(gf, continuousValues); |     return PotentiallyPrunedComponentError(gf, continuousValues); | ||||||
|   }; |   }; | ||||||
|   DecisionTree<Key, double> error_tree(factors_, errorFunc); |   DecisionTree<Key, double> error_tree(factors_, errorFunc); | ||||||
|   return error_tree; |   return error_tree; | ||||||
|  | @ -241,7 +240,7 @@ AlgebraicDecisionTree<Key> HybridGaussianFactor::errorTree( | ||||||
| double HybridGaussianFactor::error(const HybridValues &values) const { | double HybridGaussianFactor::error(const HybridValues &values) const { | ||||||
|   // Directly index to get the component, no need to build the whole tree.
 |   // Directly index to get the component, no need to build the whole tree.
 | ||||||
|   const sharedFactor gf = factors_(values.discrete()); |   const sharedFactor gf = factors_(values.discrete()); | ||||||
|   return potentiallyPrunedComponentError(gf, values.continuous()); |   return PotentiallyPrunedComponentError(gf, values.continuous()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| }  // namespace gtsam
 | }  // namespace gtsam
 | ||||||
|  |  | ||||||
|  | @ -189,10 +189,6 @@ class GTSAM_EXPORT HybridGaussianFactor : public HybridFactor { | ||||||
|    */ |    */ | ||||||
|   static Factors augment(const FactorValuePairs &factors); |   static Factors augment(const FactorValuePairs &factors); | ||||||
| 
 | 
 | ||||||
|   /// Helper method to compute the error of a component.
 |  | ||||||
|   double potentiallyPrunedComponentError( |  | ||||||
|       const sharedFactor &gf, const VectorValues &continuousValues) const; |  | ||||||
| 
 |  | ||||||
|   /// Helper struct to assist private constructor below.
 |   /// Helper struct to assist private constructor below.
 | ||||||
|   struct ConstructorHelper; |   struct ConstructorHelper; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue