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

« back to all changes in this revision

Viewing changes to inst/wavelets/wfbtmanip/nat2freqOrder.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:
19
19
%   NAT2FREQORDER(wt,nodes) does the same but works only with nodes
20
20
%   listed in nodes.
21
21
%
22
 
%   REMARK: The function is self invertible.
 
22
%   NAT2FREQORDER(...,'rev') changes the frequency ordering back to
 
23
%   natural ordering.
23
24
%
24
25
%
25
26
%@end verbatim
26
 
%@strong{Url}: @url{http://ltfat.sourceforge.net/doc/wavelets/wfbtmanip/nat2freqOrder.php}
 
27
%@strong{Url}: @url{http://ltfat.github.io/doc/wavelets/wfbtmanip/nat2freqOrder.html}
27
28
%@seealso{wfbtinit, wfbtmultid, nodebforder}
28
29
%@end deftypefn
29
30
 
30
 
% Copyright (C) 2005-2014 Peter L. Soendergaard <soender@users.sourceforge.net>.
31
 
% This file is part of LTFAT version 2.0.1
 
31
% Copyright (C) 2005-2015 Peter L. Soendergaard <peter@sonderport.dk>.
 
32
% This file is part of LTFAT version 2.1.0
32
33
%
33
34
% This program is free software: you can redistribute it and/or modify
34
35
% it under the terms of the GNU General Public License as published by
52
53
    varargin(strcmp('rev',varargin)) = [];
53
54
end
54
55
 
 
56
bftreepath = nodeBForder(0,wt);
 
57
 
55
58
if isempty(varargin)
56
 
   % Work with the whole tree
57
 
   treePath = nodeBForder(0,wt);
58
 
   %skip root
59
 
   treePath = treePath(2:end);
 
59
   treePath = bftreepath(2:end);% skip root
60
60
else
61
61
   % Work with specified nodes only
62
62
   nodes = varargin{1}; 
68
68
 
69
69
% Dual-tree complex wavelet packets require some more tweaking.
70
70
 if isfield(wt,'dualnodes')
 
71
     
71
72
    locIdxs = arrayfun(@(tEl) find(wt.children{wt.parents(tEl)}==tEl,1),treePath);
72
73
    treeNodes = treePath(rem(locIdxs,2)~=1);
73
74
    % Root was removed so the following will not fail
80
81
 
81
82
        if do_rev
82
83
          jj = wt.children{jj}(1);
83
 
        else
 
84
        else 
84
85
          jj = wt.children{jj}(end);
85
86
        end
86
87
        
88
89
 
89
90
 end
90
91
 
91
 
 
92
 
% Get loc. index of nodes
93
 
locIdxs = arrayfun(@(tEl) find(wt.children{wt.parents(tEl)}==tEl,1),treePath);
94
 
 
95
 
% Get only nodes connected to a high-pass output
96
 
treeNodes = treePath(rem(locIdxs,2)~=1);
97
 
 
98
 
for nodeId=treeNodes
99
 
       % now for the filter reordering
100
 
       wt.nodes{nodeId}.g = wt.nodes{nodeId}.g(end:-1:1);
101
 
       wt.nodes{nodeId}.h = wt.nodes{nodeId}.h(end:-1:1);
102
 
       wt.nodes{nodeId}.a = wt.nodes{nodeId}.a(end:-1:1);
103
 
       
104
 
        % Do the same with the dual tree if it exists
105
 
        if isfield(wt,'dualnodes')
106
 
            wt.dualnodes{nodeId}.g = wt.dualnodes{nodeId}.g(end:-1:1);
107
 
            wt.dualnodes{nodeId}.h = wt.dualnodes{nodeId}.h(end:-1:1);
108
 
            wt.dualnodes{nodeId}.a = wt.dualnodes{nodeId}.a(end:-1:1);
109
 
        end
110
 
end
 
92
% Array indexed by nodeId
 
93
reordered = zeros(size(bftreepath));
 
94
 
 
95
% Long version
 
96
if 1
 
97
    for nodeId=bftreepath
 
98
        ch = postpad(wt.children{nodeId},numel(wt.nodes{nodeId}.g));
 
99
        odd = 1;
 
100
        if reordered(nodeId) && rem(numel(ch),2)==1
 
101
            odd = 0;
 
102
        end 
 
103
 
 
104
        for m=0:numel(ch)-1
 
105
            if ch(m+1) ~= 0
 
106
                if rem(m,2)==odd
 
107
                   reordered(ch(m+1)) = 1;
 
108
                end
 
109
            end
 
110
        end    
 
111
    end
 
112
end
 
113
 
 
114
% Reorder filters
 
115
for nodeId=treePath(logical(reordered(treePath)))
 
116
    wt = reorderFilters(nodeId,wt);
 
117
end
 
118
 
 
119
function wt = reorderFilters(nodeId,wt)
 
120
% now for the filter reordering
 
121
wt.nodes{nodeId}.g = wt.nodes{nodeId}.g(end:-1:1);
 
122
wt.nodes{nodeId}.h = wt.nodes{nodeId}.h(end:-1:1);
 
123
wt.nodes{nodeId}.a = wt.nodes{nodeId}.a(end:-1:1);
 
124
 
 
125
% Do the same with the dual tree if it exists
 
126
if isfield(wt,'dualnodes')
 
127
    wt.dualnodes{nodeId}.g = wt.dualnodes{nodeId}.g(end:-1:1);
 
128
    wt.dualnodes{nodeId}.h = wt.dualnodes{nodeId}.h(end:-1:1);
 
129
    wt.dualnodes{nodeId}.a = wt.dualnodes{nodeId}.a(end:-1:1);
 
130
end
 
131
 
 
132
 
111
133
 
112
134
 
113
135