Skip to content

Commit

Permalink
fixes small bug in chunkermat, working toward speeding up chunkermata…
Browse files Browse the repository at this point in the history
…pply
  • Loading branch information
askhamwhat committed May 29, 2024
1 parent a723d77 commit 10b2692
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion chunkie/chunkermat.m
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
chnkri = chnkrs(i);
for j = 1:nchunkers
chnkrj = chnkrs(j);
if (chnkri.nch < 1 || chnkri.k < 1 || chnkrj.nch<1 || chnkri.k<1)
if (chnkri.nch < 1 || chnkri.k < 1 || chnkrj.nch<1 || chnkrj.k<1)
sysmat_tmp = [];
break
end
Expand Down
17 changes: 5 additions & 12 deletions chunkie/chunkermatapply.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function u = chunkermatapply(chnkr,kern,dval,dens,cormat,opts)
function u = chunkermatapply(chnkr,kern,dens,cormat,opts)
%CHUNKERMATAPPLY - apply chunkermat system on chunker defined by kern
%
% Syntax: u = chunkermatapply(chnkr,kern,dval,dens,sigma,opts)
% Syntax: u = chunkermatapply(chnkr,kern,dens,sigma,opts)
%
% Input:
% chnkobj - chunker object describing boundary
Expand All @@ -14,13 +14,6 @@
% ptinfo.n - unit normals (2,:)
% ptinfo.d2 - second derivative in underlying
% parameterization (2,:)
% dval - (default 0.0) float or float array. Let A be the matrix
% corresponding to on-curve convolution with the provided kernel.
% If a scalar is provided, the system matrix is
% A + dval*eye(size(A))
% If a vector is provided, it should be length size(A,1). The
% system matrix is then
% A + diag(dval)
% dens - density on boundary, should have size opdims(2) x k x nch
% where k = chnkr.k, nch = chnkr.nch, where opdims is the
% size of kern for a single src,targ pair
Expand Down Expand Up @@ -120,10 +113,10 @@
error(msg);
end

if nargin < 5
if nargin < 4
cormat = [];
end
if nargin < 6
if nargin < 5
opts = [];
end

Expand Down Expand Up @@ -203,7 +196,7 @@


% apply local corrections and diagonal scaling
u = dval*dens + cormat*dens;
u = cormat*dens;

% apply smooth quadratures
if size(kern) == 1
Expand Down
8 changes: 4 additions & 4 deletions devtools/test/chunkermatapplyTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
udense = sys*dens;
start = tic; cormat = chunkermat(chnkr,fkern,struct("corrections",true));
toc(start)
sysapply = @(sigma) chunkermatapply(chnkr,fkern,-0.5,sigma,cormat);
sysapply = @(sigma) -0.5*sigma + chunkermatapply(chnkr,fkern,sigma,cormat);
start = tic; u = sysapply(dens); t1 = toc(start);

fprintf('%5.2e s : time for matrix free apply\n',t1)
Expand Down Expand Up @@ -89,7 +89,7 @@

udense = sys*bdry_data;
cormat = chunkermat(chnkr,kerns,struct("corrections",true));
sysapply = @(sigma) chunkermatapply(chnkr,kerns,eye(2),sigma,cormat);
sysapply = @(sigma) sigma + chunkermatapply(chnkr,kerns,sigma,cormat);

start = tic; u = sysapply(bdry_data); t1 = toc(start);
fprintf('%5.2e s : time for matrix free apply\n',t1)
Expand Down Expand Up @@ -153,7 +153,7 @@

udense = sys*dens;
cormat = chunkermat(cgrph,fkern,struct("corrections",true));
sysapply = @(sigma) chunkermatapply(cgrph,fkern,1,sigma,cormat);
sysapply = @(sigma) sigma + chunkermatapply(cgrph,fkern,sigma,cormat);

start = tic; u = sysapply(dens); t1 = toc(start);
fprintf('%5.2e s : time for matrix free apply\n',t1)
Expand Down Expand Up @@ -201,7 +201,7 @@

udense = sys*bdry_data;
cormat = chunkermat(cgrph,kerns,struct("corrections",true));
sysapply = @(sigma) chunkermatapply(cgrph,kerns,1,sigma,cormat);
sysapply = @(sigma) sigma + chunkermatapply(cgrph,kerns,sigma,cormat);
start = tic; u = sysapply(bdry_data); t1 = toc(start);
fprintf('%5.2e s : time for matrix free apply\n',t1)

Expand Down

0 comments on commit 10b2692

Please sign in to comment.