File data_analysis/auxfunctions/orthonormality/assert_orthonormality.m changed (mode: 100644) (index 0250778..5316acf) |
1 |
|
function assert_orthonormality(Q, norm_tol, orthog_tol) |
|
|
1 |
|
function on_info = assert_orthonormality(Q, norm_tol, orthog_tol) |
2 |
2 |
% Asserts that the rows of matrix Q are mutually orthonormal |
% Asserts that the rows of matrix Q are mutually orthonormal |
3 |
3 |
% within numerical tolerances specified by 'norm_tol' and 'orthog_tol' |
% within numerical tolerances specified by 'norm_tol' and 'orthog_tol' |
4 |
4 |
% If the assertion fails, additional information is displayed |
% If the assertion fails, additional information is displayed |
5 |
5 |
% about the cause of the failure and the size of the deviation |
% about the cause of the failure and the size of the deviation |
6 |
6 |
|
|
7 |
7 |
failure = false; |
failure = false; |
8 |
|
[~, orthog, normal, info] = orthonormality(Q, norm_tol, orthog_tol); |
|
|
8 |
|
[~, orthog, normal, on_info] = orthonormality(Q, norm_tol, orthog_tol); |
9 |
9 |
|
|
10 |
10 |
if ~orthog |
if ~orthog |
11 |
11 |
failure = true; |
failure = true; |
12 |
12 |
|
|
13 |
13 |
% display info about the cause and size of failure |
% display info about the cause and size of failure |
14 |
|
[deviations, sortorder] = sort(info.orthog.deviations, 'descend'); |
|
15 |
|
off_cols = info.orthog.offenders.cols(sortorder); |
|
16 |
|
off_rows = info.orthog.offenders.rows(sortorder); |
|
|
14 |
|
[deviations, sortorder] = sort(on_info.orthog.deviations, 'descend'); |
|
15 |
|
off_cols = on_info.orthog.offenders.cols(sortorder); |
|
16 |
|
off_rows = on_info.orthog.offenders.rows(sortorder); |
17 |
17 |
|
|
18 |
18 |
disp(['\nPairs of rows violating orthogonality & amount of violation:',10,... |
disp(['\nPairs of rows violating orthogonality & amount of violation:',10,... |
19 |
19 |
'(sorted in order of decreasing violation)']) |
'(sorted in order of decreasing violation)']) |
|
... |
... |
function assert_orthonormality(Q, norm_tol, orthog_tol) |
27 |
27 |
failure = true; |
failure = true; |
28 |
28 |
|
|
29 |
29 |
% display info about the cause and size of failure |
% display info about the cause and size of failure |
30 |
|
[deviations, sortorder] = sort(info.norm.deviations, 'descend'); |
|
31 |
|
offenders = info.norm.offenders(sortorder); |
|
|
30 |
|
[deviations, sortorder] = sort(on_info.norm.deviations, 'descend'); |
|
31 |
|
offenders = on_info.norm.offenders(sortorder); |
32 |
32 |
|
|
33 |
33 |
disp(['Rows violating normality and amount of violation:',10,... |
disp(['Rows violating normality and amount of violation:',10,... |
34 |
34 |
'(sorted in order of decreasing violation)']) |
'(sorted in order of decreasing violation)']) |
File data_analysis/auxfunctions/orthonormality/orthonormality.m changed (mode: 100644) (index 4460e50..d05e4db) |
1 |
|
function [orthonorm, orthog, normal, info] = orthonormality(Q, norm_tol, orthog_tol) |
|
|
1 |
|
function [orthonorm, orthog, normal, on_info] = orthonormality(Q, norm_tol, orthog_tol) |
2 |
2 |
% [orthonorm, orthog, normal, info] = orthonormality(Q, norm_tol, orthog_tol) |
% [orthonorm, orthog, normal, info] = orthonormality(Q, norm_tol, orthog_tol) |
3 |
3 |
% returns a boolean 'orthonorm' indicating whether the rows of matrix Q |
% returns a boolean 'orthonorm' indicating whether the rows of matrix Q |
4 |
4 |
% are orthonormal within numerical tolerances norn_tol and orthog_tol. |
% are orthonormal within numerical tolerances norn_tol and orthog_tol. |
|
... |
... |
function [orthonorm, orthog, normal, info] = orthonormality(Q, norm_tol, orthog_ |
15 |
15 |
% from 1 (assesses the normalisation) and if the non-diagonal elements are |
% from 1 (assesses the normalisation) and if the non-diagonal elements are |
16 |
16 |
% within a tolerence 'orthog_tol' from 0 (assesses orthogonality). |
% within a tolerence 'orthog_tol' from 0 (assesses orthogonality). |
17 |
17 |
|
|
18 |
|
info = {}; |
|
|
18 |
|
on_info = {}; |
19 |
19 |
|
|
20 |
20 |
A=Q*Q'; |
A=Q*Q'; |
21 |
|
|
|
|
21 |
|
on_info.matrix_size = size(A); |
22 |
22 |
|
|
23 |
23 |
norm_deviations = (abs(diag(A)-1)); |
norm_deviations = (abs(diag(A)-1)); |
24 |
24 |
norm_violations = find(norm_deviations > norm_tol); |
norm_violations = find(norm_deviations > norm_tol); |
25 |
25 |
normal = isempty(norm_violations); |
normal = isempty(norm_violations); |
26 |
26 |
|
|
27 |
27 |
if ~normal |
if ~normal |
28 |
|
info.norm.offenders = norm_violations; |
|
29 |
|
info.norm.deviations = norm_deviations(norm_violations); |
|
|
28 |
|
on_info.norm.offenders = norm_violations; |
|
29 |
|
on_info.norm.deviations = norm_deviations(norm_violations); |
30 |
30 |
|
|
31 |
31 |
% figure |
% figure |
32 |
32 |
% title('abs deviation from normalisation'); |
% title('abs deviation from normalisation'); |
|
... |
... |
orthog_deviations = abs(tril(A,-1)); |
41 |
41 |
orthog = isempty(orthog_viol_rows); |
orthog = isempty(orthog_viol_rows); |
42 |
42 |
|
|
43 |
43 |
if ~orthog |
if ~orthog |
44 |
|
info.orthog.offenders.cols = orthog_viol_cols; |
|
45 |
|
info.orthog.offenders.rows = orthog_viol_rows; |
|
|
44 |
|
on_info.orthog.offenders.cols = orthog_viol_cols; |
|
45 |
|
on_info.orthog.offenders.rows = orthog_viol_rows; |
46 |
46 |
|
|
47 |
47 |
orthog_critical_devs = zeros(size(orthog_viol_rows)); |
orthog_critical_devs = zeros(size(orthog_viol_rows)); |
48 |
48 |
for k=1:length(orthog_viol_rows) |
for k=1:length(orthog_viol_rows) |
|
... |
... |
if ~orthog |
50 |
50 |
col = orthog_viol_cols(k); |
col = orthog_viol_cols(k); |
51 |
51 |
orthog_critical_devs(k) = orthog_deviations(row, col); |
orthog_critical_devs(k) = orthog_deviations(row, col); |
52 |
52 |
end |
end |
53 |
|
info.orthog.deviations = orthog_critical_devs; |
|
|
53 |
|
on_info.orthog.deviations = orthog_critical_devs; |
54 |
54 |
end |
end |
55 |
55 |
|
|
56 |
56 |
|
|
File data_analysis/unittests/entanglement_evaluation_test.m changed (mode: 100644) (index 4883f0d..50ee99d) |
... |
... |
function modefunctions_test(shared) |
149 |
149 |
'relative', tol); |
'relative', tol); |
150 |
150 |
|
|
151 |
151 |
%figure; plot(real(ev.readout_modes')) |
%figure; plot(real(ev.readout_modes')) |
152 |
|
% check orthonormality |
|
|
152 |
|
|
|
153 |
|
%%% check that the orthonormality test does the right thing |
153 |
154 |
on_matrix_entangling = ev.entangling_modes*(ev.entangling_modes)'; |
on_matrix_entangling = ev.entangling_modes*(ev.entangling_modes)'; |
|
155 |
|
[modefct_no, samples_per_pulse] = size(ev.entangling_modes); |
|
156 |
|
assertEqual(size(on_matrix_entangling), modefct_no*[1,1]) |
|
157 |
|
norm_tol = inf; orthog_tol = inf; % don't care about precision here, only about checking rows vs checking columns |
|
158 |
|
on_info = assert_orthonormality(ev.readout_modes,norm_tol, orthog_tol); |
|
159 |
|
assertEqual(on_info.matrix_size, modefct_no*[1,1]) |
|
160 |
|
%%%% |
|
161 |
|
|
|
162 |
|
% check orthonormality |
154 |
163 |
on_matrix_readout = ev.readout_modes*(ev.readout_modes)'; |
on_matrix_readout = ev.readout_modes*(ev.readout_modes)'; |
155 |
164 |
for k=1:ev.pulse_gammas_no |
for k=1:ev.pulse_gammas_no |
156 |
165 |
start_mode = (k-1)*ev.mech_frequencies_no + 1; |
start_mode = (k-1)*ev.mech_frequencies_no + 1; |
|
... |
... |
function efficiency_visibility_test_sub(ev, nu, eta) |
700 |
709 |
% disp([10, 10, '***************',10, prefix, 'correction performed as expected!',10]) |
% disp([10, 10, '***************',10, prefix, 'correction performed as expected!',10]) |
701 |
710 |
|
|
702 |
711 |
function traceout_test(shared) |
function traceout_test(shared) |
703 |
|
clc |
|
704 |
712 |
ev = run_quicker_test(shared); |
ev = run_quicker_test(shared); |
705 |
713 |
% ev.mech_frequencies = [1.2, 2.3, 4.1,5.7]; |
% ev.mech_frequencies = [1.2, 2.3, 4.1,5.7]; |
706 |
714 |
|
|