~ubuntu-branches/ubuntu/wily/octave-ltfat/wily-proposed

« back to all changes in this revision

Viewing changes to inst/fourier/long2fir.m

  • Committer: Package Import Robot
  • Author(s): Sébastien Villemot, Rafael Laboissiere
  • Date: 2015-07-18 23:36:41 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20150718233641-jhuf3f551a3523qc
Tags: 2.1.0+dfsg-1
* Team upload.

[ Rafael Laboissiere ]
* Imported Upstream version 2.1.0+dfsg
* d/rules: Prevent unit testing on armhf and mips.
  This avoids FTBFS on theses architectures (see Bug#765545).
* Unit testing does not need X-window anymore
  + d/rules: Do not use xfvb-run to run the tests.
  + d/control: Drop xauth, xvfb, and gnuplot-nox from Build-Depends.
    Also, the versioned dependency on octave-pkg-dev is relaxed.
* Drop .jar file from upstream tarball, complying with the Debian Policy
  + d/copyright: Exclude file blockproc.jar
  + d/rules: Add get-orig-source target
  + d/watch: Mangle upstream version to cope with "+dfsg" tag
* Build blockproc.jar, which is deleted from the upstream tarball
  + d/rules: Add commands for building blockproc.jar
  + d/control: Build-depend on default-jdk
  + d/p/fix-path-of-included-makefile.patch: New patch
* Bump Standard-Versions to 3.9.6 (no changes needed)
* d/p/autoload-yes.patch: Remove patch (deprecated upstream)
* Bump Build-Depends on octave to >> 4.0.0~rc4-1 (for sndfile support)
* d/check.m: Avoid verbose output of unit tests
* d/watch: Add the repacksuffix option
* d/p/add-hardening-flags.patch: Drop patch (applied upstream)
* d/p/fix-path-of-included-makefile.patch: Drop patch (applied upstream)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
function g=long2fir(g,varargin);
2
 
%-*- texinfo -*-
3
 
%@deftypefn {Function} long2fir
4
 
%@verbatim
5
 
%LONG2FIR   Cut LONG window to FIR
6
 
%   Usage:  g=long2fir(g,L);
7
 
%
8
 
%   LONG2FIR(g,L) will cut the LONG window g to a length L FIR window by
9
 
%   cutting out the middle part. Note that this is a slightly different
10
 
%   behaviour than MIDDLEPAD.
11
 
%
12
 
%   LONG2FIR(g,L,'wp') or LONG2FIR(g,L,'hp') does the same assuming the
13
 
%   input window is a whole-point even or half-point even window,
14
 
%   respectively.
15
 
%
16
 
%@end verbatim
17
 
%@strong{Url}: @url{http://ltfat.sourceforge.net/doc/fourier/long2fir.php}
18
 
%@seealso{fir2long, middlepad}
19
 
%@end deftypefn
20
 
 
21
 
% Copyright (C) 2005-2014 Peter L. Soendergaard <soender@users.sourceforge.net>.
22
 
% This file is part of LTFAT version 2.0.1
23
 
%
24
 
% This program is free software: you can redistribute it and/or modify
25
 
% it under the terms of the GNU General Public License as published by
26
 
% the Free Software Foundation, either version 3 of the License, or
27
 
% (at your option) any later version.
28
 
%
29
 
% This program is distributed in the hope that it will be useful,
30
 
% but WITHOUT ANY WARRANTY; without even the implied warranty of
31
 
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
 
% GNU General Public License for more details.
33
 
%
34
 
% You should have received a copy of the GNU General Public License
35
 
% along with this program.  If not, see <http://www.gnu.org/licenses/>.
36
 
 
37
 
if nargin<1
38
 
  error('%s: Too few input parameters.',upper(mfilename));
39
 
end;
40
 
 
41
 
definput.flags.centering = {'unsymmetric','wp','hp'};
42
 
definput.keyvals.L      = [];
43
 
definput.keyvals.cutrel = [];
44
 
 
45
 
[flags,kv,L]=ltfatarghelper({'L'},definput,varargin);
46
 
 
47
 
W=length(g);
48
 
 
49
 
if W<L
50
 
  error('L must be smaller than length of window.');
51
 
end;
52
 
 
53
 
if ~isempty(kv.cutrel)
54
 
  maxval=max(abs(g));
55
 
  mask=abs(g)>maxval*kv.cutrel;
56
 
  L=W-2*min(abs(find(mask)-L/2));
57
 
end;
58
 
 
59
 
if isempty(L)
60
 
    error(['%s: You must specify a way to shorten the window, either by ' ...
61
 
           'specifying the length or through a flag.'],upper(mfilename));
62
 
end;
63
 
 
64
 
if flags.do_unsymmetric
65
 
  % No assumption on the symmetry of the window.
66
 
 
67
 
  if rem(L,2)==0
68
 
    % HPE middlepad works the same way as the FIR cutting (e.g. just
69
 
    % removing middle points) for even values of L.
70
 
    g=middlepad(g,L,'hp');
71
 
  else
72
 
    % WPE middlepad works the same way as the FIR cutting (e.g. just
73
 
    % removing middle points) for odd values of L.
74
 
    g=middlepad(g,L);
75
 
  end;
76
 
  
77
 
else
78
 
  if flags.do_wp
79
 
    g=middlepad(g,L);
80
 
    if rem(L,2)==0
81
 
      g(L/2+1)=0;
82
 
    end;
83
 
  else
84
 
    g=middlepad(g,L,'hp');
85
 
    if rem(L,2)==1
86
 
      g(ceil(L/2))=0;
87
 
    end;
88
 
  end;
89
 
end;
90
 
 
91