Skip to content

Commit

Permalink
Create get_sigs.m
Browse files Browse the repository at this point in the history
  • Loading branch information
jghoskins committed Oct 18, 2024
1 parent 2e6cd6d commit 839b7ef
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions chunkie/+chnk/+smoother/get_sigs.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
function [val,grad] = get_sigs(src_input,rt,sig0,dlam)

rc = src_input.centroids;
dlens = src_input.lengths;

[~,ns] = size(rc);
[~,nt] = size(rt);

xc = repmat(rc(1,:),nt,1);
yc = repmat(rc(2,:),nt,1);
dl = repmat(dlens,nt,1);

xt = repmat(rt(1,:).',1,ns);
yt = repmat(rt(2,:).',1,ns);

dx = xt-xc;
dy = yt-yc;
dr = sqrt(dx.^2+dy.^2);
dmin = min(dr,[],2);

dsigj = dl/dlam;
dexpn = exp(-(dr.^2-dmin.^2)./(2*sig0^2));
dsignum = sum(dsigj.*dexpn,2);
dsigden = sum(dexpn,2);
dsignumx = -dsigj.*dexpn.*(dx./sig0^2);
dsignumy = -dsigj.*dexpn.*(dy./sig0^2);
dsig = dsignum./dsigden;
dsigx = dsignumx./dsigden;
dsigy = dsignumy./dsigden;

val = dsig;

sz = size(dsig);
grad = zeros([sz,2]);
grad(:,:,1) = dsigx;
grad(:,:,2) = dsigy;

grad = squeeze(grad);

end

0 comments on commit 839b7ef

Please sign in to comment.