From: <cde...@us...> - 2010-11-26 16:56:47
|
Revision: 7955 http://octave.svn.sourceforge.net/octave/?rev=7955&view=rev Author: cdemills Date: 2010-11-26 16:56:40 +0000 (Fri, 26 Nov 2010) Log Message: ----------- Intermediate version, some matrix ops are still not working as they should Modified Paths: -------------- trunk/octave-forge/extra/dataframe/inst/@dataframe/mrdivide.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_basecomp.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_func.m Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/mrdivide.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/mrdivide.m 2010-11-26 16:38:36 UTC (rev 7954) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/mrdivide.m 2010-11-26 16:56:40 UTC (rev 7955) @@ -28,7 +28,7 @@ %# try - resu = df_func(@mrdivide, A, B); + resu = df_func(@mrdivide, A, B, false, [true false]); catch disp(lasterr()); error("Operator / problem for %s vs. %s", class(A), class(B)); Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_basecomp.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_basecomp.m 2010-11-26 16:38:36 UTC (rev 7954) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_basecomp.m 2010-11-26 16:56:40 UTC (rev 7955) @@ -55,9 +55,16 @@ if (!isempty(A._name{1})) if (!isempty(B._name{1})) - if (!any(strcmp(cellstr(A._name{1}), cellstr(B._name{1})))), + dummy = !(strcmp(cellstr(A._name{1}), cellstr(B._name{1}))\ + | (A._over{1}(:)) | (B._over{1}(:))); + if (any(dummy)), error("Incompatible row names"); endif + dummy = A._over{1} > B._over{1}; + if (any(dummy)), + C._name{1}(dummy) = B._name{1}(dummy); + C._over{1}(dummy) = B._over{1}(dummy); + endif endif else if (nargout > 2), @@ -67,24 +74,31 @@ if (!isempty(A._name{2})) if (!isempty(B._name{2})) - if (!any(strcmp(cellstr(A._name{2}), cellstr(B._name{2})))), + dummy = !(strcmp(cellstr(A._name{2}), cellstr(B._name{2}))\ + | (A._over{2}(:)) | (B._over{2}(:))); + if (any(dummy)), error("Incompatible column names"); endif + dummy = A._over{2} > B._over{2}; + if (any(dummy)), + C._name{2}(dummy) = B._name{2}(dummy); + C._over{2}(dummy) = B._over{2}(dummy); + endif endif else - if (nargout > 2), + if (nargout > 2 && !isempty(B._name{2})), C._name{2} = B._name{2}; C._over{2} = B._over{2}; endif endif - if (isempty(A._src) && nargout > 2), + if (isempty(A._src) && nargout > 2 && !isempty(B._src)), C._src = B._src; endif endif else if (nargout > 2), C = df_allmeta(B); endif endif - else + else %# one of the arg is a scalar if (isa(A, 'dataframe')) if (nargout > 2), C = df_allmeta(A); endif else Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_func.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_func.m 2010-11-26 16:38:36 UTC (rev 7954) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_func.m 2010-11-26 16:56:40 UTC (rev 7955) @@ -79,17 +79,88 @@ endif endif else - error('To be implemented'); - resu._data = cellfun(@(x, y) feval(func, x, y, varargin{:}), A._data, \ - B._data, "UniformOutput", false); + if (itercol), + for indi = resu._cnt(2):-1:1, + switch resu._type{indi} + case "char" + resu._data{indi} = feval(func, char(A._data{indi}), char(B._data{indi})); + otherwise + resu._data{indi} = feval(func, A._data{indi}, B._data{indi}); + endswitch + endfor + else + dummy = horzcat(A._data {:}); + if whole(1), + for indi = resu._cnt(2):-1:1, + switch resu._type{indi} + case "char" + resu._data{indi} = feval(func, dummy, char(B._data{indi})); + otherwise + resu._data{indi} = feval(func, dummy, B._data{indi}); + endswitch + endfor + else + for indi = resu._cnt(2):-1:1, + switch resu._type{indi} + case "char" + resu._data{indi} = feval(func, dummy(indi, :), char(B._data{indi})); + otherwise + resu._data{indi} = feval(func, dummy(indi, :), B._data{indi}); + endswitch + endfor + endif + endif endif - else - if (isscalar(B) || ismatrix(B)), - resu._data = cellfun(@(x) feval(func, x, B, varargin{:}), A._data, \ - "UniformOutput", false); + else %# B is not a dataframe + if (isscalar(B)), + for indi = resu._cnt(2):-1:1, + switch resu._type{indi} + case "char" + resu._data{indi} = feval(func, char(A._data{indi}), B); + otherwise + resu._data{indi} = feval(func, A._data{indi}, B); + endswitch + endfor else - error("Function %s not implemented for %s by %s", \ - func2str(func), class(A), class(B)); + if (itercol), + if (whole(2)), + for indi = resu._cnt(2):-1:1, + switch resu._type{indi} + case "char" + resu._data{indi} = feval(func, char(A._data{indi}), B); + otherwise + resu._data{indi} = feval(func, A._data{indi}, B); + endswitch + endfor + else + for indi = resu._cnt(2):-1:1, + switch resu._type{indi} + case "char" + resu._data{indi} = feval(func, char(A._data{indi}), \ + B(:, indi)); + otherwise + resu._data{indi} = feval(func, A._data{indi}, B(:, indi)); + endswitch + endfor + endif + else + dummy = horzcat(A._data {:}); + if whole(1), + for indi = resu._cnt(2):-1:1, + resu._data{indi} = feval(func, dummy, B(:, indi)); + endfor + else + if !whole(2), + for indi = resu._cnt(2):-1:1, + resu._data{indi} = feval(func, dummy(indi, :), B(:, indi)); + endfor + else + for indi = resu._cnt(2):-1:1, + resu._data{indi} = feval(func, dummy(indi, :), B); + endfor + endif + endif + endif endif endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |