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 pathlambda2.m
103 lines (84 loc) · 4.29 KB
/
lambda2.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
function [afixed,sqnorm,Qahat,Z] = lambda2 (afloat,Qahat)
%LAMBDA2: Integer ambiguity estimation using LAMBDA (basic version)
%
% This routine performs an integer ambiguity estimation using the
% LAMBDA-method, as developed by the Delft University of Technology,
% Mathematical Geodesy and Positioning.
%
% Input arguments:
% afloat: Float ambiguities (\hat{a}, must be a column!)
% Qahat : Variance/covariance matrix of ambiguities (Q_\hat{a})
%
% Output arguments:
% afixed: Estimated integers
% sqnorm: Distance between candidates and float ambiguity vector
% Qzhat : Decorrelated variance/covariance matrix
% Z : Transformation matrix
% ----------------------------------------------------------------------
% File.....: lambda2.m
% Date.....: 19-MAY-1999
% Author...: Peter Joosten
% Mathematical Geodesy and Positioning
% Delft University of Technology
% ----------------------------------------------------------------------
% ----------------------------------------------------------------------
% Initalise
% ----------------------------------------------------------------------
ncands = 2;
n = size (Qahat,1);
afixed = zeros(n,ncands);
sqnorm = zeros(1,ncands);
% ----------------------------------------------------------------------
% --- Perform tests on the input, these tests are rather extensive ---
% --- and can be switched off (by commenting-out) if necessary ---
% --- Tests: Is the Q-matrix symmetric? ---
% --- Is the Q-matrix positive-definite? ---
% --- Do the Q-matrix and ambiguity-vector have identical ---
% --- dimensions? ---
% --- Is the ambiguity vector a column? ---
% ----------------------------------------------------------------------
%%if ~isequal(Qahat-Qahat'<1E-12,ones(size(Qahat)));
%% error ('Variance/covariance matrix is not symmetric!');
%%end;
if sum(eig(Qahat)>0) ~= size(Qahat,1);
error ('Variance/covariance matrix is not positive definite!');
end;
if length(afloat) ~= size(Qahat,1);
error (['Variance/covariance matrix and vector of ambiguities do not have' ...
' identical dimensions!']);
end;
if size(afloat,2) ~= 1;
error ('Ambiguity-vector should be a column-vector');
end;
% ----------------------------------------------------------------------
% Make estimates in 'a' between -1 and +1 by subtracting an
% integer number, store the increments in 'incr' (= shift the centre
% of the ellipsoid over the grid by an integer translation)
% ----------------------------------------------------------------------
incr = afloat - rem(afloat,1);
afloat = rem(afloat,1);
% ----------------------------------------------------------------------
% Compute the Z-transformation based on L and D of Q, ambiguities
% are transformed according to \hat{z} = Z^T\hat{a}, Q is transformed
% according to Q_\hat{z} = Z^T * Q_\hat{a} * Z
% ----------------------------------------------------------------------
[Qahat,Z,L,D,afloat] = decorrel (Qahat,afloat);
% ----------------------------------------------------------------------
% Compute a suitable Chi^2 such that we have the requested number of
% candidates at minimum; use an 'eps' to make sure the candidates are
% inside the ellipsoid and not exactly on the border.
% ----------------------------------------------------------------------
Chi2 = chistart (D,L,afloat,ncands);
% ----------------------------------------------------------------------
% Find the requested number of candidates (search)
% ----------------------------------------------------------------------
[afixed,sqnorm,ierr] = lsearch (afloat,L,D,Chi2,ncands);
if ierr == 1; error ('Not enough candidates were found!!'); end;
% ----------------------------------------------------------------------
% --- Perform the back-transformation and add the increments
% ----------------------------------------------------------------------
afixed = (afixed' * inv(Z))';
afixed = round(afixed + repmat(incr,1,ncands));
% ----------------------------------------------------------------------
% End of routine: lambda2
% ----------------------------------------------------------------------