FT_DSP.gitlink.net/master/html/_sources/functionlib/dsplib/linspace.rst.txt

73 lines
2.0 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

LinSpace
=================
生成从 ``start````end`` 的等间距序列,线性插值
.. math::
\text{output}_i = \text{start} + i \cdot \frac{\text{end} - \text{start}}{\text{length} - 1},\quad i = 0, 1, \dots, \text{length} - 1
输入:
- **start** - 序列起始值。
- **end** - 序列终止值(包含)。
- **length** - 序列点数;要求 length ≥ 2。
- **core_mask可选** - 核掩码(仅适用于共享存储版本)。
输出:
- **output** - 输出序列地址float32
支持平台:
``FT78NE``
``MT7004``
.. note::
- FT78NE 支持fp32
- MT7004 支持fp32, fp16
- 多核版本按行数均匀分割,各核处理自己的段落。
- 步长计算为 (end - start) / (length - 1)。
**共享存储版本:**
.. c:function:: void hp_linspace_s(half *output, half start, half end, int length, int core_mask)
.. c:function:: void fp_linspace_s(float *output, float start, float end, int length, int core_mask)
**C调用示例**
.. code-block:: c
:linenos:
:emphasize-lines: 9
#include <stdio.h>
int main(int argc, char* argv[]) {
float *output = (float *)0xA0000000; // DDR
float start = 0.0f;
float end = 100.0f;
int length = 1001;
int core_mask = 0xff;
fp_linspace_s(output, start, end, length, core_mask);
return 0;
}
**私有存储版本:**
.. c:function:: void hp_linspace_p(half *output, half start, half end, int length)
.. c:function:: void fp_linspace_p(float *output, float start, float end, int length)
**C调用示例**
.. code-block:: c
:linenos:
:emphasize-lines: 8
#include <stdio.h>
int main(int argc, char* argv[]) {
float *output = (float *)0x10000000; // L2
float start = 0.0f;
float end = 100.0f;
int num = 1000;
fp_linspace_p(output, start, end, num);
return 0;
}