cmprod
Calculate the dot product of complex matrices.
The function interface declaration is as follows:
Operations on numbers of the float type:
void (vsip_cmprod_f)(const vsip_cmview_f *a, const vsip_cmview_f *b, const vsip_cmview_f *c);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
a |
Pointer to the source complex matrix |
The value cannot be NULL. |
Input |
b |
Pointer to the source complex matrix |
The value cannot be NULL. |
Input |
c |
Pointer to the destination complex matrix |
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"
void CmprodExample()
{
int32_t row = 4;
int32_t col = 3;
int64_t rowStride = 1;
int64_t colStride = row * rowStride;
uint64_t offset = 0;
int32_t len = 2 * (col * colStride + offset);
float *src1 = (float *)malloc(len * sizeof(float));
float *src2 = (float *)malloc(len * sizeof(float));
float *dst = (float *)malloc(len * sizeof(float));
for (int32_t i = 0; i < len; ++i) {
src1[i] = 1 + i / 100.0f;
src2[i] = 2 + i / 100.0f;
}
vsip_cblock_f *block_a = vsip_cblockbind_f(src1, NULL, len, VSIP_MEM_NONE);
vsip_cblock_f *block_b = vsip_cblockbind_f(src2, NULL, len, VSIP_MEM_NONE);
vsip_cblock_f *block_c = vsip_cblockbind_f(dst, NULL, len, VSIP_MEM_NONE);
vsip_cmview_f *a = vsip_cmbind_f(block_a, offset, colStride, col, rowStride, row);
vsip_cblockadmit_f(block_a, VSIP_TRUE);
vsip_cmview_f *b = vsip_cmbind_f(block_b, offset, colStride, col, rowStride, row);
vsip_cblockadmit_f(block_b, VSIP_TRUE);
vsip_cmview_f *c = vsip_cmbind_f(block_c, offset, colStride, col, rowStride, row);
vsip_cblockadmit_f(block_c, VSIP_TRUE);
vsip_cmprod_f(a, b, c);
vsip_cmalldestroy_f(a);
vsip_cmalldestroy_f(b);
vsip_cmalldestroy_f(c);
printf("src1:\n");
for (int32_t i = 0; i < col; ++i) {
for (int32_t j = 0; j < row; ++j) {
printf("%.5f ", src1[i * row * 2 + j * 2]);
printf("%.5f ", src1[i * row * 2 + j * 2 + 1]);
}
printf("\n");
}
printf("\nsrc2:\n");
for (int32_t i = 0; i < col; ++i) {
for (int32_t j = 0; j < row; ++j) {
printf("%.5f ", src2[i * row * 2 + j * 2]);
printf("%.5f ", src2[i * row * 2 + j * 2 + 1]);
}
printf("\n");
}
printf("\ndst:\n");
for (int32_t i = 0; i < col; ++i) {
for (int32_t j = 0; j < row; ++j) {
printf("%.5f ", dst[i * row * 2 + j * 2]);
printf("%.5f ", dst[i * row * 2 + j * 2 + 1]);
}
printf("\n");
}
free(src1);
free(src2);
free(dst);
}
int main(void) {
CmprodExample();
return 0;
}
Output:
src1: 1.00000 1.01000 1.02000 1.03000 1.04000 1.05000 1.06000 1.07000 1.08000 1.09000 1.10000 1.11000 1.12000 1.13000 1.14000 1.15000 1.16000 1.17000 1.18000 1.19000 1.20000 1.21000 1.22000 1.23000 src2: 2.00000 2.01000 2.02000 2.03000 2.04000 2.05000 2.06000 2.07000 2.08000 2.09000 2.10000 2.11000 2.12000 2.13000 2.14000 2.15000 2.16000 2.17000 2.18000 2.19000 2.20000 2.21000 2.22000 2.23000 dst: -0.09330 12.82900 -0.09390 12.95200 -0.09450 13.07500 -0.09510 13.19800 -0.09570 13.82980 -0.09630 13.96240 -0.09690 14.09500 -0.09750 14.22760 -0.09810 14.83060 -0.09870 14.97280 -0.09930 15.11500 -0.09990 15.25720
Parent topic: Matrix Operation Functions