static float lpc_from_data(float[] data, float[] lpc, int n, int m) {
        float[] aut = new float[m + 1];
        float error;
        int i, j;

        // autocorrelation, p+1 lag coefficients
        j = m + 1;
        while (j-- != 0) {
            float d = 0;
            for (i = j; i < n; i++) {
                d += data[i] * data[i - j];
            }
            aut[j] = d;
        }

        // Generate lpc coefficients from autocorr values
        error = aut[0];
        /*
         if(error==0){
         for(int k=0; k<m; k++) lpc[k]=0.0f;
         return 0;
         }
         */

        for (i = 0; i < m; i++) {
            float r = -aut[i + 1];

            if (error == 0) {
                for (int k = 0; k < m; k++) {
                    lpc[k] = 0.0f;
                }
                return 0;
            }

            // Sum up this iteration's reflection coefficient; note that in
            // Vorbis we don't save it.  If anyone wants to recycle this code
            // and needs reflection coefficients, save the results of 'r' from
            // each iteration.
            for (j = 0; j < i; j++) {
                r -= lpc[j] * aut[i - j];
            }
            r /= error;

            // Update LPC coefficients and total error
            lpc[i] = r;
            for (j = 0; j < i / 2; j++) {
                float tmp = lpc[j];
                lpc[j] += r * lpc[i - 1 - j];
                lpc[i - 1 - j] += r * tmp;
            }
            if (i % 2 != 0) {
                lpc[j] += lpc[j] * r;
            }

            error *= 1.0 - r * r;
        }

        // we need the error value to know how big an impulse to hit the
        // filter with later
        return error;
    }