-
Notifications
You must be signed in to change notification settings - Fork 0
/
represent_Hrand_real.m
64 lines (53 loc) · 1.84 KB
/
represent_Hrand_real.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
function [nodes, weights, xloc] = represent_Hrand_real(f,acc,l)
% Anil Damle
% develop hankel based representation for f
% do not use directly on fft of signals, for that use represent_H_fourier
% the code assumes that the samples are on the integers 0:length(f)-1
% inputs:
% f: signal to be represented, vector length 2n-1
% acc: accuracy of representation, scalar
% l: expected rank, i.e. number of nodes...
% outputs:
% nodes: nodes of representation, vector of necessary length
% weights: weights of representation, vector of necessary length
%compute coneigensystem
N = length(f);
xloc = linspace(0,1,N);
%svd method for finding coneigenvalue/vector
p = 10; %added oversampling factor
[x, ~] = svd_coneigen_rand(f,acc,l);
%find roots of con-eignepolynomial inside unit circle
rx = roots(flip(x(:).'));
rx = rx(abs(rx)<1);
% add if only real poles are desired...
rx = rx(abs(imag(rx))<1e-5);
rx = real(rx);
% maybe clean up with Newtons method...
% rxN = newton_vector(flip(x(:).'),polyder(flip(x(:).')),rx,acc/10);
% rx = rxN(abs(rxN)<1);
nodes = (N-1)*log(rx(:));
%construct vandermonde matrix
V = exp((ones(length(xloc),1)*nodes.').*(xloc(:)*ones(1,length(nodes))));
weights = V\f(:);
if ~isempty(find(abs(weights)<acc,1))
nodes = nodes(abs(weights)>=acc);
nodes = nodes(:);
%recompute without un-necessary nodes
V = exp((ones(length(xloc),1)*nodes.').*(xloc(:)*ones(1,length(nodes))));
weights = V\f(:);
end
% %% in case something breaks...
% nodes = rx(:);
%
%
% %construct vandermonde matrix
% V = exp((ones(length(xloc),1)*log(nodes).').*(xloc(:)*ones(1,length(nodes))));
% weights = V\f(:);
% if ~isempty(find(abs(weights)<acc,1))
% nodes = nodes(abs(weights)>=acc);
% nodes = nodes(:);
% %recompute without un-necessary nodes
% V = (ones(length(xloc),1)*nodes.').^(xloc(:)*ones(1,length(nodes)));
% weights = V\f(:);
% end
%