---
title: v?linearfrac
description: "使用标量scale，shift对向量src1，src2执行线性分式变换，即"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/2300/accel/kunpengaccel_kml_16_0303.html
sourcePath: /source/zh/kunpengboostkithistory/2300/accel/kunpengaccel_kml_16_0303.html
indexId: 84e92eee82c381bf7f6dd0d354c19ede2584c3869cdf93a3d521042135a6157174
---
# v?linearfrac

使用标量scale，shift对向量src1，src2执行线性分式变换，即


#### 接口定义

C interface：

void vslinearfrac(const int len, const float *src1, const float *src2, const float scalea, const float shifta, const float scaleb, const float shiftb, float *dst);

void vdlinearfrac(const int len, const double *src1, const double *src2, const double scalea, const double shifta, const double scaleb, const double shiftb, double *dst);


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| len | 整型数 | 表示输入向量的元素个数。 len≤0时会提示len无效并返回。 | 输入 |
| src1 | 在vslinearfrac中是单精度浮点类型。 在vdlinearfrac中是双精度浮点类型。 | 输入向量src1，向量长度为len。 若为空指针，会提示空指针错误并返回。 | 输入 |
| src2 | 在vslinearfrac中是单精度浮点类型。 在vdlinearfrac中是双精度浮点类型。 | 输入向量src2，向量长度为len。 若为空指针，会提示空指针错误并返回。 | 输入 |
| scalea | 在vslinearfrac中是单精度浮点类型。 在vdlinearfrac中是双精度浮点类型。 | src1的缩放常量。 | 输入 |
| shifta | 在vslinearfrac中是单精度浮点类型。 在vdlinearfrac中是双精度浮点类型。 | src1的偏移常量。 | 输入 |
| scaleb | 在vslinearfrac中是单精度浮点类型。 在vdlinearfrac中是双精度浮点类型。 | src2的缩放常量。 | 输入 |
| shiftb | 在vslinearfrac中是单精度浮点类型。 在vdlinearfrac中是双精度浮点类型。 | src2的偏移常量。 | 输入 |
| dst | 在vslinearfrac中是单精度浮点类型。 在vdlinearfrac中是双精度浮点类型。 | 输出dst，向量长度为len。 若为空指针，会提示空指针错误并返回。 | 输出 |


#### 输出结果

输出线性分式变换的结果。


#### 依赖

C: "kvml.h"


#### 示例

C interface：
```
#define N 4
const float src1[N] = {-8.0f, 25.0f, +INFINITY, -0.0f};
const float src2[N] = {6.2f, -4.3f, -192.4, -3.1f};
const float scalea = 0.2f;
const float shifta = 1.0f;
const float scaleb = -0.2f;
const float shiftb = -1.1f;
float dst[N] = {0};
vslinearfrac(N, src1, src2, scalea, shifta, scaleb, shiftb, dst);
printFArr("input1:", N, src1);
printFArr("input2:", N, src2);
printf("scalea : %.3f, shifta : %.3f, scalea : %.3f, shifta : %.3f\n", scalea, shifta, scaleb, shiftb);
printFArr("output:", N, dst);
/**
*  input1:  -8.000   25.000      inf   -0.000
*  input2:   6.200   -4.300 -192.400   -3.100
*  scalea : 0.200, shifta : 1.000, scalea : -0.200, shifta : -1.100
*  output:   0.256  -25.000      inf   -2.083
*/
```
