---
title: Cgemv
description: "| 硬件型号 | 支持情况 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/SiP/SIP_API_0011.html
sourcePath: /source/zh/canncommercial/900/API/SiP/SIP_API_0011.html
indexId: 4bc504b79294c4263336c8ffeb3d3a0bcb6a283b60c63369bcd6479b9693be4255
---
# Cgemv

#### 产品支持情况

| 硬件型号 | 支持情况 |
| --- | --- |
| Atlas 200I/500 A2 推理产品 | 不支持 |
| Atlas 推理系列产品 | 不支持 |
| Atlas 训练系列产品 | 不支持 |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | 支持 |
| Atlas A3 推理系列产品 / Atlas A3 训练系列产品 | 支持 |


#### 功能描述

接口功能

- asdBlasMakeCgemvPlan：初始化该句柄对应的Cgemv算子配置。
- asdBlasCgemv：一个矩阵向量乘法，用于计算复数矩阵A与复数向量x的乘积，结果存储在复数向量y中。

计算公式

- asdBlasCgemv的计算公式：
  其中，，alpha和beta是标量，x和y是向量，A是一个m*n的矩阵。


- 示例：
  输入“A”
  为：

```
[   [ 1+i,1+2i ],
[ 1+2i,1+3i ]  ]
```


  输入“x”为：

```
[ 2+i,2+2i ]
```


  输入“y”为：

```
[ 1+i,1+2i ]
```


  输入“m”为：2，输入“n”为： 2，输入“trans”为'N'：2，输入“alpha”为：1+i，“beta”为：2+2i。

  输入“lda”为： 2，输入“incx”为：1，输入“incy”为：1。

  调用“asdBlasMakeCgemvPlan”生成plan。

  调用“asdBlasCgemv”接口执行后，输出“y”为：

```
[ -10 + 12i,-19 + 15i]
```


#### 函数原型

- AspbStatus asdBlasMakeCgemvPlan(asdBlasHandle handle, asdBlasOperation_t trans, const int64_t m, const int64_t n,aclTensor *y, const int64_t incy)
- AspbStatus asdBlasCgemv(asdBlasHandle handle, asdBlasOperation_t trans, const int64_t m, const int64_t n,const std::complex<float> *alpha, aclTensor *A, const int64_t lda, aclTensor *x,const int64_t incx, const std::complex<float> *beta, aclTensor *y, const int64_t incy)


#### 参数说明

- asdBlasMakeCgemvPlan| 参数名称 | Input/Output | 类型 | 描述 |
| --- | --- | --- | --- |
| handle | Input | asdBlasHandle | cgemv算子的句柄。 |
| trans | Input | asdBlasOperation\_t | 指定矩阵A是否需要转置。 ASDBLAS\_OP\_N // 不转置 ASDBLAS\_OP\_T // 转置 ASDBLAS\_OP\_C // 共轭转置 |
| m | Input | const int64\_t | 矩阵A的行数，向量y的元素个数。 |
| n | Input | const int64\_t | 矩阵A的列数，向量x的元素个数。 |
| y | Input | aclTensor \* | 向量y。 |
| incy | Input | const int64\_t | 向量y的步长。 |


- asdBlasCgemv| 参数名称 | Input/Output | 类型 | 描述 |
| --- | --- | --- | --- |
| handle | Input | asdBlasHandle | cgemv算子的句柄。 |
| trans | Input | asdBlasOperation\_t | 指定矩阵A是否需要转置。 ASDBLAS\_OP\_N // 不转置 ASDBLAS\_OP\_T // 转置 ASDBLAS\_OP\_C // 共轭转置 |
| m | Input | const int64\_t | 矩阵A的行数，向量y的元素个数。 |
| n | Input | const int64\_t | 矩阵A的列数，向量x的元素个数。 |
| alpha | Input | const std::complex<float> \* | 公式中的alpha，复数标量，用于乘以矩阵和向量乘法的结果。 |
| A | Input | aclTensor \* | 公式中的矩阵A，列主序，Device侧的Tensor，数据类型仅支持COMPLEX64，数据格式支持ND，shape为[m，n]。 |
| lda | Input | const int64\_t | A左右相邻元素间的内存地址偏移量（当前约束为m）。 |
| x | Input | aclTensor \* | 公式中的向量x，Device侧的Tensor，数据类型仅支持COMPLEX64，数据格式支持ND，shape为[n]。 |
| incx | Input | const std::complex<float> | 向量x的步长（当前约束为1）。 |
| beta | Input | const std::complex<float> \* | 公式中的beta，复数标量，用于乘以向量y 。 |
| y | Input/Output | aclTensor \* | 公式中的向量y，Device侧的Tensor，数据类型仅支持COMPLEX64，数据格式支持ND，shape为[m]。 |
| incy | Input | const int64\_t | 向量y的步长（当前约束为1）。 |


#### 返回值说明

返回值相关说明参见返回值。


#### 约束说明

- asdBlasMakeCgemvPlan：无。
- asdBlasCgemv

  - 输入的元素个数m，n当前覆盖支持[1, 8193]。
  - 算子输入矩阵A为列主序，输入shape为[m, n]、[m]、[n]，输出shape为[m]。

  - 算子实际计算时，不支持ND高维度运算（不支持维度≥3的运算）。


#### 调用示例

算子的调用示例参见Cgemv。
