Add alternativeName()
							parent
							
								
									29e2339af8
								
							
						
					
					
						commit
						7aab3796b0
					
				| 
						 | 
				
			
			@ -162,6 +162,12 @@ inline Key W(std::uint64_t j) { return Symbol('w', j); }
 | 
			
		|||
inline Key X(std::uint64_t j) { return Symbol('x', j); }
 | 
			
		||||
inline Key Y(std::uint64_t j) { return Symbol('y', j); }
 | 
			
		||||
inline Key Z(std::uint64_t j) { return Symbol('z', j); }
 | 
			
		||||
 | 
			
		||||
/** Generates symbol shorthands with alternative names different than the
 | 
			
		||||
 * one-letter predefined ones. */
 | 
			
		||||
inline std::function<Key(std::uint64_t)> alternativeName(const char c) {
 | 
			
		||||
	return [c](std::uint64_t j) { return gtsam::Symbol(c, j); };
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// traits
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,6 +40,25 @@ TEST(Key, KeySymbolConversion) {
 | 
			
		|||
  EXPECT(assert_equal(original, actual))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* ************************************************************************* */
 | 
			
		||||
TEST(Key, SymbolAlternativeNames) {
 | 
			
		||||
  const auto x1 = gtsam::symbol_shorthand::X(1);
 | 
			
		||||
  const auto v1 = gtsam::symbol_shorthand::V(1);
 | 
			
		||||
  const auto a1 = gtsam::symbol_shorthand::A(1);
 | 
			
		||||
 | 
			
		||||
  const auto Z = gtsam::symbol_shorthand::alternativeName('x');
 | 
			
		||||
  const auto DZ = gtsam::symbol_shorthand::alternativeName('v');
 | 
			
		||||
  const auto DDZ = gtsam::symbol_shorthand::alternativeName('a');
 | 
			
		||||
 | 
			
		||||
  const auto z1 = Z(1);
 | 
			
		||||
  const auto dz1 = DZ(1);
 | 
			
		||||
  const auto ddz1 = DDZ(1);
 | 
			
		||||
 | 
			
		||||
  EXPECT(assert_equal(x1, z1));
 | 
			
		||||
  EXPECT(assert_equal(v1, dz1));
 | 
			
		||||
  EXPECT(assert_equal(a1, ddz1));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* ************************************************************************* */
 | 
			
		||||
template<int KeySize>
 | 
			
		||||
Key KeyTestValue();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue