---
title: KIPL_Bsder
description: "计算basis样条拟合函数在位置x处的导数值。"
url: https://www.hikunpeng.com/document/detail/zh/hpchistory/hpckit/develop2400/kunpengaccel_kml_0543.html
sourcePath: /source/zh/hpchistory/hpckit/develop2400/kunpengaccel_kml_0543.html
indexId: 3bda6944e796ad5e08f983cbc56ba365ad56329db6175064bdd107c2701503e867
---
# KIPL_Bsder

计算basis样条拟合函数在位置x处的导数值。

#### 接口定义

float KIPL_Bsder(int ideriv, float xi, int k, float *xKnot, int ncoef, float *coef)


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| ideriv | 整型数 | 需要计算的导数阶数。 | 输入 |
| xi | 单精度浮点数 | 需要计算导数值的位置。 | 输入 |
| ncoef | 整型数 | 表示coef数组长度，与nData相等。 | 输入 |
| k | 整型数 | 表示样条的阶数。 | 输入 |
| xKnot | 单精度浮点数组 | 长度为nData+k的数组，表示KIPL\_Bsnak生成的节点序列。 | 输入 |
| coef | 单精度浮点数组 | 长度为nData的数组，表示生成的系数序列。 | 输入 |
| 返回值 | 单精度浮点数 | basis样条拟合函数在位置x处的导数值。 | 输出 |


#### 依赖

#include "kipl.h"


#### 示例

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

int main()
{
    int data_n = 11;
    float data_x[data_n];
    float data_y[data_n];
    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]);
    }
    int k = 3;
    float bscoef[data_n], xknot[data_n + k];
    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;
        float x = test_x[i];
        y = KIPL_Bsder(ideriv, x, k, xknot, data_n, bscoef);
    }
    return 0;
}
```
