#include #include // Quantizes the signal x of size n with nq quantized values // Returns the quantized signal of x // See quantlm_idx to get the indexed quantifier for each values of x void quantlm(double* x,int n,int nq) { // q is the centroid // qi a i that x[i] is associated to qi // qn is the number of x associated to qi double* q=(double *)calloc(nq,sizeof(double)); int* qi=(int *)calloc(n,sizeof(int)); int* qn=(int *)calloc(nq,sizeof(int)); double dmean=0.0; // Uniform initialization of the centroids double xmin=x[0]; double xmax=x[0]; for (int i=0;ix[i]) xmin=x[i]; if (xmaxqn[bigq]) bigq=j; } q[i]=q[bigq]+0.00001; running=false; } } } //for (int i=0;ix[i]) xmin=x[i]; if (xmaxqn[bigq]) bigq=j; } q[i]=q[bigq]+0.00001; running=false; } } } //for (int i=0;i