-
Notifications
You must be signed in to change notification settings - Fork 4
/
buildproblem.m
73 lines (64 loc) · 2.28 KB
/
buildproblem.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
function problem = buildproblem(n, N, M, I, J, H, kappa1, kappa2, p, A, Ra)
%
% TODO : refactor
%
% Returns a problem structure containing all information pertaining to a
% rotation synchronization problem.
%
% INPUTS:
%
% n = 2, 3 or 4: work with rotations in SO(n), i.e., n-by-n orthog. matrices
% N : number of rotations to synchronize
% M : number of measurements of rotation ratios
% I, J : length-M vectors of indices between 1 and N
% H : n-by-n-by-M matrix; Each matrix H(:, :, k) in SO(n) is a measurement
% of the ratio Ra*Rb', where Ra is the I(k)'s rotation matrix to
% synchronize and Rb is the J(k)'s rotation matrix to synchronize
% kappa1,2 : length-M vectors of confidences in the M measurements
% p : probability that a measurement is not an outlier
% A : (optional) vector of indices of the anchors of the problem, i.e.,
% indices of the known rotation matrices; if omitted, replaced by [1].
% Ra : (optional) nxnx|A| matrix with anchored rotations; if omitted,
% replaced by the identity matrix eye(n).
%
% OUTPUTS:
%
% problem : a structure containing all the given information plus some
% precomputed data.
%
% Nicolas Boumal, UCLouvain, Aug. 17, 2011
problem = struct();
problem.n = n;
problem.N = N;
problem.M = M;
problem.I = I;
problem.J = J;
problem.H = H;
problem.kappa1 = kappa1;
problem.kappa2 = kappa2;
problem.p = p;
% date of birth of the problem structure
problem.dob = clock();
if exist('A', 'var') && ~isempty(A)
problem.A = A;
problem.Ra = Ra;
else
problem.A = 1;
problem.Ra = eye(n);
end
scaled = true;
problem.c1 = langevinnormalizations(n, kappa1, scaled);
problem.c2 = langevinnormalizations(n, kappa2, scaled);
% d(i) is the number of measurements involving rotation i, i.e., it is
% the degree of node i in the measurement graph.
problem.d = hist([I ; J], 1:N).';
if ~isconnected(problem.N, problem.I, problem.J)
warning('synch:disconnected', 'The measurement graph is disconnected!');
problem.disconnected = true;
else
problem.disconnected = false;
end
[maskI, maskJ] = computemasks(N, I, J);
problem.maskI = maskI;
problem.maskJ = maskJ;
end