---
title: ?imatdiv
description: "矩阵缩放后in-place除计算。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/240RC2/accel/kunpengaccel_kml_16_0295.html
sourcePath: /source/zh/kunpengboostkithistory/240RC2/accel/kunpengaccel_kml_16_0295.html
indexId: dc66dbe7d097957fadbc80405aadd03631bc3e3a78148ead841157e10473a37b76
---
# ?imatdiv

矩阵缩放后in-place除计算。

即。

op可取值：。

#### 接口定义

C interface：

void cblas_simatdiv(const enum CBLAS_ORDER ordering, const enum CBLAS_TRANSPOSE TransA, const BLASINT m, const BLASINT n, const float alpha, float *A, const BLASINT lda, float *BC, const BLASINT ldb);

void cblas_dimatdiv(const enum CBLAS_ORDER ordering, const enum CBLAS_TRANSPOSE TransA, const BLASINT m, const BLASINT n, const double alpha, double *A, const BLASINT lda, double *BC, const BLASINT ldb);

void cblas_cimatdiv(const enum CBLAS_ORDER ordering, const enum CBLAS_TRANSPOSE TransA, const BLASINT m, const BLASINT n, const float *alpha, float *A, const BLASINT lda, float *BC, const BLASINT ldb);

void cblas_zimatdiv(const enum CBLAS_ORDER ordering, const enum CBLAS_TRANSPOSE TransA, const BLASINT m, const BLASINT n, const double *alpha, double *A, const BLASINT lda, double *BC, const BLASINT ldb);

Fortran interface：

CALL SIMATDIV(ORDER, TRANSA, M, N, ALPHA, A, LDA, BC, LDB)

CALL DIMATDIV(ORDER, TRANSA, M, N, ALPHA, A, LDA, BC, LDB)

CALL CIMATDIV(ORDER, TRANSA, M, N, ALPHA, A, LDA, BC, LDB)

CALL ZIMATDIV(ORDER, TRANSA, M, N, ALPHA, A, LDA, BC, LDB)


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| order | 枚举类型CBLAS\_ORDER | 表示矩阵是行主序或列主序。 | 输入 |
| TransA | 枚举类型CBLAS\_TRANSPOSE | 矩阵A为常规矩阵，转置矩阵或共轭矩阵。 如果TransA = CblasNoTrans，op(A) = A。 如果TransA = CblasTrans，op(A) = A'。 如果TransA = CblasConjNoTrans，op(A) = conj(A)。 如果TransA = CblasConjTrans，op(A) = conj(A')。 | 输入 |
| M | 整型数 | 矩阵op(A)、BC的行。 | 输入 |
| N | 整型数 | 矩阵op(A)、BC的列。 | 输入 |
| alpha | 在simatdiv中是单精度浮点类型。 在dimatdiv中是双精度浮点类型。 在cimatdiv中是单精度复数类型。 在zimatdiv中是双精度复数类型。 | 表示乘法系数。 | 输入 |
| A | 在simatdiv中是单精度浮点类型。 在dimatdiv中是双精度浮点类型。 在cimatdiv中是单精度复数类型。 在zimatdiv中是双精度复数类型。 | 矩阵A。 | 输入 |
| lda | 整型数 | 矩阵A为列存，TransA = CblasNoTrans，lda至少max(1, m)，否则max(1, n)。 矩阵A为行存，TransA = CblasNoTrans，lda至少max(1, n)，否则max(1, m)。 | 输入 |
| BC | 在simatdiv中是单精度浮点类型。 在dimatdiv中是双精度浮点类型。 在cimatdiv中是单精度复数类型。 在zimatdiv中是双精度复数类型。 | 矩阵BC。 | 输入 |
| ldb | 整型数 | 矩阵为列存，TransB = CblasNoTrans，ldb至少max(1, m)，否则max(1, n)。 矩阵为行存，TransB = CblasNoTrans，ldb至少max(1, n)，否则max(1, m)。 | 输入 |


#### 依赖

#include "kblas.h"


#### 示例

C interface：

```
int m = 4;
int n = 3;
int lda = 4;
int ldb = 4;
float alpha = 2.0;
/**
*    A:
*         0.235257, 0.268674, 0.151790,
*         -0.204541, 0.142802, 0.036246,
*         -0.238498, 0.423810, 0.181002,
*         -0.002402, -0.240821, -0.309177
*    BC:
*         -0.284033, -0.407091, 0.487585,
*         -0.126079, 0.380664, -0.407300,
*         0.243892, -0.259406, -0.257296,
*         0.018376, 0.148356, 0.379532,
*/
float a[12] = {0.645728, 0.664078, 0.775762,
0.806953, 0.601041, 0.714864,
0.915711, 0.803360, 0.562129,
0.522928, 0.647835, 0.824213
};
float bc[12] = {-2.414662, -3.030372, 6.424446,
1.232803, 5.331337, -22.474379,
-2.045228, -1.224161, -2.843022,
-15.298911, -1.232085, -2.455110
};
cblas_simatdiv(CblasColMajor, CblasNoTrans, m, n, alpha, a, lda, bc, ldb);
/**
* Output BC:
*        -2.414662, -3.030372, 6.424446,
*        1.232803, 5.331337, -22.474379,
*        -2.045228, -1.224161, -2.843022,
*        -15.298911, -1.232085, -2.455110
*/
```

Fortran interface：

```
PROGRAM IMATDIV
INTEGER :: M=4, N=3
INTEGER :: LDA=4, LDB=4
REAL(4) :: ALPHA=2.0
REAL(4) :: A(4, 3), BC(4, 3)
DATA A/0.645728, 0.664078, 0.775762,
0.806953, 0.601041, 0.714864,
0.915711, 0.803360, 0.562129,
0.522928, 0.647835, 0.824213/
DATA BC/-2.414662, -3.030372, 6.424446,
1.232803, 5.331337, -22.474379,
-2.045228, -1.224161, -2.843022,
-15.298911, -1.232085, -2.455110/
EXTERNAL SIMATDIV
CALL SIMATDIV('C', 'N', M, N, ALPHA, A, LDA, BC, LDB)
END
* Output BC:
*        1.798285, 2.196716, 1.565241,
*        2.386664, 1.469238, 1.978835,
*        3.396264, 1.824785, 1.380008,
*        1.925460, 1.502539, 2.252343
```
