/
first.m
74 lines (41 loc) · 1.06 KB
/
first.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
function [p_angles,iterations,U1]=first(n,k,data,initvecs,SBSP,swtch)
d=n-k;
L=length(data);
p_angles=[];
iterations=[];
U1=initvecs(:,1:k);
L=length(data);
outputindex = linspace(1,L,25);
outputindex = floor(outputindex);
for i=1:L
if any(outputindex==i)
perc=100*i/L;
perc=round(perc);
%string = sprintf('%d percent of algorithm 1, with switch %d, complete', perc,swtch);
%disp(string);
end
nu=1/sqrt(i);
newx=data(i,:)';
if swtch==1
newx/norm(newx);
elseif swtch==0
else
error('Invalid switch')
end
U1=U1+(nu*newx*newx'*U1);
[U1 S V]=svd(U1,0);
%U1 = U1(:,1:k);
% if ~isequal(size(U1),size(SBSP))
% size(U1)
% error('sizes not equal!')
% end
D1=subspace(U1,SBSP);
if D1<eps*100
D1=0;
end
D1=single(D1);
D1=D1/(pi/2);
p_angles=[p_angles, D1];
iterations=[iterations,i];
end
return