Repository navigation
Expand file tree
/
Copy pathperformance_evals_plot.m
More file actions
222 lines (188 loc) · 8.89 KB
/
Copy pathperformance_evals_plot.m
File metadata and controls
222 lines (188 loc) · 8.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
%% This is the plotting script associated with performance_evals_run.m
clear all
clc
%% Compare direct assembly of Hermite transform against stable one
addpath('modules/quadrature/')
addpath('modules/')
load("data/numerical_eval_N_multiple_transforms.mat")
%% Exclude error values above threshold for cleanliness of plots
threshold = 1e-1;
d_error_GW(d_error_GW > threshold) = NaN;
Tinv_error_direct(Tinv_error_direct > threshold) = NaN;
Tinv_error_B(Tinv_error_B > threshold) = NaN;
Tinv_error_GW(Tinv_error_GW > threshold) = NaN;
T_error_direct(T_error_direct > threshold) = NaN;
T_error_B(T_error_B > threshold) = NaN;
T_error_GW(T_error_GW > threshold) = NaN;
%% Plot 1: Assembly time
clear h
figure(1)
h(3)=loglog(N_vec,time_GW,'-','Color','blue','LineWidth',3,'MarkerFaceColor','white')
hold on
h(2)=loglog(N_vec,time_B,'-.','Color','#edb120','LineWidth',3,'MarkerFaceColor','white')
h(1)=loglog(N_vec,time_direct,'--','Color','#c74cb9','LineWidth',3,'MarkerFaceColor','white')%,'Color','#edb120','LineWidth',2)
h(4)=loglog(N_vec,N_vec.^2*1e-6,'-.','Color','red','LineWidth',1,'MarkerFaceColor','white')%,'Color','#edb120','LineWidth',2)
set(gca,'FontSize',16)
ylabel('CPU time (sec)','Interpreter','latex', 'FontSize', 22)
xlabel('$N$','Interpreter','latex', 'FontSize', 22)
legend(h,'Direct', 'Bunck', 'Golub--Welsch','$\mathcal{O}(N^2)$','Interpreter','latex', 'FontSize', 16,'Location','northwest')
grid on
xlim([min(N_vec),max(N_vec)])
hold off
exportgraphics(gcf,strcat("images/assembly_time_multiple.pdf"),'ContentType','vector')
%% Plot 2: Error in T
clear h
figure(2)
h(3)=loglog(N_vec,T_error_GW./T_norm_exact,'-','Color','blue','LineWidth',3,'MarkerFaceColor','white')
hold on
h(2)=loglog(N_vec,T_error_B./T_norm_exact,'-.','Color','#edb120','LineWidth',3,'MarkerFaceColor','white')
h(1)=loglog(N_vec,T_error_direct./T_norm_exact,'--','Color','#c74cb9','LineWidth',3,'MarkerFaceColor','white')%,'Color','#edb120','LineWidth',2)
set(gca,'FontSize',16)
ylabel('$\|T-T_{\mathrm{approx}}\|_2/\|T\|_2$','Interpreter','latex', 'FontSize', 22)
xlabel('$N$','Interpreter','latex', 'FontSize', 22)
legend(h,'Direct', 'Bunck', 'Golub--Welsch','Interpreter','latex', 'FontSize', 16,'Location','northwest')
grid on
hold off
xlim([min(N_vec),max(N_vec)])
ylim([1e-15,1])
exportgraphics(gcf,strcat("images/error_T_multiple.pdf"),'ContentType','vector')
%% Plot 3: Error in Tinv
clear h
figure(3)
h(3)=loglog(N_vec,Tinv_error_GW./T_inv_norm_exact,'-','Color','blue','LineWidth',3,'MarkerFaceColor','white')
hold on
h(2)=loglog(N_vec,Tinv_error_B./T_inv_norm_exact,'-.','Color','#edb120','LineWidth',3,'MarkerFaceColor','white')
h(1)=loglog(N_vec,Tinv_error_direct./T_inv_norm_exact,'--','Color','#c74cb9','LineWidth',3,'MarkerFaceColor','white')%,'Color','#edb120','LineWidth',2)
set(gca,'FontSize',16)
ylabel('$\|T^{-1}-T_{\mathrm{approx}}^{-1}\|_2/\|T^{-1}\|_2$','Interpreter','latex', 'FontSize', 22)
xlabel('$N$','Interpreter','latex', 'FontSize', 22)
xlim([min(N_vec),max(N_vec)])
ylim([1e-15,1])
legend(h,'Direct', 'Bunck', 'Golub--Welsch','Interpreter','latex', 'FontSize', 16,'Location','northwest')
grid on
hold off
exportgraphics(gcf,strcat("images/error_Tinv_multiple.pdf"),'ContentType','vector')
%% Plot 4: Condition number of T
clear h
figure(4)
h(3)=loglog(N_vec,cond_GW,'-','Color','blue','LineWidth',3,'MarkerFaceColor','white')
hold on
h(2)=loglog(N_vec,cond_B,'-.','Color','#edb120','LineWidth',3,'MarkerFaceColor','white')
h(1)=loglog(N_vec,cond_direct,'--','Color','#c74cb9','LineWidth',3,'MarkerFaceColor','white')%,'Color','#edb120','LineWidth',2)
set(gca,'FontSize',16)
ylabel('$\mathrm{cond}(T)$','Interpreter','latex', 'FontSize', 22)
xlabel('$N$','Interpreter','latex', 'FontSize', 22)
legend(h,'Direct', 'Bunck', 'Golub--Welsch','Interpreter','latex', 'FontSize', 16,'Location','northwest')
grid on
hold off
xlim([min(N_vec),max(N_vec)])
exportgraphics(gcf,strcat("images/cond_T_multiple.pdf"),'ContentType','vector')
%% Plot 5: Condition number of Tinv
clear h
figure(5)
h(3)=loglog(N_vec,cond_inv_GW,'-','Color','blue','LineWidth',3,'MarkerFaceColor','white')
hold on
h(2)=loglog(N_vec,cond_inv_B,'-.','Color','#edb120','LineWidth',3,'MarkerFaceColor','white')
h(1)=loglog(N_vec,cond_inv_direct,'--','Color','#c74cb9','LineWidth',3,'MarkerFaceColor','white')%,'Color','#edb120','LineWidth',2)
set(gca,'FontSize',16)
ylabel('$\mathrm{cond}(T)$','Interpreter','latex', 'FontSize', 22)
xlabel('$N$','Interpreter','latex', 'FontSize', 22)
legend(h,'Direct', 'Bunck', 'Golub--Welsch','Interpreter','latex', 'FontSize', 16,'Location','northwest')
grid on
xlim([min(N_vec),max(N_vec)])
ylim([1,1e16])
hold off
exportgraphics(gcf,strcat("images/cond_inv_T_multiple.pdf"),'ContentType','vector')
%% Plot 6: Accuracy of asymptotic algorithm
load("data/numerical_eval_N_multiple_transforms_asymptotic.mat")
Tinv_error_GW(Tinv_error_GW > threshold) = NaN;
T_error_GW(T_error_GW > threshold) = NaN;
clear h
figure(6)
h(2)=loglog(N_vec,T_error_GW./T_norm_exact,'-','Color','blue','LineWidth',3,'MarkerFaceColor','white')
hold on
load("data/numerical_eval_N_multiple_transforms_clenshaw.mat")
Tinv_error_GW(Tinv_error_GW > threshold) = NaN;
T_error_GW(T_error_GW > threshold) = NaN;
h(3)=loglog(N_vec,T_error_GW./T_norm_exact,'-.','Color','black','LineWidth',3,'MarkerFaceColor','white')
h(1)=loglog(N_vec,N_vec.^(-4)*0.1,'--','Color','red','LineWidth',1.5,'MarkerFaceColor','white')
% loglog(N_vec,T_error_B./T_norm_exact,'-','Color','green','LineWidth',3,'MarkerFaceColor','white')
%loglog(N_vec,N_vec.^(-4),'-.','Color','red','LineWidth',1.5,'MarkerFaceColor','white')
set(gca,'FontSize',16)
ylabel('$\|T-T_{\mathrm{approx}}\|_2/\|T\|_2$','Interpreter','latex', 'FontSize', 22)
xlabel('$N$','Interpreter','latex', 'FontSize', 22)
legend(h,'$\mathcal{O}(N^{-4})$', 'Asymptotic','Clenshaw','Interpreter','latex', 'FontSize', 16,'Location','northwest')
grid on
hold off
ylim([1e-15,1])
xlim([min(N_vec),max(N_vec)])
exportgraphics(gcf,strcat("images/error_T_asymptotic.pdf"),'ContentType','vector')
%% Plot 7: Accuracy of asymptotic algorithm in d
load("data/numerical_eval_N_multiple_transforms_asymptotic.mat")
Tinv_error_GW(Tinv_error_GW > threshold) = NaN;
T_error_GW(T_error_GW > threshold) = NaN;
clear h
figure(7)
h(2)=loglog(N_vec,d_error_GW,'-','Color','blue','LineWidth',3,'MarkerFaceColor','white')
hold on
h(1)=loglog(N_vec,N_vec.^(-4)*0.1,'--','Color','red','LineWidth',1.5,'MarkerFaceColor','white')
loglog(N_vec,T_error_B./T_norm_exact,'-','Color','green','LineWidth',3,'MarkerFaceColor','white')
%loglog(N_vec,N_vec.^(-4),'-.','Color','red','LineWidth',1.5,'MarkerFaceColor','white')
set(gca,'FontSize',16)
ylabel('$\|d-d_{\mathrm{approx}}\|_2/\|d\|_2$','Interpreter','latex', 'FontSize', 22)
xlabel('$N$','Interpreter','latex', 'FontSize', 22)
legend(h,'$\mathcal{O}(N^{-4})$', 'Asymptotic','Interpreter','latex', 'FontSize', 16,'Location','northwest')
grid on
hold off
ylim([1e-15,1])
xlim([min(N_vec),max(N_vec)])
exportgraphics(gcf,strcat("images/error_d_asymptotic.pdf"),'ContentType','vector')
%% Plot 8: Accuracy of asymptotic algorithm Tinv
load("data/numerical_eval_N_multiple_transforms_asymptotic.mat")
Tinv_error_GW(Tinv_error_GW > threshold) = NaN;
T_error_GW(T_error_GW > threshold) = NaN;
clear h
figure(8)
h(2)=loglog(N_vec,Tinv_error_GW./T_inv_norm_exact,'-','Color','blue','LineWidth',3,'MarkerFaceColor','white')
hold on
load("data/numerical_eval_N_multiple_transforms_clenshaw.mat")
Tinv_error_GW(Tinv_error_GW > threshold) = NaN;
T_error_GW(T_error_GW > threshold) = NaN;
h(3)=loglog(N_vec,Tinv_error_GW./T_norm_exact,'-.','Color','black','LineWidth',3,'MarkerFaceColor','white')
h(1)=loglog(N_vec,N_vec.^(-4)*0.1,'--','Color','red','LineWidth',1.5,'MarkerFaceColor','white')
%loglog(N_vec,N_vec.^(-4),'-.','Color','red','LineWidth',1.5,'MarkerFaceColor','white')
set(gca,'FontSize',16)
ylabel('$\|T^{-1}-T^{-1}_{\mathrm{approx}}\|_2/\|T^{-1}\|_2$','Interpreter','latex', 'FontSize', 22)
xlabel('$N$','Interpreter','latex', 'FontSize', 22)
legend(h,'$\mathcal{O}(N^{-4})$', 'Asymptotic','Clenshaw','Interpreter','latex', 'FontSize', 16,'Location','northwest')
grid on
hold off
ylim([1e-15,1])
xlim([min(N_vec),max(N_vec)])
exportgraphics(gcf,strcat("images/error_T_inv_asymptotic.pdf"),'ContentType','vector')
%% Plot 9: Depiction of Q
figure(9)
N = 100;
[d,Q] = initialise_Hermite_transform_Golub_Welsch(N);
x = hermpts(N);
m = max(abs(Q(:)));
imagesc(0:N-1,0:N-1,Q,[-m,m])
axis square
axis([0,N-1,0,N-1])
colormap turbo
colorbar
set(gca,'FontSize',16)
xlabel('$j$','Interpreter','latex', 'FontSize', 22)
ylabel('$k$','Interpreter','latex', 'FontSize', 22)
title('$Q_{kj}$','Interpreter','latex', 'FontSize', 22)
exportgraphics(gcf,strcat("images/depict_Q.pdf"),'ContentType','vector')
%% Plot 10: Depiction of d
figure(10)
plot(x,d, 'linewidth',2)
axis square
axis([1.1*x(1),1.1*x(N),0,1.1*max(d)])
grid on
set(gca,'FontSize',16)
xlabel('$x_j$','Interpreter','latex', 'FontSize', 22)
ylabel('$D_{jj}$','Interpreter','latex', 'FontSize', 22)
exportgraphics(gcf,strcat("images/depict_d.pdf"),'ContentType','vector')