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

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

int main()
{
    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[test_n];
    float test_y[test_n];
    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]);
    }
    float b[data_n], cscoef[4 * data_n];
    KIPL_Csint(data_n, data_x, data_y, cscoef);

    int nintv = data_n - 1;
    for (int i = 0; i < test_n; i++) {
        float y;
        float x = test_x[i];
        y = KIPL_Csval(x, nintv, data_x, cscoef);
        printf("%f  %f\n", x, y);
    }
    int nintv = data_n - 1;
    int ideriv = 0;
    float derValue[test_n];
    KIPL_Cs1gd(ideriv, test_n, test_x, nintv, data_x, cscoef, derValue);

    free(data_x);
    free(data_y);
    return 0;
}
```

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

int main()
{
    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[test_n];
    float test_y[test_n];
    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]);
    }
    float b[data_n], cscoef[4 * data_n];
    float weight[data_n];
    float smpar = data_n;
    for (int i = 0; i < data_n; i++) {
        weight[i] = 0.1;
    }
    KIPL_Cssmh(data_n, data_x, data_y, weight, smpar, cscoef);
    int nintv = data_n - 1;
    for (int i = 0; i < test_n; i++) {
        float y;
        float x = test_x[i];
        y = KIPL_Csval(x, nintv, data_x, cscoef);
        printf("%f  %f\n", x, y);
    }
    free(data_x);
    free(data_y);
    return 0;
}
```
