?omatsub
矩阵缩放后out-place减计算。
即。
op可取值:。
接口定义
C interface:
void cblas_somatsub(const enum CBLAS_ORDER ordering, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, const BLASINT m, const BLASINT n, const float alpha, float *A, const BLASINT lda, const float beta, float *B, const BLASINT ldb, float *C, const BLASINT ldc);
void cblas_domatsub(const enum CBLAS_ORDER ordering, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, const BLASINT m, const BLASINT n, const double alpha, double *A, const BLASINT lda, const double beta, double *B, const BLASINT ldb, double *C, const BLASINT ldc);
void cblas_comatsub(const enum CBLAS_ORDER ordering, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, const BLASINT m, const BLASINT n, const float *alpha, float *A, const BLASINT lda, const float *beta, float *B, const BLASINT ldb, float *C, const BLASINT ldc);
void cblas_zomatsub(const enum CBLAS_ORDER ordering, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, const BLASINT m, const BLASINT n, const double *alpha, double *A, const BLASINT lda, const double *beta, double *B, const BLASINT ldb, double *C, const BLASINT ldc);
Fortran interface:
CALL SOMATSUB(ORDER, TRANSA, TRANSB, M, N, ALPHA, A, LDA, BETA, B, LDB, C, LDC)
CALL DOMATSUB(ORDER, TRANSA, TRANSB, M, N, ALPHA, A, LDA, BETA, B, LDB, C, LDC)
CALL COMATSUB(ORDER, TRANSA, TRANSB, M, N, ALPHA, A, LDA, BETA, B, LDB, C, LDC)
CALL ZOMATSUB(ORDER, TRANSA, TRANSB, M, N, ALPHA, A, LDA, BETA, B, LDB, C, LDC)
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
order |
枚举类型CBLAS_ORDER |
表示矩阵是行主序或列主序。 |
输入 |
TransA |
枚举类型CBLAS_TRANSPOSE |
矩阵A为常规矩阵,转置矩阵,共轭矩阵或转置共轭矩阵。
|
输入 |
TransB |
枚举类型CBLAS_TRANSPOSE |
矩阵B为常规矩阵,转置矩阵,共轭矩阵或转置共轭矩阵。
|
输入 |
M |
整型数 |
矩阵op(A)、op(B)、C的行。 |
输入 |
N |
整型数 |
矩阵op(A)、op(B)、C的列。 |
输入 |
alpha |
|
表示乘法系数。 |
输入 |
A |
|
矩阵A。 |
输入 |
lda |
整型数 |
|
输入 |
beta |
|
表示乘法系数。 |
输入 |
B |
|
矩阵B。 |
输入 |
ldb |
整型数 |
|
输入 |
C |
|
矩阵C。 |
输出 |
ldc |
整型数 |
矩阵为列存,ldc至少max(1, m),否则max(1, n)。 |
输入 |
依赖
#include "kblas.h"
示例
C interface:
int m = 4; int n = 3; int lda = 4; int ldb = 4; int ldc = 4; float alpha = 2.0; float beta = 1.0; /** * A: * 0.878666, 0.587949, 0.911689, * 0.537057, 0.738171, 0.775693, * 0.933167, 0.700325, 0.563810, * 0.712020, 0.606780, 0.538903 * B: * 0.780532, 0.649196, 0.703486, * 0.854725, 0.511782, 0.570734, * 0.550857, 0.832913, 0.937889, * 0.838400, 0.885429, 0.970482 * C: * 0, 0, 0, * 0, 0, 0, * 0, 0, 0, * 0, 0, 0 */ float a[12] = {0.878666, 0.587949, 0.911689, 0.537057, 0.738171, 0.775693, 0.933167, 0.700325, 0.563810, 0.712020, 0.606780, 0.538903 }; float b[12] = {0.780532, 0.649196, 0.703486, 0.854725, 0.511782, 0.570734, 0.550857, 0.832913, 0.937889, 0.838400, 0.885429, 0.970482 }; float c[12] = {0}; cblas_somatsub(CblasColMajor, CblasNoTrans, CblasNoTrans, m, n, alpha, a, lda, beta, b, ldb, c, ldc); /** * Output C: * 0.976800, 0.526701, 1.119892, * 0.219388, 0.964561, 0.980653, * 1.315476, 0.567737, 0.189731, * 0.585641, 0.328131, 0.107325 */
Fortran interface:
PROGRAM OMATSUB INTEGER :: M=4, N=3 INTEGER :: LDA=4, LDB=4, LDC=4 REAL(4) :: ALPHA=2.0 REAL(4) :: BETA=1.0 REAL(4) :: A(4, 3), B(4, 3), C(4, 3) DATA A/0.878666, 0.587949, 0.911689, 0.537057, 0.738171, 0.775693, 0.933167, 0.700325, 0.563810, 0.712020, 0.606780, 0.538903/ DATA B/0.780532, 0.649196, 0.703486, 0.854725, 0.511782, 0.570734, 0.550857, 0.832913, 0.937889, 0.838400, 0.885429, 0.970482/ DATA C/0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0/ EXTERNAL SOMATSUB CALL SOMATSUB('C', 'N', 'N', M, N, ALPHA, A, LDA, BETA, B, LDB, C, LDC) END * Output BC: * 0.976800, 0.526701, 1.119892, * 0.219388, 0.964561, 0.980653, * 1.315476, 0.567737, 0.189731, * 0.585641, 0.328131, 0.107325