hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_lapack_dormhr (f08ng)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_lapack_dormhr (f08ng) multiplies an arbitrary real matrix C by the real orthogonal matrix Q which was determined by nag_lapack_dgehrd (f08ne) when reducing a real general matrix to Hessenberg form.

Syntax

[c, info] = f08ng(side, trans, ilo, ihi, a, tau, c, 'm', m, 'n', n)
[c, info] = nag_lapack_dormhr(side, trans, ilo, ihi, a, tau, c, 'm', m, 'n', n)

Description

nag_lapack_dormhr (f08ng) is intended to be used following a call to nag_lapack_dgehrd (f08ne), which reduces a real general matrix A to upper Hessenberg form H by an orthogonal similarity transformation: A=QHQT. nag_lapack_dgehrd (f08ne) represents the matrix Q as a product of ihi-ilo elementary reflectors. Here ilo and ihi are values determined by nag_lapack_dgebal (f08nh) when balancing the matrix; if the matrix has not been balanced, ilo=1 and ihi=n.
This function may be used to form one of the matrix products
QC , QTC , CQ ​ or ​ CQT ,  
overwriting the result on C (which may be any real rectangular matrix).
A common application of this function is to transform a matrix V of eigenvectors of H to the matrix QV of eigenvectors of A.

References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

Parameters

Compulsory Input Parameters

1:     side – string (length ≥ 1)
Indicates how Q or QT is to be applied to C.
side='L'
Q or QT is applied to C from the left.
side='R'
Q or QT is applied to C from the right.
Constraint: side='L' or 'R'.
2:     trans – string (length ≥ 1)
Indicates whether Q or QT is to be applied to C.
trans='N'
Q is applied to C.
trans='T'
QT is applied to C.
Constraint: trans='N' or 'T'.
3:     ilo int64int32nag_int scalar
4:     ihi int64int32nag_int scalar
These must be the same arguments ilo and ihi, respectively, as supplied to nag_lapack_dgehrd (f08ne).
Constraints:
  • if side='L' and m>0, 1 ilo ihi m ;
  • if side='L' and m=0, ilo=1 and ihi=0;
  • if side='R' and n>0, 1 ilo ihi n ;
  • if side='R' and n=0, ilo=1 and ihi=0.
5:     alda: – double array
The first dimension, lda, of the array a must satisfy
  • if side='L', lda max1,m ;
  • if side='R', lda max1,n .
The second dimension of the array a must be at least max1,m if side='L' and at least max1,n if side='R'.
Details of the vectors which define the elementary reflectors, as returned by nag_lapack_dgehrd (f08ne).
6:     tau: – double array
The dimension of the array tau must be at least max1,m-1 if side='L' and at least max1,n-1 if side='R'
Further details of the elementary reflectors, as returned by nag_lapack_dgehrd (f08ne).
7:     cldc: – double array
The first dimension of the array c must be at least max1,m.
The second dimension of the array c must be at least max1,n.
The m by n matrix C.

Optional Input Parameters

1:     m int64int32nag_int scalar
Default: the first dimension of the array c.
m, the number of rows of the matrix C; m is also the order of Q if side='L'.
Constraint: m0.
2:     n int64int32nag_int scalar
Default: the second dimension of the array c.
n, the number of columns of the matrix C; n is also the order of Q if side='R'.
Constraint: n0.

Output Parameters

1:     cldc: – double array
The first dimension of the array c will be max1,m.
The second dimension of the array c will be max1,n.
c stores QC or QTC or CQ or CQT as specified by side and trans.
2:     info int64int32nag_int scalar
info=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

   info=-i
If info=-i, parameter i had an illegal value on entry. The parameters are numbered as follows:
1: side, 2: trans, 3: m, 4: n, 5: ilo, 6: ihi, 7: a, 8: lda, 9: tau, 10: c, 11: ldc, 12: work, 13: lwork, 14: info.
It is possible that info refers to a parameter that is omitted from the MATLAB interface. This usually indicates that an error in one of the other input parameters has caused an incorrect value to be inferred.

Accuracy

The computed result differs from the exact result by a matrix E such that
E2 = Oε C2 ,  
where ε is the machine precision.

Further Comments

The total number of floating-point operations is approximately 2nq2 if side='L' and 2mq2 if side='R', where q=ihi-ilo.
The complex analogue of this function is nag_lapack_zunmhr (f08nu).

Example

This example computes all the eigenvalues of the matrix A, where
A = 0.35 0.45 -0.14 -0.17 0.09 0.07 -0.54 0.35 -0.44 -0.33 -0.03 0.17 0.25 -0.32 -0.13 0.11 ,  
and those eigenvectors which correspond to eigenvalues λ such that Reλ<0. Here A is general and must first be reduced to upper Hessenberg form H by nag_lapack_dgehrd (f08ne). The program then calls nag_lapack_dhseqr (f08pe) to compute the eigenvalues, and nag_lapack_dhsein (f08pk) to compute the required eigenvectors of H by inverse iteration. Finally nag_lapack_dormhr (f08ng) is called to transform the eigenvectors of H back to eigenvectors of the original matrix A.
function f08ng_example


fprintf('f08ng example results\n\n');

n   = int64(4);
ilo = int64(1);
ihi = n;
a = [ 0.35,  0.45, -0.14, -0.17;
      0.09,  0.07, -0.54,  0.35;
     -0.44, -0.33, -0.03,  0.17;
      0.25, -0.32, -0.13,  0.11];

% Reduce A to upper Hessenberg Form A = QHQ^T
[H, tau, info] = f08ne( ...
                        ilo, ihi, a);

% Form Q
[Q, info] = f08nf( ...
                   ilo, ihi, H, tau);

% Schur factorize H = Y*T*Y^T
job   = 'Schur form';
compz = 'No Vectors';
[~, wr, wi, ~, info] = f08pe( ...
                              job, compz, ilo, ihi, H, Q);

w = wr + i*wi;
disp('Eigenvalues of A');
disp(w);

% Calculate eigenvetors of H corresponding to negative real part eigenvalues
select = (wr < 0);

job = 'Right';
eigsrc = 'QR';
initv = 'No initial vectors';
vl = [];
vr = zeros(n,n);
[~, ~, ~, VR, m, ifaill, ifailr, info] = ...
f08pk( ...
       job, eigsrc, initv, select, H, wr, wi, vl, vr, n);

% Eigenvectors of A = Q*VR
side = 'Left';
trans = 'No transpose';
[V, info] = f08ng( ...
                   side, trans, ilo, ihi, H, tau, VR);

% Combine columns of V into complex eigenvectors Z
j = 0;
for k = 1:n
  if select(k)
    j = j+1;
    if (wi(k)==0)
      % Normalize eigenvector: largest element positive
      [~,l] = max(abs(V(:,j)));
      if V(l,j) < 0;
        V(:,j) = -V(:,j);
      end                      
      Z(:,j) = complex(V(:,j));
    else
      Z(:,j)   = V(:,j) + i*V(:,j+1);
      Z(:,j+1) = V(:,j) - i*V(:,j+1);
      % Normalize: largest element is real
      [~,l] = max(abs(real(Z(:,j)))+abs(imag(Z(:,j))));
      Z(:,j) = Z(:,j)*conj(Z(l,j))/abs(Z(l,j));
      Z(:,j+1) = Z(:,j+1)*conj(Z(l,j+1))/abs(Z(l,j+1));
      j = j+1;
      select(k+1) = false;
    end
  end
end
disp('Eigenvectors corresponding to eigenvalues with negative real part');
disp(Z);


f08ng example results

Eigenvalues of A
   0.7995 + 0.0000i
  -0.0994 + 0.4008i
  -0.0994 - 0.4008i
  -0.1007 + 0.0000i

Eigenvectors corresponding to eigenvalues with negative real part
  -0.2379 + 0.3134i  -0.2379 - 0.3134i   0.1493 + 0.0000i
   0.3100 - 0.6430i   0.3100 + 0.6430i   0.3956 + 0.0000i
   0.1196 - 0.3795i   0.1196 + 0.3795i   0.7075 + 0.0000i
   0.8319 + 0.0000i   0.8319 + 0.0000i   0.8603 + 0.0000i


PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015