79 lines
2.5 KiB
ReStructuredText
79 lines
2.5 KiB
ReStructuredText
Range
|
||
=================
|
||
|
||
生成等差序列,逐元素写入输出:
|
||
|
||
.. math::
|
||
|
||
output_i = start + i \times delta,\quad i = 0, 1, \dots, \text{length} - 1
|
||
|
||
输入:
|
||
- **start** - 序列起始值。
|
||
- **delta** - 公差。
|
||
- **length** - 序列长度。
|
||
- **core_mask(可选)** - 核掩码(仅适用于共享存储版本)。
|
||
|
||
输出:
|
||
- **output** - 输出数据地址。
|
||
|
||
支持平台:
|
||
``FT78NE``
|
||
``MT7004``
|
||
|
||
.. note::
|
||
- FT78NE 支持 int8, int16, int32, fp32, fp64。
|
||
- MT7004 支持 fp16, fp32, int16, int32(如需 fp16,请使用相应 fp16 实现)。
|
||
|
||
**共享存储版本:**
|
||
|
||
.. c:function:: void i8_range_s(int8_t* output, int8_t start, int8_t delta, int length, int core_mask)
|
||
.. c:function:: void i16_range_s(int16_t* output, int16_t start, int16_t delta, int length, int core_mask)
|
||
.. c:function:: void i32_range_s(int32_t* output, int32_t start, int32_t delta, int length, int core_mask)
|
||
.. c:function:: void fp_range_s(float* output, float start, float delta, int length, int core_mask)
|
||
.. c:function:: void dp_range_s(double* output, double start, double delta, int length, int core_mask)
|
||
|
||
**C调用示例:**
|
||
|
||
.. code-block:: c
|
||
:linenos:
|
||
:emphasize-lines: 10
|
||
|
||
#include <stdio.h>
|
||
#include <stdbool.h>
|
||
|
||
int main(int argc, char* argv[]) {
|
||
float *output = (float *)0xA0000000; // DDR
|
||
float start = 1.5f;
|
||
float delta = 0.5f;
|
||
int length = 1000;
|
||
int core_mask = 0xff;
|
||
fp_range_s(output, start, delta, length, core_mask);
|
||
return 0;
|
||
}
|
||
|
||
**私有存储版本:**
|
||
|
||
.. c:function:: void i8_range_p(int8_t* output, int8_t start, int8_t delta, int length)
|
||
.. c:function:: void i16_range_p(int16_t* output, int16_t start, int16_t delta, int length)
|
||
.. c:function:: void i32_range_p(int32_t* output, int32_t start, int32_t delta, int length)
|
||
.. c:function:: void fp_range_p(float* output, float start, float delta, int length)
|
||
.. c:function:: void dp_range_p(double* output, double start, double delta, int length)
|
||
|
||
**C调用示例:**
|
||
|
||
.. code-block:: c
|
||
:linenos:
|
||
:emphasize-lines: 9
|
||
|
||
#include <stdio.h>
|
||
#include <stdbool.h>
|
||
|
||
int main(int argc, char* argv[]) {
|
||
float *output = (float *)0x10000000; // L2
|
||
float start = 1.5f;
|
||
float delta = 0.5f;
|
||
int length = 1000;
|
||
fp_range_p(output, start, delta, length);
|
||
return 0;
|
||
}
|