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 pathchistart.m
117 lines (88 loc) · 3.62 KB
/
chistart.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 Chi2 = chistart (D,L,a,ncands,factor)
%CHISTART: Computes the initial size of the search ellipsoid
%
% This routine computes or approximates the initial size of the
% search ellipsoid. If the requested number of candidates is not
% more than the dimension + 1, this is done by computing the squared
% distances of partially rounded float vectors to the float vector in
% the metric of the covariance matrix. Otherwise an approximation is used.
%
% Input arguments
% L,D : LtDL-decomposition of the variance-covariance matrix of
% the float ambiguities (preferably decorrelated)
% a : float ambiguites (preferably decorrelated)
% ncands: Requested number of candidates (default = 2)
% factor: Multiplication factor for the volume of the resulting
% search ellipsoid (default = 1.5)
%
% Output arguments:
% Chi2 : Size of the search ellipsoid
% ----------------------------------------------------------------------
% File.....: chistart.m
% Date.....: 19-MAY-1999
% Author...: Peter Joosten
% Mathematical Geodesy and Positioning
% Delft University of Technology
% ----------------------------------------------------------------------
% ------------------
% --- Initialize ---
% ------------------
if nargin < 4; ncands = 2 ; end;
if nargin < 5; factor = 1.5; end;
n = max(size(a));
% ----------------------------------------------------------------------
% --- Computation depends on the number of candidates to be computed ---
% ----------------------------------------------------------------------
if ncands == 1;
% ---------------------------------------------------
% --- The squared norm, based on the bootstrapped ---
% --- solution will be computed ---
% ---------------------------------------------------
afloat = a;
afixed = a;
for i = 1:n;
dw = 0;
for j = 1:n-1;
dw = dw + L(i,j) * (a(j) - afixed(j));
end;
a(i) = a(i) - dw;
afixed(i) = round (a(i));
end;
Chi2 = (afloat-afixed)' * inv(L'*diag(D)*L) * (afloat-afixed) + 1d-6;
elseif ncands <= n+1;
% ----------------------------------------------
% --- The right squared norm can be computed ---
% ----------------------------------------------
Linv = inv(L);
Dinv = 1./D;
dist = round(a) - a;
e = Linv'*dist;
Chi = [zeros(1,n) sum(Dinv' .* e .* e)];
% ------------------------------------------
% --- Compute the real squared distances ---
% ------------------------------------------
for i = 1:n;
Chi(i) = 0;
for j = 1:i;
Chi(i) = Chi(i) + Dinv(j) * Linv(i,j) * (2*e(j)+Linv(i,j));
end;
Chi(i) = Chi(n+1) + abs(Chi(i));
end;
% ---------------------------------------------------------------
% --- Sort the results, and return the appropriate number ---
% --- Add an "eps", to make sure there is no boundary problem ---
% ---------------------------------------------------------------
Chi = sort(Chi);
Chi2 = Chi(ncands) + 1d-6;
else
% -----------------------------------------------------
% An approximation for the squared norm is computed ---
% -----------------------------------------------------
Linv = inv(L);
Dinv = 1./D;
Vn = (2/n) * (pi ^ (n/2) / gamma(n/2));
Chi2 = factor * (ncands / sqrt((prod(1 ./ Dinv)) * Vn)) ^ (2/n);
end;
% ----------------------------------------------------------------------
% End of routine: chistart
% ----------------------------------------------------------------------