Where
=================



逐元素根据条件选择两个输入中的元素

.. math::

    output_i = \begin{cases}
        input0_i, & \text{if } condition_i \text{ is True} \\
        input1_i, & \text{if } condition_i \text{ is False}
    \end{cases}

输入：
    - **input0** - 第一个输入数据地址。
    - **input1** - 第二个输入数据地址。
    - **condition** - 条件数据地址。
    - **length** - 计算长度。
    - **core_mask** - 核掩码（仅共享存储版本需要）。

输出：
    - **output** - 计算结果地址。

支持平台：
    ``FT78NE``
    ``MT7004``

.. note::
    - FT78NE 支持int8, int16, int32, fp16, fp32, fp64, cplx64, cplx128
    - MT7004 支持fp16, fp32, int16, int32, cplx64

**共享存储版本:**

.. c:function:: void i8_where_s(int8_t* input0, int8_t* input1, bool* condition, int8_t* output, int length, int core_mask)
.. c:function:: void i16_where_s(int16_t* input0, int16_t* input1, bool* condition, int16_t* output, int length, int core_mask)
.. c:function:: void i32_where_s(int32_t* input0, int32_t* input1, bool* condition, int32_t* output, int length, int core_mask)
.. c:function:: void hp_where_s(half* input0, half* input1, bool* condition, half* output, int length, int core_mask)
.. c:function:: void fp_where_s(float* input0, float* input1, bool* condition, float* output, int length, int core_mask)
.. c:function:: void dp_where_s(double* input0, double* input1, bool* condition, double* output, int length, int core_mask)
.. c:function:: void c64_where_s(float* input0, float* input1, bool* condition, float* output, int length, int core_mask)
.. c:function:: void c128_where_s(double* input0, double* input1, bool* condition, double* output, int length, int core_mask)

**C调用示例：**

.. code-block:: c
    :linenos:
    :emphasize-lines: 11

    //FT78NE示例
    #include <stdio.h>
    #include <where.h>
    int main(int argc, char* argv[]) {
        float *input0 = (float *)0xA0000000;   //input0在DDR空间
        float *input1 = (float *)0xB0000000;   //input1在DDR空间
        bool *condition = (bool *)0xC0000000;  //condition在DDR空间
        float *output = (float *)0xD0000000;   //output在DDR空间
        int length = 1000;
        int core_mask = 0xff;
        fp_where_s(input0, input1, condition, output, length, core_mask);
        return 0;
    }


**私有存储版本:**

.. c:function:: void i8_where_p(int8_t* input0, int8_t* input1, bool* condition, int8_t* output, int length)
.. c:function:: void i16_where_p(int16_t* input0, int16_t* input1, bool* condition, int16_t* output, int length)
.. c:function:: void i32_where_p(int32_t* input0, int32_t* input1, bool* condition, int32_t* output, int length)
.. c:function:: void hp_where_p(half* input0, half* input1, bool* condition, half* output, int length)
.. c:function:: void fp_where_p(float* input0, float* input1, bool* condition, float* output, int length)
.. c:function:: void dp_where_p(double* input0, double* input1, bool* condition, double* output, int length)
.. c:function:: void c64_where_p(float* input0, float* input1, bool* condition, float* output, int length)
.. c:function:: void c128_where_p(double* input0, double* input1, bool* condition, double* output, int length)

    
**C调用示例：**

.. code-block:: c
    :linenos:
    :emphasize-lines: 10

    //FT78NE示例
    #include <stdio.h>
    #include <where.h>
    int main(int argc, char* argv[]) {
        float *input0 = (float *)0x10000000;   //input0在L2空间
        float *input1 = (float *)0x10001000;   //input1在L2空间
        bool *condition = (bool *)0x10002000;  //condition在L2空间
        float *output = (float *)0x10003000;   //output在L2空间
        int length = 1000;
        fp_where_p(input0, input1, condition, output, length);
        return 0;
    }