# HG changeset patch # User Ben Abbott # Date 1223038593 -7200 # Node ID 78cf5edb69cedfc3f5a98514c74c9325de0e56a9 # Parent 9780ca97156e8fac00a5f2c330f179baf1298921 deconv.m: Fix row/col orientation & length of output diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,5 +1,7 @@ 2008-09-29 Ben Abbott + * polynomial/deconv.m: Fix row/col orientation & length of output. + * polynomial/conv.m: Correct row/col orientation of output. 2008-09-24 John W. Eaton diff --git a/scripts/polynomial/deconv.m b/scripts/polynomial/deconv.m --- a/scripts/polynomial/deconv.m +++ b/scripts/polynomial/deconv.m @@ -49,6 +49,11 @@ lb = ly - la + 1; + ## Ensure A is oriented as Y. + if (diff (size (y)(1:2)) * diff (size (a)(1:2)) < 0) + a = permute (a, [2, 1]); + endif + if (ly > la) b = filter (y, a, [1, (zeros (1, ly - la))]); elseif (ly == la) @@ -61,7 +66,16 @@ if (ly == lc) r = y - conv (a, b); else - r = [(zeros (1, lc - ly)), y] - conv (a, b); + ## Respect the orientation of Y" + if (size (y, 1) <= size (y, 2)) + r = [(zeros (1, lc - ly)), y] - conv (a, b); + else + r = [(zeros (lc - ly, 1)); y] - conv (a, b); + endif + if (ly < la) + ## Trim the remainder is equal to the length of Y. + r = r(end-(length(y)-1):end); + endif endif endfunction