Rate This Document
Findability
Accuracy
Completeness
Readability

cvget

Obtain the complex value of the specified index for a complex vector.

The function interface declaration is as follows:

Operations on numbers of the float type:

vsip_cscalar_f (vsip_cvget_f)(const vsip_cvview_f *v, uint64_t i);

Parameters

Parameter

Description

Value Range

Input/Output

v

Pointer to the source complex vector

The value cannot be NULL.

Input

i

Index variable

Greater than or equal to 0 and less than the vector size

Output

Abnormal Input

When a null pointer is input or the index is out of bound, the function directly returns a complex NaN value.

Example

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "kvsip.h"
#include "vsip.h"
#include "vsip_type.h"

#define BUFFER_SIZE_T 10
void CvgetExample()
{
    float src[BUFFER_SIZE_T] = {1.64f, 1.63f, -1.09f, 0.71f, -3.20f, -0.43f, 0.41f, -4.83f, 5.36f, -4.40f};
    uint64_t j = 2;
    int64_t cvLen = BUFFER_SIZE_T / 2;
    int64_t stride = 1;
    uint64_t offset = 0;

    vsip_cblock_f *block_a = vsip_cblockbind_f(src, NULL, cvLen, VSIP_MEM_NONE);

    vsip_cvview_f *a = vsip_cvbind_f(block_a, offset, stride, cvLen);
    vsip_cblockadmit_f(block_a, VSIP_TRUE);

    vsip_cscalar_f dst = vsip_cvget_f(a, j);

    vsip_cvalldestroy_f(a);

    printf("src:\n");
    for (int32_t i = 0; i < cvLen; ++i) {
        printf("%.2f ", src[i * 2]);
        printf("%.2f    ", src[i * 2 + 1]);
    }
    printf("\ndst: %.2f %.2f\n", dst.r, dst.i);
}

int main(void) {
    CvgetExample();
    return 0;
}

Output:

src:
1.64 1.63    -1.09 0.71    -3.20 -0.43    0.41 -4.83    5.36 -4.40
dst: -3.20 -0.43