From: <cde...@us...> - 2010-12-01 08:45:14
|
Revision: 7966 http://octave.svn.sourceforge.net/octave/?rev=7966&view=rev Author: cdemills Date: 2010-12-01 08:45:08 +0000 (Wed, 01 Dec 2010) Log Message: ----------- A few fixes for single-dimension writing, and around COW logic Modified Paths: -------------- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_basecomp.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_cow.m trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_func.m trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m 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-30 21:58:08 UTC (rev 7965) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_basecomp.m 2010-12-01 08:45:08 UTC (rev 7966) @@ -40,8 +40,8 @@ %# if strict is set, B may not be non-scalar vs scalar if ((!(isscalar(A) || isscalar(B)))||(strict && isscalar(A))), if (itercol), %# requires full compatibility - Csize = size(A); - if (any(Csize - size(B))), + Csize = size(A)(1:2); + if (any(Csize - size(B)(1:2))), %# disp([size(A) size(B)]) error("Non compatible row and columns sizes (op1 is %dx%d, op2 is %dx%d)",\ Csize, size(B)); @@ -49,18 +49,18 @@ else %# compatibility with matrix product if (size(A, 2) - size(B, 1)), error("Non compatible columns vs. rows size (op1 is %dx%d, op2 is %dx%d)",\ - size(A), size(B)); + size(A)(1:2), size(B)(1:2)); endif Csize = [size(A, 1) size(B, 2)]; endif endif else if (isscalar(A)), - Csize = size(B); + Csize = size(B)(1:2); else if (size(A, 1) != size(B, 1)), error("Non compatible row sizes (op1 is %dx%d, op2 is %dx%d)",\ - size(A), size(B)); + size(A), size(B)(1:2)); endif Csize = [size(A, 2) size(B, 2)]; endif Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_cow.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_cow.m 2010-11-30 21:58:08 UTC (rev 7965) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_cow.m 2010-12-01 08:45:08 UTC (rev 7966) @@ -34,22 +34,28 @@ endif if isempty(inds), inds = 1; endif - for indi = inds, - dummy = df._rep{col}; dummy(indi)=[]; + dummy = df._rep{col}; dummy(indi) = 0; [t1, t2] = ismember(df._rep{col}(indi)(:), dummy); for indj = t2(find(t2)), %# Copy-On-Write %# determines the index for the next column t1 = 1+max(df._rep{col}); - %# update repetition index aliasing this one - df._rep{col}(find(df._rep{col} == indj)(2:end)) = t1; %# duplicate the touched column - df._data{col} = horzcat(df._data{col}, df._data{col}(:, indj)); - if (length(S.subs) > 1), + df._data{col} = horzcat(df._data{col}, \ + df._data{col}(:, df._rep{col}(indj))); + if (indi > 1) + %# a new column has been created + df._rep{col}(indi) = t1; + else + %# update repetition index aliasing this one + dummy = find(dummy == indi); + df._rep{col}(dummy) = t1; + endif + if (length(S.subs) > 1 && indi > 1), %# adapt the sheet index accordingly - indk = find(S.subs{2} == indj); - S.subs{2}(indk(2:end)) = t1; + S.subs{2}(find(S.subs{2}==indi)) = t1; endif + endfor endfor 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-30 21:58:08 UTC (rev 7965) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/private/df_func.m 2010-12-01 08:45:08 UTC (rev 7966) @@ -64,10 +64,10 @@ for indi = resu._cnt(2):-1:1, switch resu._type{indi} case "char" - resu._data{indi} = feval(func, A(:, indi, :), \ + resu._data{indi} = feval(func, squeeze(A(:, indi, :)), \ char(B._data{indi}(:, B._rep{indi}))); otherwise - resu._data{indi} = feval(func, A(:, indi, :), \ + resu._data{indi} = feval(func, squeeze(A(:, indi, :)), \ B._data{indi}(:, B._rep{indi})); endswitch resu._rep{indi} = 1:size(resu._data{indi}, 2); @@ -176,8 +176,8 @@ otherwise unfolded = A._data{indi}(:, A._rep{indi}); endswitch - resu._data{indi} = squeeze(feval(func, unfolded, \ - B(:, indi, :))); + resu._data{indi} = feval(func, unfolded, \ + squeeze(B(:, indi, :))); resu._rep{indi} = 1:size(resu._data{indi}, 2); endfor endif Modified: trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m =================================================================== --- trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m 2010-11-30 21:58:08 UTC (rev 7965) +++ trunk/octave-forge/extra/dataframe/inst/@dataframe/subsasgn.m 2010-12-01 08:45:08 UTC (rev 7966) @@ -130,8 +130,13 @@ case '()' [indr, nrow, S(1).subs{1}] = df_name2idx(df._name{1}, S(1).subs{1}, \ df._cnt(1), 'row'); - [indc, ncol, S(1).subs{2}] = df_name2idx(df._name{2}, S(1).subs{2}, \ - df._cnt(2), 'column'); + if (length(S(1).subs) > 1), + [indc, ncol, S(1).subs{2}] = df_name2idx(df._name{2}, S(1).subs{2}, \ + df._cnt(2), 'column'); + else + indc = 1; ncol = 1; + S(1).subs{2} = 1; %# avoid an error at line 516 + endif resu = df_matassign(df, S, indc, ncol, RHS); endswitch @@ -527,6 +532,7 @@ df._data{indc(indi)} = fillfunc(df._data{indc(indi)}, S, indi); S = Sorig; catch + disp(lasterr) disp('line 470 '); keyboard end_try_catch # catch This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |