1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
function t=isevenfunction(f,varargin);
%-*- texinfo -*-
%@deftypefn {Function} isevenfunction
%@verbatim
%ISEVENFUNCTION True if function is even
% Usage: t=isevenfunction(f);
% t=isevenfunction(f,tol);
%
% ISEVENFUNCTION(f) returns 1 if f is whole point even. Otherwise it
% returns 0.
%
% ISEVENFUNCTION(f,tol) does the same, using the tolerance tol to measure
% how large the error between the two parts of the vector can be. Default
% is 1e-10.
%
% Adding the flag 'hp' as the last argument does the same for half point
% even functions.
%
%@end verbatim
%@strong{Url}: @url{http://ltfat.github.io/doc/fourier/isevenfunction.html}
%@seealso{middlepad, peven}
%@end deftypefn
% Copyright (C) 2005-2016 Peter L. Soendergaard <peter@sonderport.dk>.
% This file is part of LTFAT version 2.2.0
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
% AUTHOR : Peter L. Soendergaard
% TESTING: OK
% REFERENCE: OK
if nargin<1
error('Too few input parameters.');
end;
if size(f,2)>1
if size(f,1)>1
error('f must be a vector');
else
% f was a row vector.
f=f(:);
end;
end;
% Define initial values for flags
definput.flags.centering = {'wp','hp'};
definput.keyvals.tol = 1e-10;
[flags,keyvals,tol]=ltfatarghelper({'tol'},definput,varargin);
L=size(f,1);
if flags.do_wp
% Determine middle point of sequence.
if rem(L,2)==0
middle=L/2;
else
middle=(L+1)/2;
end;
% Relative norm of difference between the parts of the signal.
d=norm(f(2:middle)-conj(flipud(f(L-middle+2:L))))/norm(f);
else
middle=floor(L/2);
d=norm(f(1:middle)-conj(flipud(f(L-middle+1:L))))/norm(f);
end;
% Return true if d less than tolerance.
t=d<=tol;
|