1 function varargout = find(df, varargin)
3 %% Copyright (C) 2009-2012 Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
5 %% This file is part of Octave.
7 %% Octave is free software; you can redistribute it and/or
8 %% modify it under the terms of the GNU General Public
9 %% License as published by the Free Software Foundation;
10 %% either version 2, or (at your option) any later version.
12 %% Octave is distributed in the hope that it will be useful,
13 %% but WITHOUT ANY WARRANTY; without even the implied
14 %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 %% PURPOSE. See the GNU General Public License for more
18 %% You should have received a copy of the GNU General Public
19 %% License along with Octave; see the file COPYING. If not,
20 %% write to the Free Software Foundation, 51 Franklin Street -
21 %% Fifth Floor, Boston, MA 02110-1301, USA.
24 %# $Id: find.m 9585 2012-02-05 15:32:46Z cdemills $
29 resu = []; mz = max(cellfun(@length, df._rep));
30 for indc = 1:df._cnt(2),
31 [indr, inds] = feval(@find, df._data{indc}(:, df._rep{indc}));
32 %# create a vector the same size as indr
33 dummy = indr; dummy(:) = indc;
34 resu = [resu; sub2ind([df._cnt(1:2) mz], indr, dummy, inds)];
36 varargout{1} = sort(resu);
38 nz = 0; idx_i = []; idx_j = [];
39 for indc = 1:df._cnt(2),
40 [dum1, dum2] = feval(@find, df._data{indc}(:, df._rep{indc}));
41 idx_i = [idx_i; dum1];
42 idx_j = [idx_j; nz + dum2];
43 nz = nz + df._cnt(1)*length(df._rep{indc});
45 varargout{1} = idx_i; varargout{2} = idx_j;
47 nz = 0; idx_i = []; idx_j = []; val = [];
48 for indc = 1:df._cnt(2),
49 [dum1, dum2, dum3] = feval(@find, df._data{indc}(:, df._rep{indc}));
50 idx_i = [idx_i; dum1];
51 idx_j = [idx_j; nz + dum2];
53 nz = nz + df._cnt(1)*length(df._rep{indc});
55 varargout{1} = idx_i; varargout{2} = idx_j; varargout{3} = val;