?(or,un)gql
生成具有正交列的实/复矩阵Q,且该矩阵定义为K个M阶基本反射器的乘积的前N列,即:Q=H(k)...H(2)H(1),其中H为?geqlf返回的。
接口定义
C Interface:
void sorgql_(const int *m, const int *n, const int *k, float *a, const int *lda, float *tau, float *work, const int *lwork, int *info);
void dorgql_(const int *m, const int *n, const int *k, double *a, const int *lda, double *tau, double *work, const int *lwork, int *info);
void cungql_(const int *m, const int *n, const int *k, float _Complex *a, const int *lda, float _Complex *tau, float _Complex *work, const int *lwork, int *info);
void zungql_(const int *m, const int *n, const int *k, double _Complex *a, const int *lda, double _Complex *tau, double _Complex *work, const int *lwork, int *info);
Fortran Interface:
SORGQL(M,N,K,A,LDA,TAU,WORK,LWORK,INFO);
DORGQL(M,N,K,A,LDA,TAU,WORK,LWORK,INFO);
CUNGQL(M,N,K,A,LDA,TAU,WORK,LWORK,INFO);
ZUNGQL(M,N,K,A,LDA,TAU,WORK,LWORK,INFO);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
m |
整数型 |
Q的行数,m ≥ 0。 |
输入 |
n |
整数型 |
Q的列数,m ≥ n ≥ 0。 |
输入 |
k |
整数型 |
构成矩阵Q的基本反射器的数量,n ≥ k ≥ 0。 |
输入 |
a |
|
维度(lda, n)。
|
输入、输出 |
lda |
整数型 |
矩阵A的主维, lda ≥ max(1,M)。 |
输入 |
tau |
|
tau(i)必须包含基本反射器H(i)的常量因子,其由?geqlf返回的。 |
输入 |
work |
|
维数(max(1,lwork))。 若info=0,work(1)返回最优lwork值。 |
输出 |
lwork |
整数型 |
数组work的维数。 lwork ≥ max(1, N),对于最优性能:lwork ≥ N*NB,其中NB为最优块大小如果lwork=-1,则该例程只计算work数组的最优大小,并以work数组的第一个值返回。 |
输入 |
info |
整数型 |
|
输出 |
依赖
#include "klapack.h"
示例
C Interface:
int m = 4; int n = 4; int k = 4; int lda = m; 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 */ dorgql_(&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 */ dorgql_(&m, &n, &k, a, &lda, tau, work, &lwork, &info); free(work); /* * Output: * A output (stored in column-major) * -0.001005 -0.000771 0.004959 0.000000 * 0.956417 0.131450 0.398383 0.000000 * 0.237698 -1.275024 -0.978923 0.000000 * -0.000000 -0.000000 -0.000000 1.000000 */
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 DORGQL(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 DORGQL(m, n, k, a, lda, tau, work, lwork, info) DEALLOCATE(work) * * Output: * A output (stored in column-major) * -0.001005 -0.000771 0.004959 0.000000 * 0.956417 0.131450 0.398383 0.000000 * 0.237698 -1.275024 -0.978923 0.000000 * -0.000000 -0.000000 -0.000000 1.000000