CMSIS-DSP Cubic Spline Interpolation

Hello.

I try to use  arm_spline_f32  function  in my PC, Qt. The function works, but output is incorrect.

Input/output data:

My realization:

void MainWindow::interpolation(const QVector<double> &t, const QVector<double> &v,
                               QVector<double> &t_inter, QVector<double> &v_inter){
    int n = 4;//t.size();
    int scale = 2;
    float32_t *inpX = (float32_t *)calloc((n-1), sizeof(float32_t));
    float32_t *inpY = (float32_t *)calloc((n-1), sizeof(float32_t));
    float32_t *outX = (float32_t *)calloc(scale*(n-1), sizeof(float32_t));

    float32_t *outY = (float32_t *)calloc(scale*(n-1), sizeof(float32_t));
    float32_t *buf = (float32_t *)calloc((2*n - 1), sizeof(float32_t));
    float32_t *coef = (float32_t *)calloc((3*(n - 1)), sizeof(float32_t));

    arm_spline_instance_f32 S;

    std::cout << "inpX , inpY \n";
    for (int i=0; i<n; i++){
        inpX[i] = t[i+15];
        inpY[i] = v[i+15];

        std::cout << "\tinpX = " << inpX[i] << " inpY = " << inpY[i] << "\n";
    }

    arm_spline_init_f32(&S, ARM_SPLINE_PARABOLIC_RUNOUT, inpX, inpY, n, coef, buf);
    arm_spline_f32(&S, outX, outY, scale);

    std::cout << "outX , outY \n";
    for (int i=0; i<scale*n; i++){
        t_inter.push_back(outX[i]);
        v_inter.push_back(outY[i]);

        std::cout << "\toutX = " << outX[i] << " outY = " << outY[i] << "\n";
    }



    free(inpX);
    free(inpY);
    free(outX);
    free(buf);
    free(coef);
    free(outY);

}

Thanks for any help

Parents Reply Children
No data
More questions in this forum