[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #65245] movfun/movmean: scope for speed up wit
From: |
A.R. Burgers |
Subject: |
[Octave-bug-tracker] [bug #65245] movfun/movmean: scope for speed up with conv |
Date: |
Sat, 3 Feb 2024 07:18:16 -0500 (EST) |
URL:
<https://savannah.gnu.org/bugs/?65245>
Summary: movfun/movmean: scope for speed up with conv
Group: GNU Octave
Submitter: arb
Submitted: Sat 03 Feb 2024 01:18:16 PM CET
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Performance
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Release: dev
Discussion Lock: Any
Operating System: Any
Fixed Release: None
Planned Release: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Sat 03 Feb 2024 01:18:16 PM CET By: A.R. Burgers <arb>
see also bug#55389
with a a vector, window size wlen odd, conv can give much faster results
because of the linearity of the operator in the movsum/movmean cases.
The following two snippets show how conv can calculate the same result for
movsum and movmean
result = movsum(a, wlen);
result = conv(a, ones(1, wlen), 'same');
result = movmean(a, wlen)
count = conv(ones(size(a)), ones(1, wlen), 'same');
result = conv(a, ones(1, wlen), 'same') ./ count;
Speed-ups can be a factor ~30
movsum time 0.321551
movsum with conv time 0.0108559
movmean time 0.520523
movmean with conv time 0.0155551
Timings obtained with this script
np = 10000; ns = 13;
nrep = 100;
a = rand(1, np);
a1 = ones(1, np);
tic;
for i = 1 : nrep
as = movsum(a, ns);
end
fprintf('movsum time %g\n', toc);
tic;
for i = 1 : nrep
as_c = conv(a, ones(1, ns), 'same');
end
fprintf('movsum with conv time %g\n', toc);
assert(all(abs(as - as_c)) < 1.e-10);
tic;
for i = 1 : nrep
as = movmean(a, ns);
end
fprintf('movmean time %g\n', toc);
tic;
for i = 1 : nrep
as_c = conv(a, ones(1, ns), 'same') ./ conv(a1, ones(1, ns), 'same');
end
fprintf('movmean with conv time %g\n', toc);
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?65245>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #65245] movfun/movmean: scope for speed up with conv,
A.R. Burgers <=