]> Creatis software - CreaPhase.git/blob - octave_packages/dataframe-0.9.1/@dataframe/bsxfun.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / dataframe-0.9.1 / @dataframe / bsxfun.m
1 function resu = bsxfun(func, A, B)
2
3   %# function resu = bsxfun(func, A, B)
4   %# Implements a wrapper around internal bsxfun
5
6   %% Copyright (C) 2009-2012 Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
7   %%
8   %% This file is part of Octave.
9   %%
10   %% Octave is free software; you can redistribute it and/or
11   %% modify it under the terms of the GNU General Public
12   %% License as published by the Free Software Foundation;
13   %% either version 2, or (at your option) any later version.
14   %%
15   %% Octave is distributed in the hope that it will be useful,
16   %% but WITHOUT ANY WARRANTY; without even the implied
17   %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18   %% PURPOSE.  See the GNU General Public License for more
19   %% details.
20   %%
21   %% You should have received a copy of the GNU General Public
22   %% License along with Octave; see the file COPYING.  If not,
23   %% write to the Free Software Foundation, 51 Franklin Street -
24   %% Fifth Floor, Boston, MA 02110-1301, USA.
25   
26   %#
27   %# $Id: bsxfun.m 9585 2012-02-05 15:32:46Z cdemills $
28   %#
29
30
31   try
32
33     [A, B, resu] = df_basecomp(A, B, true, @bsxfun);
34
35     for indi = 1:max(A._cnt(2), B._cnt(2)),
36       indA = min(indi, A._cnt(2));
37       indB = min(indi, B._cnt(2));
38       Au = A._data{indA}(:, A._rep{indA});
39       Bu = B._data{indB}(:, B._rep{indB});
40       resu._data{indi} = bsxfun(func, Au, Bu);
41       resu._rep{indi} = 1:size(resu._data{indi}, 2);
42     endfor
43
44     resu = df_thirddim(resu);
45
46   catch
47     disp(lasterr());
48     error('bsxfun: non-compatible dimensions')
49   end_try_catch
50   
51 endfunction