18#include <yarp/math/Math.h>
19#include <yarp/math/SVD.h>
23using namespace yarp::sig;
24using namespace yarp::math;
46 int d=(int)points.front().length();
47 int N=(int)points.size();
49 Matrix U(N,N); U.diagonal(u);
51 for (
int row=0; row<Q.rows(); row++)
52 for (
int col=0; col<Q.cols(); col++)
53 Q(row,col)=points[col][row];
54 for (
int col=0; col<Q.cols(); col++)
55 Q(Q.rows()-1,col)=1.0;
56 Matrix Qt=Q.transposed();
63 int j=0;
double max=M(j,j);
64 for (
int row=1; row<M.rows(); row++)
72 double step_size=(
max-d-1.0)/((d+1.0)*(
max-1.0));
73 Vector new_u=(1.0-step_size)*u;
75 if (
norm(new_u-u)<tol)
82 Matrix P=Q.removeRows(Q.rows()-1,1);
84 Matrix C(c.length(),c.length());
85 for (
int col=0; col<C.cols(); col++)
86 C.setCol(col,c[col]*c);
87 A=(1.0/d)*pinv(P*U*P.transposed()-C);
bool minVolumeEllipsoid(const std::deque< yarp::sig::Vector > &points, const double tol, yarp::sig::Matrix &A, yarp::sig::Vector &c)
Find the minimum volume ellipsoide (MVEE) of a set of N d-dimensional data points.
double norm(const yarp::sig::Matrix &M, int col)
Returns the norm of the vector given in the form: matrix(:,col).