csvmul
复数标量与复数向量乘法运算。
函数接口声明如下:
float型数的操作:
void (vsip_csvmul_f)(vsip_cscalar_f alpha, const vsip_cvview_f *b, const vsip_cvview_f *r);
参数
参数名 |
描述 |
取值范围 |
输入/输出 |
---|---|---|---|
alpha |
运算复数标量 |
不限 |
输入 |
b |
指向源复数向量的指针。 |
非空 |
输入 |
r |
指向目的复数向量的指针。 |
非空 |
输出 |
异常输入
空指针输入时,函数直接返回。
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #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; } |
运行结果:
1 2 3 4 5 | 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 |
父主题: 向量运算函数