cmtrans
Perform transpose operations on complex matrices.
The function interface declaration is as follows:
Operations on numbers of the float type:
void (vsip_cmtrans_f)(const vsip_cmview_f *A, const vsip_cmview_f *R);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
A |
Pointer to the source complex matrix |
The value cannot be NULL. |
Input |
R |
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 CmtransExample()
{
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);
int32_t dstRow = col;
int32_t dstCol = row;
int64_t dstColStride = dstRow * rowStride;
int32_t dstLen = 2 * (dstCol * dstColStride + offset);
float *src = (float *)malloc(len * sizeof(float));
float *dst = (float *)malloc(dstLen * sizeof(float));
for (int32_t i = 0; i < len; ++i) {
src[i] = 1 + i / 100.0f;
}
vsip_cblock_f *block_a = vsip_cblockbind_f(src, NULL, len, VSIP_MEM_NONE);
vsip_cblock_f *block_r = vsip_cblockbind_f(dst, NULL, dstLen, 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 *r = vsip_cmbind_f(block_r, offset, dstColStride, dstCol, rowStride, dstRow);
vsip_cblockadmit_f(block_r, VSIP_TRUE);
vsip_cmtrans_f(a, r);
vsip_cmalldestroy_f(a);
vsip_cmalldestroy_f(r);
printf("src:\n");
for (int32_t i = 0; i < col; ++i) {
for (int32_t j = 0; j < row; ++j) {
printf("%.5f ", src[i * row * 2 + j * 2]);
printf("%.5f ", src[i * row * 2 + j * 2 + 1]);
}
printf("\n");
}
printf("\ndst:\n");
for (int32_t i = 0; i < dstCol; ++i) {
for (int32_t j = 0; j < dstRow; ++j) {
printf("%.5f ", dst[i * dstRow * 2 + j * 2]);
printf("%.5f ", dst[i * dstRow * 2 + j * 2 + 1]);
}
printf("\n");
}
free(src);
free(dst);
}
int main(void) {
CmtransExample();
return 0;
}
Output:
src: 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 dst: 1.00000 1.01000 1.08000 1.09000 1.16000 1.17000 1.02000 1.03000 1.10000 1.11000 1.18000 1.19000 1.04000 1.05000 1.12000 1.13000 1.20000 1.21000 1.06000 1.07000 1.14000 1.15000 1.22000 1.23000
Parent topic: Matrix Operation Functions