cvdiv
Perform division operations on complex vectors.
The function interface declaration is as follows:
Operations on numbers of the float type:
void (vsip_cvadd_f)(const vsip_cvview_f *a, const vsip_cvview_f *b, const vsip_cvview_f *r);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
a |
Pointer to the source complex vector |
The value cannot be NULL. |
Input |
b |
Pointer to the source complex vector |
The value cannot be NULL. |
Input |
r |
Pointer to the destination complex vector |
The value cannot be NULL. |
Output |
Abnormal Input
When a null pointer is input, the function directly returns a result.
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 CvdivExample()
{
float src1[BUFFER_SIZE_T] = {1.64f, 1.63f, -1.09f, 0.71f, -3.20f, -0.43f, 0.41f, -4.83f, 5.36f, -4.40f};
float src2[BUFFER_SIZE_T] = {-0.23f, 3.15f, -7.11f, 5.94f, 4.38f, 6.51f, -7.28f, -3.27f, 1.08f, 3.28f};
float dst[BUFFER_SIZE_T];
int64_t stride = 1;
int64_t cvLen = BUFFER_SIZE_T / 2;
uint64_t offset = 0;
vsip_cblock_f *block_a = vsip_cblockbind_f(src1, NULL, cvLen, VSIP_MEM_NONE);
vsip_cblock_f *block_b = vsip_cblockbind_f(src2, NULL, cvLen, VSIP_MEM_NONE);
vsip_cblock_f *block_r = vsip_cblockbind_f(dst, 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_cvview_f *b = vsip_cvbind_f(block_b, offset, stride, cvLen);
vsip_cblockadmit_f(block_b, VSIP_TRUE);
vsip_cvview_f *r = vsip_cvbind_f(block_r, offset, stride, cvLen);
vsip_cblockadmit_f(block_r, VSIP_TRUE);
vsip_cvdiv_f(a, b, r);
vsip_cvalldestroy_f(a);
vsip_cvalldestroy_f(b);
vsip_cvalldestroy_f(r);
printf("src1:\n");
for (int32_t i = 0; i < cvLen; ++i) {
printf("%.4f ", src1[i * 2]);
printf("%.4f ", src1[i * 2 + 1]);
}
printf("\nsrc2:\n");
for (int32_t i = 0; i < cvLen; ++i) {
printf("%.4f ", src2[i * 2]);
printf("%.4f ", src2[i * 2 + 1]);
}
printf("\ndst:\n");
for (int32_t i = 0; i < cvLen; ++i) {
printf("%.4f ", dst[i * 2]);
printf("%.4f ", dst[i * 2 + 1]);
}
printf("\n");
}
int main(void) {
CvdivExample();
return 0;
}
Output:
src1: 1.6400 1.6300 -1.0900 0.7100 -3.2000 -0.4300 0.4100 -4.8300 5.3600 -4.4000 src2: -0.2300 3.1500 -7.1100 5.9400 4.3800 6.5100 -7.2800 -3.2700 1.0800 3.2800 dst: 0.4769 -0.5555 0.1394 0.0166 -0.2731 0.3078 0.2011 0.5731 -0.7248 -1.8728
Parent topic: Vector Operation Functions