---
title: KIPL_Cssmh
description: "计算平滑的三次样条系数逼近噪声数据。"
url: https://www.hikunpeng.com/document/detail/zh/hpchistory/hpckit/develop2400/kunpengaccel_kml_0546.html
sourcePath: /source/zh/hpchistory/hpckit/develop2400/kunpengaccel_kml_0546.html
indexId: c0022d589005d4f374dfdbecb9560813ee6befb40329358ff832d1661f0635f667
---
# KIPL_Cssmh

计算平滑的三次样条系数逼近噪声数据。

#### 接口定义

void KIPL_Cssmh(int nData, float *xData, float *fData, float *weight, float smpar, float *coef)


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| nData | 整型数 | 表示xData数组元素个数。 | 输入 |
| xData | 单精度浮点数组 | 长度为nData的数组，表示数据点的横坐标。 | 输入 |
| fData | 单精度浮点数组 | 长度为nData的数组，表示数据点的纵坐标。 | 输入 |
| weight | 单精度浮点数组 | 包含fData标准偏差估计值的长度为nData的数组 | 输入 |
| smpar | 单精度浮点数 | 控制平滑度的非负数。 | 输入 |
| coef | 单精度浮点数组 | 长度为4\*nData的数组，表示生成的系数序列。 | 输出 |


#### 依赖

#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]);
    }
    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);
    }
    return 0;
}
```
