?(or,un)mql
计算或,其中Q是由?geqlf计算得到。当Q转置,实数时表示,复数时表示;当Q不转置,表示Q。
接口定义
C Interface:
void sormql_(const char *uplo, const char *trans, const int *m, const int *n, const int *k, float *a, const int *lda, const float *tau, float *c, const int *ldc, float *work, const int *lwork, int *info);
void dormql_(const char *uplo, const char *trans, const int *m, const int *n, const int *k, double *a, const int *lda, const double *tau, double *c, const int *ldc, double *work, const int *lwork, int *info);
void cunmql_(const char *uplo, const char *trans, const int *m, const int *n, const int *k, float _Complex *a, const int *lda, const float _Complex *tau, float _Complex *c, const int *ldc, float _Complex *work, const int *lwork, int *info);
void zunmql_(const char *uplo, const char *trans, const int *m, const int *n, const int *k, double _Complex *a, const int *lda, const double _Complex *tau, double _Complex *c, const int *ldc, double _Complex *work, const int *lwork, int *info);
Fortran Interface:
SORMQL(side,trans,m,n,k,a,lda,tau,c,ldc,work,lwork,info);
DORMQL(side,trans,m,n,k,a,lda,tau,c,ldc,work,lwork,info);
CUNMQL(side,trans,m,n,k,a,lda,tau,c,ldc,work,lwork,info);
ZUNMQL(side,trans,m,n,k,a,lda,tau,c,ldc,work,lwork,info);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
side |
字符型 |
|
输入 |
trans |
字符型 |
|
输入 |
M |
整数型 |
C的行数,M ≥ 0。 |
输入 |
N |
整数型 |
C的列数,N ≥ 0。 |
输入 |
K |
整数型 |
生成Q的元素反射器的个数。
|
输入 |
A |
|
原始矩阵,维数(LDA,K)。 |
输入 |
lda |
整数型 |
矩阵A的主维。
|
输入 |
tau |
|
tau(i)必须包含基本反射器H(i)的常量因子,其由?geqlf返回的。 |
输入 |
C |
|
待计算矩阵,维数为(LDC, N)。 |
输入、输出 |
ldc |
整数型 |
矩阵C的主维,ldc ≥ max(1,M)。 |
输入 |
work |
|
维数(max(1,lwork))。 若info=0,work(1)返回最优lwork值。 |
输出 |
lwork |
整数型 |
work的大小。
如果lwork=-1,则该例程只计算work数组的最优大小,并以work数组的第一个值返回。 |
输入 |
info |
整数型 |
|
输出 |
依赖
#include "klapack.h"
示例
C Interface:
char side = 'L'; char trans = 'N'; int m = 4; int n = 4; int k = 4; int lda = 4; int ldc = 4; int info = 0; double tau[4] = {1.003949, 1.125229, 1.978923, 0.000000}; double *work = NULL; double qwork; int lwork = -1; /* * tau: * 1.003949 1.125229 1.978923 0.000000 * A (4x4, stored in column-major): * -1.036040 -0.892502 -0.120115 -0.425611 * 0.654120 0.468127 0.644302 -0.601906 * -0.135860 0.502159 1.077637 -0.103204 * -0.480109 -1.207226 0.162668 0.227483 * *C (4x4, stored in column-major): * 2.229, 8.103, 7.810, 0.087, * 8.667, 8.859, 2.911, 4.091, * 0.205, 1.273, 1.396, 2.553, * 2.758, 4.317, 3.161, 8.791 */ double a[] = {-1.036040, 0.654120, 0.135860, -0.480109, -0.892502, 0.468127, 0.502159, -1.207226, -0.120115, 0.644302, 1.077637, 0.162668, -0.425611, -0.601906, -0.103204, 0.227483}; double c[] = {2.229, 8.667, 0.205, 2.758, 8.103, 8.859, 1.273, 4.317, 7.810, 2.911, 1.396, 3.161, 0.087, 4.091, 2.553, 8.791}; /* Query optimal work size */ dormql_(&side, &trans, &m, &n, &k, a, &lda, tau, c, &ldc, &qwork, &lwork, &info); if (info != 0) { return ERROR; } lwork = (int)qwork; work = (double *)malloc(sizeof(double) * lwork); /* Calculate Q */ dormql_(&side, &trans, &m, &n, &k, a, &lda, tau, c, &ldc, &qwork, &lwork, &info); free(work); /* * Output: * C output (stored in column-major) * 8.335757 0.876180 3.263161 2.758000 * 8.767347 -0.464834 2.323291 4.317000 * 3.108108 -1.403301 -0.168152 3.161000 * 4.519460 -2.717441 -0.868974 8.791000 */
Fortran Interface:
CHARACTER :: side = "L" CHARACTER :: trans = "N" PARAMETER (m = 4) PARAMETER (n = 4) PARAMETER (k = 4) PARAMETER (lda = 4) PARAMETER (ldc = 4) INTEGER :: info = 0 REAL(8) :: tau(4) REAL(8) :: qwork(1) INTEGER :: lwork = -1 REAL(8), ALLOCATABLE :: work(:) * * tau: * 1.003949 1.125229 1.978923 0.000000 * A (4x4, stored in column-major): * -1.036040 -0.892502 -0.120115 -0.425611 * 0.654120 0.468127 0.644302 -0.601906 * -0.135860 0.502159 1.077637 -0.103204 * -0.480109 -1.207226 0.162668 0.227483 * C (4x4, stored in column-major): * 2.229, 8.103, 7.810, 0.087, * 8.667, 8.859, 2.911, 4.091, * 0.205, 1.273, 1.396, 2.553, * 2.758, 4.317, 3.161, 8.791 * DATA tau /1.003949, 1.125229, 1.978923, 0.000000/ REAL(8) :: a(m, n) DATA a / -1.036040, 0.654120, 0.135860, -0.480109, $ -0.892502, 0.468127, 0.502159, -1.207226, $ -0.120115, 0.644302, 1.077637, 0.162668, $ -0.425611, -0.601906, -0.103204, 0.227483 / DATA c / 2.229, 8.667, 0.205, 2.758, $ 8.103, 8.859, 1.273, 4.317, $ 7.810, 2.911, 1.396, 3.161, $ 0.087, 4.091, 2.553, 8.791 EXTERNAL DORGLQ * Query optimal work size CALL DORMQL(side, trans, m, n, k, a, lda, tau, c, ldc, qwork, lwork, info) IF (info.NE.0) THEN CALL EXIT(1) END IF lwork = INT(qwork(1)) ALLOCATE(work(lwork)) * Calculate Q CALL DORMQL(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info) DEALLOCATE(work) * * Output: * C output (stored in column-major) * 8.335757 0.876180 3.263161 2.758000 * 8.767347 -0.464834 2.323291 4.317000 * 3.108108 -1.403301 -0.168152 3.161000 * 4.519460 -2.717441 -0.868974 8.791000 *