From: <cde...@us...> - 2010-10-29 08:19:21
|
Revision: 7893 http://octave.svn.sourceforge.net/octave/?rev=7893&view=rev Author: cdemills Date: 2010-10-29 08:19:14 +0000 (Fri, 29 Oct 2010) Log Message: ----------- Implemented the dotted basic matrix-like ops on DF Modified Paths: -------------- trunk/octave-forge/extra/dataframe/inst/@dataframe/mldivide.m Added Paths: ----------- trunk/octave-forge/extra/dataframe/inst/@dataframe/ldivide.m trunk/octave-forge/extra/dataframe/inst/@dataframe/rdivide.m trunk/octave-forge/extra/dataframe/inst/@dataframe/times.m Added: trunk/octave-forge/extra/dataframe/inst/@dataframe/ldivide.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/ldivide.m (rev 0) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/ldivide.m 2010-10-29 08:19:14 UTC (rev 7893) @@ -0,0 +1,60 @@ +function resu = ldivide(A, B); + + %# function resu = ldivide(A, B) + %# Implements the '-' operator when at least one argument is a dataframe. + + %% Copyright (C) 2009-2010 Pascal Dupuis <Pas...@uc...> + %% + %% This file is part of Octave. + %% + %% Octave is free software; you can redistribute it and/or + %% modify it under the terms of the GNU General Public + %% License as published by the Free Software Foundation; + %% either version 2, or (at your option) any later version. + %% + %% Octave is distributed in the hope that it will be useful, + %% but WITHOUT ANY WARRANTY; without even the implied + %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + %% PURPOSE. See the GNU General Public License for more + %% details. + %% + %% You should have received a copy of the GNU General Public + %% License along with Octave; see the file COPYING. If not, + %% write to the Free Software Foundation, 59 Temple Place - + %% Suite 330, Boston, MA 02111-1307, USA. + + %# + %# $Id$ + %# + + [A, B] = df_basecomp(A, B); + + if isa(B, 'dataframe') + if !isa(A, 'dataframe'), + resu = B; + if isscalar(A) + resu._data = cellfun(@(x) A.\x, B._data, "UniformOutput", false); + elseif ismatrix(A), + resu._data = cellfun(@(x, y) x.\y, num2cell(A, 1), B._data,\ + "UniformOutput", false); + else + error("Operator .\ not implemented"); + endif + else + resu = A; + resu._data = cellfun(@(x, y) x.\y, A._data, B._data,\ + "UniformOutput", false); + endif + else + resu = A; + if isscalar(B), + resu._data = cellfun(@(x) x.\B, A._data, "UniformOutput", false); + elseif ismatrix(B), + resu._data = cellfun(@(x, y) x.\y, A._data, num2cell(B, 1),\ + "UniformOutput", false); + else + error("Operator .\ not implemented"); + endif + endif + +endfunction Property changes on: trunk/octave-forge/extra/dataframe/inst/@dataframe/ldivide.m ___________________________________________________________________ Added: svn:keywords + Id Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/mldivide.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/mldivide.m 2010-10-29 07:14:29 UTC (rev 7892) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/mldivide.m 2010-10-29 08:19:14 UTC (rev 7893) @@ -33,7 +33,7 @@ if !isa(A, 'dataframe'), resu = B; if isscalar(A) - resu._data = cellfun(@(x) A<x, B._data, "UniformOutput", false); + resu._data = cellfun(@(x) A\x, B._data, "UniformOutput", false); elseif ismatrix(A), resu._data = num2cell(A\cell2mat(B._data), 1); else Added: trunk/octave-forge/extra/dataframe/inst/@dataframe/rdivide.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/rdivide.m (rev 0) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/rdivide.m 2010-10-29 08:19:14 UTC (rev 7893) @@ -0,0 +1,60 @@ +function resu = rdivide(A, B); + + %# function resu = rdivide(A, B) + %# Implements the '.*' operator when at least one argument is a dataframe. + + %% Copyright (C) 2009-2010 Pascal Dupuis <Pas...@uc...> + %% + %% This file is part of Octave. + %% + %% Octave is free software; you can redistribute it and/or + %% modify it under the terms of the GNU General Public + %% License as published by the Free Software Foundation; + %% either version 2, or (at your option) any later version. + %% + %% Octave is distributed in the hope that it will be useful, + %% but WITHOUT ANY WARRANTY; without even the implied + %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + %% PURPOSE. See the GNU General Public License for more + %% details. + %% + %% You should have received a copy of the GNU General Public + %% License along with Octave; see the file COPYING. If not, + %% write to the Free Software Foundation, 59 Temple Place - + %% Suite 330, Boston, MA 02111-1307, USA. + + %# + %# $Id$ + %# + + [A, B] = df_basecomp(A, B); + + if isa(B, 'dataframe') + if !isa(A, 'dataframe'), + resu = B; + if isscalar(A) + resu._data = cellfun(@(x) A./x, B._data, "UniformOutput", false); + elseif ismatrix(A), + resu._data = cellfun(@(x, y) x./y, num2cell(A, 1), B._data,\ + "UniformOutput", false); + else + error("Operator ./ not implemented"); + endif + else + resu = A; + resu._data = cellfun(@(x, y) x./y, A._data, B._data,\ + "UniformOutput", false); + endif + else + resu = A; + if isscalar(B), + resu._data = cellfun(@(x) x./B, A._data, "UniformOutput", false); + elseif ismatrix(B), + resu._data = cellfun(@(x, y) x./y, A._data, num2cell(B, 1),\ + "UniformOutput", false); + else + error("Operator ./ not implemented"); + endif + endif + +endfunction Property changes on: trunk/octave-forge/extra/dataframe/inst/@dataframe/rdivide.m ___________________________________________________________________ Added: svn:keywords + Id Added: trunk/octave-forge/extra/dataframe/inst/@dataframe/times.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/times.m (rev 0) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/times.m 2010-10-29 08:19:14 UTC (rev 7893) @@ -0,0 +1,60 @@ +function resu = times(A, B); + + %# function resu = times(A, B) + %# Implements the '.*' operator when at least one argument is a dataframe. + + %% Copyright (C) 2009-2010 Pascal Dupuis <Pas...@uc...> + %% + %% This file is part of Octave. + %% + %% Octave is free software; you can redistribute it and/or + %% modify it under the terms of the GNU General Public + %% License as published by the Free Software Foundation; + %% either version 2, or (at your option) any later version. + %% + %% Octave is distributed in the hope that it will be useful, + %% but WITHOUT ANY WARRANTY; without even the implied + %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + %% PURPOSE. See the GNU General Public License for more + %% details. + %% + %% You should have received a copy of the GNU General Public + %% License along with Octave; see the file COPYING. If not, + %% write to the Free Software Foundation, 59 Temple Place - + %% Suite 330, Boston, MA 02111-1307, USA. + + %# + %# $Id$ + %# + + [A, B] = df_basecomp(A, B); + + if isa(B, 'dataframe') + if !isa(A, 'dataframe'), + resu = B; + if isscalar(A) + resu._data = cellfun(@(x) A.*x, B._data, "UniformOutput", false); + elseif ismatrix(A), + resu._data = cellfun(@(x, y) x.*y, num2cell(A, 1), B._data,\ + "UniformOutput", false); + else + error("Operator .* not implemented"); + endif + else + resu = A; + resu._data = cellfun(@(x, y) x.*y, A._data, B._data,\ + "UniformOutput", false); + endif + else + resu = A; + if isscalar(B), + resu._data = cellfun(@(x) x.*B, A._data, "UniformOutput", false); + elseif ismatrix(B), + resu._data = cellfun(@(x, y) x.*y, A._data, num2cell(B, 1),\ + "UniformOutput", false); + else + error("Operator .* not implemented"); + endif + endif + +endfunction Property changes on: trunk/octave-forge/extra/dataframe/inst/@dataframe/times.m ___________________________________________________________________ Added: svn:keywords + Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |