---
title: cmherm
description: "复数矩阵的共轭转置运算。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengaccel/system-lib/ug-kvsip/kunpengaccel_kvsip_06_0087.html
sourcePath: /source/zh/kunpengaccel/system-lib/ug-kvsip/kunpengaccel_kvsip_06_0087.html
indexId: 12aea42f175522ef50a53950d19178a9f06efe3b1b7ca2021551466c1cea8ab475
---
# cmherm

复数矩阵的共轭转置运算。

函数接口声明如下：

float型函数操作：

void (vsip_cmherm_f)(const vsip_cmview_f *A, const vsip_cmview_f *R);

#### 参数

| 参数名 | 描述 | 取值范围 | 输入/输出 |
| --- | --- | --- | --- |
| A | 指向源复数矩阵的指针。 | 非空 | 输入 |
| R | 指向目标复数矩阵的指针。 | 非空 | 输出 |


#### 异常输入

空指针输入时，函数直接返回。


#### 示例

```
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "kvsip.h"
#include "vsip.h"
#include "vsip_type.h"

void CmhermExample()
{
    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_cmherm_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) {
    CmhermExample();
    return 0;
}
```

运行结果：

```
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
```
