forked from idaohang/borre
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathl_detail.m
126 lines (110 loc) · 3.11 KB
/
l_detail.m
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
% L_DETAIL Step by step explainations of a Matlab implementation of the Lambda
% method. We follow the notation introduced in Strang and Borre,
% pages 495--499
% Written by Kai Borre
% March 23, 2002
fprintf('\n')
echo on
% Test example
I_hat = [5.45;3.1;2.97];
%I_hat =[0; 1];
n = size(I_hat,1);
Sigma = [6.29 5.978 .544; 5.978 6.292 2.34; .544 2.34 6.288];
%Sigma = [53.40 38.40;38.40 28.00];
echo off
% Given float ambiguities
fprintf('\nFloat ambiguities I_hat')
for i = 1:n
fprintf('\n%12.3f', I_hat(i,1))
end
% Original covariance matrix for I_hat
fprintf('\n\nCovariance matrix for I_hat Sigma')
for i = 1:n
fprintf('\n')
for j = 1:n
fprintf('%12.3f', Sigma(i,j))
end
end
fprintf('\n\n')
echo on
% Shift of I_hat in order to secure that -1 < I_hat <= +1
echo off
shifts = I_hat-rem(I_hat,1);
fprintf('\n\nInteger shifts of I_hat')
for i = 1:n
fprintf('\n%12.0f', shifts(i,1))
end
% Remainders of I_hat
I_hat = rem(I_hat,1);
fprintf('\n\nRemainders of I_hat')
for i = 1:n
fprintf('\n%12.3f', I_hat(i,1))
end
% L^T*D*L factorization of Sigma
[L,D] = ldldecom(Sigma);
fprintf('\n\nSigma is factorized into L^T*D*L')
fprintf('\n\nThe lower triangular L')
for i = 1:n
fprintf('\n')
for j = 1:n
fprintf('%12.3f',L(i,j))
end
end
fprintf('\n\nThe diagonal matrix D\n')
for i = 1:n
fprintf('%12.3f',D(i))
end
% Computing the size of the search volume
chi2 = chistart(D,L,I_hat,1);
fprintf('\n\nchi^2 = %5.3f\n',chi2)
% Doing the decorrelation
[Sigma_t,Z,L_t,D_t] = decorrel(Sigma,I_hat);
fprintf('\nInteger transformation matrix Z')
for i = 1:n
fprintf('\n')
for j = 1:n
fprintf('%12.0f',Z(i,j))
end
end
% I_hat transformed: z = Z'*I_hat
fprintf('\n\nTransformed, shifted ambiguities z = Z^T*I_hat')
z = Z'*I_hat;
for i = 1:n
fprintf('\n%12.3f',z(i))
end
% The transformed, decorrelated covariance matrix : Sigma_t = Z^T*Sigma*Z
fprintf('\n\nThe transformed, decorrelated covariance matrix Sigma_t = Z^T*Sigma*Z.')
fprintf('\n\nSigma_t = Z^T*Sigma*Z')
for i = 1:n
fprintf('\n')
for j = 1:n
fprintf('%12.3f',Sigma_t(i,j))
end
end
fprintf('\nNote the deminished off-diagonal terms!')
fprintf('\n\nThe lower triangular L_t used in the search')
for i = 1:n
fprintf('\n')
for j = 1:n
fprintf('%12.3f',L_t(i,j))
end
end
fprintf('\n\nThe diagonal matrix D_t used in the seach\n')
for i = 1:n
fprintf('%12.3f',D_t(i))
end
fprintf('\n\n')
echo on
% Determining the size of the search volume for the transformed L_t and D_t
echo off
chi2 = chistart(D_t,L_t,z,1);
fprintf('\n\nchi^2 for the transformed problem = %5.3f\n',chi2)
fprintf('\nThe search domain is defined as')
fprintf('\n (I-I_hat)^T*(Z^T*Sigma*Z)*(I-I_hat) < chi^2, for I integer')
[I_bar,sqnorm,ierr] = lsearch(z,L_t,D_t,chi2,1);
I_bar = (I_bar' * inv(Z))'+shifts;
fprintf('\n\nFixed ambiguities I_bar')
for i = 1:n
fprintf('\n%12.0f', I_bar(i,1))
end
%%%%%%%%%%%%%%%%%%%%%%%%%%% end l_detail.m %%%%%%%%%%%%