Commit 859b763b authored by Edwin Carlinet's avatar Edwin Carlinet
Browse files

Fixes in covariance and cvxhull accumulators. Cvxhull is now

optimized and does not put inner-line points in the point set.

      *  mln/accu/accumulators/covariance.hpp: Sumtype/SumSqrType is
         the underlying scalar type, not the sum vector type.
      *  mln/accu/accumulators/cvxhull.hpp: Add missing 'make()'
         generators in cvxhull feature. Optimzation: inner-line points
         are not put in the cvxhull candidate points.
parent 0b32a28f
......@@ -21,7 +21,7 @@ namespace mln
/// V(X) = E(\norm X - E(X) \norm_2^2)
/// \f]
template <typename T,
typename SumType = typename boost::promote<T>::type,
typename SumType = typename boost::promote<typename T::value_type>::type,
typename SumSqrType = SumType>
struct covariance;
}
......@@ -157,7 +157,6 @@ namespace mln
return result_type::Zero();
double n = accu.m_count;
std::cout << accu.m_sum / n << std::endl;
result_type COV;
for (int i = 0; i < ndim; ++i)
for (int j = i; j < ndim; ++j)
......
......@@ -27,6 +27,14 @@ namespace mln
{
typedef accumulators::cvxhull<P> type;
};
template <typename P>
accumulators::cvxhull<P>
make() const
{
return accumulators::cvxhull<P> ();
}
};
struct pvector : simple_feature<pvector>
......@@ -36,6 +44,13 @@ namespace mln
{
typedef accumulators::cvxhull<P> type;
};
template <typename P>
accumulators::cvxhull<P>
make() const
{
return accumulators::cvxhull<P> ();
}
};
}
......@@ -80,12 +95,26 @@ namespace mln
void init()
{
m_points.clear();
m_newline = true;
}
void take(const P& p)
{
mln_precondition(m_points.empty() || m_points.back() < p);
m_points.push_back(p);
if (m_points.empty() or m_points.back()[0] != p[0])
{
m_points.push_back(p);
m_newline = true;
}
else if (m_newline)
{
m_points.push_back(p);
m_newline = false;
}
else
{
m_points.back() = p;
}
}
template <typename A>
......@@ -114,6 +143,7 @@ namespace mln
private:
std::vector<P> m_points;
bool m_newline;
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment