Home > manopt > manifolds > ttfixedrank > TTeMPS_1.1 > examples > ex_henon_3_hermite.m

# ex_henon_3_hermite

## PURPOSE

Example for the algorithms described in

## SYNOPSIS

This is a script file.

## DESCRIPTION

``` Example for the algorithms described in

D. Kressner, M. Steinlechner, A. Uschmajew:
Low-rank tensor methods with subspace correction for symmetric eigenvalue problems
SIAM J. Sci. Comput., 36(5):A2346-A2368, 2014.

Code to produce Figure 4.4: Three Eigenvalues for Henon-Heiles with
with n=28, d=10```

## CROSS-REFERENCE INFORMATION

This function calls:
This function is called by:

## SOURCE CODE

```0001 % Example for the algorithms described in
0002 %
0003 %       D. Kressner, M. Steinlechner, A. Uschmajew:
0004 %        Low-rank tensor methods with subspace correction for symmetric eigenvalue problems
0005 %        SIAM J. Sci. Comput., 36(5):A2346-A2368, 2014.
0006 %
0007 % Code to produce Figure 4.4: Three Eigenvalues for Henon-Heiles with
0008 % with n=28, d=10
0009
0010 %   TTeMPS Toolbox.
0011 %   Michael Steinlechner, 2013-2016
0012 %   Questions and contact: michael.steinlechner@epfl.ch
0014 % =========================================================================
0015 clear all
0016 close all
0017
0018 n = 28;
0019 d = 10;
0020 A = TTeMPS_op_NN_hermite(n, d);
0021 p = 3;
0022 r = 1;
0023
0024 % Run block eigenvalue procedure:
0025 % =========================================================================
0026
0027 if ~exist('hh_3_blk_hermite.mat','file')
0028     opts = struct( 'maxiter', 3, ...
0029                    'maxrank', 40, ...
0030                    'tol', 1e-8, ...
0031                    'tolOP', 1e-3, ...
0032                    'tolLOBPCG', 1e-6, ...
0033                    'maxiterLOBPCG', 500, ...
0034                    'verbose', true , ...
0035                    'precInner', true);
0036
0037     rng(11)
0038     rr = [1, 1 * ones(1, d-1), 1];
0039     [X_blk_hermite, C_blk_hermite, evalue_blk_hermite, residuums_blk_hermite, micro_res_blk_hermite, objective_blk_hermite, t_blk_hermite] = block_eigenvalue( A, p, rr, opts);
0040     save('hh_3_blk_hermite', 'X_blk_hermite', 'C_blk_hermite', 'evalue_blk_hermite', 'residuums_blk_hermite', 'micro_res_blk_hermite', 'objective_blk_hermite','t_blk_hermite');
0041 else
0043 end
0044
0045 % Run EVAMEn:
0046 % =========================================================================
0047
0048 if ~exist('hh_3_evamen_hermite.mat','file')
0049     opts = struct( 'maxiter', 3, ...
0050                    'maxrank', 40, ...
0051                    'maxrankRes', 2, ...
0052                    'tol', 1e-8, ...
0053                    'tolOP', 1e-3, ...
0054                    'tolLOBPCG', 1e-6, ...
0055                    'maxiterLOBPCG', 500, ...
0056                    'verbose', true , ...
0057                    'precInner', true);
0058     rng(11)
0059     rr = [1, 1 * ones(1, d-1), 1];
0060     [X_evamen_hermite, C_evamen_hermite, evalue_evamen_hermite, residuums_evamen_hermite, micro_res_evamen_hermite, objective_evamen_hermite, t_evamen_hermite] = amen_eigenvalue( A, 1, p, rr, opts);
0061     save('hh_3_evamen_hermite', 'X_evamen_hermite', 'C_evamen_hermite', 'evalue_evamen_hermite', 'residuums_evamen_hermite', 'micro_res_evamen_hermite', 'objective_evamen_hermite','t_evamen_hermite');
0062 else
0064 end
0065
0066
0067 % Prepare data for plotting:
0068 % =========================================================================
0069
0070 evalue_end = repmat(evalue_blk_hermite(:,end), [1,size(evalue_blk_hermite,2)-1]);
0071 ev_blk_hermite = abs(evalue_blk_hermite(:,1:end-1) - evalue_end);
0072 ev_evamen_hermite = abs(evalue_evamen_hermite(:,1:end-1) - evalue_end);
0073
0074
0075 % Plot vs. Iterations
0076 % =========================================================================
0077 f = figure
0078 set(0,'defaultlinelinewidth',2)
0079 subplot(1,2,1)
0080
0081 semilogy( sqrt(sum(micro_res_blk_hermite.^2, 1)), '-b' )
0082 hold on
0083 semilogy( sqrt(sum(micro_res_evamen_hermite.^2, 1)), '-k' )
0084
0085 semilogy( sum(ev_blk_hermite,1), '--b' )
0086 semilogy( sum(ev_evamen_hermite,1), '--k' )
0087
0088 res_blk_hermite         = sqrt(sum(micro_res_blk_hermite.^2, 1))
0089 res_evamen_hermite  = sqrt(sum(micro_res_evamen_hermite.^2, 1))
0090
0091 semilogy((d-1):(d-1):length(micro_res_blk_hermite),res_blk_hermite(:,(d-1):(d-1):end),'ob')
0092 semilogy((d-1):(d-1):length(micro_res_evamen_hermite),res_evamen_hermite(:,(d-1):(d-1):end),'ok')
0093
0094 semilogy((d-1):(d-1):length(ev_blk_hermite),sum(ev_blk_hermite(:,(d-1):(d-1):end),1),'ob')
0095 semilogy((d-1):(d-1):length(ev_evamen_hermite),sum(ev_evamen_hermite(:,(d-1):(d-1):end),1),'ok')
0096
0097 set(gca,'fontsize',20)
0098 xlabel('Microiterations')
0099 ylabel('Residual and eigenvalue error')
0100
0101 % Plot vs. Time
0102 % =========================================================================
0103
0104 subplot(1,2,2)
0105 semilogy( t_blk_hermite, sqrt(sum(micro_res_blk_hermite.^2, 1)), '-b' )
0106 hold on
0107 semilogy( t_evamen_hermite, sqrt(sum(micro_res_evamen_hermite.^2, 1)), '-k' )
0108
0109 semilogy( t_blk_hermite, sum(ev_blk_hermite,1), '--b' )
0110 semilogy( t_evamen_hermite, sum(ev_evamen_hermite,1), '--k' )
0111
0112 semilogy(t_blk_hermite((d-1):(d-1):end),res_blk_hermite(:,(d-1):(d-1):end),'ob')
0113 semilogy(t_evamen_hermite((d-1):(d-1):end),res_evamen_hermite(:,(d-1):(d-1):end),'ok')
0114
0115 semilogy(t_blk_hermite((d-1):(d-1):end),sum(ev_blk_hermite(:,(d-1):(d-1):end),1),'ob')
0116 semilogy(t_evamen_hermite((d-1):(d-1):end),sum(ev_evamen_hermite(:,(d-1):(d-1):end),1),'ok')
0117
0118 semilogy(t_blk_hermite((d-1):(d-1):end),        res_blk_hermite(:,(d-1):(d-1):end),'ob')
0119 semilogy(t_evamen_hermite((d-1):(d-1):end), res_evamen_hermite(:,(d-1):(d-1):end),'ok')
0120
0121 semilogy(t_blk_hermite((d-1):(d-1):end),        sum(ev_blk_hermite(:,(d-1):(d-1):end),1),'ob')
0122 semilogy(t_evamen_hermite((d-1):(d-1):end), sum(ev_evamen_hermite(:,(d-1):(d-1):end),1),'ok')
0123
0124
0125 h_leg = legend('Res. err., Block-ALS',...
0126        'Res. err. EVAMEn, prec.',...
0127        'EV. err., Block-ALS',...
0128        'EV. err. EVAMEn, prec.')
0129 set(gca,'fontsize',20)
0130 set(h_leg, 'fontsize',16)
0131 xlabel('Time [s]')
0132 ylabel('Residual and eigenvalue error')
0133
0134 set(f, 'Position', [0 0 1200 700])```

Generated on Fri 30-Sep-2022 13:18:25 by m2html © 2005