FIX: C code (double, float, ...) + wrapper (read/write data, get medoids)
[epclust.git] / code / stage1 / src / Algorithm / compute_coefficients.c
index a7a73f3..cfec0e6 100644 (file)
@@ -6,14 +6,14 @@
 
 // compute rows of the matrix of reduced coordinates
 void compute_coefficients(PowerCurve* powerCurves, uint32_t nbSeries, uint32_t nbValues,
-       Real* reducedCoordinates, uint32_t index, uint32_t nbReducedCoordinates)
+       float* reducedCoordinates, uint32_t index, uint32_t nbReducedCoordinates)
 {
        uint32_t D = (1 << nbReducedCoordinates);
-       Real* x = (Real*) malloc(nbValues*sizeof(Real));
+       double* x = (double*) malloc(nbValues*sizeof(double));
        for (uint32_t i=0; i<nbValues; i++)
                x[i] = i;
-       Real* y = (Real*) malloc(nbValues*sizeof(Real));
-       Real* interpolatedTranformedCurve = (Real*) malloc(D*sizeof(Real));
+       double* y = (double*) malloc(nbValues*sizeof(double));
+       double* interpolatedTranformedCurve = (double*) malloc(D*sizeof(double));
        gsl_interp* linearInterpolation = gsl_interp_alloc(gsl_interp_linear, nbValues);
        gsl_interp_accel* acc = gsl_interp_accel_alloc();
        gsl_wavelet_workspace* work = gsl_wavelet_workspace_alloc(D);
@@ -29,7 +29,7 @@ void compute_coefficients(PowerCurve* powerCurves, uint32_t nbSeries, uint32_t n
                for (uint32_t j=0; j<D; j++)
                {
                        interpolatedTranformedCurve[j] = 
-                               gsl_interp_eval(linearInterpolation, x, y, j*((Real)(nbValues-1)/(D-1)), acc);
+                               gsl_interp_eval(linearInterpolation, x, y, j*((float)(nbValues-1)/(D-1)), acc);
                }
                //DWT transform (in place) on interpolated curve [TODO: clarify stride parameter]
                gsl_wavelet_transform_forward(w, interpolatedTranformedCurve, 1, D, work);
@@ -40,7 +40,7 @@ void compute_coefficients(PowerCurve* powerCurves, uint32_t nbSeries, uint32_t n
                {
                        t1 += (1 << j);
                        //reducedCoordinates[(index+i)*nbReducedCoordinates+j] = sqrt( sum( x[t0:t1]^2 ) )
-                       Real sumOnSegment = 0.0;
+                       float sumOnSegment = 0.0;
                        for (uint32_t u=t0; u<t1; u++)
                                sumOnSegment += interpolatedTranformedCurve[u]*interpolatedTranformedCurve[u];
                        reducedCoordinates[(index+i)*nbReducedCoordinates+j] = sqrt(sumOnSegment);