csvmul
Multiply a complex scalar and a complex vector.
The function interface declaration is as follows:
Operations on numbers of the float type:
void (vsip_csvmul_f)(vsip_cscalar_f alpha, const vsip_cvview_f *b, const vsip_cvview_f *r);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
alpha |
Complex scalar to be operated |
Unlimited |
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 CsvmulExample()
{
vsip_cscalar_f alpha = {1.4f, -0.2f};
float src[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_b = vsip_cblockbind_f(src, NULL, cvLen, VSIP_MEM_NONE);
vsip_cblock_f *block_r = vsip_cblockbind_f(dst, NULL, cvLen, VSIP_MEM_NONE);
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_csvmul_f(alpha, b, r);
vsip_cvalldestroy_f(b);
vsip_cvalldestroy_f(r);
printf("alpha: %.4f %.4f\n", alpha.r, alpha.i);
printf("src2:\n");
for (int32_t i = 0; i < cvLen; ++i) {
printf("%.4f ", src[i * 2]);
printf("%.4f ", src[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) {
CsvmulExample();
return 0;
}
Output:
alpha: 1.4000 -0.2000 src2: -0.2300 3.1500 -7.1100 5.9400 4.3800 6.5100 -7.2800 -3.2700 1.0800 3.2800 dst: 0.3080 4.4560 -8.7660 9.7380 7.4340 8.2380 -10.8460 -3.1220 2.1680 4.3760
Parent topic: Vector Operation Functions