---
title: 示例
description: "```"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_1138.html
sourcePath: /source/zh/kunpenghpcs/hpckit/devg/kunpengaccel_kml_1138.html
indexId: d17087d92ab9e25fad1f8ba681598e0e1769fe2695702f494dddedca825ba05061
---
# 示例

```
#include <stdio.h>
#include <math.h>
#include "kipl.h"

int main()
{
    const int data_n = 11;
    float *data_x = (float *)malloc(data_n * sizeof(float));
    float *data_y = (float *)malloc(data_n * sizeof(float));
    for (int i = 0; i < data_n; i++) {
        data_x[i] = (float)(i) / (data_n - 1);
        data_y[i] = sin(15.0 * data_x[i]);
    }
    int test_n = 2 * data_n - 1;
    float *test_x = （float *）malloc(test_n * sizeof(float));
    float *test_y = （float *）malloc(test_n * sizeof(float));
    for (int i = 0; i < test_n; i++) {
        test_x[i] = (float)(i) / (test_n - 1);
        test_y[i] = sin(15.0 * test_x[i]);
    }
    const int k = 3;
    float *bscoef = (float *)malloc(data_n * sizeof(float));
    float *xknot = (float *)malloc((data_n + k) * sizeof(float));
    int ideriv = 0;
    
    KIPL_Bsnak(data_n, data_x, k, xknot);
    KIPL_Bsint(data_n, data_x, data_y, k, xknot, bscoef);
    
    for (int i = 0; i < test_n; i++) {
        float y, deriv;
        float x = test_x[i];
        y = KIPL_Bsval(x, k, xknot, data_n, bscoef);
        deriv = KIPL_Bsder(ideriv, x, k, xknot, data_n, bscoef);
    }
    free(data_x);
    free(data_y);
    return 0;
}
```
