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

« back to all changes in this revision

Viewing changes to inst/comp/vect2cell.m

  • Committer: Package Import Robot
  • Author(s): Rafael Laboissiere
  • Date: 2014-10-09 13:58:00 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20141009135800-5kw1gvovmqh34bmm
Tags: 2.0.1-1
* Imported Upstream version 2.0.1
* d/p/autoload-yes.patch: Refresh patch
* d/p/add-subdirs-to-loadpath.patch: Drop patch (fixed upstream)
* d/check.m: Use the upstream unit testing script
* d/rules: Fix permission of all *.m files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
function c = vect2cell(x,idx)
2
 
 
3
 
idxEnd = cumsum(idx(:));
4
 
idxStart = [1;1+idxEnd(1:end-1)];
5
 
c = arrayfun(@(idS,idE) x(idS:idE,:),idxStart,idxEnd,'UniformOutput',0);
6
 
 
7
 
 
8
2
%-*- texinfo -*-
9
3
%@deftypefn {Function} vect2cell
10
4
%@verbatim
 
5
%VECT2CELL Vector to cell
 
6
%
 
7
%   Works exactly like mat2cell(x,idx,size(x,2))
 
8
%   but it is faster.
11
9
%@end verbatim
12
10
%@strong{Url}: @url{http://ltfat.sourceforge.net/doc/comp/vect2cell.php}
13
11
%@end deftypefn
14
12
 
15
13
% Copyright (C) 2005-2014 Peter L. Soendergaard <soender@users.sourceforge.net>.
16
 
% This file is part of LTFAT version 1.4.4
 
14
% This file is part of LTFAT version 2.0.1
17
15
%
18
16
% This program is free software: you can redistribute it and/or modify
19
17
% it under the terms of the GNU General Public License as published by
28
26
% You should have received a copy of the GNU General Public License
29
27
% along with this program.  If not, see <http://www.gnu.org/licenses/>.
30
28
 
 
29
if sum(idx)~=size(x,1)
 
30
    error('%s: Sizes do not comply.',upper(mfilename));
 
31
end
 
32
 
 
33
idxEnd = cumsum(idx(:));
 
34
idxStart = [1;1+idxEnd(1:end-1)];
 
35
c = arrayfun(@(idS,idE) x(idS:idE,:),idxStart,idxEnd,'UniformOutput',0);
 
36