This repository has been archived by the owner on Nov 22, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdecorrel.m
117 lines (91 loc) · 3.21 KB
/
decorrel.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
function [Q,Z,L,D,z] = decorrel (Q,a);
%DECORREL: Decorrelate a (co)variance matrix of ambiguities
%
% This routine creates a decorrelated Q-matrix, by finding the
% Z-matrix and performing the corresponding transformation.
%
% The method is described in:
% The routine is based on Fortran routines written by Paul de Jonge (TUD)
% and on Matlab-routines written by Kai Borre.
% The resulting Z-matrix can be used as follows:
% z = Zt * a; \hat(z) = Zt * \hat(a);
% Q_\hat(z) = Zt * Q_\hat(a) * Z
%
% Input arguments:
% a: Original ambiguities
% Q: Variance/covariance matrux of ambiguities (original)
%
% Output arguments:
% Q: Decorrelated variance/covariance matrix
% Z: Z-transformation matrix
% L: L matrix (from LtDL-decomposition of Q, optional)
% D: D matrix (from LtDL-decomposition of Q, optional)
% z: Transformed ambiguities (optional)
% ----------------------------------------------------------------------
% Function.: decorrel
% Date.....: 19-MAY-1999
% Author...: Peter Joosten
% Mathematical Geodesy and Positioning
% Delft University of Technology
% ----------------------------------------------------------------------
% -----------------------
% --- Initialisations ---
% -----------------------
n = size(Q,1);
Zti = eye(n);
i1 = n - 1;
sw = 1;
% --------------------------
% --- LtDL decomposition ---
% --------------------------
[L,D] = ldldecom (Q);
% ------------------------------------------
% --- The actual decorrelation procedure ---
% ------------------------------------------
while sw;
i = n;
sw = 0;
while ( ~sw ) & (i > 1)
i = i - 1;
if (i <= i1);
for j = i+1:n
mu = round(L(j,i));
if mu ~= 0
L(j:n,i) = L(j:n,i) - mu * L(j:n,j);
Zti(1:n,j) = Zti(1:n,j) + mu * Zti(1:n,i);
end
end
end;
delta = D(i) + L(i+1,i)^2 * D(i+1);
if (delta < D(i+1))
lambda(3) = D(i+1) * L(i+1,i) / delta;
eta = D(i) / delta;
D(i) = eta * D(i+1);
D(i+1) = delta;
Help = L(i+1,1:i-1) - L(i+1,i) .* L(i,1:i-1);
L(i+1,1:i-1) = lambda(3) * L(i+1,1:i-1) + eta * L(i,1:i-1);
L(i,1:i-1) = Help;
L(i+1,i) = lambda(3);
Help = L(i+2:n,i);
L(i+2:n,i) = L(i+2:n,i+1);
L(i+2:n,i+1) = Help;
Help = Zti(1:n,i);
Zti(1:n,i) = Zti(1:n,i+1);
Zti(1:n,i+1) = Help;
i1 = i;
sw = 1;
end;
end;
end;
% ---------------------------------------------------------------------
% --- Return the transformed Q-matrix and the transformation-matrix ---
% --- Return the decorrelated ambiguities, if they were supplied ---
% ---------------------------------------------------------------------
Z = inv(Zti');
Q = Z' * Q * Z;
if nargin == 2 & nargout >= 5;
z = Z' * a; %
end;
% ----------------------------------------------------------------------
% End of routine: decorrel
% ----------------------------------------------------------------------