From 10b2692149bc30c35618e18e6e69f08b064ee71f Mon Sep 17 00:00:00 2001 From: Travis Askham Date: Wed, 29 May 2024 10:34:30 -0400 Subject: [PATCH] fixes small bug in chunkermat, working toward speeding up chunkermatapply --- chunkie/chunkermat.m | 2 +- chunkie/chunkermatapply.m | 17 +++++------------ devtools/test/chunkermatapplyTest.m | 8 ++++---- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/chunkie/chunkermat.m b/chunkie/chunkermat.m index 79f2fa5..fd6d5a8 100644 --- a/chunkie/chunkermat.m +++ b/chunkie/chunkermat.m @@ -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 diff --git a/chunkie/chunkermatapply.m b/chunkie/chunkermatapply.m index 8b91580..517c260 100644 --- a/chunkie/chunkermatapply.m +++ b/chunkie/chunkermatapply.m @@ -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 @@ -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 @@ -120,10 +113,10 @@ error(msg); end -if nargin < 5 +if nargin < 4 cormat = []; end -if nargin < 6 +if nargin < 5 opts = []; end @@ -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 diff --git a/devtools/test/chunkermatapplyTest.m b/devtools/test/chunkermatapplyTest.m index 211828f..3cd14f4 100644 --- a/devtools/test/chunkermatapplyTest.m +++ b/devtools/test/chunkermatapplyTest.m @@ -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) @@ -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) @@ -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) @@ -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)