21 #ifndef mia_core_nccsum_hh 22 #define mia_core_nccsum_hh 28 #include <emmintrin.h> 36 m_sumab_by_a2b2(0.0), m_sumab_by_suma2(0.0),
37 m_mean_a(0.0), m_mean_b(0.0)
41 NCCGradHelper(
double sumab_by_a2b2,
double sumab_by_suma2,
double mean_a,
double mean_b):
42 m_sumab_by_a2b2(2.0 * sumab_by_a2b2), m_sumab_by_suma2(sumab_by_suma2),
43 m_mean_a(mean_a), m_mean_b(mean_b)
48 return m_sumab_by_a2b2 * ( m_sumab_by_suma2 * ( a - m_mean_a ) - (b - m_mean_b));
53 double m_sumab_by_a2b2;
54 double m_sumab_by_suma2;
63 typedef double v2df __attribute__ ((vector_size (16)));
65 NCCSums():m_sumab(0.0), m_n(0.0) {
66 double zero[2] = {0.0, 0.0};
67 m_sum = _mm_loadu_pd(zero);
71 void add(
double a,
double b) {
72 v2df val = {
static_cast<double>(a), static_cast<double>(b)};
82 m_sum2 += other.m_sum2;
83 m_sumab += other.m_sumab;
88 bool has_samples()
const {
94 std::pair<double, NCCGradHelper> get_grad_helper()
const;
109 m_suma2(0.0), m_sumb2(0.0),
110 m_sumab(0.0), m_n(0.0) {
113 void add(
double a,
double b) {
123 m_suma += other.m_suma;
124 m_sumb += other.m_sumb;
125 m_suma2 += other.m_suma2;
126 m_sumb2 += other.m_sumb2;
127 m_sumab += other.m_sumab;
132 double value()
const;
134 std::pair<double, NCCGradHelper> get_grad_helper()
const;
153 inline NCCSums
operator + (
const NCCSums& lhs,
const NCCSums& rhs)
NCCSums operator+(const NCCSums &lhs, const NCCSums &rhs)
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
EXPORT_2D C2DFVectorfield & operator+=(C2DFVectorfield &a, const C2DFVectorfield &b)
float get_gradient_scale(double a, double b) const
void add(double a, double b)
NCCGradHelper(double sumab_by_a2b2, double sumab_by_suma2, double mean_a, double mean_b)
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
#define NS_MIA_END
conveniance define to end the mia namespace