58 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C++
		
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C++
		
	
	
/**
 | 
						|
 * @file    Factor.h
 | 
						|
 * @brief   A simple factor class to use in a factor graph
 | 
						|
 * @brief   factor
 | 
						|
 * @author  Kai Ni
 | 
						|
 * @author  Frank Dellaert
 | 
						|
 */
 | 
						|
 | 
						|
// \callgraph
 | 
						|
 | 
						|
#pragma once
 | 
						|
 | 
						|
#include <list>
 | 
						|
#include <boost/utility.hpp> // for noncopyable
 | 
						|
#include <gtsam/base/Testable.h>
 | 
						|
#include <gtsam/inference/Key.h>
 | 
						|
#include <gtsam/inference/SymbolMap.h>
 | 
						|
 | 
						|
namespace gtsam {
 | 
						|
 | 
						|
  /** 
 | 
						|
   * A simple factor class to use in a factor graph.
 | 
						|
   *
 | 
						|
   * We make it noncopyable so we enforce the fact that factors are
 | 
						|
   * kept in pointer containers. To be safe, you should make them
 | 
						|
   * immutable, i.e., practicing functional programming. However, this
 | 
						|
   * conflicts with efficiency as well, esp. in the case of incomplete
 | 
						|
   * QR factorization. A solution is still being sought.
 | 
						|
   * 
 | 
						|
   * A Factor is templated on a Config, for example VectorConfig is a configuration of
 | 
						|
   * labeled vectors. This way, we can have factors that might be defined on discrete
 | 
						|
   * variables, continuous ones, or a combination of both. It is up to the config to 
 | 
						|
   * provide the appropriate values at the appropriate time.
 | 
						|
   */ 
 | 
						|
  template <class Config>
 | 
						|
  class Factor : public Testable< Factor<Config> >
 | 
						|
  {
 | 
						|
  public:
 | 
						|
 | 
						|
    virtual ~Factor() {};
 | 
						|
		
 | 
						|
    /**
 | 
						|
     * negative log probability 
 | 
						|
     */
 | 
						|
    virtual double error(const Config& c) const = 0;
 | 
						|
 | 
						|
    /**
 | 
						|
     * return keys in preferred order
 | 
						|
     */
 | 
						|
    virtual std::list<Symbol> keys() const = 0;
 | 
						|
		
 | 
						|
    /** 
 | 
						|
     * @return the number of nodes the factor connects
 | 
						|
     */
 | 
						|
    virtual std::size_t size() const = 0;
 | 
						|
  };
 | 
						|
}
 |