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_sparseig_complex_proc (f12aq)

Purpose

nag_sparseig_complex_proc (f12aq) is a post-processing function in a suite of functions consisting of nag_sparseig_complex_init (f12an), nag_sparseig_complex_iter (f12ap), nag_sparseig_complex_proc (f12aq), nag_sparseig_complex_option (f12ar) and nag_sparseig_complex_monit (f12as), that must be called following a final exit from nag_sparseig_complex_proc (f12aq).

Syntax

[nconv, d, z, v, comm, icomm, ifail] = f12aq(sigma, resid, v, comm, icomm)
[nconv, d, z, v, comm, icomm, ifail] = nag_sparseig_complex_proc(sigma, resid, v, comm, icomm)

Description

The suite of functions is designed to calculate some of the eigenvalues, λ λ , (and optionally the corresponding eigenvectors, x x ) of a standard eigenvalue problem Ax = λx Ax = λx , or of a generalized eigenvalue problem Ax = λBx Ax = λBx  of order n n , where n n  is large and the coefficient matrices A A  and B B  are sparse, complex and nonsymmetric. The suite can also be used to find selected eigenvalues/eigenvectors of smaller scale dense, complex and nonsymmetric problems.
Following a call to nag_sparseig_complex_iter (f12ap), nag_sparseig_complex_proc (f12aq) returns the converged approximations to eigenvalues and (optionally) the corresponding approximate eigenvectors and/or an orthonormal basis for the associated approximate invariant subspace. The eigenvalues (and eigenvectors) are selected from those of a standard or generalized eigenvalue problem defined by complex nonsymmetric matrices. There is negligible additional cost to obtain eigenvectors; an orthonormal basis is always computed, but there is an additional storage cost if both are requested.
nag_sparseig_complex_proc (f12aq) is based on the function zneupd from the ARPACK package, which uses the Implicitly Restarted Arnoldi iteration method. The method is described in Lehoucq and Sorensen (1996) and Lehoucq (2001) while its use within the ARPACK software is described in great detail in Lehoucq et al. (1998). An evaluation of software for computing eigenvalues of sparse nonsymmetric matrices is provided in Lehoucq and Scott (1996). This suite of functions offers the same functionality as the ARPACK software for complex nonsymmetric problems, but the interface design is quite different in order to make the option setting clearer and to simplify some of the interfaces.
nag_sparseig_complex_proc (f12aq) is a post-processing function that must be called following a successful final exit from nag_sparseig_complex_iter (f12ap). nag_sparseig_complex_proc (f12aq) uses data returned from nag_sparseig_complex_iter (f12ap) and options set either by default or explicitly by calling nag_sparseig_complex_option (f12ar), to return the converged approximations to selected eigenvalues and (optionally):
the corresponding approximate eigenvectors;
an orthonormal basis for the associated approximate invariant subspace;
both.

References

Lehoucq R B (2001) Implicitly restarted Arnoldi methods and subspace iteration SIAM Journal on Matrix Analysis and Applications 23 551–562
Lehoucq R B and Scott J A (1996) An evaluation of software for computing eigenvalues of sparse nonsymmetric matrices Preprint MCS-P547-1195 Argonne National Laboratory
Lehoucq R B and Sorensen D C (1996) Deflation techniques for an implicitly restarted Arnoldi iteration SIAM Journal on Matrix Analysis and Applications 17 789–821
Lehoucq R B, Sorensen D C and Yang C (1998) ARPACK Users' Guide: Solution of Large-scale Eigenvalue Problems with Implicitly Restarted Arnoldi Methods SIAM, Philidelphia

Parameters

Compulsory Input Parameters

1:     sigma – complex scalar
If one of the Shifted Inverse (see nag_sparseig_complex_option (f12ar)) modes has been selected then sigma contains the shift used; otherwise sigma is not referenced.
2:     resid( : :) – complex array
Note: the dimension of the array resid must be at least nn (see nag_sparseig_complex_init (f12an)).
Must not be modified following a call to nag_sparseig_complex_iter (f12ap) since it contains data required by nag_sparseig_complex_proc (f12aq).
3:     v(ldv, : :) – complex array
The first dimension of the array v must be at least nn
The second dimension of the array must be at least max (1,ncv) max(1,ncv)
The ncv columns of v contain the Arnoldi basis vectors for OPOP as constructed by nag_sparseig_complex_iter (f12ap).
4:     comm( : :) – complex array
Note: the dimension of the array comm must be at least max (1,lcomm)max(1,lcomm) (see nag_sparseig_complex_init (f12an)).
On initial entry: must remain unchanged from the prior call to nag_sparseig_complex_init (f12an).
5:     icomm( : :) – int64int32nag_int array
Note: the dimension of the array icomm must be at least max (1,licomm)max(1,licomm) (see nag_sparseig_complex_init (f12an)).
On initial entry: must remain unchanged from the prior call to nag_sparseig_complex_init (f12an).

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

ldz ldv

Output Parameters

1:     nconv – int64int32nag_int scalar
The number of converged eigenvalues as found by nag_sparseig_complex_option (f12ar).
2:     d( : :) – complex array
Note: the dimension of the array d must be at least ncvncv (see nag_sparseig_complex_init (f12an)).
The first nconv locations of the array d contain the converged approximate eigenvalues.
3:     z(n × ncvn×ncv) – complex array
If the default option Vectors = RITZVectors=RITZ (see nag_sparseig_real_option (f12ad)) has been selected then z contains the final set of eigenvectors corresponding to the eigenvalues held in d. The complex eigenvector associated with an eigenvalue is stored in the corresponding column of z.
4:     v(ldv, : :) – complex array
The first dimension of the array v will be nn
The second dimension of the array will be max (1,ncv) max(1,ncv)
ldv = icomm(comm(1) . re + 1)ldv=icommcomm1.re+1.
If the option Vectors = SCHURVectors=SCHUR or RITZRITZ has been set and a separate array z has been passed (i.e., z does not equal v), then the first nconv columns of v will contain approximate Schur vectors that span the desired invariant subspace.
5:     comm( : :) – complex array
Note: the dimension of the array comm must be at least max (1,lcomm)max(1,lcomm) (see nag_sparseig_complex_init (f12an)).
Contains data on the current state of the solution.
6:     icomm( : :) – int64int32nag_int array
Note: the dimension of the array icomm must be at least max (1,licomm)max(1,licomm) (see nag_sparseig_complex_init (f12an)).
Contains data on the current state of the solution.
7:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry, ldz < max (1,n) ldz < max(1,n)  or ldz < 1 ldz < 1  when no vectors are required.
  ifail = 2ifail=2
On entry, the option Vectors = Select Vectors = Select  was selected, but this is not yet implemented.
  ifail = 3ifail=3
The number of eigenvalues found to sufficient accuracy prior to calling nag_sparseig_complex_proc (f12aq), as communicated through the parameter icomm, is zero.
  ifail = 4ifail=4
The number of converged eigenvalues as calculated by nag_sparseig_complex_iter (f12ap) differ from the value passed to it through the parameter icomm.
  ifail = 5ifail=5
Unexpected error during calculation of a Schur form: there was a failure to compute all the converged eigenvalues. Please contact NAG.
  ifail = 6ifail=6
Unexpected error: the computed Schur form could not be reordered by an internal call. Please contact NAG.
  ifail = 7ifail=7
Unexpected error in internal call while calculating eigenvectors. Please contact NAG.
  ifail = 8ifail=8
Either the solver function nag_sparseig_complex_iter (f12ap) has not been called prior to the call of this function or a communication array has become corrupted.
  ifail = 9ifail=9
The function was unable to dynamically allocate sufficient internal workspace. Please contact NAG.
  ifail = 10ifail=10
An unexpected error has occurred. Please contact NAG.

Accuracy

The relative accuracy of a Ritz value, λ λ , is considered acceptable if its Ritz estimate Tolerance × |λ| Tolerance × |λ| . The default Tolerance used is the machine precision given by nag_machine_precision (x02aj).

Further Comments

None.

Example

function nag_sparseig_complex_proc_example
n = int64(100);
nx = int64(10);
nev = int64(4);
ncv = int64(20);

irevcm = int64(0);
resid = complex(zeros(100,1));
v = complex(zeros(100,20));
x = complex(zeros(100,1));
mx = complex(zeros(100,1));

sigma = complex(0);


% Initialisation Step
[icomm, comm, ifail] = nag_sparseig_complex_init(n, nev, ncv);

% Solve
while (irevcm ~= 5)
  [irevcm, resid, v, x, mx, nshift, comm, icomm, ifail] = ...
    nag_sparseig_complex_iter(irevcm, resid, v, x, mx, comm, icomm);
  if (irevcm == 1 || irevcm == -1)
    x = f12_av(nx, x);
  elseif (irevcm == 4)
    [niter, nconv, ritz, rzest] = nag_sparseig_complex_monit(icomm, comm);
    fprintf('Iteration %d, No. converged = %d, norm of estimates = %16.8g\n',  ...
            niter, nconv, norm(rzest(1:double(nev)),2));
  end
end

% Post-process to compute eigenvalues/vectors
[nconv, d, z, v, comm, icomm, ifail] = ...
    nag_sparseig_complex_proc(sigma, resid, v, comm, icomm);
% sort to avoid difference in order showing as an error



function [w] = f12_av(nx, v)

  inx = double(nx); % nx is int64

  w = complex(zeros(inx*inx,1));

  h2 = double(-(inx+1)^2);

  w(1:inx) = tv(inx, v(1:inx));
  w(1:inx) = h2*v(inx+1:2*inx)+w(1:inx);

  for j=2:double(inx-1)
    lo = (j-1)*inx +1;
    hi = j*inx;

    w(lo:hi) = tv(inx, v(lo:hi));
    w(lo:hi) = h2*v(lo-inx:lo-1)+w(lo:hi);
    w(lo:hi) = h2*v(hi+1:hi+inx)+w(lo:hi);
  end


  lo = (inx-1)*inx +1;
  hi = inx*inx;
  w(lo:hi) = tv(inx, v(lo:hi));
  w(lo:hi) = h2*v(lo-inx:lo-1)+w(lo:hi);

function [y] = tv(inx,x)

  y = zeros(inx,1);

  dd = double(4*(inx+1)^2);
  dl = double(-(inx+1)^2 - 0.5*100*(inx+1));
  du = double(-(inx+1)^2 + 0.5*100*(inx+1));

  y(1) = dd*x(1) + du*x(2);
  for j=2:double(inx-1)
    y(j) = dl*x(j-1) + dd*x(j) + du*x(j+1);
  end
  y(inx) = dl*x(inx-1) + dd*x(inx);
 
Iteration 1, No. converged = 0, norm of estimates =        133.43269
Iteration 2, No. converged = 0, norm of estimates =        99.725711
Iteration 3, No. converged = 0, norm of estimates =         42.48146
Iteration 4, No. converged = 0, norm of estimates =        8.1805323
Iteration 5, No. converged = 0, norm of estimates =        1.7794793
Iteration 6, No. converged = 0, norm of estimates =       0.49794897
Iteration 7, No. converged = 0, norm of estimates =       0.12604717
Iteration 8, No. converged = 0, norm of estimates =      0.026883649
Iteration 9, No. converged = 0, norm of estimates =     0.0070182429
Iteration 10, No. converged = 0, norm of estimates =     0.0014438635
Iteration 11, No. converged = 0, norm of estimates =    0.00040007427
Iteration 12, No. converged = 0, norm of estimates =     0.0001059392
Iteration 13, No. converged = 0, norm of estimates =     2.803229e-05
Iteration 14, No. converged = 0, norm of estimates =    7.7343157e-06
Iteration 15, No. converged = 0, norm of estimates =    1.9579037e-06
Iteration 16, No. converged = 0, norm of estimates =      6.15616e-07
Iteration 17, No. converged = 0, norm of estimates =    1.2591405e-07
Iteration 18, No. converged = 0, norm of estimates =    3.7790713e-08
Iteration 19, No. converged = 2, norm of estimates =    8.3787181e-09
Iteration 20, No. converged = 2, norm of estimates =    1.8827432e-09
Iteration 21, No. converged = 2, norm of estimates =    1.6920778e-10
Iteration 22, No. converged = 2, norm of estimates =     2.299125e-11
Iteration 23, No. converged = 2, norm of estimates =     3.391976e-12
Iteration 24, No. converged = 2, norm of estimates =    5.5954988e-13

function f12aq_example
n = int64(100);
nx = int64(10);
nev = int64(4);
ncv = int64(20);

irevcm = int64(0);
resid = complex(zeros(100,1));
v = complex(zeros(100,20));
x = complex(zeros(100,1));
mx = complex(zeros(100,1));

sigma = complex(0);


% Initialisation Step
[icomm, comm, ifail] = f12an(n, nev, ncv);

% Solve
while (irevcm ~= 5)
  [irevcm, resid, v, x, mx, nshift, comm, icomm, ifail] = ...
    f12ap(irevcm, resid, v, x, mx, comm, icomm);
  if (irevcm == 1 || irevcm == -1)
    x = f12_av(nx, x);
  elseif (irevcm == 4)
    [niter, nconv, ritz, rzest] = f12as(icomm, comm);
    fprintf('Iteration %d, No. converged = %d, norm of estimates = %16.8g\n', ...
            niter, nconv, norm(rzest(1:double(nev)),2));
  end
end

% Post-process to compute eigenvalues/vectors
[nconv, d, z, v, comm, icomm, ifail] = f12aq(sigma, resid, v, comm, icomm);
% sort to avoid difference in order showing as an error



function [w] = f12_av(nx, v)

  inx = double(nx); % nx is int64

  w = complex(zeros(inx*inx,1));

  h2 = double(-(inx+1)^2);

  w(1:inx) = tv(inx, v(1:inx));
  w(1:inx) = h2*v(inx+1:2*inx)+w(1:inx);

  for j=2:double(inx-1)
    lo = (j-1)*inx +1;
    hi = j*inx;

    w(lo:hi) = tv(inx, v(lo:hi));
    w(lo:hi) = h2*v(lo-inx:lo-1)+w(lo:hi);
    w(lo:hi) = h2*v(hi+1:hi+inx)+w(lo:hi);
  end


  lo = (inx-1)*inx +1;
  hi = inx*inx;
  w(lo:hi) = tv(inx, v(lo:hi));
  w(lo:hi) = h2*v(lo-inx:lo-1)+w(lo:hi);

function [y] = tv(inx,x)

  y = zeros(inx,1);

  dd = double(4*(inx+1)^2);
  dl = double(-(inx+1)^2 - 0.5*100*(inx+1));
  du = double(-(inx+1)^2 + 0.5*100*(inx+1));

  y(1) = dd*x(1) + du*x(2);
  for j=2:double(inx-1)
    y(j) = dl*x(j-1) + dd*x(j) + du*x(j+1);
  end
  y(inx) = dl*x(inx-1) + dd*x(inx);
 
Iteration 1, No. converged = 0, norm of estimates =        133.43269
Iteration 2, No. converged = 0, norm of estimates =        99.725711
Iteration 3, No. converged = 0, norm of estimates =         42.48146
Iteration 4, No. converged = 0, norm of estimates =        8.1805323
Iteration 5, No. converged = 0, norm of estimates =        1.7794793
Iteration 6, No. converged = 0, norm of estimates =       0.49794897
Iteration 7, No. converged = 0, norm of estimates =       0.12604717
Iteration 8, No. converged = 0, norm of estimates =      0.026883649
Iteration 9, No. converged = 0, norm of estimates =     0.0070182429
Iteration 10, No. converged = 0, norm of estimates =     0.0014438635
Iteration 11, No. converged = 0, norm of estimates =    0.00040007427
Iteration 12, No. converged = 0, norm of estimates =     0.0001059392
Iteration 13, No. converged = 0, norm of estimates =     2.803229e-05
Iteration 14, No. converged = 0, norm of estimates =    7.7343157e-06
Iteration 15, No. converged = 0, norm of estimates =    1.9579037e-06
Iteration 16, No. converged = 0, norm of estimates =      6.15616e-07
Iteration 17, No. converged = 0, norm of estimates =    1.2591405e-07
Iteration 18, No. converged = 0, norm of estimates =    3.7790713e-08
Iteration 19, No. converged = 2, norm of estimates =    8.3787181e-09
Iteration 20, No. converged = 2, norm of estimates =    1.8827432e-09
Iteration 21, No. converged = 2, norm of estimates =    1.6920778e-10
Iteration 22, No. converged = 2, norm of estimates =     2.299125e-11
Iteration 23, No. converged = 2, norm of estimates =     3.391976e-12
Iteration 24, No. converged = 2, norm of estimates =    5.5954988e-13


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–2013