?(or,un)glq
生成具有正交行的实/复矩阵Q,且该矩阵定义为K个N阶基本反射器的乘积的前M行,即:Q=H(k)...H(2)H(1),其中H为?gelqf返回的。
接口定义
C Interface:
void sorglq_(const int *m, const int *n, const int *k, float *a, const int *lda, const float *tau, float *work, const int *lwork, int *info);
void dorglq_(const int *m, const int *n, const int *k, double *a, const int *lda, const double *tau, double *work, const int *lwork, int *info);
void cunglq_(const int *m, const int *n, const int *k, float_Complex *a, const int *lda, const float_Complex *tau, float_Complex *work, const int *lwork, int *info);
void zunglq_(const int *m, const int *n, const int *k, double_Complex *a, const int *lda, const double_Complex *tau, double_Complex *work, const int *lwork, int *info);
Fortran Interface:
SORGLQ(M, N, K, A, LDA, TAU, WORK, LWORK, INFO);
DORGLQ(M, N, K, A, LDA, TAU, WORK, LWORK, INFO);
CUNGLQ(M, N, K, A, LDA, TAU, WORK, LWORK, INFO);
ZUNGLQ(M, N, K, A, LDA, TAU, WORK, LWORK, INFO);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
m |
整数型 |
矩阵Q的行数,m ≥ 0。 |
输入 |
n |
整数型 |
矩阵Q的列数,n ≥ m。 |
输入 |
k |
整数型 |
构成矩阵Q的基本反射器的数量,m ≥ k ≥0。 |
输入 |
a |
|
维度(lda, n)。
|
输入、输出 |
lda |
整数型 |
A的leading dimension,lda ≥ max(1, m)。 |
输入 |
tau |
|
tau(i)必须包含基本反射器H(i)的常量因子,其由?gelqf返回的。 |
输入 |
work |
|
维数(max(1,lwork))。若info=0,work(1)返回最优lwork值。 |
输出 |
lwork |
整数型 |
数组work的维数。lwork ≥ max(1, m),对于最优性能:lwork ≥ m*nb,其中nb为最优块大小如果lwork=-1,则该例程只计算work数组的最优大小,并以work数组的第一个值返回。 |
输入 |
info |
整数型 |
|
输出 |
依赖
#include "klapack.h"
示例
C Interface:
int m = 4; int n = 4; int k = 4; int lda = 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 */ 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}; /* Query optimal work size */ dorglq_(&m, &n, &k, a, &lda, tau, &qwork, &lwork, &info); if (info != 0) { return ERROR; } lwork = (int)qwork; work = (double *)malloc(sizeof(double) * lwork); /* Calculate Q */ dorglq_(&m, &n, &k, a, &lda, tau, work, &lwork, &info); free(work); /* * Output: * A output (stored in column-major) * -0.003949 0.089763 0.576860 0.811886 * 0.896027 -0.205343 0.333180 -0.209669 * 0.427292 0.639078 -0.551720 0.323428 * 0.120589 -0.735769 -0.501826 0.438490 */
Fortran Interface:
PARAMETER (m = 4) PARAMETER (n = 4) PARAMETER (k = 4) PARAMETER (lda = 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 * 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 / EXTERNAL DORGLQ * Query optimal work size CALL DORGLQ(m, n, k, a, lda, tau, qwork, lwork, info) IF (info.NE.0) THEN CALL EXIT(1) END IF lwork = INT(qwork(1)) ALLOCATE(work(lwork)) * Calculate Q CALL DORGLQ(m, n, k, a, lda, tau, work, lwork, info) DEALLOCATE(work) * Output: * A output (stored in column-major) * -0.003949 0.089763 0.576860 0.811886 * 0.896027 -0.205343 0.333180 -0.209669 * 0.427292 0.639078 -0.551720 0.323428 * 0.120589 -0.735769 -0.501826 0.438490