-
Notifications
You must be signed in to change notification settings - Fork 5
/
derivativesOfCauchyCoord.m
59 lines (42 loc) · 1.47 KB
/
derivativesOfCauchyCoord.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
function [D, E] = derivativesOfCauchyCoord(cage, z, holeCenters)
% Compute first and second derivatives of regular Cauchy coordiantes
%
% Input parameters:
% cage - cage
% z - points inside the cage
z = reshape(z, [], 1);
remove2coeffAtHoles = true;
if iscell(cage)
if nargout>1
[D, E] = cellfun(@(c) derivativesOfCauchyCoord(c, z, holeCenters), cage, 'UniformOutput', false);
E = cat(2, E{:});
else
D = cellfun(@(c) derivativesOfCauchyCoord(c, z, holeCenters), cage, 'UniformOutput', false);
end
D = cat(2, D{:});
if numel(cage)>1
% remove 2 holomorphic DOF for each hole
if remove2coeffAtHoles
cageSizes = cellfun(@numel, cage);
flags = true(sum(cageSizes), 1);
flags( reshape(cumsum(cageSizes(1:end-1)),[],1) + [1 2] ) = false;
D = D(:, flags);
if nargout>1, E = E(:, flags); end
end
assert(nargin>2 && ~isempty(holeCenters));
holeCenters = reshape(holeCenters, 1, []);
D = [D 1./(z-holeCenters)];
if nargout>1, E = [E -(z-holeCenters).^-2]; end
end
else
Aj = cage - cage([end 1:end-1], :);
Ajp = Aj([2:end 1], :);
Bj = bsxfun(@minus, cage.', z);
Bjp = Bj(:, [2:end 1]);
Bjm = Bj(:, [end 1:end-1]);
oneOver2pi_i = 1/(2*pi*1i);
D = oneOver2pi_i*(bsxfun(@rdivide, log(Bj./Bjm), Aj.') - bsxfun(@rdivide, log(Bjp./Bj), Ajp.'));
if(nargout > 1)
E = oneOver2pi_i*(Bjp-Bjm)./(Bjm.*Bj.*Bjp);
end
end