new scaledProduct method instead of DiscreteProduct
							parent
							
								
									90825b96af
								
							
						
					
					
						commit
						82dba6322f
					
				|  | @ -124,11 +124,10 @@ namespace gtsam { | |||
|    * @param factors The factors to multiply as a DiscreteFactorGraph. | ||||
|    * @return DiscreteFactor::shared_ptr | ||||
|    */ | ||||
|   static DiscreteFactor::shared_ptr DiscreteProduct( | ||||
|       const DiscreteFactorGraph& factors) { | ||||
|   DiscreteFactor::shared_ptr DiscreteFactorGraph::scaledProduct() const { | ||||
|     // PRODUCT: multiply all factors
 | ||||
|     gttic(product); | ||||
|     DiscreteFactor::shared_ptr product = factors.product(); | ||||
|     DiscreteFactor::shared_ptr product = this->product(); | ||||
|     gttoc(product); | ||||
| 
 | ||||
|     // Max over all the potentials by pretending all keys are frontal:
 | ||||
|  | @ -145,7 +144,7 @@ namespace gtsam { | |||
|   std::pair<DiscreteConditional::shared_ptr, DiscreteFactor::shared_ptr>  //
 | ||||
|   EliminateForMPE(const DiscreteFactorGraph& factors, | ||||
|                   const Ordering& frontalKeys) { | ||||
|     DiscreteFactor::shared_ptr product = DiscreteProduct(factors); | ||||
|     DiscreteFactor::shared_ptr product = factors.scaledProduct(); | ||||
| 
 | ||||
|     // max out frontals, this is the factor on the separator
 | ||||
|     gttic(max); | ||||
|  | @ -223,7 +222,7 @@ namespace gtsam { | |||
|   std::pair<DiscreteConditional::shared_ptr, DiscreteFactor::shared_ptr>  //
 | ||||
|   EliminateDiscrete(const DiscreteFactorGraph& factors, | ||||
|                     const Ordering& frontalKeys) { | ||||
|     DiscreteFactor::shared_ptr product = DiscreteProduct(factors); | ||||
|     DiscreteFactor::shared_ptr product = factors.scaledProduct(); | ||||
| 
 | ||||
|     // sum out frontals, this is the factor on the separator
 | ||||
|     gttic(sum); | ||||
|  |  | |||
|  | @ -150,6 +150,11 @@ class GTSAM_EXPORT DiscreteFactorGraph | |||
|   /** return product of all factors as a single factor */ | ||||
|   DiscreteFactor::shared_ptr product() const; | ||||
| 
 | ||||
|   /** Return product of all factors as a single factor,
 | ||||
|    * which is scaled by the max to prevent underflow | ||||
|    */ | ||||
|   DiscreteFactor::shared_ptr scaledProduct() const; | ||||
| 
 | ||||
|   /** 
 | ||||
|    * Evaluates the factor graph given values, returns the joint probability of | ||||
|    * the factor graph given specific instantiation of values | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue