?(or,un)mrq
计算或,其中Q是由?gerqf计算得到。当Q转置,实数时表示,复数时表示;当Q不转置,表示Q。
接口定义
C Interface:
void sormrq_(const char *side, const char *trans, const int *m, const int *n, const int *k, float *a, const int *lda, float *tau, float *c, const int *ldc, float *work, const int *lwork, int *info);
void dormrq_(const char *side, const char *trans, const int *m, const int *n, const int *k, double *a, const int *lda, double *tau, double *c, const int *ldc, double *work, const int *lwork, int *info);
void cunmrq_(const char *side, const char *trans, const int *m, const int *n, const int *k, float _Complex *a, const int *lda, float _Complex *tau, float _Complex *c, const int *ldc, float _Complex *work, const int *lwork, int *info);
void zunmrq_(const char *side, const char *trans, const int *m, const int *n, const int *k, double _Complex *a, const int *lda, double _Complex *tau, double _Complex *c, const int *ldc, double _Complex *work, const int *lwork, int *info);
Fortran Interface:
SORMQR(SIDE,TRANS,M,N,K,A,LDA,TAU,C,LDC,WORK, LWORK, INFO);
DORMQR(SIDE,TRANS,M,N,K,A,LDA,TAU,C,LDC,WORK, LWORK, INFO);
CUNMQR(SIDE,TRANS,M,N,K,A,LDA,TAU,C,LDC,WORK, LWORK, INFO);
ZUNMQR(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 |
整数型 |
矩阵A的主维,lda ≥ max(1,K)。 |
输入 |
tau |
|
tau(i)必须包含基本反射器H(i)的常量因子,其由?gerqf返回的。 |
输入 |
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 */ dormrq_(&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 */ dormrq_(&side, &trans, &m, &n, &k, a, &lda, tau, c, &ldc, &qwork, &lwork, &info); free(work); /* * Output: * C output (stored in column-major) * 0.009265 -1.159433 -9.412653 2.758000 * -0.006793 -4.874383 -12.228202 4.317000 * -0.016693 -4.849802 -6.359105 3.161000 * 0.000914 0.912554 -6.587947 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 DORMRQ(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 DORMRQ(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info) DEALLOCATE(work) * * Output: * C output (stored in column-major) * 0.009265 -1.159433 -9.412653 2.758000 * -0.006793 -4.874383 -12.228202 4.317000 * -0.016693 -4.849802 -6.359105 3.161000 * 0.000914 0.912554 -6.587947 8.791000 *