subtraction
							parent
							
								
									b4e65e9631
								
							
						
					
					
						commit
						bf85f10de7
					
				| 
						 | 
				
			
			@ -6,6 +6,7 @@
 | 
			
		|||
 * @author  Christian Potthast
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <boost/bind.hpp>
 | 
			
		||||
#include <boost/foreach.hpp>
 | 
			
		||||
#include "Errors.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -30,8 +31,21 @@ struct equalsVector : public std::binary_function<const Vector&, const Vector&,
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
bool Errors::equals(const Errors& expected, double tol) const {
 | 
			
		||||
  if( size() != expected.size() ) return false;
 | 
			
		||||
  return equal(begin(),end(),expected.begin(),equalsVector(tol));
 | 
			
		||||
	if( size() != expected.size() ) return false;
 | 
			
		||||
	return equal(begin(),end(),expected.begin(),equalsVector(tol));
 | 
			
		||||
	// TODO: use boost::bind(&equal_with_abs_tol,_1, _2,tol)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* ************************************************************************* */
 | 
			
		||||
Errors Errors::operator-(const Errors& b) const {
 | 
			
		||||
	size_t m = size();
 | 
			
		||||
  if (b.size()!=m)
 | 
			
		||||
    throw(std::invalid_argument("Errors::operator-: incompatible sizes"));
 | 
			
		||||
	Errors result;
 | 
			
		||||
	Errors::const_iterator it = b.begin();
 | 
			
		||||
  BOOST_FOREACH(const Vector& ai, *this)
 | 
			
		||||
		result.push_back(ai - *(it++));
 | 
			
		||||
	return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* ************************************************************************* */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,6 +26,9 @@ namespace gtsam {
 | 
			
		|||
    /** equals, for unit testing */
 | 
			
		||||
    bool equals(const Errors& expected, double tol=1e-9) const;
 | 
			
		||||
 | 
			
		||||
    /** subtraction */
 | 
			
		||||
    Errors operator-(const Errors& b) const;
 | 
			
		||||
 | 
			
		||||
  }; // Errors
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue