Mercurial > octave
comparison scripts/signal/movfun.m @ 30893:e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
* accumarray.m, accumdim.m, quadl.m, quadv.m, randi.m, structfun.m,
__is_function__.m, uigetfile.m, uimenu.m, uiputfile.m, doc_cache_create.m,
colorspace_conversion_input_check.m, imageIO.m, argnames.m, vectorize.m,
vectorize.m, normest1.m, inputname.m, nthargout.m, display_info_file.m,
decic.m, ode15i.m, ode15s.m, ode23.m, ode23s.m, ode45.m, odeset.m,
check_default_input.m, integrate_adaptive.m, ode_event_handler.m,
runge_kutta_23.m, runge_kutta_23s.m, runge_kutta_45_dorpri.m,
runge_kutta_interpolate.m, starting_stepsize.m, __all_opts__.m, fminbnd.m,
fminsearch.m, fminunc.m, fsolve.m, fzero.m, sqp.m, fplot.m, plotyy.m,
__bar__.m, __ezplot__.m, flat_entry.html, profexport.m, movfun.m, bicg.m,
bicgstab.m, cgs.m, eigs.m, gmres.m, pcg.m, __alltohandles__.m, __sprand__.m,
qmr.m, tfqmr.m, dump_demos.m:
Replace "func", "fun", "fn" in documentation and variable names with "fcn".
author | Rik <rik@octave.org> |
---|---|
date | Mon, 04 Apr 2022 18:14:56 -0700 |
parents | 796f54d4ddbf |
children | 597f3ee61a48 |
comparison
equal
deleted
inserted
replaced
30892:1a3cc2811090 | 30893:e1788b1a315f |
---|---|
225 ncols = prod (szx(dperm(2:end))); # rest of dimensions as single column | 225 ncols = prod (szx(dperm(2:end))); # rest of dimensions as single column |
226 x = reshape (x, N, ncols); # reshape input | 226 x = reshape (x, N, ncols); # reshape input |
227 | 227 |
228 ## Obtain function for boundary conditions | 228 ## Obtain function for boundary conditions |
229 if (isnumeric (bc)) | 229 if (isnumeric (bc)) |
230 bcfunc = @replaceval_bc; | 230 bcfcn = @replaceval_bc; |
231 bcfunc (true, bc); # initialize replaceval function with value | 231 bcfcn (true, bc); # initialize replaceval function with value |
232 else | 232 else |
233 switch (tolower (bc)) | 233 switch (tolower (bc)) |
234 case "shrink" | 234 case "shrink" |
235 bcfunc = @shrink_bc; | 235 bcfcn = @shrink_bc; |
236 | 236 |
237 case "discard" | 237 case "discard" |
238 bcfunc = []; | 238 bcfcn = []; |
239 C -= length (Cpre); | 239 C -= length (Cpre); |
240 Cpre = Cpos = []; | 240 Cpre = Cpos = []; |
241 N = length (C); | 241 N = length (C); |
242 szx(dperm(1)) = N; | 242 szx(dperm(1)) = N; |
243 | 243 |
244 case "fill" | 244 case "fill" |
245 bcfunc = @replaceval_bc; | 245 bcfcn = @replaceval_bc; |
246 bcfunc (true, NaN); | 246 bcfcn (true, NaN); |
247 | 247 |
248 case "same" | 248 case "same" |
249 bcfunc = @same_bc; | 249 bcfcn = @same_bc; |
250 | 250 |
251 case "periodic" | 251 case "periodic" |
252 bcfunc = @periodic_bc; | 252 bcfcn = @periodic_bc; |
253 | 253 |
254 endswitch | 254 endswitch |
255 endif | 255 endif |
256 | 256 |
257 ## FIXME: Validation doesn't seem to work correctly (noted 12/16/2018). | 257 ## FIXME: Validation doesn't seem to work correctly (noted 12/16/2018). |
277 | 277 |
278 ## Apply processing to each column | 278 ## Apply processing to each column |
279 ## FIXME: Is it faster with cellfun? Don't think so, but needs testing. | 279 ## FIXME: Is it faster with cellfun? Don't think so, but needs testing. |
280 y = zeros (N, ncols, soutdim); | 280 y = zeros (N, ncols, soutdim); |
281 parfor i = 1:ncols | 281 parfor i = 1:ncols |
282 y(:,i,:) = movfun_oncol (fcn_, x(:,i), wlen, bcfunc, | 282 y(:,i,:) = movfun_oncol (fcn_, x(:,i), wlen, bcfcn, |
283 slc, C, Cpre, Cpos, win, soutdim); | 283 slc, C, Cpre, Cpos, win, soutdim); |
284 endparfor | 284 endparfor |
285 | 285 |
286 ## Restore shape | 286 ## Restore shape |
287 y = reshape (y, [szx(dperm), soutdim]); | 287 y = reshape (y, [szx(dperm), soutdim]); |
288 y = permute (y, [dperm, nd+1]); | 288 y = permute (y, [dperm, nd+1]); |
289 y = squeeze (y); | 289 y = squeeze (y); |
290 | 290 |
291 endfunction | 291 endfunction |
292 | 292 |
293 function y = movfun_oncol (fcn, x, wlen, bcfunc, slcidx, C, Cpre, Cpos, win, odim) | 293 function y = movfun_oncol (fcn, x, wlen, bcfcn, slcidx, C, Cpre, Cpos, win, odim) |
294 | 294 |
295 N = length (Cpre) + length (C) + length (Cpos); | 295 N = length (Cpre) + length (C) + length (Cpos); |
296 y = NA (N, odim); | 296 y = NA (N, odim); |
297 | 297 |
298 ## Process center part | 298 ## Process center part |
299 y(C,:) = fcn (x(slcidx)); | 299 y(C,:) = fcn (x(slcidx)); |
300 | 300 |
301 ## Process boundaries | 301 ## Process boundaries |
302 if (! isempty (Cpre)) | 302 if (! isempty (Cpre)) |
303 y(Cpre,:) = bcfunc (fcn, x, Cpre, win, wlen, odim); | 303 y(Cpre,:) = bcfcn (fcn, x, Cpre, win, wlen, odim); |
304 endif | 304 endif |
305 if (! isempty (Cpos)) | 305 if (! isempty (Cpos)) |
306 y(Cpos,:) = bcfunc (fcn, x, Cpos, win, wlen, odim); | 306 y(Cpos,:) = bcfcn (fcn, x, Cpos, win, wlen, odim); |
307 endif | 307 endif |
308 | 308 |
309 endfunction | 309 endfunction |
310 | 310 |
311 ## Apply "shrink" boundary conditions | 311 ## Apply "shrink" boundary conditions |